Skip to content

Commit 9084db0

Browse files
committed
new(tests): Add EIP-6110 Sepolia Variant Contract test
1 parent 78f962a commit 9084db0

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

tests/prague/eip6110_deposits/helpers.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,33 @@ def calldata(self) -> bytes:
8282
+ self.signature
8383
)
8484

85+
@cached_property
86+
def log(self) -> bytes:
87+
"""
88+
Returns the log data for the deposit event.
89+
90+
event DepositEvent(
91+
bytes pubkey,
92+
bytes withdrawal_credentials,
93+
bytes amount,
94+
bytes signature,
95+
bytes index
96+
);
97+
"""
98+
return (
99+
b"\0" * (192)
100+
+ self.pubkey
101+
+ b"\0" * (48)
102+
+ self.withdrawal_credentials
103+
+ b"\0" * (32)
104+
+ (self.amount).to_bytes(8, byteorder="little")
105+
+ b"\0" * (56)
106+
+ self.signature
107+
+ b"\0" * (32)
108+
+ (self.index).to_bytes(8, byteorder="little")
109+
+ b"\0" * (24)
110+
)
111+
85112
def with_source_address(self, source_address: Address) -> "DepositRequest":
86113
"""Return a copy."""
87114
return self.copy()
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
"""Test sepolia variant logs contract."""
2+
3+
from ethereum_test_tools import (
4+
Account,
5+
Alloc,
6+
Block,
7+
BlockchainTestFiller,
8+
Header,
9+
Requests,
10+
Transaction,
11+
)
12+
from ethereum_test_tools import Macros as Om
13+
from ethereum_test_tools import Opcodes as Op
14+
15+
from .helpers import DepositRequest
16+
from .spec import Spec, ref_spec_6110
17+
18+
REFERENCE_SPEC_GIT_PATH = ref_spec_6110.git_path
19+
REFERENCE_SPEC_VERSION = ref_spec_6110.version
20+
21+
22+
def test_sepolia_extraneous_log(
23+
blockchain_test: BlockchainTestFiller,
24+
pre: Alloc,
25+
):
26+
"""Test sepolia variant logs contract."""
27+
# Supplant mainnet contract with the Sepolia variant, which emits two logs, one of which
28+
# has a different data length.
29+
deposit_request = DepositRequest(
30+
pubkey=0x01,
31+
withdrawal_credentials=0x02,
32+
amount=120_000_000_000_000_000,
33+
signature=0x03,
34+
index=0x0,
35+
)
36+
37+
bytecode = (
38+
Op.LOG1(
39+
# ERC-20 token transfer log
40+
0,
41+
32,
42+
0xDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF,
43+
)
44+
+ Om.MSTORE(deposit_request.log)
45+
+ Op.LOG1(
46+
0,
47+
len(deposit_request.log),
48+
0x649BBC62D0E31342AFEA4E5CD82D4049E7E1EE912FC0889AA790803BE39038C5,
49+
)
50+
+ Op.STOP
51+
)
52+
assert len(deposit_request.log) == 576
53+
54+
pre[Spec.DEPOSIT_CONTRACT_ADDRESS] = Account(
55+
code=bytecode,
56+
nonce=1,
57+
balance=0,
58+
)
59+
sender = pre.fund_eoa()
60+
61+
tx = Transaction(
62+
to=Spec.DEPOSIT_CONTRACT_ADDRESS,
63+
sender=sender,
64+
gas_limit=100_000,
65+
)
66+
67+
blockchain_test(
68+
pre=pre,
69+
blocks=[
70+
Block(
71+
txs=[tx],
72+
header_verify=Header(
73+
requests_hash=Requests(deposit_request),
74+
),
75+
),
76+
],
77+
post={},
78+
)

0 commit comments

Comments
 (0)