Skip to content

Commit 9d53cbf

Browse files
dependabot[bot]BobTheBuidlergithub-actions[bot]
authored
fix: reject empty code contract attachment (#2215)
* fix: reject empty code contract attachment * chore: compile C files for source control --------- Co-authored-by: BobTheBuidler <bobthebuidlerdefi@gmail.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent a2f9400 commit 9d53cbf

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

brownie/network/contract.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@ def at(
334334
)
335335

336336
build = self._build
337+
# If constructor execution removed the code (e.g. selfdestruct), this
338+
# address is not attachable even though the creation tx succeeded.
339+
actual_bytecode = web3.eth.get_code(address).hex().removeprefix("0x")
340+
if not actual_bytecode:
341+
raise ContractNotFound(f"No contract deployed at {address}")
342+
337343
contract = ProjectContract(self._project, build, address, owner, tx)
338344
if not _verify_deployed_code(address, build["deployedBytecode"], build["language"]):
339345
# prevent trace attempts when the bytecode doesn't match

build/__native_eth_brownie.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57724,7 +57724,7 @@ CPyL3: ;
5772457724
CPy_INCREF(cpy_r_val);
5772557725
return cpy_r_val;
5772657726
CPyL4: ;
57727-
cpy_r_r1 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'on', 'True', 'true'}) */
57727+
cpy_r_r1 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'True', 'true', 'on'}) */
5772857728
CPy_INCREF(cpy_r_val);
5772957729
if (likely(PyUnicode_Check(cpy_r_val)))
5773057730
cpy_r_r2 = cpy_r_val;
@@ -57744,7 +57744,7 @@ CPyL4: ;
5774457744
cpy_r_r6 = 1 ? Py_True : Py_False;
5774557745
return cpy_r_r6;
5774657746
CPyL8: ;
57747-
cpy_r_r7 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'off', 'false', 'False'}) */
57747+
cpy_r_r7 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'False', 'off', 'false'}) */
5774857748
CPy_INCREF(cpy_r_val);
5774957749
if (likely(PyUnicode_Check(cpy_r_val)))
5775057750
cpy_r_r8 = cpy_r_val;
@@ -111440,7 +111440,7 @@ CPyL3: ;
111440111440
if (!cpy_r_r7) goto CPyL21;
111441111441
cpy_r_r8 = CPy_GetExcValue();
111442111442
cpy_r_exc = cpy_r_r8;
111443-
cpy_r_r9 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'eth_estimateGas', 'eth_call'}) */
111443+
cpy_r_r9 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'eth_call', 'eth_estimateGas'}) */
111444111444
cpy_r_r10 = PySet_Contains(cpy_r_r9, cpy_r_method);
111445111445
cpy_r_r11 = cpy_r_r10 >= 0;
111446111446
if (unlikely(!cpy_r_r11)) {
@@ -111556,7 +111556,7 @@ CPyL21: ;
111556111556
if (!cpy_r_r32) goto CPyL39;
111557111557
cpy_r_r33 = CPy_GetExcValue();
111558111558
cpy_r_exc = cpy_r_r33;
111559-
cpy_r_r34 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'eth_estimateGas', 'eth_call'}) */
111559+
cpy_r_r34 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'eth_call', 'eth_estimateGas'}) */
111560111560
cpy_r_r35 = PySet_Contains(cpy_r_r34, cpy_r_method);
111561111561
cpy_r_r36 = cpy_r_r35 >= 0;
111562111562
if (unlikely(!cpy_r_r36)) {
@@ -111662,7 +111662,7 @@ CPyL41: ;
111662111662
if (!cpy_r_r57) goto CPyL54;
111663111663
CPy_Unreachable();
111664111664
CPyL43: ;
111665-
cpy_r_r58 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'eth_estimateGas', 'eth_call'}) */
111665+
cpy_r_r58 = CPyStatics[DIFFCHECK_PLACEHOLDER]; /* frozenset({'eth_call', 'eth_estimateGas'}) */
111666111666
cpy_r_r59 = PySet_Contains(cpy_r_r58, cpy_r_method);
111667111667
cpy_r_r60 = cpy_r_r59 >= 0;
111668111668
if (unlikely(!cpy_r_r60)) {
@@ -183538,19 +183538,19 @@ CPyL20: ;
183538183538
if (!cpy_r_r41) goto CPyL44;
183539183539
CPyL21: ;
183540183540
cpy_r_r42 = CPySequenceTuple_GetItemUnsafe(cpy_r_r38, cpy_r_r40);
183541-
if (PyLong_Check(cpy_r_r42))
183541+
if (PyUnicode_Check(cpy_r_r42))
183542183542
cpy_r_r43 = cpy_r_r42;
183543183543
else {
183544183544
cpy_r_r43 = NULL;
183545183545
}
183546183546
if (cpy_r_r43 != NULL) goto __LL1100;
183547-
if (PyUnicode_Check(cpy_r_r42))
183547+
if (PyLong_Check(cpy_r_r42))
183548183548
cpy_r_r43 = cpy_r_r42;
183549183549
else {
183550183550
cpy_r_r43 = NULL;
183551183551
}
183552183552
if (cpy_r_r43 != NULL) goto __LL1100;
183553-
CPy_TypeErrorTraceback("brownie/project/compiler/vyper.py", "_convert_to_semver", 524, CPyStatic_vyper___globals, "union[int, str]", cpy_r_r42);
183553+
CPy_TypeErrorTraceback("brownie/project/compiler/vyper.py", "_convert_to_semver", 524, CPyStatic_vyper___globals, "union[str, int]", cpy_r_r42);
183554183554
goto CPyL45;
183555183555
__LL1100: ;
183556183556
cpy_r_r44 = PyObject_Str(cpy_r_r43);
@@ -276772,7 +276772,7 @@ const char * const CPyLit_Str[] = {
276772276772
"\004\017REQUEST_HEADERS\vNetworkType\rNetworkConfig\017ConfigContainer",
276773276773
"\005\022set_active_network\fclear_active\bproperty\016active_network\fnetwork_type",
276774276774
"\a\004mode\006Config\nConfigDict\004once\016filterwarnings\bcategory\017parse_variables",
276775-
"\t\aresolve\002on\004True\003off\005False\aMapping\aTypeVar\boverload\020dotenv.variables",
276775+
"\t\aresolve\004True\002on\005False\003off\aMapping\aTypeVar\boverload\020dotenv.variables",
276776276776
"\006\002_T\r^[-+]\?[0-9]+$\tINT_REGEX\nEthAddress\005Fixed\003Wei",
276777276777
"\005\031brownie.convert.datatypes\ato_bool\bto_bytes\nto_decimal\006to_int",
276778276778
"\a\tto_string\ato_uint\024brownie.convert.main\a__new__\b__hash__\006__lt__\006__le__",
@@ -276857,7 +276857,7 @@ const char * const CPyLit_Str[] = {
276857276857
"\003\021brownie.utils.sql\veth_getCode\016LONGTERM_CACHE",
276858276858
"\005#brownie.network.middlewares.caching\ttable_key\003cur\004lock\vloop_thread",
276859276859
"\004\tis_killed\nlast_block\017last_block_seen\flast_request",
276860-
"\004\030RequestCachingMiddleware\fWeb3RPCError\017eth_estimateGas\beth_call",
276860+
"\004\030RequestCachingMiddleware\fWeb3RPCError\beth_call\017eth_estimateGas",
276861276861
"\004\frpc_response\005error\022ContractLogicError\017web3.exceptions",
276862276862
"\002+brownie.network.middlewares.catch_tx_revert\031TxRevertCatcherMiddleware",
276863276863
"\005\016client_version\nganache/v7\016programCounter\017program_counter\fVM Exception",
@@ -277213,8 +277213,8 @@ const int CPyLit_Tuple[] = {
277213277213
1196, 1196, 2, 2464, 2241, 2, 47, 51
277214277214
};
277215277215
const int CPyLit_FrozenSet[] = {
277216-
6, 3, 669, 670, 469, 3, 671, 470, 672, 2, 1075, 1076, 2, 1039, 1038,
277217-
3, 1076, 1039, 1038, 2, 2076, 2077
277216+
6, 3, 669, 469, 670, 3, 671, 672, 470, 2, 1075, 1076, 2, 1039, 1038,
277217+
3, 1075, 1039, 1038, 2, 2076, 2077
277218277218
};
277219277219
CPyModule *CPyModule_brownie____c_constants__internal = NULL;
277220277220
CPyModule *CPyModule_brownie____c_constants;

0 commit comments

Comments
 (0)