verify `CAPELLA_FORK_EPOCH == FAR_FUTURE_EPOCH` for supported networks (#4369)
This commit is contained in:
parent
ed672113bc
commit
df54470b13
|
@ -294,7 +294,7 @@ proc produceSyncAggregate*(
|
|||
|
||||
proc isEpochLeadTime*(
|
||||
pool: SyncCommitteeMsgPool, epochsToSyncPeriod: uint64): bool =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# This ensures a uniform distribution without requiring additional state:
|
||||
# (1/4) = 1/4, 4 slots out
|
||||
# (3/4) * (1/3) = 1/4, 3 slots out
|
||||
|
|
|
@ -209,6 +209,7 @@ elif const_preset == "mainnet":
|
|||
for network in [
|
||||
mainnetMetadata, praterMetadata, ropstenMetadata, sepoliaMetadata]:
|
||||
checkForkConsistency(network.cfg)
|
||||
doAssert network.cfg.CAPELLA_FORK_EPOCH == FAR_FUTURE_EPOCH
|
||||
|
||||
proc getMetadataForNetwork*(
|
||||
networkName: string): Eth2NetworkMetadata {.raises: [Defect, IOError].} =
|
||||
|
|
|
@ -27,8 +27,6 @@ const
|
|||
"Beacon node is currently syncing and not serving request on that endpoint"
|
||||
BlockNotFoundError* =
|
||||
"Block header/data has not been found"
|
||||
BlockProduceError =
|
||||
"Could not produce the block"
|
||||
EmptyRequestBodyError* =
|
||||
"Empty request's body"
|
||||
InvalidBlockObjectError* =
|
||||
|
@ -126,8 +124,6 @@ const
|
|||
"Validator index exceeds maximum supported number of validators"
|
||||
StateNotFoundError* =
|
||||
"Could not get requested state"
|
||||
SlotNotFoundError =
|
||||
"Slot number is too far away"
|
||||
SlotNotInNextWallSlotEpochError* =
|
||||
"Requested slot not in next wall-slot epoch"
|
||||
SlotFromThePastError* =
|
||||
|
@ -138,8 +134,6 @@ const
|
|||
"Requested epoch is from incorrect fork"
|
||||
ProposerNotFoundError* =
|
||||
"Could not find proposer for the head and slot"
|
||||
NoHeadForSlotError =
|
||||
"Cound not find head for slot"
|
||||
EpochOverflowValueError* =
|
||||
"Requesting epoch for which slot would overflow"
|
||||
InvalidPeerStateValueError* =
|
||||
|
@ -164,8 +158,6 @@ const
|
|||
"Missing `beacon_block_root` value"
|
||||
InvalidBeaconBlockRootValueError* =
|
||||
"Invalid `beacon_block_root` value"
|
||||
EpochOutsideSyncCommitteePeriodError =
|
||||
"Epoch is outside the sync committee period of the state"
|
||||
InvalidSyncCommitteeSignatureMessageError* =
|
||||
"Unable to decode sync committee message(s)"
|
||||
InvalidSyncCommitteeSubscriptionRequestError* =
|
||||
|
@ -192,20 +184,8 @@ const
|
|||
"Could not add some keystores"
|
||||
InvalidKeystoreObjects* =
|
||||
"Invalid keystore objects found"
|
||||
KeystoreAdditionSuccess =
|
||||
"All keystores has been added"
|
||||
KeystoreModificationFailure =
|
||||
"Could not change keystore(s) state"
|
||||
KeystoreModificationSuccess =
|
||||
"Keystore(s) state was successfully modified"
|
||||
KeystoreRemovalSuccess =
|
||||
"Keystore(s) was successfully removed"
|
||||
KeystoreRemovalFailure =
|
||||
"Could not remove keystore(s)"
|
||||
InvalidValidatorPublicKey* =
|
||||
"Invalid validator's public key(s) found"
|
||||
BadRequestFormatError =
|
||||
"Bad request format"
|
||||
InvalidAuthorizationError* =
|
||||
"Invalid Authorization Header"
|
||||
PrunedStateError* =
|
||||
|
|
|
@ -130,7 +130,7 @@ type
|
|||
signature*: ValidatorSig
|
||||
## Signature by the validator(s) over the block root of `slot`
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#contributionandproof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#contributionandproof
|
||||
ContributionAndProof* = object
|
||||
aggregator_index*: uint64 # `ValidatorIndex` after validation
|
||||
contribution*: SyncCommitteeContribution
|
||||
|
@ -184,12 +184,12 @@ type
|
|||
signature_slot*: Slot
|
||||
## Slot at which the aggregate signature was created (untrusted)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
||||
LightClientFinalityUpdate* = object
|
||||
# The beacon block header that is attested to by the sync committee
|
||||
# Header attested to by the sync committee
|
||||
attested_header*: BeaconBlockHeader
|
||||
|
||||
# The finalized beacon block header attested to by Merkle branch
|
||||
# Finalized header corresponding to `attested_header.state_root`
|
||||
finalized_header*: BeaconBlockHeader
|
||||
finality_branch*: FinalityBranch
|
||||
|
||||
|
@ -198,9 +198,9 @@ type
|
|||
# Slot at which the aggregate signature was created (untrusted)
|
||||
signature_slot*: Slot
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
||||
LightClientOptimisticUpdate* = object
|
||||
# The beacon block header that is attested to by the sync committee
|
||||
# Header attested to by the sync committee
|
||||
attested_header*: BeaconBlockHeader
|
||||
|
||||
# Sync committee aggregate signature
|
||||
|
|
|
@ -90,7 +90,7 @@ type
|
|||
parent_hash*: Eth2Digest
|
||||
total_difficulty*: Eth2Digest # uint256
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
BeaconState* = object
|
||||
# Versioning
|
||||
genesis_time*: uint64
|
||||
|
|
|
@ -220,7 +220,7 @@ template is_finality_update*(update: SomeLightClientUpdate): bool =
|
|||
template is_next_sync_committee_known*(store: LightClientStore): bool =
|
||||
not isZeroMemory(store.next_sync_committee)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/altair/light-client/sync-protocol.md#get_safety_threshold
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/light-client/sync-protocol.md#get_safety_threshold
|
||||
func get_safety_threshold*(store: LightClientStore): uint64 =
|
||||
max(
|
||||
store.previous_max_active_participants,
|
||||
|
@ -320,7 +320,7 @@ func contextEpoch*(bootstrap: altair.LightClientBootstrap): Epoch =
|
|||
func contextEpoch*(update: SomeLightClientUpdate): Epoch =
|
||||
update.attested_header.slot.epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#is_merge_transition_complete
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#is_merge_transition_complete
|
||||
func is_merge_transition_complete*(
|
||||
state: bellatrix.BeaconState | capella.BeaconState): bool =
|
||||
const defaultExecutionPayloadHeader =
|
||||
|
|
|
@ -333,7 +333,7 @@ proc get_contribution_and_proof_signature*(
|
|||
|
||||
blsSign(privkey, signing_root.data)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/altair/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/validator.md#aggregation-selection
|
||||
func is_sync_committee_aggregator*(signature: ValidatorSig): bool =
|
||||
let
|
||||
signatureDigest = eth2digest(signature.blob)
|
||||
|
|
|
@ -484,7 +484,7 @@ proc makeBeaconBlock*(
|
|||
forkyState.data.latest_execution_payload_header.transactions_root =
|
||||
transactions_root.get
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#beaconblockbody
|
||||
# Effectively hash_tree_root(ExecutionPayload) with the beacon block
|
||||
# body, with the execution payload replaced by the execution payload
|
||||
# header. htr(payload) == htr(payload header), so substitute.
|
||||
|
|
|
@ -430,7 +430,7 @@ proc process_bls_to_execution_change*(
|
|||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/beacon-chain.md#operations
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.0/specs/capella/beacon-chain.md#modified-process_operations
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#modified-process_operations
|
||||
proc process_operations(cfg: RuntimeConfig,
|
||||
state: var ForkyBeaconState,
|
||||
body: SomeForkyBeaconBlockBody,
|
||||
|
|
|
@ -723,7 +723,7 @@ iterator get_inactivity_penalty_deltas*(
|
|||
state.inactivity_scores[vidx]
|
||||
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
iterator get_inactivity_penalty_deltas*(
|
||||
cfg: RuntimeConfig, state: bellatrix.BeaconState | capella.BeaconState,
|
||||
info: altair.EpochInfo): (ValidatorIndex, Gwei) =
|
||||
|
@ -879,7 +879,7 @@ func get_adjusted_total_slashing_balance*(
|
|||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.2.0/specs/bellatrix/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/bellatrix/beacon-chain.md#slashings
|
||||
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
||||
validator.slashed and
|
||||
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
||||
|
|
Loading…
Reference in New Issue