Skip to content

Commit

Permalink
Merge pull request #35 from ethereum/genesis-rlp-difficulty-fix
Browse files Browse the repository at this point in the history
spec,filler: Fix `difficulty>0` on post merge fixtures, add `genesisRLP`
  • Loading branch information
spencer-tb authored Jan 19, 2023
2 parents 1b5c61c + cb28984 commit 4de323c
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/ethereum_test_tools/common/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ class Fixture:

blocks: List[FixtureBlock]
genesis: FixtureHeader
genesis_rlp: str
head: str
fork: str
pre_state: Mapping[str, Account]
Expand Down Expand Up @@ -990,6 +991,7 @@ def default(self, obj):
for b in obj.blocks
],
"genesisBlockHeader": self.default(obj.genesis),
"genesisRLP": obj.genesis_rlp,
"lastblockhash": obj.head,
"network": obj.fork,
"pre": json.loads(json.dumps(obj.pre_state, cls=JSONEncoder)),
Expand Down
3 changes: 2 additions & 1 deletion src/ethereum_test_tools/filling/fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def fill_test(

t8n.reset_traces()

genesis = test.make_genesis(b11r, t8n, fork)
genesis_rlp, genesis = test.make_genesis(b11r, t8n, fork)

try:
(blocks, head, alloc) = test.make_blocks(
Expand All @@ -57,6 +57,7 @@ def fill_test(
fixture = Fixture(
blocks=blocks,
genesis=genesis,
genesis_rlp=genesis_rlp,
head=head,
fork="+".join([fork] + [str(eip) for eip in eips])
if eips is not None
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum_test_tools/spec/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def make_genesis(
b11r: BlockBuilder,
t8n: TransitionTool,
fork: str,
) -> FixtureHeader:
) -> Tuple[str, FixtureHeader]:
"""
Create a genesis block from the test definition.
"""
Expand Down
8 changes: 4 additions & 4 deletions src/ethereum_test_tools/spec/blockchain_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def make_genesis(
b11r: BlockBuilder,
t8n: TransitionTool,
fork: str,
) -> FixtureHeader:
) -> Tuple[str, FixtureHeader]:
"""
Create a genesis block from the state test definition.
"""
Expand All @@ -67,7 +67,7 @@ def make_genesis(
transactions_root=EmptyTrieRoot,
receipt_root=EmptyTrieRoot,
bloom="0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", # noqa: E501
difficulty=0x20000,
difficulty=0x20000 if env.difficulty is None else env.difficulty,
number=0,
gas_limit=env.gas_limit,
gas_used=0,
Expand All @@ -81,10 +81,10 @@ def make_genesis(
else None,
)

(_, h) = b11r.build(genesis.to_geth_dict(), "", [])
(genesis_rlp, h) = b11r.build(genesis.to_geth_dict(), "", [])
genesis.hash = h

return genesis
return genesis_rlp, genesis

def make_block(
self,
Expand Down
8 changes: 4 additions & 4 deletions src/ethereum_test_tools/spec/state_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def make_genesis(
b11r: BlockBuilder,
t8n: TransitionTool,
fork: str,
) -> FixtureHeader:
) -> Tuple[str, FixtureHeader]:
"""
Create a genesis block from the state test definition.
"""
Expand All @@ -66,7 +66,7 @@ def make_genesis(
transactions_root=EmptyTrieRoot,
receipt_root=EmptyTrieRoot,
bloom="0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", # noqa: E501
difficulty=0x20000,
difficulty=0x20000 if env.difficulty is None else env.difficulty,
number=env.number - 1,
gas_limit=env.gas_limit,
# We need the base fee to remain unchanged from the genesis
Expand All @@ -84,10 +84,10 @@ def make_genesis(
else None,
)

(_, h) = b11r.build(genesis.to_geth_dict(), "", [])
(genesis_rlp, h) = b11r.build(genesis.to_geth_dict(), "", [])
genesis.hash = h

return genesis
return genesis_rlp, genesis

def make_blocks(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum_test_tools/tests/test_filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_make_genesis(fork: str, hash: str):
b11r = EvmBlockBuilder()
t8n = EvmTransitionTool()

genesis = StateTest(
_, genesis = StateTest(
env=env, pre=pre, post={}, txs=[], name="some_state_test"
).make_genesis(b11r, t8n, fork)
assert genesis.hash is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"baseFeePerGas": "0x3e8",
"hash": "0x6241b4534da26b654ec5bb30d29b1d5202454af544b05828433354da7471957c"
},
"genesisRLP": "0xf90200f901fba00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a089a5be1d3306f6f05b42678ef13ac3dbc37bef9a2a80862c21eb22eee29194c2a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008088016345785d8a0000808000a000000000000000000000000000000000000000000000000000000000000000008800000000000000008203e8c0c0",
"lastblockhash": "0xf5e2f23d9a212edbb35a07bc9f582f4a632b694bd4ef8742de8ad6c6acacf72c",
"network": "London",
"pre": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"baseFeePerGas": "0x3e8",
"hash": "0x6241b4534da26b654ec5bb30d29b1d5202454af544b05828433354da7471957c"
},
"genesisRLP": "0xf90200f901fba00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a089a5be1d3306f6f05b42678ef13ac3dbc37bef9a2a80862c21eb22eee29194c2a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b9010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000830200008088016345785d8a0000808000a000000000000000000000000000000000000000000000000000000000000000008800000000000000008203e8c0c0",
"lastblockhash": "0xf5e2f23d9a212edbb35a07bc9f582f4a632b694bd4ef8742de8ad6c6acacf72c",
"network": "London",
"pre": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"nonce": "0x0000000000000000",
"hash": "0x07a0192766c62d9bdb9e357ebdffd4d8c1d12c15b467c453772c3f8027f02886"
},
"genesisRLP": "0xf901fff901faa00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0aff9f63320a482f8c4e4f15f659e6a7ac382138fbbb6919243b0cba4c5988a5aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be40085012a05f2008000a00000000000000000000000000000000000000000000000000000000000000000880000000000000000c0c0",
"lastblockhash": "0xe1eaa067c6bc24e4dd3dc7e2a8cff9d7dcc8783548228b1e0f85bdff2bfd087c",
"network": "Istanbul",
"pre": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"baseFeePerGas": "0x7",
"hash": "0xc23ec9a992cd009c20de66b8b0b54f358f1b684ed55f841d71aa5031e1c11b5f"
},
"genesisRLP": "0xf90200f901fba00000000000000000000000000000000000000000000000000000000000000000a01dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347940000000000000000000000000000000000000000a0aff9f63320a482f8c4e4f15f659e6a7ac382138fbbb6919243b0cba4c5988a5aa056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421a056e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421b901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000083020000808502540be40085012a05f2008000a0000000000000000000000000000000000000000000000000000000000000000088000000000000000007c0c0",
"lastblockhash": "0x1efac4df8d7cb16ef204132c796dba20ecda56a5bcd60be83eddd22330a0402a",
"network": "London",
"pre": {
Expand Down

0 comments on commit 4de323c

Please sign in to comment.