add constants, add backfill

This commit is contained in:
Jacek Sieka 2021-05-24 18:12:53 +02:00
parent 658e92af96
commit ce928cdc89
No known key found for this signature in database
GPG Key ID: A1B09461ABB656B8
4 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,10 @@
# Mainnet preset - Altair
# State vector lengths
# ---------------------------------------------------------------
# 2**24 (= 16,777,216) historical roots, ~26,131 years
HISTORICAL_BLOCK_ROOTS_LIMIT: 16777216
# Updated penalty values
# ---------------------------------------------------------------
# 3 * 2**24 (= 50,331,648)

View File

@ -1,5 +1,10 @@
# Minimal preset - Altair
# State vector lengths
# ---------------------------------------------------------------
# 2**24 (= 16,777,216) historical roots, ~26,131 years
HISTORICAL_BLOCK_ROOTS_LIMIT: 16777216
# Updated penalty values
# ---------------------------------------------------------------
# 3 * 2**24 (= 50,331,648)

View File

@ -44,6 +44,7 @@
- [Block processing](#block-processing)
- [Modified `process_attestation`](#modified-process_attestation)
- [Modified `process_deposit`](#modified-process_deposit)
- [Historical roots updates](#historical-roots-updates)
- [Sync committee processing](#sync-committee-processing)
- [Epoch processing](#epoch-processing)
- [Justification and finalization](#justification-and-finalization)

View File

@ -58,6 +58,13 @@ 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 backfill_historical_block_roots(pre: BeaconState) -> List[Root, HISTORICAL_BLOCK_ROOTS_LIMIT]:
# Split historical blocks into chunks of SLOTS_PER_HISTORICAL_ROOT
# For each chunk, compute hash_tree_root(chunk) and add to returned list
# For new altair-based chains, use an empty list
# Backfilling requires access to external block storage.
return []
def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
epoch = phase0.get_current_epoch(pre)
@ -76,6 +83,7 @@ def upgrade_to_altair(pre: phase0.BeaconState) -> BeaconState:
block_roots=pre.block_roots,
state_roots=pre.state_roots,
historical_root=hash_tree_root(pre.historical_roots),
historical_block_roots=backfill_historical_block_roots(pre),
# Eth1
eth1_data=pre.eth1_data,
eth1_data_votes=pre.eth1_data_votes,