631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707 | @pytest.mark.with_all_contract_creating_tx_types()
def test_delegated_eoa_can_send_creating_tx(
state_test: StateTestFiller,
pre: Alloc,
tx_type: int,
fork: Fork,
) -> None:
"""
Test the executing a delegated EOA can send creating tx, with correct
context.
"""
storage = Storage()
delegation_code = Op.STOP
delegation_address = pre.deploy_contract(delegation_code)
designation = Spec.delegation_designation(delegation_address)
auth_signer = pre.fund_eoa(delegation=delegation_address)
test_bytes = b"\xde" * 32
deployed_address = compute_create_address(
address=auth_signer,
nonce=1,
)
initcode_len = 72
initcode = (
Op.SSTORE(storage.store_next(1, hint="outer code worked"), 1)
# verify that the sender being delegated doesn't affect context values
+ Op.SSTORE(storage.store_next(auth_signer, hint="sender"), Op.CALLER)
+ Op.SSTORE(storage.store_next(auth_signer, hint="origin"), Op.ORIGIN)
+ Op.SSTORE(
storage.store_next(deployed_address, hint="address"), Op.ADDRESS
)
+ Op.SSTORE(
storage.store_next(initcode_len, hint="codesize"), Op.CODESIZE
)
+ Op.SSTORE(
storage.store_next(Bytes().keccak256(), hint="codehash_address"),
Op.EXTCODEHASH(Op.ADDRESS),
)
+ Op.SSTORE(
storage.store_next(
designation.keccak256(), hint="codehash_origin"
),
Op.EXTCODEHASH(Op.ORIGIN),
)
# deploy
+ Op.MSTORE(0, Op.PUSH32(test_bytes))
+ Op.RETURN(0, len(test_bytes))
)
assert initcode_len == len(initcode)
tx = Transaction(
ty=tx_type,
gas_limit=200_000 + (Op.SSTORE(key_warm=False) * 7).gas_cost(fork),
to=None,
value=0,
data=initcode,
sender=auth_signer,
)
assert deployed_address == tx.created_contract
state_test(
pre=pre,
tx=tx,
post={
auth_signer: Account(
nonce=2,
code=Spec.delegation_designation(delegation_address),
storage={},
),
deployed_address: Account(code=test_bytes, storage=storage),
},
)
|