mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-02 03:15:11 -05:00
Merge branch 'hardcoded-ttd' into tests/merge
This commit is contained in:
@@ -52,7 +52,7 @@ def test_process_light_client_update_not_updated(spec, state):
|
||||
sync_committee_signature = compute_aggregate_sync_committee_signature(
|
||||
spec,
|
||||
state,
|
||||
block.slot,
|
||||
block_header.slot,
|
||||
committee,
|
||||
)
|
||||
next_sync_committee_branch = [spec.Bytes32() for _ in range(spec.floorlog2(spec.NEXT_SYNC_COMMITTEE_INDEX))]
|
||||
|
||||
@@ -100,8 +100,7 @@ def build_empty_block(spec, state, slot=None):
|
||||
empty_block.body.sync_aggregate.sync_committee_signature = spec.G2_POINT_AT_INFINITY
|
||||
|
||||
if is_post_merge(spec):
|
||||
randao_mix = spec.compute_randao_mix(state, empty_block.body.randao_reveal)
|
||||
empty_block.body.execution_payload = build_empty_execution_payload(spec, state, randao_mix)
|
||||
empty_block.body.execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
return empty_block
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None):
|
||||
gas_limit=latest.gas_limit, # retain same limit
|
||||
gas_used=0, # empty block, 0 gas
|
||||
timestamp=timestamp,
|
||||
extra_data=spec.ByteList[spec.MAX_EXTRA_DATA_BYTES](),
|
||||
base_fee_per_gas=latest.base_fee_per_gas, # retain same base_fee
|
||||
block_hash=spec.Hash32(),
|
||||
transactions=empty_txs,
|
||||
@@ -45,6 +46,7 @@ def get_execution_payload_header(spec, execution_payload):
|
||||
gas_limit=execution_payload.gas_limit,
|
||||
gas_used=execution_payload.gas_used,
|
||||
timestamp=execution_payload.timestamp,
|
||||
extra_data=execution_payload.extra_data,
|
||||
base_fee_per_gas=execution_payload.base_fee_per_gas,
|
||||
block_hash=execution_payload.block_hash,
|
||||
transactions_root=spec.hash_tree_root(execution_payload.transactions)
|
||||
|
||||
@@ -148,6 +148,34 @@ def test_bad_parent_hash_regular_payload(spec, state):
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
|
||||
|
||||
@with_merge_and_later
|
||||
@spec_state_test
|
||||
def test_bad_random_first_payload(spec, state):
|
||||
# pre-state
|
||||
state = build_state_with_incomplete_transition(spec, state)
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
execution_payload.random = b'\x42' * 32
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
|
||||
|
||||
@with_merge_and_later
|
||||
@spec_state_test
|
||||
def test_bad_random_regular_payload(spec, state):
|
||||
# pre-state
|
||||
state = build_state_with_complete_transition(spec, state)
|
||||
next_slot(spec, state)
|
||||
|
||||
# execution payload
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
execution_payload.random = b'\x04' * 32
|
||||
|
||||
yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
|
||||
|
||||
|
||||
@with_merge_and_later
|
||||
@spec_state_test
|
||||
def test_bad_number_regular_payload(spec, state):
|
||||
|
||||
@@ -143,6 +143,9 @@ def process_and_sign_block_without_header_validations(spec, state, block):
|
||||
state_root=spec.Bytes32(),
|
||||
body_root=block.body.hash_tree_root(),
|
||||
)
|
||||
if is_post_merge(spec):
|
||||
if spec.is_execution_enabled(state, block.body):
|
||||
spec.process_execution_payload(state, block.body.execution_payload, spec.EXECUTION_ENGINE)
|
||||
|
||||
# Perform rest of process_block transitions
|
||||
spec.process_randao(state, block.body)
|
||||
@@ -150,9 +153,6 @@ def process_and_sign_block_without_header_validations(spec, state, block):
|
||||
spec.process_operations(state, block.body)
|
||||
if is_post_altair(spec):
|
||||
spec.process_sync_aggregate(state, block.body.sync_aggregate)
|
||||
if is_post_merge(spec):
|
||||
if spec.is_execution_enabled(state, block.body):
|
||||
spec.process_execution_payload(state, block.body.execution_payload, spec.EXECUTION_ENGINE)
|
||||
|
||||
# Insert post-state rot
|
||||
block.state_root = state.hash_tree_root()
|
||||
@@ -196,8 +196,7 @@ def test_parent_from_same_slot(spec, state):
|
||||
child_block.parent_root = state.latest_block_header.hash_tree_root()
|
||||
|
||||
if is_post_merge(spec):
|
||||
randao_mix = spec.compute_randao_mix(state, child_block.body.randao_reveal)
|
||||
child_block.body.execution_payload = build_empty_execution_payload(spec, state, randao_mix)
|
||||
child_block.body.execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
# Show that normal path through transition fails
|
||||
failed_state = state.copy()
|
||||
|
||||
Reference in New Issue
Block a user