Skip to content

Commit 9ee19ac

Browse files
spencer-tbMariusVanDerWijdenmarioevz
authored
fillers/eips/eip3860: Update EIP-3860 Due to Spec Change (#29)
* Small change for EIP-3860 spec change. * Small change for EIP-3860 spec change and fix for salt change. * Tox fix. * Add additional OOG error catching. * Fix initcode contract data copy. * Merge conflicts. * fillers/eips: add salt to create2 contract creation (#20) * fillers/eips: add salt to create2 contract creation (#20) * SSTORE a value regardless of what CALL returns for further validation. * Apply suggestions from code review Co-authored-by: Marius van der Wijden <[email protected]> Co-authored-by: Mario Vega <[email protected]>
1 parent 00dc3c1 commit 9ee19ac

File tree

1 file changed

+40
-4
lines changed

1 file changed

+40
-4
lines changed

fillers/eips/eip3860.py

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,18 @@ def generate_create_opcode_initcode_test_cases(
457457
"""
458458
env = Environment()
459459

460+
call_code = Yul(
461+
"""
462+
{
463+
calldatacopy(0, 0, calldatasize())
464+
let call_result := call(5000000, \
465+
0x0000000000000000000000000000000000000100, \
466+
0, 0, calldatasize(), 0, 0)
467+
sstore(call_result, 1)
468+
}
469+
"""
470+
)
471+
460472
if opcode == "create":
461473
code = Yul(
462474
"""
@@ -483,7 +495,7 @@ def generate_create_opcode_initcode_test_cases(
483495
let contract_length := calldatasize()
484496
calldatacopy(0, 0, contract_length)
485497
let gas1 := gas()
486-
let res := create2(0, 0, contract_length, 0xdeadbeef)
498+
let res := create2(0, 0, contract_length, 0xDEADBEEF)
487499
let gas2 := gas()
488500
sstore(0, res)
489501
sstore(1, sub(gas1, gas2))
@@ -492,9 +504,10 @@ def generate_create_opcode_initcode_test_cases(
492504
)
493505
created_contract_address = compute_create2_address(
494506
address=0x100,
495-
salt=0,
507+
salt=0xDEADBEEF,
496508
initcode=initcode.assemble(),
497509
)
510+
498511
else:
499512
raise Exception("invalid opcode for generator")
500513

@@ -504,13 +517,17 @@ def generate_create_opcode_initcode_test_cases(
504517
code=code,
505518
nonce=1,
506519
),
520+
to_address(0x200): Account(
521+
code=call_code,
522+
nonce=1,
523+
),
507524
}
508525

509526
post: Dict[Any, Any] = {}
510527

511528
tx = Transaction(
512529
nonce=0,
513-
to=to_address(0x100),
530+
to=to_address(0x200),
514531
data=initcode,
515532
gas_limit=10000000,
516533
gas_price=10,
@@ -525,14 +542,24 @@ def generate_create_opcode_initcode_test_cases(
525542
expected_gas_usage += PUSH_DUP_OPCODE_GAS
526543

527544
if len(initcode.assemble()) > MAX_INITCODE_SIZE and eip_3860_active:
545+
# Call returns 0 as out of gas s[0]==1
546+
post[to_address(0x200)] = Account(
547+
nonce=1,
548+
storage={
549+
0: 1,
550+
1: 0,
551+
},
552+
)
553+
528554
post[created_contract_address] = Account.NONEXISTENT
529555
post[to_address(0x100)] = Account(
530556
nonce=1,
531557
storage={
532558
0: 0,
533-
1: expected_gas_usage,
559+
1: 0,
534560
},
535561
)
562+
536563
else:
537564
# The initcode is only executed if the length check succeeds
538565
expected_gas_usage += initcode.execution_gas
@@ -552,6 +579,15 @@ def generate_create_opcode_initcode_test_cases(
552579
len(initcode.assemble())
553580
)
554581

582+
# Call returns 1 as valid initcode length s[0]==1 && s[1]==1
583+
post[to_address(0x200)] = Account(
584+
nonce=1,
585+
storage={
586+
0: 0,
587+
1: 1,
588+
},
589+
)
590+
555591
post[created_contract_address] = Account(code=initcode.deploy_code)
556592
post[to_address(0x100)] = Account(
557593
nonce=2,

0 commit comments

Comments
 (0)