mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-17 04:56:24 +00:00
fixes
This commit is contained in:
parent
3ea0b90d4c
commit
d1b46e2489
4
setup.py
4
setup.py
@ -201,7 +201,7 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) ->
|
|||||||
# NOTE: trim whitespace from spec
|
# NOTE: trim whitespace from spec
|
||||||
ssz_objects[current_name] = "\n".join(line.rstrip() for line in source.splitlines())
|
ssz_objects[current_name] = "\n".join(line.rstrip() for line in source.splitlines())
|
||||||
else:
|
else:
|
||||||
raise Exception("unrecognized python code element")
|
raise Exception("unrecognized python code element: " + source)
|
||||||
elif isinstance(child, Table):
|
elif isinstance(child, Table):
|
||||||
for row in child.children:
|
for row in child.children:
|
||||||
cells = row.children
|
cells = row.children
|
||||||
@ -831,7 +831,7 @@ class PySpecCommand(Command):
|
|||||||
self.out_dir = 'pyspec_output'
|
self.out_dir = 'pyspec_output'
|
||||||
self.build_targets = """
|
self.build_targets = """
|
||||||
minimal:presets/minimal:configs/minimal.yaml
|
minimal:presets/minimal:configs/minimal.yaml
|
||||||
mainnet:presets/mainnet:configs/mainnet.yaml
|
mainnet:presets/mainnet:configs/mainnet.yaml
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
- [`BeaconBlockBody`](#beaconblockbody)
|
- [`BeaconBlockBody`](#beaconblockbody)
|
||||||
- [`BeaconState`](#beaconstate)
|
- [`BeaconState`](#beaconstate)
|
||||||
- [New containers](#new-containers)
|
- [New containers](#new-containers)
|
||||||
|
- [`HistoricalBatchSummary`](#historicalbatchsummary)
|
||||||
- [`SyncAggregate`](#syncaggregate)
|
- [`SyncAggregate`](#syncaggregate)
|
||||||
- [`SyncCommittee`](#synccommittee)
|
- [`SyncCommittee`](#synccommittee)
|
||||||
- [Helper functions](#helper-functions)
|
- [Helper functions](#helper-functions)
|
||||||
@ -204,11 +205,14 @@ class BeaconState(Container):
|
|||||||
|
|
||||||
### New containers
|
### New containers
|
||||||
|
|
||||||
|
#### `HistoricalBatchSummary`
|
||||||
|
|
||||||
```python
|
```python
|
||||||
# The tree roots that make up a phase0 HistoricalBatch making its layout
|
|
||||||
# hash_tree_root-compatible.
|
|
||||||
class HistoricalBatchSummary(Container):
|
class HistoricalBatchSummary(Container):
|
||||||
|
"""
|
||||||
|
`HistoricalBatchSummary` matches the components of the phase0 HistoricalBatch
|
||||||
|
making the two hash_tree_root-compatible.
|
||||||
|
"""
|
||||||
block_batch_root: Root
|
block_batch_root: Root
|
||||||
state_batch_root: Root
|
state_batch_root: Root
|
||||||
```
|
```
|
||||||
|
@ -58,7 +58,7 @@ def translate_participation(state: BeaconState, pending_attestations: Sequence[p
|
|||||||
for flag_index in participation_flag_indices:
|
for flag_index in participation_flag_indices:
|
||||||
epoch_participation[index] = add_flag(epoch_participation[index], flag_index)
|
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
|
# 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
|
# 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
|
# 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:
|
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
|
||||||
epoch = phase0.get_current_epoch(pre)
|
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
|
# 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)
|
assert hash_tree_root(historical_batches) == hash_tree_root(pre.historical_roots)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user