Skip to content

Commit b0717ae

Browse files
authored
Merge branch 'dev' into dependabot/github_actions/dev/actions/checkout-4
2 parents 9402459 + 934e278 commit b0717ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+643
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
os: ["ubuntu-latest", "windows-2022"]
25-
type: ["brownie", "buidler", "dapp", "embark", "hardhat", "solc", "truffle", "waffle", "foundry", "standard", "vyper"]
25+
type: ["brownie", "buidler", "dapp", "embark", "hardhat", "solc", "truffle", "waffle", "foundry", "standard", "vyper", "solc_multi_file", "hardhat_multi_file"]
2626
exclude:
2727
# Currently broken, tries to pull git:// which is blocked by GH
2828
- type: embark

crytic_compile/compilation_unit.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ def __init__(self, crytic_compile: "CryticCompile", unique_id: str):
4646
compiler="N/A", version="N/A", optimized=False
4747
)
4848

49+
# if the compilation unit comes from etherscan-like service and is a proxy,
50+
# store the implementation address
51+
self._implementation_address: Optional[str] = None
52+
4953
self._crytic_compile: "CryticCompile" = crytic_compile
5054

5155
if unique_id == ".":
@@ -130,6 +134,24 @@ def create_source_unit(self, filename: Filename) -> SourceUnit:
130134
self.filenames.append(filename)
131135
return self._source_units[filename]
132136

137+
@property
138+
def implementation_address(self) -> Optional[str]:
139+
"""Return the implementation address if the compilation unit is a proxy
140+
141+
Returns:
142+
Optional[str]: Implementation address
143+
"""
144+
return self._implementation_address
145+
146+
@implementation_address.setter
147+
def implementation_address(self, implementation: str) -> None:
148+
"""Set the implementation address
149+
150+
Args:
151+
implementation (str): Implementation address
152+
"""
153+
self._implementation_address = implementation
154+
133155
# endregion
134156
###################################################################################
135157
###################################################################################

crytic_compile/platform/etherscan.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,14 @@ def compile(self, crytic_compile: "CryticCompile", **kwargs: str) -> None:
401401
optimize_runs=optimize_runs,
402402
)
403403
compilation_unit.compiler_version.look_for_installed_version()
404+
405+
if "Proxy" in result and result["Proxy"] == "1":
406+
assert "Implementation" in result
407+
implementation = str(result["Implementation"])
408+
if target.startswith(tuple(SUPPORTED_NETWORK)):
409+
implementation = f"{target[:target.find(':')]}:{implementation}"
410+
compilation_unit.implementation_address = implementation
411+
404412
solc_standard_json.standalone_compile(
405413
filenames,
406414
compilation_unit,

scripts/ci_test_etherscan.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ cd "$DIR" || exit 255
77

88
solc-select use 0.4.25 --always-install
99

10-
delay_no_key () {
10+
delay_etherscan () {
1111
# Perform a small sleep when API key is not available (e.g. on PR CI from external contributor)
1212
if [ "$GITHUB_ETHERSCAN" = "" ]; then
1313
sleep 5s
14+
else
15+
# Always sleep 2 second in the CI
16+
# We have a lot of concurrent github action so this is needed
17+
sleep 2s
1418
fi
1519
}
1620

@@ -24,7 +28,7 @@ then
2428
fi
2529
echo "::endgroup::"
2630

27-
delay_no_key
31+
delay_etherscan
2832

2933
# From crytic/slither#1154
3034
echo "::group::Etherscan #3"
@@ -37,7 +41,7 @@ then
3741
fi
3842
echo "::endgroup::"
3943

40-
delay_no_key
44+
delay_etherscan
4145

4246
# From crytic/crytic-compile#415
4347
echo "::group::Etherscan #4"
@@ -50,7 +54,7 @@ then
5054
fi
5155
echo "::endgroup::"
5256

53-
delay_no_key
57+
delay_etherscan
5458

5559
# From crytic/crytic-compile#150
5660
echo "::group::Etherscan #5"
@@ -70,6 +74,8 @@ then
7074
fi
7175
echo "::endgroup::"
7276

77+
delay_etherscan
78+
7379
# From crytic/crytic-compile#151
7480
echo "::group::Etherscan #6"
7581
crytic-compile 0x4c808e3c011514d5016536af11218eec537eb6f5 --compile-remove-metadata --etherscan-apikey "$GITHUB_ETHERSCAN"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
DIR=$(mktemp -d)
4+
5+
cp -r tests/hardhat-multi-file "$DIR"
6+
cd "$DIR/hardhat-multi-file" || exit 255
7+
npm install
8+
crytic-compile --compile-remove-metadata --export-formats solc,truffle .
9+
10+
cd - || exit 255
11+
node tests/process_combined_solc.js "$DIR/hardhat-multi-file/crytic-export/combined_solc.json" "$DIR"
12+
DIFF=$(diff -r "$DIR/hardhat-multi-file/crytic-export" tests/expected/hardhat-multi-file)
13+
if [ "$?" != "0" ] || [ "$DIFF" != "" ]
14+
then
15+
echo "hardhat-multi-file test failed"
16+
echo "$DIFF"
17+
exit 255
18+
fi

scripts/ci_test_solc_multi_file.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
3+
DIR=$(mktemp -d)
4+
5+
cp -r tests/solc-multi-file "$DIR"
6+
cd "$DIR/solc-multi-file" || exit 255
7+
crytic-compile --compile-remove-metadata --export-formats solc,truffle A.sol
8+
9+
cd - || exit 255
10+
node tests/process_combined_solc.js "$DIR/solc-multi-file/crytic-export/combined_solc.json" "$DIR"
11+
DIFF=$(diff -r "$DIR/solc-multi-file/crytic-export" tests/expected/solc-multi-file)
12+
if [ "$?" != "0" ] || [ "$DIFF" != "" ]
13+
then
14+
echo "solc-multi-file test failed"
15+
echo "$DIFF"
16+
exit 255
17+
fi

tests/expected/hardhat-multi-file/A.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/B.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/C.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

tests/expected/hardhat-multi-file/D.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)