Skip to content

Commit

Permalink
feat(forks): Add pre-alloacted contract for 7002
Browse files Browse the repository at this point in the history
  • Loading branch information
marioevz committed May 17, 2024
1 parent 40cdf66 commit f501c64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,25 +491,40 @@ def solc_min_version(cls) -> Version:
@classmethod
def pre_allocation_blockchain(cls) -> Mapping:
"""
Prague requires pre-allocation of the beacon chain deposit contract for EIP-6110
Prague requires pre-allocation of the beacon chain deposit contract for EIP-6110, and
the exits contract for EIP-7002.
"""
DEPOSIT_CONTRACT_TREE_DEPTH = 32
new_allocation = {}

# Compute the initialization storage
# Add the beacon chain deposit contract
DEPOSIT_CONTRACT_TREE_DEPTH = 32
storage = {}
next_hash = sha256(b"\x00" * 64).digest()
for i in range(DEPOSIT_CONTRACT_TREE_DEPTH + 2, DEPOSIT_CONTRACT_TREE_DEPTH * 2 + 1):
storage[i] = next_hash
next_hash = sha256(next_hash + next_hash).digest()

with open(CURRENT_FOLDER / "deposit_contract.bin", mode="rb") as f:
new_allocation = {
0x00000000219AB540356CBB839CBE05303D7705FA: {
"nonce": 1,
"code": f.read(),
"storage": storage,
new_allocation.update(
{
0x00000000219AB540356CBB839CBE05303D7705FA: {
"nonce": 1,
"code": f.read(),
"storage": storage,
}
}
}
)

# Add the withdrawal request contract
with open(CURRENT_FOLDER / "withdrawal_request.bin", mode="rb") as f:
new_allocation.update(
{
0x00A3CA265EBCB825B45F985A16CEFB49958CE017: {
"nonce": 1,
"code": f.read(),
},
}
)
return new_allocation | super(Prague, cls).pre_allocation_blockchain()

@classmethod
Expand Down
Binary file added src/ethereum_test_forks/forks/withdrawal_request.bin
Binary file not shown.

0 comments on commit f501c64

Please sign in to comment.