Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed May 16, 2023
1 parent 0581373 commit d163bef
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion specs/_features/eip6110/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
# Verify the execution payload is valid
versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments]
assert execution_engine.notify_new_payload(NewPayloadRequest(execution_payload=payload))
assert execution_engine.notify_new_payload(
NewPayloadRequest(execution_payload=payload, versioned_hashes=versioned_hashes)
)
# Cache execution payload header
state.latest_execution_payload_header = ExecutionPayloadHeader(
parent_hash=payload.parent_hash,
Expand Down
5 changes: 4 additions & 1 deletion specs/deneb/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,11 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
# Verify the execution payload is valid
# [Modified in Deneb]
versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments]
assert execution_engine.notify_new_payload(NewPayloadRequest(execution_payload=payload, versioned_hashes=versioned_hashes))
assert execution_engine.notify_new_payload(
NewPayloadRequest(execution_payload=payload, versioned_hashes=versioned_hashes)
)

# Cache execution payload header
state.latest_execution_payload_header = ExecutionPayloadHeader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,35 @@ def run_execution_payload_processing(spec, state, execution_payload, valid=True,
- post-state ('post').
If ``valid == False``, run expecting ``AssertionError``
"""
# Before Deneb, only `body.execution_payload` matters. `BeaconBlockBody` is just a wrapper.
body = spec.BeaconBlockBody(execution_payload=execution_payload)

yield 'pre', state
yield 'execution', {'execution_valid': execution_valid}
yield 'execution_payload', execution_payload
yield 'body', body

called_new_block = False

class TestEngine(spec.NoopExecutionEngine):
def notify_new_payload(self, new_payload_request) -> bool:
nonlocal called_new_block, execution_valid
called_new_block = True
assert new_payload_request.execution_payload == execution_payload
assert new_payload_request.execution_payload == body.execution_payload
return execution_valid

if not valid:
expect_assertion_error(lambda: spec.process_execution_payload(state, execution_payload, TestEngine()))
expect_assertion_error(lambda: spec.process_execution_payload(state, body, TestEngine()))
yield 'post', None
return

spec.process_execution_payload(state, execution_payload, TestEngine())
spec.process_execution_payload(state, body, TestEngine())

# Make sure we called the engine
assert called_new_block

yield 'post', state

assert state.latest_execution_payload_header == get_execution_payload_header(spec, execution_payload)
assert state.latest_execution_payload_header == get_execution_payload_header(spec, body.execution_payload)


def run_success_test(spec, state):
Expand Down
2 changes: 1 addition & 1 deletion tests/formats/operations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Operations:
| `proposer_slashing` | `ProposerSlashing` | `proposer_slashing` | `process_proposer_slashing(state, proposer_slashing)` |
| `voluntary_exit` | `SignedVoluntaryExit` | `voluntary_exit` | `process_voluntary_exit(state, voluntary_exit)` |
| `sync_aggregate` | `SyncAggregate` | `sync_aggregate` | `process_sync_aggregate(state, sync_aggregate)` (new in Altair) |
| `execution_payload` | `ExecutionPayload` | `execution_payload` | `process_execution_payload(state, execution_payload)` (new in Bellatrix) |
| `execution_payload` | `BeaconBlockBody` | **`body`** | `process_execution_payload(state, body)` (new in Bellatrix) |
| `withdrawals` | `ExecutionPayload` | `execution_payload` | `process_withdrawals(state, execution_payload)` (new in Capella) |
| `bls_to_execution_change` | `SignedBLSToExecutionChange` | `address_change` | `process_bls_to_execution_change(state, address_change)` (new in Capella) |
| `deposit_receipt` | `DepositReceipt` | `deposit_receipt` | `process_deposit_receipt(state, deposit_receipt)` (new in EIP6110) |
Expand Down

0 comments on commit d163bef

Please sign in to comment.