Rename `HistoricalBatchSummary` -> `HistoricalSummary` and `historical_batches` -> `historical_summaries`
This commit is contained in:
parent
b6ac1fa099
commit
1cfabcbe54
2
setup.py
2
setup.py
|
@ -660,7 +660,7 @@ def get_empty_list_result(fn): # type: ignore
|
|||
process_withdrawals = no_op(process_withdrawals)
|
||||
process_bls_to_execution_change = no_op(process_bls_to_execution_change)
|
||||
get_expected_withdrawals = get_empty_list_result(get_expected_withdrawals)
|
||||
process_historical_batches_update = no_op(process_historical_batches_update)
|
||||
process_historical_summaries_update = no_op(process_historical_summaries_update)
|
||||
|
||||
|
||||
#
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
- [`Withdrawal`](#withdrawal)
|
||||
- [`BLSToExecutionChange`](#blstoexecutionchange)
|
||||
- [`SignedBLSToExecutionChange`](#signedblstoexecutionchange)
|
||||
- [`HistoricalBatchSummary`](#historicalbatchsummary)
|
||||
- [`HistoricalSummary`](#historicalsummary)
|
||||
- [Extended Containers](#extended-containers)
|
||||
- [`ExecutionPayload`](#executionpayload)
|
||||
- [`ExecutionPayloadHeader`](#executionpayloadheader)
|
||||
|
@ -31,7 +31,7 @@
|
|||
- [`is_partially_withdrawable_validator`](#is_partially_withdrawable_validator)
|
||||
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
|
||||
- [Epoch processing](#epoch-processing)
|
||||
- [Historical batches updates](#historical-batches-updates)
|
||||
- [Historical summaries updates](#historical-summaries-updates)
|
||||
- [Block processing](#block-processing)
|
||||
- [New `get_expected_withdrawals`](#new-get_expected_withdrawals)
|
||||
- [New `process_withdrawals`](#new-process_withdrawals)
|
||||
|
@ -118,12 +118,12 @@ class SignedBLSToExecutionChange(Container):
|
|||
signature: BLSSignature
|
||||
```
|
||||
|
||||
#### `HistoricalBatchSummary`
|
||||
#### `HistoricalSummary`
|
||||
|
||||
```python
|
||||
class HistoricalBatchSummary(Container):
|
||||
class HistoricalSummary(Container):
|
||||
"""
|
||||
`HistoricalBatchSummary` matches the components of the phase0 HistoricalBatch
|
||||
`HistoricalSummary` matches the components of the phase0 `HistoricalBatch`
|
||||
making the two hash_tree_root-compatible.
|
||||
"""
|
||||
block_batch_root: Root
|
||||
|
@ -211,7 +211,7 @@ class BeaconState(Container):
|
|||
latest_block_header: BeaconBlockHeader
|
||||
block_roots: Vector[Root, SLOTS_PER_HISTORICAL_ROOT]
|
||||
state_roots: Vector[Root, SLOTS_PER_HISTORICAL_ROOT]
|
||||
historical_roots: List[Root, HISTORICAL_ROOTS_LIMIT] # Frozen in Capella, replaced by historical_batches
|
||||
historical_roots: List[Root, HISTORICAL_ROOTS_LIMIT] # Frozen in Capella, replaced by historical_summaries
|
||||
# Eth1
|
||||
eth1_data: Eth1Data
|
||||
eth1_data_votes: List[Eth1Data, EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH]
|
||||
|
@ -242,7 +242,7 @@ class BeaconState(Container):
|
|||
next_withdrawal_index: WithdrawalIndex # [New in Capella]
|
||||
next_withdrawal_validator_index: ValidatorIndex # [New in Capella]
|
||||
# Deep history valid from Capella onwards
|
||||
historical_batches: List[HistoricalBatchSummary, HISTORICAL_ROOTS_LIMIT] # [New in Capella]
|
||||
historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT] # [New in Capella]
|
||||
```
|
||||
|
||||
## Helpers
|
||||
|
@ -289,7 +289,7 @@ def is_partially_withdrawable_validator(validator: Validator, balance: Gwei) ->
|
|||
|
||||
### Epoch processing
|
||||
|
||||
*Note*: The function `process_historical_batches_update` replaces `process_historical_roots_update` in Bellatrix.
|
||||
*Note*: The function `process_historical_summaries_update` replaces `process_historical_roots_update` in Bellatrix.
|
||||
|
||||
```python
|
||||
def process_epoch(state: BeaconState) -> None:
|
||||
|
@ -302,23 +302,23 @@ def process_epoch(state: BeaconState) -> None:
|
|||
process_effective_balance_updates(state)
|
||||
process_slashings_reset(state)
|
||||
process_randao_mixes_reset(state)
|
||||
process_historical_batches_update(state) # [Modified in Capella]
|
||||
process_historical_summaries_update(state) # [Modified in Capella]
|
||||
process_participation_flag_updates(state)
|
||||
process_sync_committee_updates(state)
|
||||
```
|
||||
|
||||
#### Historical batches updates
|
||||
#### Historical summaries updates
|
||||
|
||||
```python
|
||||
def process_historical_batches_update(state: BeaconState) -> None:
|
||||
def process_historical_summaries_update(state: BeaconState) -> None:
|
||||
# Set historical block root accumulator.
|
||||
next_epoch = Epoch(get_current_epoch(state) + 1)
|
||||
if next_epoch % (SLOTS_PER_HISTORICAL_ROOT // SLOTS_PER_EPOCH) == 0:
|
||||
historical_batch = HistoricalBatchSummary(
|
||||
historical_summary = HistoricalSummary(
|
||||
block_batch_root=hash_tree_root(state.block_roots),
|
||||
state_batch_root=hash_tree_root(state.state_roots),
|
||||
)
|
||||
state.historical_batches.append(historical_batch)
|
||||
state.historical_summaries.append(historical_summary)
|
||||
```
|
||||
|
||||
### Block processing
|
||||
|
|
|
@ -8,20 +8,20 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
)
|
||||
|
||||
|
||||
def run_process_historical_batches_update(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_historical_batches_update')
|
||||
def run_process_historical_summaries_update(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_historical_summaries_update')
|
||||
|
||||
|
||||
@with_phases([CAPELLA])
|
||||
@spec_state_test
|
||||
def test_historical_batches_accumulator(spec, state):
|
||||
def test_historical_summaries_accumulator(spec, state):
|
||||
# skip ahead to near the end of the historical batch period (excl block before epoch processing)
|
||||
state.slot = spec.SLOTS_PER_HISTORICAL_ROOT - 1
|
||||
pre_historical_batches = state.historical_batches.copy()
|
||||
pre_historical_summaries = state.historical_summaries.copy()
|
||||
|
||||
yield from run_process_historical_batches_update(spec, state)
|
||||
yield from run_process_historical_summaries_update(spec, state)
|
||||
|
||||
assert len(state.historical_batches) == len(pre_historical_batches) + 1
|
||||
summary = state.historical_batches[len(state.historical_batches) - 1]
|
||||
assert len(state.historical_summaries) == len(pre_historical_summaries) + 1
|
||||
summary = state.historical_summaries[len(state.historical_summaries) - 1]
|
||||
assert summary.block_batch_root == state.block_roots.hash_tree_root()
|
||||
assert summary.state_batch_root == state.state_roots.hash_tree_root()
|
||||
|
|
|
@ -7,8 +7,8 @@ from eth2spec.test.helpers.epoch_processing import (
|
|||
)
|
||||
|
||||
|
||||
def run_process_historical_batches_update(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_historical_batches_update')
|
||||
def run_process_historical_summaries_update(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_historical_summaries_update')
|
||||
|
||||
|
||||
@with_eip4844_and_later
|
||||
|
@ -16,8 +16,8 @@ def run_process_historical_batches_update(spec, state):
|
|||
def test_no_op(spec, state):
|
||||
# skip ahead to near the end of the historical batch period (excl block before epoch processing)
|
||||
state.slot = spec.SLOTS_PER_HISTORICAL_ROOT - 1
|
||||
historical_batches_len = len(state.historical_batches)
|
||||
historical_summaries_len = len(state.historical_summaries)
|
||||
|
||||
yield from run_process_historical_batches_update(spec, state)
|
||||
yield from run_process_historical_summaries_update(spec, state)
|
||||
|
||||
assert len(state.historical_batches) == historical_batches_len
|
||||
assert len(state.historical_summaries) == historical_summaries_len
|
||||
|
|
|
@ -25,8 +25,8 @@ def get_process_calls(spec):
|
|||
'process_effective_balance_updates',
|
||||
'process_slashings_reset',
|
||||
'process_randao_mixes_reset',
|
||||
# Capella replaced `process_historical_roots_update` with `process_historical_batches_update`
|
||||
'process_historical_batches_update' if is_post_capella(spec) else (
|
||||
# Capella replaced `process_historical_roots_update` with `process_historical_summaries_update`
|
||||
'process_historical_summaries_update' if is_post_capella(spec) else (
|
||||
'process_historical_roots_update'
|
||||
),
|
||||
# Altair replaced `process_participation_record_updates` with `process_participation_flag_updates`
|
||||
|
|
|
@ -1029,7 +1029,7 @@ def test_historical_batch(spec, state):
|
|||
pre_historical_roots = state.historical_roots.copy()
|
||||
|
||||
if is_post_capella(spec):
|
||||
pre_historical_batches = state.historical_batches.copy()
|
||||
pre_historical_summaries = state.historical_summaries.copy()
|
||||
|
||||
yield 'pre', state
|
||||
|
||||
|
@ -1048,9 +1048,9 @@ def test_historical_batch(spec, state):
|
|||
assert state.historical_roots == pre_historical_roots
|
||||
if spec.fork == EIP4844:
|
||||
# TODO: no-op for now in EIP4844 testnet
|
||||
assert state.historical_batches == pre_historical_batches
|
||||
assert state.historical_summaries == pre_historical_summaries
|
||||
else:
|
||||
assert len(state.historical_batches) == len(pre_historical_batches) + 1
|
||||
assert len(state.historical_summaries) == len(pre_historical_summaries) + 1
|
||||
else:
|
||||
assert len(state.historical_roots) == len(pre_historical_roots) + 1
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ def test_historical_accumulator(spec, state):
|
|||
pre_historical_roots = state.historical_roots.copy()
|
||||
|
||||
if is_post_capella(spec):
|
||||
pre_historical_batches = state.historical_batches.copy()
|
||||
pre_historical_summaries = state.historical_summaries.copy()
|
||||
|
||||
yield 'pre', state
|
||||
slots = spec.SLOTS_PER_HISTORICAL_ROOT
|
||||
|
@ -89,8 +89,8 @@ def test_historical_accumulator(spec, state):
|
|||
assert state.historical_roots == pre_historical_roots
|
||||
if spec.fork == EIP4844:
|
||||
# TODO: no-op for now in EIP4844 testnet
|
||||
assert state.historical_batches == pre_historical_batches
|
||||
assert state.historical_summaries == pre_historical_summaries
|
||||
else:
|
||||
assert len(state.historical_batches) == len(pre_historical_batches) + 1
|
||||
assert len(state.historical_summaries) == len(pre_historical_summaries) + 1
|
||||
else:
|
||||
assert len(state.historical_roots) == len(pre_historical_roots) + 1
|
||||
|
|
|
@ -28,12 +28,12 @@ if __name__ == "__main__":
|
|||
bellatrix_mods = altair_mods
|
||||
|
||||
_new_capella_mods = {key: 'eth2spec.test.capella.epoch_processing.test_process_' + key for key in [
|
||||
'historical_batches_update',
|
||||
'historical_summaries_update',
|
||||
]}
|
||||
capella_mods = combine_mods(_new_capella_mods, bellatrix_mods)
|
||||
|
||||
_new_eip4844_mods = {key: 'eth2spec.test.eip4844.epoch_processing.test_process_' + key for key in [
|
||||
'historical_batches_update',
|
||||
'historical_summaries_update',
|
||||
]}
|
||||
eip4844_mods = combine_mods(_new_eip4844_mods, capella_mods)
|
||||
|
||||
|
|
Loading…
Reference in New Issue