v1.1.6 spec updates (#3206)

This commit is contained in:
tersec 2021-12-17 06:56:33 +00:00 committed by GitHub
parent 7eecbedf3e
commit d7799ecdcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 25 additions and 43 deletions

View File

@ -297,7 +297,7 @@ template toGaugeValue(x: Quantity): int64 =
func compute_time_at_slot(genesis_time: uint64, slot: Slot): uint64 =
genesis_time + slot * SECONDS_PER_SLOT
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#get_eth1_data
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/validator.md#get_eth1_data
func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
let eth1_voting_period_start_slot =
getStateField(state, slot) - getStateField(state, slot) mod
@ -305,7 +305,7 @@ func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
compute_time_at_slot(
getStateField(state, genesis_time), eth1_voting_period_start_slot)
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#get_eth1_data
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/validator.md#get_eth1_data
func is_candidate_block(cfg: RuntimeConfig,
blk: Eth1Block,
period_start: uint64): bool =
@ -712,7 +712,7 @@ template trackFinalizedState*(m: Eth1Monitor,
finalizedStateDepositIndex: uint64): bool =
trackFinalizedState(m.depositsChain, finalizedEth1Data, finalizedStateDepositIndex)
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/validator.md#get_eth1_data
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/validator.md#get_eth1_data
proc getBlockProposalData*(chain: var Eth1Chain,
state: ForkedHashedBeaconState,
finalizedEth1Data: Eth1Data,

View File

@ -848,7 +848,7 @@ proc validateSyncCommitteeMessage*(
return ok((positionsInSubcommittee, sig))
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
proc validateContribution*(
dag: ChainDAGRef,
batchCrypto: ref BatchCrypto,

View File

@ -314,7 +314,7 @@ func get_initial_beacon_block*(state: altair.HashedBeaconState):
altair.TrustedSignedBeaconBlock(
message: message, root: hash_tree_root(message))
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/merge/beacon-chain.md#testing
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#testing
func get_initial_beacon_block*(state: merge.HashedBeaconState):
merge.TrustedSignedBeaconBlock =
# The genesis block is implicitly trusted

View File

@ -52,7 +52,7 @@ const
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16
SYNC_COMMITTEE_SUBNET_COUNT* = 4
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/setup.py#L478-L479
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/setup.py#L478-L479
FINALIZED_ROOT_INDEX* = 105.GeneralizedIndex
NEXT_SYNC_COMMITTEE_INDEX* = 55.GeneralizedIndex

View File

@ -89,7 +89,7 @@ type
parent_hash*: Eth2Digest
total_difficulty*: Eth2Digest # uint256
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/merge/beacon-chain.md#beaconstate
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#beaconstate
BeaconState* = object
# Versioning
genesis_time*: uint64
@ -218,7 +218,7 @@ type
state_root*: Eth2Digest ##\
body*: TrustedBeaconBlockBody
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/merge/beacon-chain.md#beaconblockbody
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#beaconblockbody
BeaconBlockBody* = object
randao_reveal*: ValidatorSig
eth1_data*: Eth1Data ##\

View File

@ -66,7 +66,7 @@ template generalized_index_parent*(
index: GeneralizedIndex): GeneralizedIndex =
index shr 1
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/ssz/merkle-proofs.md#merkle-multiproofs
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/ssz/merkle-proofs.md#merkle-multiproofs
iterator get_branch_indices*(
tree_index: GeneralizedIndex): GeneralizedIndex =
## Get the generalized indices of the sister chunks along the path
@ -76,7 +76,7 @@ iterator get_branch_indices*(
yield generalized_index_sibling(index)
index = generalized_index_parent(index)
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/ssz/merkle-proofs.md#merkle-multiproofs
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/ssz/merkle-proofs.md#merkle-multiproofs
iterator get_path_indices*(
tree_index: GeneralizedIndex): GeneralizedIndex =
## Get the generalized indices of the chunks along the path
@ -107,7 +107,7 @@ func get_helper_indices*(
res.sort(SortOrder.Descending)
res
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/ssz/merkle-proofs.md#merkle-multiproofs
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/ssz/merkle-proofs.md#merkle-multiproofs
func check_multiproof_acceptable*(
indices: openArray[GeneralizedIndex]): Result[void, string] =
# Check that proof verification won't allocate excessive amounts of memory.
@ -369,7 +369,7 @@ func is_active_validator*(validator: Validator, epoch: Epoch): bool =
## Check if ``validator`` is active
validator.activation_epoch <= epoch and epoch < validator.exit_epoch
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#get_active_validator_indices
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#get_active_validator_indices
iterator get_active_validator_indices*(state: ForkyBeaconState, epoch: Epoch):
ValidatorIndex =
for idx in 0..<state.validators.len:
@ -401,7 +401,7 @@ func get_current_epoch*(state: ForkyBeaconState): Epoch =
doAssert state.slot >= GENESIS_SLOT, $state.slot
compute_epoch_at_slot(state.slot)
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#get_current_epoch
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#get_current_epoch
func get_current_epoch*(state: ForkedHashedBeaconState): Epoch =
## Return the current epoch.
withState(state): state.data.slot.epoch
@ -510,20 +510,20 @@ func get_subtree_index*(idx: GeneralizedIndex): uint64 =
func is_merge_transition_complete*(state: merge.BeaconState): bool =
state.latest_execution_payload_header != default(ExecutionPayloadHeader)
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/merge/beacon-chain.md#is_merge_block
func is_merge_block(
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#is_merge_transition_block
func is_merge_transition_block(
state: merge.BeaconState,
body: merge.BeaconBlockBody | merge.TrustedBeaconBlockBody |
merge.SigVerifiedBeaconBlockBody): bool =
not is_merge_transition_complete(state) and
body.execution_payload != default(merge.ExecutionPayload)
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/specs/merge/beacon-chain.md#is_execution_enabled
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#is_execution_enabled
func is_execution_enabled*(
state: merge.BeaconState,
body: merge.BeaconBlockBody | merge.TrustedBeaconBlockBody |
merge.SigVerifiedBeaconBlockBody): bool =
is_merge_block(state, body) or is_merge_transition_complete(state)
is_merge_transition_block(state, body) or is_merge_transition_complete(state)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/merge/beacon-chain.md#compute_timestamp_at_slot
func compute_timestamp_at_slot*(state: ForkyBeaconState, slot: Slot): uint64 =

View File

@ -1,5 +1,5 @@
# Mainnet preset - Merge
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/presets/mainnet/merge.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/presets/mainnet/merge.yaml
const
# Updated penalty values
# ---------------------------------------------------------------

View File

@ -1,5 +1,5 @@
# Mainnet preset - Phase0
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/presets/mainnet/phase0.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/presets/mainnet/phase0.yaml
const
#

View File

@ -1,5 +1,5 @@
# Minimal preset - Phase0
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/presets/minimal/phase0.yaml
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/presets/minimal/phase0.yaml
const
#

View File

@ -322,7 +322,7 @@ proc process_deposit*(cfg: RuntimeConfig,
ok()
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#voluntary-exits
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#voluntary-exits
proc check_voluntary_exit*(
cfg: RuntimeConfig,
state: ForkyBeaconState,

View File

@ -990,7 +990,6 @@ proc process_epoch*(
init(info, state)
info.process_attestations(state, cache)
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#justification-and-finalization
process_justification_and_finalization(state, info.balances, flags)
# state.slot hasn't been incremented yet.
@ -1003,31 +1002,14 @@ proc process_epoch*(
# the finalization rules triggered.
doAssert state.finalized_checkpoint.epoch + 3 >= currentEpoch
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#rewards-and-penalties-1
process_rewards_and_penalties(state, info)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#registry-updates
process_registry_updates(cfg, state, cache)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#slashings
process_slashings(state, info.balances.current_epoch)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#eth1-data-votes-updates
process_eth1_data_reset(state)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#effective-balances-updates
process_effective_balance_updates(state)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#slashings-balances-updates
process_slashings_reset(state)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#randao-mixes-updates
process_randao_mixes_reset(state)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#historical-roots-updates
process_historical_roots_update(state)
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/beacon-chain.md#participation-records-rotation
process_participation_record_updates(state)
func init*(

View File

@ -64,7 +64,7 @@ type
func hash*(x: AggregatorDuty): Hash =
hashAllFields(x)
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/specs/phase0/validator.md#phase-0-attestation-subnet-stability
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/specs/phase0/validator.md#phase-0-attestation-subnet-stability
func randomStabilitySubnet*(
self: ActionTracker, epoch: Epoch): tuple[subnet_id: SubnetId, expiration: Epoch] =
(

View File

@ -80,7 +80,7 @@ suite "Ethereum Foundation - Altair - Unittests - Sync protocol" & preset():
res
genesisState = newClone(initGenesisState(cfg = cfg))
# https://github.com/ethereum/consensus-specs/blob/v1.1.4/tests/core/pyspec/eth2spec/test/altair/unittests/test_sync_protocol.py#L22-L78
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/tests/core/pyspec/eth2spec/test/altair/unittests/test_sync_protocol.py#L22-L78
test "process_light_client_update_not_updated":
var forked = assignClone(genesisState[])
template state: untyped {.inject.} = forked[].altairData.data
@ -135,7 +135,7 @@ suite "Ethereum Foundation - Altair - Unittests - Sync protocol" & preset():
store.valid_updates.pop() == update
store.snapshot == pre_snapshot
# https://github.com/ethereum/consensus-specs/blob/v1.1.5/tests/core/pyspec/eth2spec/test/altair/unittests/test_sync_protocol.py#L81-L144
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/tests/core/pyspec/eth2spec/test/altair/unittests/test_sync_protocol.py#L81-L144
test "process_light_client_update_timeout":
var forked = assignClone(genesisState[])
template state: untyped {.inject.} = forked[].altairData.data
@ -200,7 +200,7 @@ suite "Ethereum Foundation - Altair - Unittests - Sync protocol" & preset():
len(store.valid_updates) == 0
store.snapshot.header == update.header
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/tests/core/pyspec/eth2spec/test/altair/unittests/test_sync_protocol.py#L150-L218
# https://github.com/ethereum/consensus-specs/blob/v1.1.6/tests/core/pyspec/eth2spec/test/altair/unittests/test_sync_protocol.py#L150-L218
test "process_light_client_update_finality_updated":
var forked = assignClone(genesisState[])
template state: untyped {.inject.} = forked[].altairData.data