Ensure that no duplidate block hashes

This commit is contained in:
Hsiao-Wei Wang 2023-01-04 18:09:38 +08:00
parent 0f07cdcf72
commit 9d14dcd8b0
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
1 changed files with 6 additions and 0 deletions

View File

@ -64,6 +64,7 @@ def test_from_syncing_to_invalid(spec, state):
block.body.execution_payload.parent_hash = (
block_hashes[f'chain_a_{i - 1}'] if i != 0 else block_hashes['block_0']
)
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_a_{i}', 'UTF-8'))
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block_hashes[f'chain_a_{i}'] = block.body.execution_payload.block_hash
@ -80,6 +81,7 @@ def test_from_syncing_to_invalid(spec, state):
block.body.execution_payload.parent_hash = (
block_hashes[f'chain_b_{i - 1}'] if i != 0 else block_hashes['block_0']
)
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_b_{i}', 'UTF-8'))
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block_hashes[f'chain_b_{i}'] = block.body.execution_payload.block_hash
@ -92,9 +94,13 @@ def test_from_syncing_to_invalid(spec, state):
# Now add block 4 to chain `b` with INVALID
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.parent_hash = signed_blocks_b[-1].message.body.execution_payload.block_hash
block.body.execution_payload.extra_data = spec.hash(bytes(f'chain_b_{i}', 'UTF-8'))
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
block_hashes['chain_b_3'] = block.body.execution_payload.block_hash
# Ensure that no duplicate block hashes
assert len(block_hashes) == len(set(block_hashes.values()))
signed_block = state_transition_and_sign_block(spec, state, block)
payload_status = PayloadStatusV1(
status=PayloadStatusV1Status.INVALID,