Skip to content

Commit e762dd6

Browse files
authored
Document new parent_slot param in process_attestation (#5500)
1 parent 3be5fe0 commit e762dd6

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

tests/core/pyspec/eth_consensus_specs/test/helpers/attestations.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@
1818
from eth_consensus_specs.utils.ssz.ssz_typing import BitList
1919

2020

21+
def get_parent_slot(state):
22+
# Outside of block processing, the bid in the state is still the
23+
# parent block's bid, so its slot is the parent block's slot.
24+
return state.latest_execution_payload_bid.slot
25+
26+
2127
def process_attestation(spec, state, attestation):
2228
if is_post_gloas(spec):
23-
# Outside of block processing, the bid in the state is still the
24-
# parent block's bid, so its slot is the parent block's slot.
25-
spec.process_attestation(state, attestation, state.latest_execution_payload_bid.slot)
29+
spec.process_attestation(state, attestation, get_parent_slot(state))
2630
else:
2731
spec.process_attestation(state, attestation)
2832

@@ -32,6 +36,7 @@ def run_attestation_processing(spec, state, attestation, valid=True):
3236
Run ``process_attestation``, yielding:
3337
- pre-state ('pre')
3438
- attestation ('attestation')
39+
- parent slot ('parent_slot' in meta, Gloas and later)
3540
- post-state ('post').
3641
If ``valid == False``, run expecting ``AssertionError``
3742
"""
@@ -40,6 +45,10 @@ def run_attestation_processing(spec, state, attestation, valid=True):
4045

4146
yield "attestation", attestation
4247

48+
# Gloas takes the parent block's slot as an extra input.
49+
if is_post_gloas(spec):
50+
yield "parent_slot", "meta", int(get_parent_slot(state))
51+
4352
# If the attestation is invalid, processing is aborted, and there is no post-state.
4453
if not valid:
4554
expect_assertion_error(lambda: process_attestation(spec, state, attestation))

tests/formats/operations/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ test handlers.
1111
description: string -- Optional description of test case, purely for debugging purposes.
1212
Tests should use the directory name of the test case as identifier, not the description.
1313
bls_setting: int -- see general test-format spec.
14+
parent_slot: int -- Only for the `attestation` handler in Gloas and later.
15+
The slot of the parent block, an extra input to `process_attestation`.
1416
```
1517
1618
### `pre.ssz_snappy`
@@ -36,7 +38,7 @@ Operations:
3638

3739
| *`operation-name`* | *`operation-object`* | *`input name`* | *`processing call`* |
3840
| -------------------------- | ---------------------------- | ------------------------- | -------------------------------------------------------------------------------- |
39-
| `attestation` | `Attestation` | `attestation` | `process_attestation(state, attestation)` |
41+
| `attestation` | `Attestation` | `attestation` | `process_attestation(state, attestation)` (`parent_slot` added in Gloas) |
4042
| `attester_slashing` | `AttesterSlashing` | `attester_slashing` | `process_attester_slashing(state, attester_slashing)` |
4143
| `block_header` | `BeaconBlock` | **`block`** | `process_block_header(state, block)` |
4244
| `deposit` | `Deposit` | `deposit` | `process_deposit(state, deposit)` (removed in Fulu) |

0 commit comments

Comments
 (0)