This commit is contained in:
Jacek Sieka 2021-05-24 22:56:37 +02:00
parent 3ea0b90d4c
commit d1b46e2489
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
3 changed files with 10 additions and 6 deletions

View File

@ -201,7 +201,7 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) ->
# NOTE: trim whitespace from spec
ssz_objects[current_name] = "\n".join(line.rstrip() for line in source.splitlines())
else:
raise Exception("unrecognized python code element")
raise Exception("unrecognized python code element: " + source)
elif isinstance(child, Table):
for row in child.children:
cells = row.children
@ -831,7 +831,7 @@ class PySpecCommand(Command):
self.out_dir = 'pyspec_output'
self.build_targets = """
minimal:presets/minimal:configs/minimal.yaml
mainnet:presets/mainnet:configs/mainnet.yaml
mainnet:presets/mainnet:configs/mainnet.yaml
"""
def finalize_options(self):

View File

@ -23,6 +23,7 @@
- [`BeaconBlockBody`](#beaconblockbody)
- [`BeaconState`](#beaconstate)
- [New containers](#new-containers)
- [`HistoricalBatchSummary`](#historicalbatchsummary)
- [`SyncAggregate`](#syncaggregate)
- [`SyncCommittee`](#synccommittee)
- [Helper functions](#helper-functions)
@ -204,11 +205,14 @@ class BeaconState(Container):
### New containers
#### `HistoricalBatchSummary`
```python
# The tree roots that make up a phase0 HistoricalBatch making its layout
# hash_tree_root-compatible.
class HistoricalBatchSummary(Container):
"""
`HistoricalBatchSummary` matches the components of the phase0 HistoricalBatch
making the two hash_tree_root-compatible.
"""
block_batch_root: Root
state_batch_root: Root
```

View File

@ -58,7 +58,7 @@ def translate_participation(state: BeaconState, pending_attestations: Sequence[p
for flag_index in participation_flag_indices:
epoch_participation[index] = add_flag(epoch_participation[index], flag_index)
def load_historical_batches(state: BeaconState, pre: BeaconState) -> List[HistoricalBatchSummary, HISTORICAL_ROOTS_LIMIT]:
def load_historical_batches(pre: BeaconState) -> List[HistoricalBatchSummary, HISTORICAL_ROOTS_LIMIT]:
# Clients need to recalculate the historical batches from genesis and return
# them here with the roots of the blocks and states separated. It's assumed
# most of these are pre-calculated and the rest are stored on-the-fly by
@ -69,7 +69,7 @@ def load_historical_batches(state: BeaconState, pre: BeaconState) -> List[Histor
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
epoch = phase0.get_current_epoch(pre)
historical_batches = load_historical_batches()
historical_batches = load_historical_batches(pre)
# Tree hash should match since HistoricalBatchSummary is an intermediate step in calculating the phase0 historical root entry
assert hash_tree_root(historical_batches) == hash_tree_root(pre.historical_roots)