Skip to content

Commit f74f2a3

Browse files
committed
lint
1 parent 4c8c279 commit f74f2a3

209 files changed

Lines changed: 4514 additions & 4510 deletions

File tree

Some content is hidden

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

scripts/filler_to_python/analyzer.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -772,13 +772,14 @@ def _find_address_refs_in_bytecode(
772772
code_bytes: bytes,
773773
known_addresses: set[Address],
774774
) -> dict[Address, int]:
775-
"""Find which known addresses are referenced in bytecode via PUSH.
775+
"""
776+
Find known addresses referenced in bytecode via PUSH.
776777
777-
Return a mapping ``address -> minimum PUSH size observed``. A push size
778-
smaller than 20 means the baseline bytecode compiled the address down
779-
to fewer bytes (the original address had leading zero bytes); the
780-
referenced contract must stay hardcoded so that the compiler keeps
781-
emitting the same short PUSH opcode and the trace stays aligned.
778+
Return a mapping ``address -> minimum PUSH size observed``.
779+
A push size < 20 means the baseline bytecode compiled the
780+
address to fewer bytes (leading zero bytes); the referenced
781+
contract must stay hardcoded so the compiler keeps emitting
782+
the same short PUSH opcode and the trace stays aligned.
782783
"""
783784
refs: dict[Address, int] = {}
784785
# Pre-compute int values for fast comparison
@@ -819,8 +820,8 @@ def _topological_sort_contracts(
819820
"""
820821
addr_set = set(contract_addrs)
821822
# forward[B] = {A} means A depends on B, so B must come first
822-
forward: dict[Address, set[Address]] = {a: set() for a in addr_set}
823-
in_deg: dict[Address, int] = {a: 0 for a in addr_set}
823+
forward: dict[Address, set[Address]] = {a: set() for a in addr_set} # noqa: C420
824+
in_deg: dict[Address, int] = dict.fromkeys(addr_set, 0)
824825
for a, dep_set in deps.items():
825826
if a not in addr_set:
826827
continue
@@ -1015,7 +1016,10 @@ def _build_accounts(
10151016
changed = False
10161017
for addr in list(non_dynamic_addrs):
10171018
for ref in deps.get(addr, set()):
1018-
if ref not in non_dynamic_addrs and ref in known_contract_addrs:
1019+
if (
1020+
ref not in non_dynamic_addrs
1021+
and ref in known_contract_addrs
1022+
):
10191023
non_dynamic_addrs.add(ref)
10201024
changed = True
10211025

@@ -1057,13 +1061,13 @@ def _build_accounts(
10571061
# sequential addresses and cannot be dynamically assigned.
10581062
# If found, disable dynamic for ALL contracts.
10591063
# ------------------------------------------------------------------
1060-
_ARITH_OPS = {"Op.ADD(", "Op.SUB(", "Op.MUL(", "Op.DIV("}
1064+
arith_ops = {"Op.ADD(", "Op.SUB(", "Op.MUL(", "Op.DIV("}
10611065
has_addr_arithmetic = False
10621066
for acct in raw_accounts:
10631067
if not acct.code_expr:
10641068
continue
10651069
for var_name in addr_var_names:
1066-
for arith_op in _ARITH_OPS:
1070+
for arith_op in arith_ops:
10671071
if f"{arith_op}{var_name}" in acct.code_expr:
10681072
has_addr_arithmetic = True
10691073
break
@@ -1078,7 +1082,7 @@ def _build_accounts(
10781082
# do this usually rely on specific pre-state contract addresses
10791083
# (dispatch-by-offset) and won't survive dynamic allocation.
10801084
# ------------------------------------------------------------------
1081-
_COMPUTED_ADDR_PATTERNS = (
1085+
computed_addr_patterns = (
10821086
"address=Op.ADD(",
10831087
"address=Op.SUB(",
10841088
"address=Op.MUL(",
@@ -1092,7 +1096,7 @@ def _build_accounts(
10921096
for acct in raw_accounts:
10931097
if not acct.code_expr:
10941098
continue
1095-
for pat in _COMPUTED_ADDR_PATTERNS:
1099+
for pat in computed_addr_patterns:
10961100
if pat in acct.code_expr:
10971101
has_computed_call_target = True
10981102
break

scripts/filler_to_python/templates/state_test.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def {{ test_name }}(
216216
{% elif account.is_sender %}
217217
pre[sender] = Account(balance={{ account.balance | format_int }}{{ ", nonce=%d" | format(account.nonce) if account.nonce }}{{ ", storage=%s" | format(account.storage | format_storage) if account.storage }}{{ ", code=%s" | format(account.code_expr | wrap_op_chain(indent=8)) if account.code_expr }})
218218
{% elif account.is_eoa and account.use_dynamic %}
219-
{{ account.var_name }} = pre.fund_eoa(amount={{ account.balance | format_int }})
219+
{{ account.var_name }} = pre.fund_eoa(amount={{ account.balance | format_int }}) # noqa: F841
220220
{% elif account.is_eoa %}
221221
pre[{{ account.var_name }}] = Account(balance={{ account.balance | format_int }}{{ ", nonce=%d" | format(account.nonce) if account.nonce }}{{ ", storage=%s" | format(account.storage | format_storage) if account.storage }}{{ ", code=%s" | format(account.code_expr | wrap_op_chain(indent=8)) if account.code_expr }})
222222
{% else %}

tests/ported_static/stBadOpcode/test_measure_gas.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ def test_measure_gas(
262262
)
263263
# Source: yul
264264
# berlin {
265-
# let retval := callcode(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
265+
# let retval := call(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
266266
# }
267-
contract_4 = pre.deploy_contract( # noqa: F841
268-
code=Op.CALLCODE(
267+
contract_3 = pre.deploy_contract( # noqa: F841
268+
code=Op.CALL(
269269
gas=Op.GAS,
270270
address=contract_2,
271271
value=Op.DUP1,
@@ -280,12 +280,13 @@ def test_measure_gas(
280280
)
281281
# Source: yul
282282
# berlin {
283-
# let retval := delegatecall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
283+
# let retval := callcode(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
284284
# }
285-
contract_5 = pre.deploy_contract( # noqa: F841
286-
code=Op.DELEGATECALL(
285+
contract_4 = pre.deploy_contract( # noqa: F841
286+
code=Op.CALLCODE(
287287
gas=Op.GAS,
288288
address=contract_2,
289+
value=Op.DUP1,
289290
args_offset=Op.DUP2,
290291
args_size=Op.DUP2,
291292
ret_offset=0x0,
@@ -297,13 +298,12 @@ def test_measure_gas(
297298
)
298299
# Source: yul
299300
# berlin {
300-
# let retval := call(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
301+
# let retval := staticcall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
301302
# }
302-
contract_3 = pre.deploy_contract( # noqa: F841
303-
code=Op.CALL(
303+
contract_6 = pre.deploy_contract( # noqa: F841
304+
code=Op.STATICCALL(
304305
gas=Op.GAS,
305306
address=contract_2,
306-
value=Op.DUP1,
307307
args_offset=Op.DUP2,
308308
args_size=Op.DUP2,
309309
ret_offset=0x0,
@@ -331,10 +331,10 @@ def test_measure_gas(
331331
)
332332
# Source: yul
333333
# berlin {
334-
# let retval := staticcall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
334+
# let retval := delegatecall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
335335
# }
336-
contract_6 = pre.deploy_contract( # noqa: F841
337-
code=Op.STATICCALL(
336+
contract_5 = pre.deploy_contract( # noqa: F841
337+
code=Op.DELEGATECALL(
338338
gas=Op.GAS,
339339
address=contract_2,
340340
args_offset=Op.DUP2,

tests/ported_static/stBadOpcode/test_operation_diff_gas.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ def test_operation_diff_gas(
257257
)
258258
# Source: yul
259259
# berlin {
260-
# let retval := callcode(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
260+
# let retval := call(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
261261
# }
262-
contract_3 = pre.deploy_contract( # noqa: F841
263-
code=Op.CALLCODE(
262+
contract_2 = pre.deploy_contract( # noqa: F841
263+
code=Op.CALL(
264264
gas=Op.GAS,
265265
address=contract_6,
266266
value=Op.DUP1,
@@ -275,12 +275,13 @@ def test_operation_diff_gas(
275275
)
276276
# Source: yul
277277
# berlin {
278-
# let retval := delegatecall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
278+
# let retval := callcode(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
279279
# }
280-
contract_4 = pre.deploy_contract( # noqa: F841
281-
code=Op.DELEGATECALL(
280+
contract_3 = pre.deploy_contract( # noqa: F841
281+
code=Op.CALLCODE(
282282
gas=Op.GAS,
283283
address=contract_6,
284+
value=Op.DUP1,
284285
args_offset=Op.DUP2,
285286
args_size=Op.DUP2,
286287
ret_offset=0x0,
@@ -292,13 +293,12 @@ def test_operation_diff_gas(
292293
)
293294
# Source: yul
294295
# berlin {
295-
# let retval := call(gas(), 0xCA11, 0, 0, 0x100, 0, 0x100)
296+
# let retval := staticcall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
296297
# }
297-
contract_2 = pre.deploy_contract( # noqa: F841
298-
code=Op.CALL(
298+
contract_5 = pre.deploy_contract( # noqa: F841
299+
code=Op.STATICCALL(
299300
gas=Op.GAS,
300301
address=contract_6,
301-
value=Op.DUP1,
302302
args_offset=Op.DUP2,
303303
args_size=Op.DUP2,
304304
ret_offset=0x0,
@@ -326,10 +326,10 @@ def test_operation_diff_gas(
326326
)
327327
# Source: yul
328328
# berlin {
329-
# let retval := staticcall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
329+
# let retval := delegatecall(gas(), 0xCA11, 0, 0x100, 0, 0x100)
330330
# }
331-
contract_5 = pre.deploy_contract( # noqa: F841
332-
code=Op.STATICCALL(
331+
contract_4 = pre.deploy_contract( # noqa: F841
332+
code=Op.DELEGATECALL(
333333
gas=Op.GAS,
334334
address=contract_6,
335335
args_offset=Op.DUP2,

tests/ported_static/stCallCodes/test_call_oog_additional_gas_costs1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_call_oog_additional_gas_costs1(
4343
gas_limit=3000000000,
4444
)
4545

46-
coinbase = pre.fund_eoa(amount=0)
46+
coinbase = pre.fund_eoa(amount=0) # noqa: F841
4747
# Source: raw
4848
# 0x6000
4949
addr = pre.deploy_contract( # noqa: F841

tests/ported_static/stCallCodes/test_call_oog_additional_gas_costs2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_call_oog_additional_gas_costs2(
4343
gas_limit=3000000000,
4444
)
4545

46-
coinbase = pre.fund_eoa(amount=0)
46+
coinbase = pre.fund_eoa(amount=0) # noqa: F841
4747
# Source: raw
4848
# 0x6000
4949
addr = pre.deploy_contract( # noqa: F841

tests/ported_static/stCallCreateCallCodeTest/test_call1024_balance_too_low.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_call1024_balance_too_low(
4444
gas_limit=9223372036854775807,
4545
)
4646

47-
addr = pre.fund_eoa(amount=7000)
47+
addr = pre.fund_eoa(amount=7000) # noqa: F841
4848
# Source: lll
4949
# { [[ 0 ]] (ADD @@0 1) [[ 1 ]] (CALL 0xfffffffffff <contract:target:0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b> @@0 0 0 0 0) } # noqa: E501
5050
target = pre.deploy_contract( # noqa: F841

tests/ported_static/stCallCreateCallCodeTest/test_call1024_oog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_call1024_oog(
8080
gas_limit=9223372036854775807,
8181
)
8282

83-
addr = pre.fund_eoa(amount=7000)
83+
addr = pre.fund_eoa(amount=7000) # noqa: F841
8484
# Source: lll
8585
# { [[ 0 ]] (ADD @@0 1) [[ 1 ]] (CALL (MUL (SUB (GAS) 10000) (SUB 1 (DIV @@0 1025))) <contract:target:0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b> 0 0 0 0 0) [[ 2 ]] (ADD 1(MUL @@0 1000)) } # noqa: E501
8686
target = pre.deploy_contract( # noqa: F841

tests/ported_static/stCallCreateCallCodeTest/test_call_lose_gas_oog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def test_call_lose_gas_oog(
4343
gas_limit=9223372036854775807,
4444
)
4545

46-
addr = pre.fund_eoa(amount=7000)
46+
addr = pre.fund_eoa(amount=7000) # noqa: F841
4747
# Source: lll
4848
# { [[ 0 ]] (ADD @@0 1) [[ 1 ]] (CALL (ADD 1(MUL @@0 100000)) <contract:target:0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b> 0 0 0 0 0) [[ 2 ]] (ADD 1(MUL @@0 1000)) } # noqa: E501
4949
target = pre.deploy_contract( # noqa: F841

tests/ported_static/stCallCreateCallCodeTest/test_callcode1024_balance_too_low.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_callcode1024_balance_too_low(
4646
gas_limit=9223372036854775807,
4747
)
4848

49-
addr = pre.fund_eoa(amount=7000)
49+
addr = pre.fund_eoa(amount=7000) # noqa: F841
5050
# Source: lll
5151
# { [[ 0 ]] (ADD @@0 1) [[ 1 ]] (CALLCODE 0xfffffffffff <contract:target:0xbbbf5374fce5edbc8e2a8697c15331677e6ebf0b> @@0 0 0 0 0) } # noqa: E501
5252
target = pre.deploy_contract( # noqa: F841

0 commit comments

Comments
 (0)