Skip to content

Commit

Permalink
Rename requests_root to requests_hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jtraglia committed Nov 22, 2024
1 parent bfe166c commit 4aad8eb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions tests/core/pyspec/eth2spec/test/helpers/execution_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def compute_el_header_block_hash(spec,
transactions_trie_root,
withdrawals_trie_root=None,
parent_beacon_block_root=None,
requests_root=None):
requests_hash=None):
"""
Computes the RLP execution block hash described by an `ExecutionPayloadHeader`.
"""
Expand Down Expand Up @@ -133,8 +133,8 @@ def compute_el_header_block_hash(spec,
# parent_beacon_root
execution_payload_header_rlp.append((Binary(32, 32), parent_beacon_block_root))
if is_post_electra(spec):
# requests_root
execution_payload_header_rlp.append((Binary(32, 32), requests_root))
# requests_hash
execution_payload_header_rlp.append((Binary(32, 32), requests_hash))

sedes = List([schema for schema, _ in execution_payload_header_rlp])
values = [value for _, value in execution_payload_header_rlp]
Expand Down Expand Up @@ -210,7 +210,7 @@ def get_consolidation_request_rlp_bytes(consolidation_request):
return b"\x02" + encode(values, sedes)


def compute_el_block_hash_with_new_fields(spec, payload, parent_beacon_block_root, requests_root):
def compute_el_block_hash_with_new_fields(spec, payload, parent_beacon_block_root, requests_hash):
if payload == spec.ExecutionPayload():
return spec.Hash32()

Expand All @@ -232,35 +232,35 @@ def compute_el_block_hash_with_new_fields(spec, payload, parent_beacon_block_roo
transactions_trie_root,
withdrawals_trie_root,
parent_beacon_block_root,
requests_root,
requests_hash,
)


def compute_el_block_hash(spec, payload, pre_state):
parent_beacon_block_root = None
requests_root = None
requests_hash = None

if is_post_deneb(spec):
previous_block_header = pre_state.latest_block_header.copy()
if previous_block_header.state_root == spec.Root():
previous_block_header.state_root = pre_state.hash_tree_root()
parent_beacon_block_root = previous_block_header.hash_tree_root()
if is_post_electra(spec):
requests_root = compute_requests_hash([])
requests_hash = compute_requests_hash([])

return compute_el_block_hash_with_new_fields(
spec, payload, parent_beacon_block_root, requests_root)
spec, payload, parent_beacon_block_root, requests_hash)


def compute_el_block_hash_for_block(spec, block):
requests_root = None
requests_hash = None

if is_post_electra(spec):
requests_list = spec.get_execution_requests_list(block.body.execution_requests)
requests_root = compute_requests_hash(requests_list)
requests_hash = compute_requests_hash(requests_list)

return compute_el_block_hash_with_new_fields(
spec, block.body.execution_payload, block.parent_root, requests_root)
spec, block.body.execution_payload, block.parent_root, requests_hash)


def build_empty_post_eip7732_execution_payload_header(spec, state):
Expand Down
6 changes: 3 additions & 3 deletions tests/core/pyspec/eth2spec/test/helpers/genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ def get_sample_genesis_execution_payload_header(spec,
transactions_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
withdrawals_trie_root = None
parent_beacon_block_root = None
requests_root = None
requests_hash = None

if is_post_capella(spec):
withdrawals_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421")
if is_post_deneb(spec):
parent_beacon_block_root = bytes.fromhex("0000000000000000000000000000000000000000000000000000000000000000")
if is_post_electra(spec):
requests_root = sha256(b"").digest()
requests_hash = sha256(b"").digest()

payload_header.block_hash = compute_el_header_block_hash(
spec,
payload_header,
transactions_trie_root,
withdrawals_trie_root,
parent_beacon_block_root,
requests_root,
requests_hash,
)
return payload_header

Expand Down

0 comments on commit 4aad8eb

Please sign in to comment.