mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-27 05:30:43 +00:00
automated v1.3.0 to v1.4.0-alpha.0 consensus spec URL updates (#4996)
* automated v1.3.0 to v1.4.0-alpha.0 consensus spec URL updates * add copyright year headers
This commit is contained in:
parent
629e60b9ca
commit
1f535336da
@ -16,7 +16,7 @@ from ./spec/datatypes/capella import
|
|||||||
from ./spec/datatypes/deneb import ExecutionPayloadHeader
|
from ./spec/datatypes/deneb import ExecutionPayloadHeader
|
||||||
|
|
||||||
type
|
type
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconstate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconstate
|
||||||
# Memory-representation-equivalent to a phase0 BeaconState for in-place SSZ
|
# Memory-representation-equivalent to a phase0 BeaconState for in-place SSZ
|
||||||
# reading and writing
|
# reading and writing
|
||||||
Phase0BeaconStateNoImmutableValidators* = object
|
Phase0BeaconStateNoImmutableValidators* = object
|
||||||
|
@ -778,7 +778,7 @@ proc getBeaconHead*(
|
|||||||
finalizedExecutionPayloadHash =
|
finalizedExecutionPayloadHash =
|
||||||
pool.dag.loadExecutionBlockHash(pool.dag.finalizedHead.blck)
|
pool.dag.loadExecutionBlockHash(pool.dag.finalizedHead.blck)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/fork_choice/safe-block.md#get_safe_execution_payload_hash
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/fork_choice/safe-block.md#get_safe_execution_payload_hash
|
||||||
safeBlockRoot = pool.forkChoice.get_safe_beacon_block_root()
|
safeBlockRoot = pool.forkChoice.get_safe_beacon_block_root()
|
||||||
safeBlock = pool.dag.getBlockRef(safeBlockRoot)
|
safeBlock = pool.dag.getBlockRef(safeBlockRoot)
|
||||||
safeExecutionPayloadHash =
|
safeExecutionPayloadHash =
|
||||||
|
@ -2644,7 +2644,7 @@ proc aggregateAll*(
|
|||||||
# Aggregation spec requires non-empty collection
|
# Aggregation spec requires non-empty collection
|
||||||
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04
|
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04
|
||||||
# Consensus specs require at least one attesting index in attestation
|
# Consensus specs require at least one attesting index in attestation
|
||||||
# - https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
||||||
return err("aggregate: no attesting keys")
|
return err("aggregate: no attesting keys")
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -25,7 +25,7 @@ logScope: topics = "spec_cache"
|
|||||||
func count_active_validators*(shufflingRef: ShufflingRef): uint64 =
|
func count_active_validators*(shufflingRef: ShufflingRef): uint64 =
|
||||||
shufflingRef.shuffled_active_validator_indices.lenu64
|
shufflingRef.shuffled_active_validator_indices.lenu64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_committee_count_per_slot
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_committee_count_per_slot
|
||||||
func get_committee_count_per_slot*(shufflingRef: ShufflingRef): uint64 =
|
func get_committee_count_per_slot*(shufflingRef: ShufflingRef): uint64 =
|
||||||
get_committee_count_per_slot(count_active_validators(shufflingRef))
|
get_committee_count_per_slot(count_active_validators(shufflingRef))
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ func get_committee_index*(shufflingRef: ShufflingRef, index: uint64):
|
|||||||
Result[CommitteeIndex, cstring] =
|
Result[CommitteeIndex, cstring] =
|
||||||
check_attestation_index(index, get_committee_count_per_slot(shufflingRef))
|
check_attestation_index(index, get_committee_count_per_slot(shufflingRef))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
iterator get_beacon_committee*(
|
iterator get_beacon_committee*(
|
||||||
shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex):
|
shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex):
|
||||||
(int, ValidatorIndex) =
|
(int, ValidatorIndex) =
|
||||||
@ -51,7 +51,7 @@ iterator get_beacon_committee*(
|
|||||||
committees_per_slot * SLOTS_PER_EPOCH
|
committees_per_slot * SLOTS_PER_EPOCH
|
||||||
): yield (index_in_committee, idx)
|
): yield (index_in_committee, idx)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
func get_beacon_committee*(
|
func get_beacon_committee*(
|
||||||
shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex):
|
shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex):
|
||||||
seq[ValidatorIndex] =
|
seq[ValidatorIndex] =
|
||||||
@ -64,7 +64,7 @@ func get_beacon_committee*(
|
|||||||
committees_per_slot * SLOTS_PER_EPOCH
|
committees_per_slot * SLOTS_PER_EPOCH
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
func get_beacon_committee_len*(
|
func get_beacon_committee_len*(
|
||||||
shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex): uint64 =
|
shufflingRef: ShufflingRef, slot: Slot, committee_index: CommitteeIndex): uint64 =
|
||||||
## Return the number of members in the beacon committee at ``slot`` for ``index``.
|
## Return the number of members in the beacon committee at ``slot`` for ``index``.
|
||||||
@ -76,7 +76,7 @@ func get_beacon_committee_len*(
|
|||||||
committees_per_slot * SLOTS_PER_EPOCH
|
committees_per_slot * SLOTS_PER_EPOCH
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
||||||
iterator get_attesting_indices*(shufflingRef: ShufflingRef,
|
iterator get_attesting_indices*(shufflingRef: ShufflingRef,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
committee_index: CommitteeIndex,
|
committee_index: CommitteeIndex,
|
||||||
@ -155,7 +155,7 @@ func get_attesting_indices_one*(shufflingRef: ShufflingRef,
|
|||||||
res = some(validator_index)
|
res = some(validator_index)
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
||||||
func get_attesting_indices*(shufflingRef: ShufflingRef,
|
func get_attesting_indices*(shufflingRef: ShufflingRef,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
committee_index: CommitteeIndex,
|
committee_index: CommitteeIndex,
|
||||||
|
@ -345,7 +345,7 @@ proc produceSyncAggregate*(
|
|||||||
|
|
||||||
proc isEpochLeadTime*(
|
proc isEpochLeadTime*(
|
||||||
pool: SyncCommitteeMsgPool, epochsToSyncPeriod: uint64): bool =
|
pool: SyncCommitteeMsgPool, epochsToSyncPeriod: uint64): bool =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#sync-committee-subnet-stability
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||||
# This ensures a uniform distribution without requiring additional state:
|
# This ensures a uniform distribution without requiring additional state:
|
||||||
# (1/4) = 1/4, 4 slots out
|
# (1/4) = 1/4, 4 slots out
|
||||||
# (3/4) * (1/3) = 1/4, 3 slots out
|
# (3/4) * (1/3) = 1/4, 3 slots out
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
|
||||||
|
|
||||||
# Merkle tree helpers
|
# Merkle tree helpers
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -364,7 +364,7 @@ proc get_head*(self: var ForkChoice,
|
|||||||
self.checkpoints.justified.balances,
|
self.checkpoints.justified.balances,
|
||||||
self.checkpoints.proposer_boost_root)
|
self.checkpoints.proposer_boost_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/fork_choice/safe-block.md#get_safe_beacon_block_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/fork_choice/safe-block.md#get_safe_beacon_block_root
|
||||||
func get_safe_beacon_block_root*(self: ForkChoice): Eth2Digest =
|
func get_safe_beacon_block_root*(self: ForkChoice): Eth2Digest =
|
||||||
# Use most recent justified block as a stopgap
|
# Use most recent justified block as a stopgap
|
||||||
self.checkpoints.justified.checkpoint.root
|
self.checkpoints.justified.checkpoint.root
|
||||||
|
@ -656,7 +656,7 @@ proc processSignedContributionAndProof*(
|
|||||||
|
|
||||||
err(v.error())
|
err(v.error())
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update
|
||||||
proc processLightClientFinalityUpdate*(
|
proc processLightClientFinalityUpdate*(
|
||||||
self: var Eth2Processor, src: MsgSource,
|
self: var Eth2Processor, src: MsgSource,
|
||||||
finality_update: ForkedLightClientFinalityUpdate
|
finality_update: ForkedLightClientFinalityUpdate
|
||||||
@ -672,7 +672,7 @@ proc processLightClientFinalityUpdate*(
|
|||||||
beacon_light_client_finality_update_dropped.inc(1, [$v.error[0]])
|
beacon_light_client_finality_update_dropped.inc(1, [$v.error[0]])
|
||||||
v
|
v
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#process_light_client_optimistic_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#process_light_client_optimistic_update
|
||||||
proc processLightClientOptimisticUpdate*(
|
proc processLightClientOptimisticUpdate*(
|
||||||
self: var Eth2Processor, src: MsgSource,
|
self: var Eth2Processor, src: MsgSource,
|
||||||
optimistic_update: ForkedLightClientOptimisticUpdate
|
optimistic_update: ForkedLightClientOptimisticUpdate
|
||||||
|
@ -1265,7 +1265,7 @@ proc validateContribution*(
|
|||||||
|
|
||||||
return ok((blck.bid, sig, participants))
|
return ok((blck.bid, sig, participants))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#light_client_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#light_client_finality_update
|
||||||
proc validateLightClientFinalityUpdate*(
|
proc validateLightClientFinalityUpdate*(
|
||||||
pool: var LightClientPool, dag: ChainDAGRef,
|
pool: var LightClientPool, dag: ChainDAGRef,
|
||||||
finality_update: ForkedLightClientFinalityUpdate,
|
finality_update: ForkedLightClientFinalityUpdate,
|
||||||
@ -1301,7 +1301,7 @@ proc validateLightClientFinalityUpdate*(
|
|||||||
pool.latestForwardedFinalitySlot = finalized_slot
|
pool.latestForwardedFinalitySlot = finalized_slot
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
|
||||||
proc validateLightClientOptimisticUpdate*(
|
proc validateLightClientOptimisticUpdate*(
|
||||||
pool: var LightClientPool, dag: ChainDAGRef,
|
pool: var LightClientPool, dag: ChainDAGRef,
|
||||||
optimistic_update: ForkedLightClientOptimisticUpdate,
|
optimistic_update: ForkedLightClientOptimisticUpdate,
|
||||||
|
@ -529,7 +529,7 @@ func toValidationError(
|
|||||||
# previously forwarded `optimistic_update`s
|
# previously forwarded `optimistic_update`s
|
||||||
errIgnore($r.error)
|
errIgnore($r.error)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update
|
||||||
proc processLightClientFinalityUpdate*(
|
proc processLightClientFinalityUpdate*(
|
||||||
self: var LightClientProcessor, src: MsgSource,
|
self: var LightClientProcessor, src: MsgSource,
|
||||||
finality_update: ForkedLightClientFinalityUpdate
|
finality_update: ForkedLightClientFinalityUpdate
|
||||||
@ -544,7 +544,7 @@ proc processLightClientFinalityUpdate*(
|
|||||||
self.latestFinalityUpdate = finality_update.toOptimistic
|
self.latestFinalityUpdate = finality_update.toOptimistic
|
||||||
v
|
v
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update
|
||||||
proc processLightClientOptimisticUpdate*(
|
proc processLightClientOptimisticUpdate*(
|
||||||
self: var LightClientProcessor, src: MsgSource,
|
self: var LightClientProcessor, src: MsgSource,
|
||||||
optimistic_update: ForkedLightClientOptimisticUpdate
|
optimistic_update: ForkedLightClientOptimisticUpdate
|
||||||
|
@ -354,7 +354,7 @@ proc installMessageValidators*(
|
|||||||
digest = forkDigests[].atConsensusFork(contextFork)
|
digest = forkDigests[].atConsensusFork(contextFork)
|
||||||
|
|
||||||
# light_client_optimistic_update
|
# light_client_optimistic_update
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#light_client_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#light_client_finality_update
|
||||||
lightClient.network.addValidator(
|
lightClient.network.addValidator(
|
||||||
getLightClientFinalityUpdateTopic(digest), proc (
|
getLightClientFinalityUpdateTopic(digest), proc (
|
||||||
msg: lcDataFork.LightClientFinalityUpdate
|
msg: lcDataFork.LightClientFinalityUpdate
|
||||||
@ -362,7 +362,7 @@ proc installMessageValidators*(
|
|||||||
validate(msg, contextFork, processLightClientFinalityUpdate))
|
validate(msg, contextFork, processLightClientFinalityUpdate))
|
||||||
|
|
||||||
# light_client_optimistic_update
|
# light_client_optimistic_update
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
|
||||||
lightClient.network.addValidator(
|
lightClient.network.addValidator(
|
||||||
getLightClientOptimisticUpdateTopic(digest), proc (
|
getLightClientOptimisticUpdateTopic(digest), proc (
|
||||||
msg: lcDataFork.LightClientOptimisticUpdate
|
msg: lcDataFork.LightClientOptimisticUpdate
|
||||||
|
@ -2549,7 +2549,7 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) =
|
|||||||
debug "Stability subnets changed; updated ENR attnets", attnets
|
debug "Stability subnets changed; updated ENR attnets", attnets
|
||||||
|
|
||||||
proc updateSyncnetsMetadata*(node: Eth2Node, syncnets: SyncnetBits) =
|
proc updateSyncnetsMetadata*(node: Eth2Node, syncnets: SyncnetBits) =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#sync-committee-subnet-stability
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||||
if node.metadata.syncnets == syncnets:
|
if node.metadata.syncnets == syncnets:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
cachedConfigSpec =
|
cachedConfigSpec =
|
||||||
RestApiResponse.prepareJsonResponse(
|
RestApiResponse.prepareJsonResponse(
|
||||||
(
|
(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/phase0.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/phase0.yaml
|
||||||
MAX_COMMITTEES_PER_SLOT:
|
MAX_COMMITTEES_PER_SLOT:
|
||||||
Base10.toString(MAX_COMMITTEES_PER_SLOT),
|
Base10.toString(MAX_COMMITTEES_PER_SLOT),
|
||||||
TARGET_COMMITTEE_SIZE:
|
TARGET_COMMITTEE_SIZE:
|
||||||
@ -88,7 +88,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
MAX_VOLUNTARY_EXITS:
|
MAX_VOLUNTARY_EXITS:
|
||||||
Base10.toString(MAX_VOLUNTARY_EXITS),
|
Base10.toString(MAX_VOLUNTARY_EXITS),
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/altair.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/altair.yaml
|
||||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR:
|
INACTIVITY_PENALTY_QUOTIENT_ALTAIR:
|
||||||
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_ALTAIR),
|
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_ALTAIR),
|
||||||
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR:
|
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR:
|
||||||
@ -104,7 +104,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
UPDATE_TIMEOUT:
|
UPDATE_TIMEOUT:
|
||||||
Base10.toString(UPDATE_TIMEOUT),
|
Base10.toString(UPDATE_TIMEOUT),
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/bellatrix.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/bellatrix.yaml
|
||||||
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX:
|
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX:
|
||||||
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_BELLATRIX),
|
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_BELLATRIX),
|
||||||
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX:
|
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX:
|
||||||
@ -120,7 +120,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
MAX_EXTRA_DATA_BYTES:
|
MAX_EXTRA_DATA_BYTES:
|
||||||
Base10.toString(uint64(MAX_EXTRA_DATA_BYTES)),
|
Base10.toString(uint64(MAX_EXTRA_DATA_BYTES)),
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/capella.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/capella.yaml
|
||||||
MAX_BLS_TO_EXECUTION_CHANGES:
|
MAX_BLS_TO_EXECUTION_CHANGES:
|
||||||
Base10.toString(uint64(MAX_BLS_TO_EXECUTION_CHANGES)),
|
Base10.toString(uint64(MAX_BLS_TO_EXECUTION_CHANGES)),
|
||||||
MAX_WITHDRAWALS_PER_PAYLOAD:
|
MAX_WITHDRAWALS_PER_PAYLOAD:
|
||||||
@ -192,7 +192,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
DEPOSIT_CONTRACT_ADDRESS:
|
DEPOSIT_CONTRACT_ADDRESS:
|
||||||
$cfg.DEPOSIT_CONTRACT_ADDRESS,
|
$cfg.DEPOSIT_CONTRACT_ADDRESS,
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#constants
|
||||||
# GENESIS_SLOT
|
# GENESIS_SLOT
|
||||||
# GENESIS_EPOCH
|
# GENESIS_EPOCH
|
||||||
# FAR_FUTURE_EPOCH
|
# FAR_FUTURE_EPOCH
|
||||||
@ -260,7 +260,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||||||
ATTESTATION_SUBNET_COUNT:
|
ATTESTATION_SUBNET_COUNT:
|
||||||
Base10.toString(ATTESTATION_SUBNET_COUNT),
|
Base10.toString(ATTESTATION_SUBNET_COUNT),
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#constants
|
||||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE:
|
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE:
|
||||||
Base10.toString(uint64(TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)),
|
Base10.toString(uint64(TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE)),
|
||||||
SYNC_COMMITTEE_SUBNET_COUNT:
|
SYNC_COMMITTEE_SUBNET_COUNT:
|
||||||
|
@ -140,16 +140,16 @@ const
|
|||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#broadcast-aggregate
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#broadcast-aggregate
|
||||||
aggregateSlotOffset* = TimeDiff(nanoseconds:
|
aggregateSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#prepare-sync-committee-message
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||||
syncCommitteeMessageSlotOffset* = TimeDiff(nanoseconds:
|
syncCommitteeMessageSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||||
syncContributionSlotOffset* = TimeDiff(nanoseconds:
|
syncContributionSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#sync-committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||||
lightClientFinalityUpdateSlotOffset* = TimeDiff(nanoseconds:
|
lightClientFinalityUpdateSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#sync-committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||||
lightClientOptimisticUpdateSlotOffset* = TimeDiff(nanoseconds:
|
lightClientOptimisticUpdateSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ func slotOrZero*(time: BeaconTime): Slot =
|
|||||||
if exSlot.afterGenesis: exSlot.slot
|
if exSlot.afterGenesis: exSlot.slot
|
||||||
else: Slot(0)
|
else: Slot(0)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_epoch_at_slot
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_epoch_at_slot
|
||||||
func epoch*(slot: Slot): Epoch = # aka compute_epoch_at_slot
|
func epoch*(slot: Slot): Epoch = # aka compute_epoch_at_slot
|
||||||
## Return the epoch number at ``slot``.
|
## Return the epoch number at ``slot``.
|
||||||
if slot == FAR_FUTURE_SLOT: FAR_FUTURE_EPOCH
|
if slot == FAR_FUTURE_SLOT: FAR_FUTURE_EPOCH
|
||||||
@ -197,14 +197,14 @@ func since_epoch_start*(slot: Slot): uint64 = # aka compute_slots_since_epoch_st
|
|||||||
template is_epoch*(slot: Slot): bool =
|
template is_epoch*(slot: Slot): bool =
|
||||||
slot.since_epoch_start == 0
|
slot.since_epoch_start == 0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
|
||||||
func start_slot*(epoch: Epoch): Slot = # aka compute_start_slot_at_epoch
|
func start_slot*(epoch: Epoch): Slot = # aka compute_start_slot_at_epoch
|
||||||
## Return the start slot of ``epoch``.
|
## Return the start slot of ``epoch``.
|
||||||
const maxEpoch = Epoch(FAR_FUTURE_SLOT div SLOTS_PER_EPOCH)
|
const maxEpoch = Epoch(FAR_FUTURE_SLOT div SLOTS_PER_EPOCH)
|
||||||
if epoch >= maxEpoch: FAR_FUTURE_SLOT
|
if epoch >= maxEpoch: FAR_FUTURE_SLOT
|
||||||
else: Slot(epoch * SLOTS_PER_EPOCH)
|
else: Slot(epoch * SLOTS_PER_EPOCH)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_previous_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_previous_epoch
|
||||||
func get_previous_epoch*(current_epoch: Epoch): Epoch =
|
func get_previous_epoch*(current_epoch: Epoch): Epoch =
|
||||||
## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
||||||
if current_epoch == GENESIS_EPOCH:
|
if current_epoch == GENESIS_EPOCH:
|
||||||
@ -217,7 +217,7 @@ iterator slots*(epoch: Epoch): Slot =
|
|||||||
for slot in start_slot ..< start_slot + SLOTS_PER_EPOCH:
|
for slot in start_slot ..< start_slot + SLOTS_PER_EPOCH:
|
||||||
yield slot
|
yield slot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#sync-committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#sync-committee
|
||||||
template sync_committee_period*(epoch: Epoch): SyncCommitteePeriod =
|
template sync_committee_period*(epoch: Epoch): SyncCommitteePeriod =
|
||||||
if epoch == FAR_FUTURE_EPOCH: FAR_FUTURE_PERIOD
|
if epoch == FAR_FUTURE_EPOCH: FAR_FUTURE_PERIOD
|
||||||
else: SyncCommitteePeriod(epoch div EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
else: SyncCommitteePeriod(epoch div EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
||||||
|
@ -22,7 +22,7 @@ from ./datatypes/capella import BeaconState, ExecutionPayloadHeader, Withdrawal
|
|||||||
|
|
||||||
export extras, forks, validator, chronicles
|
export extras, forks, validator, chronicles
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#increase_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#increase_balance
|
||||||
func increase_balance*(balance: var Gwei, delta: Gwei) =
|
func increase_balance*(balance: var Gwei, delta: Gwei) =
|
||||||
balance += delta
|
balance += delta
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ func increase_balance*(
|
|||||||
if delta != 0: # avoid dirtying the balance cache if not needed
|
if delta != 0: # avoid dirtying the balance cache if not needed
|
||||||
increase_balance(state.balances.mitem(index), delta)
|
increase_balance(state.balances.mitem(index), delta)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#decrease_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#decrease_balance
|
||||||
func decrease_balance*(balance: var Gwei, delta: Gwei) =
|
func decrease_balance*(balance: var Gwei, delta: Gwei) =
|
||||||
balance =
|
balance =
|
||||||
if delta > balance:
|
if delta > balance:
|
||||||
@ -47,7 +47,7 @@ func decrease_balance*(
|
|||||||
if delta != 0: # avoid dirtying the balance cache if not needed
|
if delta != 0: # avoid dirtying the balance cache if not needed
|
||||||
decrease_balance(state.balances.mitem(index), delta)
|
decrease_balance(state.balances.mitem(index), delta)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#deposits
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#deposits
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-apply_deposit
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-apply_deposit
|
||||||
func get_validator_from_deposit*(deposit: DepositData):
|
func get_validator_from_deposit*(deposit: DepositData):
|
||||||
Validator =
|
Validator =
|
||||||
@ -66,13 +66,13 @@ func get_validator_from_deposit*(deposit: DepositData):
|
|||||||
effective_balance: effective_balance
|
effective_balance: effective_balance
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_activation_exit_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_activation_exit_epoch
|
||||||
func compute_activation_exit_epoch*(epoch: Epoch): Epoch =
|
func compute_activation_exit_epoch*(epoch: Epoch): Epoch =
|
||||||
## Return the epoch during which validator activations and exits initiated in
|
## Return the epoch during which validator activations and exits initiated in
|
||||||
## ``epoch`` take effect.
|
## ``epoch`` take effect.
|
||||||
epoch + 1 + MAX_SEED_LOOKAHEAD
|
epoch + 1 + MAX_SEED_LOOKAHEAD
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_validator_churn_limit
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_validator_churn_limit
|
||||||
func get_validator_churn_limit*(
|
func get_validator_churn_limit*(
|
||||||
cfg: RuntimeConfig, state: ForkyBeaconState, cache: var StateCache):
|
cfg: RuntimeConfig, state: ForkyBeaconState, cache: var StateCache):
|
||||||
uint64 =
|
uint64 =
|
||||||
@ -82,7 +82,7 @@ func get_validator_churn_limit*(
|
|||||||
count_active_validators(
|
count_active_validators(
|
||||||
state, state.get_current_epoch(), cache) div cfg.CHURN_LIMIT_QUOTIENT)
|
state, state.get_current_epoch(), cache) div cfg.CHURN_LIMIT_QUOTIENT)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#initiate_validator_exit
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#initiate_validator_exit
|
||||||
func initiate_validator_exit*(
|
func initiate_validator_exit*(
|
||||||
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||||
index: ValidatorIndex, cache: var StateCache): Result[void, cstring] =
|
index: ValidatorIndex, cache: var StateCache): Result[void, cstring] =
|
||||||
@ -133,7 +133,7 @@ func initiate_validator_exit*(
|
|||||||
|
|
||||||
from ./datatypes/deneb import BeaconState
|
from ./datatypes/deneb import BeaconState
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||||
func get_slashing_penalty*(state: ForkyBeaconState,
|
func get_slashing_penalty*(state: ForkyBeaconState,
|
||||||
@ -150,13 +150,13 @@ func get_slashing_penalty*(state: ForkyBeaconState,
|
|||||||
else:
|
else:
|
||||||
{.fatal: "invalid BeaconState type".}
|
{.fatal: "invalid BeaconState type".}
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||||
func get_whistleblower_reward*(validator_effective_balance: Gwei): Gwei =
|
func get_whistleblower_reward*(validator_effective_balance: Gwei): Gwei =
|
||||||
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT
|
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||||
func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): Gwei =
|
func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): Gwei =
|
||||||
@ -168,7 +168,7 @@ func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): G
|
|||||||
else:
|
else:
|
||||||
{.fatal: "invalid BeaconState type".}
|
{.fatal: "invalid BeaconState type".}
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||||
proc slash_validator*(
|
proc slash_validator*(
|
||||||
@ -222,7 +222,7 @@ proc slash_validator*(
|
|||||||
func genesis_time_from_eth1_timestamp*(cfg: RuntimeConfig, eth1_timestamp: uint64): uint64 =
|
func genesis_time_from_eth1_timestamp*(cfg: RuntimeConfig, eth1_timestamp: uint64): uint64 =
|
||||||
eth1_timestamp + cfg.GENESIS_DELAY
|
eth1_timestamp + cfg.GENESIS_DELAY
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#genesis-block
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#genesis-block
|
||||||
func get_initial_beacon_block*(state: phase0.HashedBeaconState):
|
func get_initial_beacon_block*(state: phase0.HashedBeaconState):
|
||||||
phase0.TrustedSignedBeaconBlock =
|
phase0.TrustedSignedBeaconBlock =
|
||||||
# The genesis block is implicitly trusted
|
# The genesis block is implicitly trusted
|
||||||
@ -287,7 +287,7 @@ func get_initial_beacon_block*(state: ForkedHashedBeaconState):
|
|||||||
withState(state):
|
withState(state):
|
||||||
ForkedTrustedSignedBeaconBlock.init(get_initial_beacon_block(forkyState))
|
ForkedTrustedSignedBeaconBlock.init(get_initial_beacon_block(forkyState))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_block_root_at_slot
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_block_root_at_slot
|
||||||
func get_block_root_at_slot*(state: ForkyBeaconState, slot: Slot): Eth2Digest =
|
func get_block_root_at_slot*(state: ForkyBeaconState, slot: Slot): Eth2Digest =
|
||||||
## Return the block root at a recent ``slot``.
|
## Return the block root at a recent ``slot``.
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ func get_block_root_at_slot*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
get_block_root_at_slot(forkyState.data, slot)
|
get_block_root_at_slot(forkyState.data, slot)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_block_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_block_root
|
||||||
func get_block_root*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest =
|
func get_block_root*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest =
|
||||||
## Return the block root at the start of a recent ``epoch``.
|
## Return the block root at the start of a recent ``epoch``.
|
||||||
get_block_root_at_slot(state, epoch.start_slot())
|
get_block_root_at_slot(state, epoch.start_slot())
|
||||||
@ -315,7 +315,7 @@ func get_block_root*(state: ForkedHashedBeaconState, epoch: Epoch): Eth2Digest =
|
|||||||
withState(state):
|
withState(state):
|
||||||
get_block_root(forkyState.data, epoch)
|
get_block_root(forkyState.data, epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_total_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_total_balance
|
||||||
template get_total_balance(
|
template get_total_balance(
|
||||||
state: ForkyBeaconState, validator_indices: untyped): Gwei =
|
state: ForkyBeaconState, validator_indices: untyped): Gwei =
|
||||||
## Return the combined effective balance of the ``indices``.
|
## Return the combined effective balance of the ``indices``.
|
||||||
@ -326,13 +326,13 @@ template get_total_balance(
|
|||||||
res += state.validators[validator_index].effective_balance
|
res += state.validators[validator_index].effective_balance
|
||||||
max(EFFECTIVE_BALANCE_INCREMENT, res)
|
max(EFFECTIVE_BALANCE_INCREMENT, res)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
|
||||||
func is_eligible_for_activation_queue*(validator: Validator): bool =
|
func is_eligible_for_activation_queue*(validator: Validator): bool =
|
||||||
## Check if ``validator`` is eligible to be placed into the activation queue.
|
## Check if ``validator`` is eligible to be placed into the activation queue.
|
||||||
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
||||||
validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
validator.effective_balance == MAX_EFFECTIVE_BALANCE
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_eligible_for_activation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_eligible_for_activation
|
||||||
func is_eligible_for_activation*(
|
func is_eligible_for_activation*(
|
||||||
state: ForkyBeaconState, validator: Validator): bool =
|
state: ForkyBeaconState, validator: Validator): bool =
|
||||||
## Check if ``validator`` is eligible for activation.
|
## Check if ``validator`` is eligible for activation.
|
||||||
@ -342,7 +342,7 @@ func is_eligible_for_activation*(
|
|||||||
# Has not yet been activated
|
# Has not yet been activated
|
||||||
validator.activation_epoch == FAR_FUTURE_EPOCH
|
validator.activation_epoch == FAR_FUTURE_EPOCH
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
||||||
proc is_valid_indexed_attestation*(
|
proc is_valid_indexed_attestation*(
|
||||||
state: ForkyBeaconState, indexed_attestation: SomeIndexedAttestation,
|
state: ForkyBeaconState, indexed_attestation: SomeIndexedAttestation,
|
||||||
flags: UpdateFlags): Result[void, cstring] =
|
flags: UpdateFlags): Result[void, cstring] =
|
||||||
@ -380,7 +380,7 @@ proc is_valid_indexed_attestation*(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
||||||
func get_attesting_indices*(state: ForkyBeaconState,
|
func get_attesting_indices*(state: ForkyBeaconState,
|
||||||
data: AttestationData,
|
data: AttestationData,
|
||||||
bits: CommitteeValidatorsBits,
|
bits: CommitteeValidatorsBits,
|
||||||
@ -445,7 +445,7 @@ proc is_valid_indexed_attestation*(
|
|||||||
|
|
||||||
# Attestation validation
|
# Attestation validation
|
||||||
# ------------------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------------------
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attestations
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attestations
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||||
|
|
||||||
func check_attestation_slot_target*(data: AttestationData): Result[Slot, cstring] =
|
func check_attestation_slot_target*(data: AttestationData): Result[Slot, cstring] =
|
||||||
@ -523,7 +523,7 @@ func get_attestation_participation_flag_indices(
|
|||||||
# TODO these duplicate some stuff in state_transition_epoch which uses TotalBalances
|
# TODO these duplicate some stuff in state_transition_epoch which uses TotalBalances
|
||||||
# better to centralize around that if feasible
|
# better to centralize around that if feasible
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_total_active_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_total_active_balance
|
||||||
func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache): Gwei =
|
func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache): Gwei =
|
||||||
## Return the combined effective balance of the active validators.
|
## Return the combined effective balance of the active validators.
|
||||||
## Note: ``get_total_balance`` returns ``EFFECTIVE_BALANCE_INCREMENT`` Gwei
|
## Note: ``get_total_balance`` returns ``EFFECTIVE_BALANCE_INCREMENT`` Gwei
|
||||||
@ -559,7 +559,7 @@ func get_base_reward(
|
|||||||
state.validators[index].effective_balance div EFFECTIVE_BALANCE_INCREMENT
|
state.validators[index].effective_balance div EFFECTIVE_BALANCE_INCREMENT
|
||||||
increments * base_reward_per_increment
|
increments * base_reward_per_increment
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attestations
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attestations
|
||||||
proc check_attestation*(
|
proc check_attestation*(
|
||||||
state: ForkyBeaconState, attestation: SomeAttestation, flags: UpdateFlags,
|
state: ForkyBeaconState, attestation: SomeAttestation, flags: UpdateFlags,
|
||||||
cache: var StateCache): Result[void, cstring] =
|
cache: var StateCache): Result[void, cstring] =
|
||||||
@ -818,7 +818,7 @@ func get_next_sync_committee*(
|
|||||||
res.aggregate_pubkey = finish(attestersAgg).toPubKey()
|
res.aggregate_pubkey = finish(attestersAgg).toPubKey()
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#genesis
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#genesis
|
||||||
proc initialize_beacon_state_from_eth1*(
|
proc initialize_beacon_state_from_eth1*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
eth1_block_hash: Eth2Digest,
|
eth1_block_hash: Eth2Digest,
|
||||||
@ -1059,7 +1059,7 @@ proc initialize_hashed_beacon_state_from_eth1*(
|
|||||||
execution_payload_header, flags))
|
execution_payload_header, flags))
|
||||||
result.root = hash_tree_root(result.data)
|
result.root = hash_tree_root(result.data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/fork.md#upgrading-the-state
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/fork.md#upgrading-the-state
|
||||||
func translate_participation(
|
func translate_participation(
|
||||||
state: var altair.BeaconState,
|
state: var altair.BeaconState,
|
||||||
pending_attestations: openArray[phase0.PendingAttestation]) =
|
pending_attestations: openArray[phase0.PendingAttestation]) =
|
||||||
@ -1145,7 +1145,7 @@ func upgrade_to_altair*(cfg: RuntimeConfig, pre: phase0.BeaconState):
|
|||||||
|
|
||||||
post
|
post
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/fork.md#upgrading-the-state
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/bellatrix/fork.md#upgrading-the-state
|
||||||
func upgrade_to_bellatrix*(cfg: RuntimeConfig, pre: altair.BeaconState):
|
func upgrade_to_bellatrix*(cfg: RuntimeConfig, pre: altair.BeaconState):
|
||||||
ref bellatrix.BeaconState =
|
ref bellatrix.BeaconState =
|
||||||
let epoch = get_current_epoch(pre)
|
let epoch = get_current_epoch(pre)
|
||||||
@ -1202,7 +1202,7 @@ func upgrade_to_bellatrix*(cfg: RuntimeConfig, pre: altair.BeaconState):
|
|||||||
latest_execution_payload_header: default(bellatrix.ExecutionPayloadHeader)
|
latest_execution_payload_header: default(bellatrix.ExecutionPayloadHeader)
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/fork.md#upgrading-the-state
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/fork.md#upgrading-the-state
|
||||||
func upgrade_to_capella*(cfg: RuntimeConfig, pre: bellatrix.BeaconState):
|
func upgrade_to_capella*(cfg: RuntimeConfig, pre: bellatrix.BeaconState):
|
||||||
ref capella.BeaconState =
|
ref capella.BeaconState =
|
||||||
let
|
let
|
||||||
@ -1285,7 +1285,7 @@ func upgrade_to_capella*(cfg: RuntimeConfig, pre: bellatrix.BeaconState):
|
|||||||
# historical_summaries initialized to correct default automatically
|
# historical_summaries initialized to correct default automatically
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/fork.md#upgrading-the-state
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/fork.md#upgrading-the-state
|
||||||
func upgrade_to_deneb*(cfg: RuntimeConfig, pre: capella.BeaconState):
|
func upgrade_to_deneb*(cfg: RuntimeConfig, pre: capella.BeaconState):
|
||||||
ref deneb.BeaconState =
|
ref deneb.BeaconState =
|
||||||
let
|
let
|
||||||
|
@ -95,7 +95,7 @@ export
|
|||||||
|
|
||||||
# API
|
# API
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#bls-signatures
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#bls-signatures
|
||||||
|
|
||||||
func toPubKey*(privkey: ValidatorPrivKey): CookedPubKey =
|
func toPubKey*(privkey: ValidatorPrivKey): CookedPubKey =
|
||||||
## Derive a public key from a private key
|
## Derive a public key from a private key
|
||||||
@ -203,7 +203,7 @@ func finish*(agg: AggregateSignature): CookedSig {.inline.} =
|
|||||||
sig.finish(agg)
|
sig.finish(agg)
|
||||||
CookedSig(sig)
|
CookedSig(sig)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#bls-signatures
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#bls-signatures
|
||||||
func blsVerify*(
|
func blsVerify*(
|
||||||
pubkey: CookedPubKey, message: openArray[byte],
|
pubkey: CookedPubKey, message: openArray[byte],
|
||||||
signature: CookedSig): bool =
|
signature: CookedSig): bool =
|
||||||
@ -216,7 +216,7 @@ func blsVerify*(
|
|||||||
## to enforce correct usage.
|
## to enforce correct usage.
|
||||||
PublicKey(pubkey).verify(message, blscurve.Signature(signature))
|
PublicKey(pubkey).verify(message, blscurve.Signature(signature))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#bls-signatures
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#bls-signatures
|
||||||
proc blsVerify*(
|
proc blsVerify*(
|
||||||
pubkey: ValidatorPubKey, message: openArray[byte],
|
pubkey: ValidatorPubKey, message: openArray[byte],
|
||||||
signature: CookedSig): bool =
|
signature: CookedSig): bool =
|
||||||
|
@ -38,16 +38,16 @@ const
|
|||||||
PARTICIPATION_FLAG_WEIGHTS* =
|
PARTICIPATION_FLAG_WEIGHTS* =
|
||||||
[TIMELY_SOURCE_WEIGHT, TIMELY_TARGET_WEIGHT, TIMELY_HEAD_WEIGHT]
|
[TIMELY_SOURCE_WEIGHT, TIMELY_TARGET_WEIGHT, TIMELY_HEAD_WEIGHT]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#misc
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#misc
|
||||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16
|
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16
|
||||||
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#constants
|
||||||
# All of these indices are rooted in `BeaconState`.
|
# All of these indices are rooted in `BeaconState`.
|
||||||
# The first member (`genesis_time`) is 32, subsequent members +1 each.
|
# The first member (`genesis_time`) is 32, subsequent members +1 each.
|
||||||
# If there are ever more than 32 members in `BeaconState`, indices change!
|
# If there are ever more than 32 members in `BeaconState`, indices change!
|
||||||
# `FINALIZED_ROOT_INDEX` is one layer deeper, i.e., `52 * 2 + 1`.
|
# `FINALIZED_ROOT_INDEX` is one layer deeper, i.e., `52 * 2 + 1`.
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/ssz/merkle-proofs.md
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/ssz/merkle-proofs.md
|
||||||
FINALIZED_ROOT_INDEX* = 105.GeneralizedIndex # `finalized_checkpoint` > `root`
|
FINALIZED_ROOT_INDEX* = 105.GeneralizedIndex # `finalized_checkpoint` > `root`
|
||||||
CURRENT_SYNC_COMMITTEE_INDEX* = 54.GeneralizedIndex # `current_sync_committee`
|
CURRENT_SYNC_COMMITTEE_INDEX* = 54.GeneralizedIndex # `current_sync_committee`
|
||||||
NEXT_SYNC_COMMITTEE_INDEX* = 55.GeneralizedIndex # `next_sync_committee`
|
NEXT_SYNC_COMMITTEE_INDEX* = 55.GeneralizedIndex # `next_sync_committee`
|
||||||
@ -94,7 +94,7 @@ type
|
|||||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||||
aggregate_pubkey*: ValidatorPubKey
|
aggregate_pubkey*: ValidatorPubKey
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#synccommitteemessage
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#synccommitteemessage
|
||||||
SyncCommitteeMessage* = object
|
SyncCommitteeMessage* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
## Slot to which this contribution pertains
|
## Slot to which this contribution pertains
|
||||||
@ -108,7 +108,7 @@ type
|
|||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
## Signature by the validator over the block root of `slot`
|
## Signature by the validator over the block root of `slot`
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#synccommitteecontribution
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#synccommitteecontribution
|
||||||
SyncCommitteeAggregationBits* =
|
SyncCommitteeAggregationBits* =
|
||||||
BitArray[SYNC_SUBCOMMITTEE_SIZE]
|
BitArray[SYNC_SUBCOMMITTEE_SIZE]
|
||||||
|
|
||||||
@ -130,18 +130,18 @@ type
|
|||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
## Signature by the validator(s) over the block root of `slot`
|
## Signature by the validator(s) over the block root of `slot`
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#contributionandproof
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#contributionandproof
|
||||||
ContributionAndProof* = object
|
ContributionAndProof* = object
|
||||||
aggregator_index*: uint64 # `ValidatorIndex` after validation
|
aggregator_index*: uint64 # `ValidatorIndex` after validation
|
||||||
contribution*: SyncCommitteeContribution
|
contribution*: SyncCommitteeContribution
|
||||||
selection_proof*: ValidatorSig
|
selection_proof*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#signedcontributionandproof
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#signedcontributionandproof
|
||||||
SignedContributionAndProof* = object
|
SignedContributionAndProof* = object
|
||||||
message*: ContributionAndProof
|
message*: ContributionAndProof
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#syncaggregatorselectiondata
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#syncaggregatorselectiondata
|
||||||
SyncAggregatorSelectionData* = object
|
SyncAggregatorSelectionData* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
subcommittee_index*: uint64 # `SyncSubcommitteeIndex` after validation
|
subcommittee_index*: uint64 # `SyncSubcommitteeIndex` after validation
|
||||||
@ -157,12 +157,12 @@ type
|
|||||||
NextSyncCommitteeBranch* =
|
NextSyncCommitteeBranch* =
|
||||||
array[log2trunc(NEXT_SYNC_COMMITTEE_INDEX), Eth2Digest]
|
array[log2trunc(NEXT_SYNC_COMMITTEE_INDEX), Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
beacon*: BeaconBlockHeader
|
beacon*: BeaconBlockHeader
|
||||||
## Beacon block header
|
## Beacon block header
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
||||||
LightClientBootstrap* = object
|
LightClientBootstrap* = object
|
||||||
header*: LightClientHeader
|
header*: LightClientHeader
|
||||||
## Header matching the requested beacon block root
|
## Header matching the requested beacon block root
|
||||||
@ -171,7 +171,7 @@ type
|
|||||||
## Current sync committee corresponding to `header.beacon.state_root`
|
## Current sync committee corresponding to `header.beacon.state_root`
|
||||||
current_sync_committee_branch*: CurrentSyncCommitteeBranch
|
current_sync_committee_branch*: CurrentSyncCommitteeBranch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
||||||
LightClientUpdate* = object
|
LightClientUpdate* = object
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
## Header attested to by the sync committee
|
## Header attested to by the sync committee
|
||||||
@ -190,7 +190,7 @@ type
|
|||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
## Slot at which the aggregate signature was created (untrusted)
|
## Slot at which the aggregate signature was created (untrusted)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
||||||
LightClientFinalityUpdate* = object
|
LightClientFinalityUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
@ -204,7 +204,7 @@ type
|
|||||||
# Slot at which the aggregate signature was created (untrusted)
|
# Slot at which the aggregate signature was created (untrusted)
|
||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
||||||
LightClientOptimisticUpdate* = object
|
LightClientOptimisticUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
@ -230,7 +230,7 @@ type
|
|||||||
LightClientBootstrap |
|
LightClientBootstrap |
|
||||||
SomeLightClientUpdate
|
SomeLightClientUpdate
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
||||||
LightClientStore* = object
|
LightClientStore* = object
|
||||||
finalized_header*: LightClientHeader
|
finalized_header*: LightClientHeader
|
||||||
## Header that is finalized
|
## Header that is finalized
|
||||||
@ -339,7 +339,7 @@ type
|
|||||||
data*: BeaconState
|
data*: BeaconState
|
||||||
root*: Eth2Digest # hash_tree_root(data)
|
root*: Eth2Digest # hash_tree_root(data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblock
|
||||||
BeaconBlock* = object
|
BeaconBlock* = object
|
||||||
## For each slot, a proposer is chosen from the validator pool to propose
|
## For each slot, a proposer is chosen from the validator pool to propose
|
||||||
## a new block. Once the block as been proposed, it is transmitted to
|
## a new block. Once the block as been proposed, it is transmitted to
|
||||||
@ -473,7 +473,7 @@ type
|
|||||||
# [New in Altair]
|
# [New in Altair]
|
||||||
sync_aggregate*: TrustedSyncAggregate
|
sync_aggregate*: TrustedSyncAggregate
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
||||||
SignedBeaconBlock* = object
|
SignedBeaconBlock* = object
|
||||||
message*: BeaconBlock
|
message*: BeaconBlock
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
@ -651,7 +651,7 @@ chronicles.formatIt SyncCommitteeContribution: shortLog(it)
|
|||||||
chronicles.formatIt ContributionAndProof: shortLog(it)
|
chronicles.formatIt ContributionAndProof: shortLog(it)
|
||||||
chronicles.formatIt SignedContributionAndProof: shortLog(it)
|
chronicles.formatIt SignedContributionAndProof: shortLog(it)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#is_valid_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#is_valid_light_client_header
|
||||||
func is_valid_light_client_header*(
|
func is_valid_light_client_header*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
||||||
true
|
true
|
||||||
|
@ -146,7 +146,7 @@ template ethAmountUnit*(typ: type) {.dirty.} =
|
|||||||
ethAmountUnit Ether
|
ethAmountUnit Ether
|
||||||
|
|
||||||
type
|
type
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#custom-types
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#custom-types
|
||||||
Eth2Domain* = array[32, byte]
|
Eth2Domain* = array[32, byte]
|
||||||
|
|
||||||
ValidatorIndex* = distinct uint32
|
ValidatorIndex* = distinct uint32
|
||||||
@ -191,7 +191,7 @@ type
|
|||||||
# SSZ / hashing purposes
|
# SSZ / hashing purposes
|
||||||
JustificationBits* = distinct uint8
|
JustificationBits* = distinct uint8
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#proposerslashing
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#proposerslashing
|
||||||
ProposerSlashing* = object
|
ProposerSlashing* = object
|
||||||
signed_header_1*: SignedBeaconBlockHeader
|
signed_header_1*: SignedBeaconBlockHeader
|
||||||
signed_header_2*: SignedBeaconBlockHeader
|
signed_header_2*: SignedBeaconBlockHeader
|
||||||
@ -203,7 +203,7 @@ type
|
|||||||
signed_header_1*: TrustedSignedBeaconBlockHeader
|
signed_header_1*: TrustedSignedBeaconBlockHeader
|
||||||
signed_header_2*: TrustedSignedBeaconBlockHeader
|
signed_header_2*: TrustedSignedBeaconBlockHeader
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attesterslashing
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attesterslashing
|
||||||
AttesterSlashing* = object
|
AttesterSlashing* = object
|
||||||
attestation_1*: IndexedAttestation
|
attestation_1*: IndexedAttestation
|
||||||
attestation_2*: IndexedAttestation
|
attestation_2*: IndexedAttestation
|
||||||
@ -215,7 +215,7 @@ type
|
|||||||
attestation_1*: TrustedIndexedAttestation
|
attestation_1*: TrustedIndexedAttestation
|
||||||
attestation_2*: TrustedIndexedAttestation
|
attestation_2*: TrustedIndexedAttestation
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#indexedattestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#indexedattestation
|
||||||
IndexedAttestation* = object
|
IndexedAttestation* = object
|
||||||
attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE]
|
attesting_indices*: List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||||
data*: AttestationData
|
data*: AttestationData
|
||||||
@ -231,7 +231,7 @@ type
|
|||||||
|
|
||||||
CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE]
|
CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attestation
|
||||||
Attestation* = object
|
Attestation* = object
|
||||||
aggregation_bits*: CommitteeValidatorsBits
|
aggregation_bits*: CommitteeValidatorsBits
|
||||||
data*: AttestationData
|
data*: AttestationData
|
||||||
@ -247,17 +247,17 @@ type
|
|||||||
|
|
||||||
ForkDigest* = distinct array[4, byte]
|
ForkDigest* = distinct array[4, byte]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#forkdata
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#forkdata
|
||||||
ForkData* = object
|
ForkData* = object
|
||||||
current_version*: Version
|
current_version*: Version
|
||||||
genesis_validators_root*: Eth2Digest
|
genesis_validators_root*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#checkpoint
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#checkpoint
|
||||||
Checkpoint* = object
|
Checkpoint* = object
|
||||||
epoch*: Epoch
|
epoch*: Epoch
|
||||||
root*: Eth2Digest
|
root*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#AttestationData
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#AttestationData
|
||||||
AttestationData* = object
|
AttestationData* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
|
|
||||||
@ -270,20 +270,20 @@ type
|
|||||||
source*: Checkpoint
|
source*: Checkpoint
|
||||||
target*: Checkpoint
|
target*: Checkpoint
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#deposit
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#deposit
|
||||||
Deposit* = object
|
Deposit* = object
|
||||||
proof*: array[DEPOSIT_CONTRACT_TREE_DEPTH + 1, Eth2Digest]
|
proof*: array[DEPOSIT_CONTRACT_TREE_DEPTH + 1, Eth2Digest]
|
||||||
## Merkle path to deposit root
|
## Merkle path to deposit root
|
||||||
|
|
||||||
data*: DepositData
|
data*: DepositData
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#depositmessage
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#depositmessage
|
||||||
DepositMessage* = object
|
DepositMessage* = object
|
||||||
pubkey*: ValidatorPubKey
|
pubkey*: ValidatorPubKey
|
||||||
withdrawal_credentials*: Eth2Digest
|
withdrawal_credentials*: Eth2Digest
|
||||||
amount*: Gwei
|
amount*: Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#depositdata
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#depositdata
|
||||||
DepositData* = object
|
DepositData* = object
|
||||||
pubkey*: ValidatorPubKey
|
pubkey*: ValidatorPubKey
|
||||||
withdrawal_credentials*: Eth2Digest
|
withdrawal_credentials*: Eth2Digest
|
||||||
@ -293,7 +293,7 @@ type
|
|||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
## Signing over DepositMessage
|
## Signing over DepositMessage
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#voluntaryexit
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#voluntaryexit
|
||||||
VoluntaryExit* = object
|
VoluntaryExit* = object
|
||||||
epoch*: Epoch
|
epoch*: Epoch
|
||||||
## Earliest epoch when voluntary exit can be processed
|
## Earliest epoch when voluntary exit can be processed
|
||||||
@ -321,7 +321,7 @@ type
|
|||||||
pubkey*: CookedPubKey
|
pubkey*: CookedPubKey
|
||||||
withdrawal_credentials*: Eth2Digest
|
withdrawal_credentials*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#validator
|
||||||
Validator* = object
|
Validator* = object
|
||||||
pubkey*: ValidatorPubKey
|
pubkey*: ValidatorPubKey
|
||||||
|
|
||||||
@ -343,7 +343,7 @@ type
|
|||||||
withdrawable_epoch*: Epoch
|
withdrawable_epoch*: Epoch
|
||||||
## When validator can withdraw funds
|
## When validator can withdraw funds
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#pendingattestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#pendingattestation
|
||||||
PendingAttestation* = object
|
PendingAttestation* = object
|
||||||
aggregation_bits*: CommitteeValidatorsBits
|
aggregation_bits*: CommitteeValidatorsBits
|
||||||
data*: AttestationData
|
data*: AttestationData
|
||||||
@ -352,12 +352,12 @@ type
|
|||||||
|
|
||||||
proposer_index*: uint64 # `ValidatorIndex` after validation
|
proposer_index*: uint64 # `ValidatorIndex` after validation
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#historicalbatch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#historicalbatch
|
||||||
HistoricalBatch* = object
|
HistoricalBatch* = object
|
||||||
block_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
block_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
||||||
state_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
state_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#fork
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#fork
|
||||||
Fork* = object
|
Fork* = object
|
||||||
previous_version*: Version
|
previous_version*: Version
|
||||||
current_version*: Version
|
current_version*: Version
|
||||||
@ -365,13 +365,13 @@ type
|
|||||||
epoch*: Epoch
|
epoch*: Epoch
|
||||||
## Epoch of latest fork
|
## Epoch of latest fork
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#eth1data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#eth1data
|
||||||
Eth1Data* = object
|
Eth1Data* = object
|
||||||
deposit_root*: Eth2Digest
|
deposit_root*: Eth2Digest
|
||||||
deposit_count*: uint64
|
deposit_count*: uint64
|
||||||
block_hash*: Eth2Digest
|
block_hash*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedvoluntaryexit
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedvoluntaryexit
|
||||||
SignedVoluntaryExit* = object
|
SignedVoluntaryExit* = object
|
||||||
message*: VoluntaryExit
|
message*: VoluntaryExit
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
@ -380,7 +380,7 @@ type
|
|||||||
message*: VoluntaryExit
|
message*: VoluntaryExit
|
||||||
signature*: TrustedSig
|
signature*: TrustedSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblockheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblockheader
|
||||||
BeaconBlockHeader* = object
|
BeaconBlockHeader* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
proposer_index*: uint64 # `ValidatorIndex` after validation
|
proposer_index*: uint64 # `ValidatorIndex` after validation
|
||||||
@ -388,14 +388,14 @@ type
|
|||||||
state_root*: Eth2Digest
|
state_root*: Eth2Digest
|
||||||
body_root*: Eth2Digest
|
body_root*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signingdata
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signingdata
|
||||||
SigningData* = object
|
SigningData* = object
|
||||||
object_root*: Eth2Digest
|
object_root*: Eth2Digest
|
||||||
domain*: Eth2Domain
|
domain*: Eth2Domain
|
||||||
|
|
||||||
GraffitiBytes* = distinct array[MAX_GRAFFITI_SIZE, byte]
|
GraffitiBytes* = distinct array[MAX_GRAFFITI_SIZE, byte]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedbeaconblockheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedbeaconblockheader
|
||||||
SignedBeaconBlockHeader* = object
|
SignedBeaconBlockHeader* = object
|
||||||
message*: BeaconBlockHeader
|
message*: BeaconBlockHeader
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
@ -428,12 +428,12 @@ type
|
|||||||
sync_committees*: Table[SyncCommitteePeriod, SyncCommitteeCache]
|
sync_committees*: Table[SyncCommitteePeriod, SyncCommitteeCache]
|
||||||
|
|
||||||
# This matches the mutable state of the Solidity deposit contract
|
# This matches the mutable state of the Solidity deposit contract
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/solidity_deposit_contract/deposit_contract.sol
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/solidity_deposit_contract/deposit_contract.sol
|
||||||
DepositContractState* = object
|
DepositContractState* = object
|
||||||
branch*: array[DEPOSIT_CONTRACT_TREE_DEPTH, Eth2Digest]
|
branch*: array[DEPOSIT_CONTRACT_TREE_DEPTH, Eth2Digest]
|
||||||
deposit_count*: array[32, byte] # Uint256
|
deposit_count*: array[32, byte] # Uint256
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#validator
|
||||||
ValidatorStatus* = object
|
ValidatorStatus* = object
|
||||||
# This is a validator without the expensive, immutable, append-only parts
|
# This is a validator without the expensive, immutable, append-only parts
|
||||||
# serialized. They're represented in memory to allow in-place SSZ reading
|
# serialized. They're represented in memory to allow in-place SSZ reading
|
||||||
@ -459,7 +459,7 @@ type
|
|||||||
withdrawable_epoch*: Epoch
|
withdrawable_epoch*: Epoch
|
||||||
## When validator can withdraw funds
|
## When validator can withdraw funds
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#validator
|
||||||
ValidatorStatusCapella* = object
|
ValidatorStatusCapella* = object
|
||||||
# This is a validator without the expensive, immutable, append-only parts
|
# This is a validator without the expensive, immutable, append-only parts
|
||||||
# serialized. They're represented in memory to allow in-place SSZ reading
|
# serialized. They're represented in memory to allow in-place SSZ reading
|
||||||
|
@ -171,7 +171,7 @@ type
|
|||||||
data*: BeaconState
|
data*: BeaconState
|
||||||
root*: Eth2Digest # hash_tree_root(data)
|
root*: Eth2Digest # hash_tree_root(data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblock
|
||||||
BeaconBlock* = object
|
BeaconBlock* = object
|
||||||
## For each slot, a proposer is chosen from the validator pool to propose
|
## For each slot, a proposer is chosen from the validator pool to propose
|
||||||
## a new block. Once the block as been proposed, it is transmitted to
|
## a new block. Once the block as been proposed, it is transmitted to
|
||||||
@ -306,7 +306,7 @@ type
|
|||||||
# Execution
|
# Execution
|
||||||
execution_payload*: ExecutionPayload # [New in Bellatrix]
|
execution_payload*: ExecutionPayload # [New in Bellatrix]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
||||||
SignedBeaconBlock* = object
|
SignedBeaconBlock* = object
|
||||||
message*: BeaconBlock
|
message*: BeaconBlock
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
@ -27,11 +27,11 @@ import
|
|||||||
export json_serialization, base
|
export json_serialization, base
|
||||||
|
|
||||||
const
|
const
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/sync-protocol.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/sync-protocol.md#constants
|
||||||
# This index is rooted in `BeaconBlockBody`.
|
# This index is rooted in `BeaconBlockBody`.
|
||||||
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
||||||
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/ssz/merkle-proofs.md
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/ssz/merkle-proofs.md
|
||||||
EXECUTION_PAYLOAD_INDEX* = 25.GeneralizedIndex # `execution_payload`
|
EXECUTION_PAYLOAD_INDEX* = 25.GeneralizedIndex # `execution_payload`
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -122,7 +122,7 @@ type
|
|||||||
ExecutionBranch* =
|
ExecutionBranch* =
|
||||||
array[log2trunc(EXECUTION_PAYLOAD_INDEX), Eth2Digest]
|
array[log2trunc(EXECUTION_PAYLOAD_INDEX), Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
beacon*: BeaconBlockHeader
|
beacon*: BeaconBlockHeader
|
||||||
## Beacon block header
|
## Beacon block header
|
||||||
@ -131,7 +131,7 @@ type
|
|||||||
## Execution payload header corresponding to `beacon.body_root` (from Capella onward)
|
## Execution payload header corresponding to `beacon.body_root` (from Capella onward)
|
||||||
execution_branch*: ExecutionBranch
|
execution_branch*: ExecutionBranch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
||||||
LightClientBootstrap* = object
|
LightClientBootstrap* = object
|
||||||
header*: LightClientHeader
|
header*: LightClientHeader
|
||||||
## Header matching the requested beacon block root
|
## Header matching the requested beacon block root
|
||||||
@ -140,7 +140,7 @@ type
|
|||||||
## Current sync committee corresponding to `header.beacon.state_root`
|
## Current sync committee corresponding to `header.beacon.state_root`
|
||||||
current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch
|
current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
||||||
LightClientUpdate* = object
|
LightClientUpdate* = object
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
## Header attested to by the sync committee
|
## Header attested to by the sync committee
|
||||||
@ -159,7 +159,7 @@ type
|
|||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
## Slot at which the aggregate signature was created (untrusted)
|
## Slot at which the aggregate signature was created (untrusted)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
||||||
LightClientFinalityUpdate* = object
|
LightClientFinalityUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
@ -173,7 +173,7 @@ type
|
|||||||
# Slot at which the aggregate signature was created (untrusted)
|
# Slot at which the aggregate signature was created (untrusted)
|
||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
||||||
LightClientOptimisticUpdate* = object
|
LightClientOptimisticUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
@ -199,7 +199,7 @@ type
|
|||||||
LightClientBootstrap |
|
LightClientBootstrap |
|
||||||
SomeLightClientUpdate
|
SomeLightClientUpdate
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
||||||
LightClientStore* = object
|
LightClientStore* = object
|
||||||
finalized_header*: LightClientHeader
|
finalized_header*: LightClientHeader
|
||||||
## Header that is finalized
|
## Header that is finalized
|
||||||
@ -299,7 +299,7 @@ type
|
|||||||
data*: BeaconState
|
data*: BeaconState
|
||||||
root*: Eth2Digest # hash_tree_root(data)
|
root*: Eth2Digest # hash_tree_root(data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblock
|
||||||
BeaconBlock* = object
|
BeaconBlock* = object
|
||||||
## For each slot, a proposer is chosen from the validator pool to propose
|
## For each slot, a proposer is chosen from the validator pool to propose
|
||||||
## a new block. Once the block as been proposed, it is transmitted to
|
## a new block. Once the block as been proposed, it is transmitted to
|
||||||
@ -441,7 +441,7 @@ type
|
|||||||
# Capella operations
|
# Capella operations
|
||||||
bls_to_execution_changes*: SignedBLSToExecutionChangeList # [New in Capella]
|
bls_to_execution_changes*: SignedBLSToExecutionChangeList # [New in Capella]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
||||||
SignedBeaconBlock* = object
|
SignedBeaconBlock* = object
|
||||||
message*: BeaconBlock
|
message*: BeaconBlock
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
@ -624,7 +624,7 @@ func shortLog*(v: SignedBLSToExecutionChange): auto =
|
|||||||
signature: shortLog(v.signature)
|
signature: shortLog(v.signature)
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/sync-protocol.md#get_lc_execution_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/sync-protocol.md#get_lc_execution_root
|
||||||
func get_lc_execution_root*(
|
func get_lc_execution_root*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest =
|
header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest =
|
||||||
let epoch = header.beacon.slot.epoch
|
let epoch = header.beacon.slot.epoch
|
||||||
@ -634,7 +634,7 @@ func get_lc_execution_root*(
|
|||||||
|
|
||||||
ZERO_HASH
|
ZERO_HASH
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/sync-protocol.md#modified-is_valid_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/sync-protocol.md#modified-is_valid_light_client_header
|
||||||
func is_valid_light_client_header*(
|
func is_valid_light_client_header*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
||||||
let epoch = header.beacon.slot.epoch
|
let epoch = header.beacon.slot.epoch
|
||||||
@ -651,13 +651,13 @@ func is_valid_light_client_header*(
|
|||||||
get_subtree_index(EXECUTION_PAYLOAD_INDEX),
|
get_subtree_index(EXECUTION_PAYLOAD_INDEX),
|
||||||
header.beacon.body_root)
|
header.beacon.body_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
func upgrade_lc_header_to_capella*(
|
func upgrade_lc_header_to_capella*(
|
||||||
pre: altair.LightClientHeader): LightClientHeader =
|
pre: altair.LightClientHeader): LightClientHeader =
|
||||||
LightClientHeader(
|
LightClientHeader(
|
||||||
beacon: pre.beacon)
|
beacon: pre.beacon)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
func upgrade_lc_bootstrap_to_capella*(
|
func upgrade_lc_bootstrap_to_capella*(
|
||||||
pre: altair.LightClientBootstrap): LightClientBootstrap =
|
pre: altair.LightClientBootstrap): LightClientBootstrap =
|
||||||
LightClientBootstrap(
|
LightClientBootstrap(
|
||||||
@ -665,7 +665,7 @@ func upgrade_lc_bootstrap_to_capella*(
|
|||||||
current_sync_committee: pre.current_sync_committee,
|
current_sync_committee: pre.current_sync_committee,
|
||||||
current_sync_committee_branch: pre.current_sync_committee_branch)
|
current_sync_committee_branch: pre.current_sync_committee_branch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
func upgrade_lc_update_to_capella*(
|
func upgrade_lc_update_to_capella*(
|
||||||
pre: altair.LightClientUpdate): LightClientUpdate =
|
pre: altair.LightClientUpdate): LightClientUpdate =
|
||||||
LightClientUpdate(
|
LightClientUpdate(
|
||||||
@ -677,7 +677,7 @@ func upgrade_lc_update_to_capella*(
|
|||||||
sync_aggregate: pre.sync_aggregate,
|
sync_aggregate: pre.sync_aggregate,
|
||||||
signature_slot: pre.signature_slot)
|
signature_slot: pre.signature_slot)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
func upgrade_lc_finality_update_to_capella*(
|
func upgrade_lc_finality_update_to_capella*(
|
||||||
pre: altair.LightClientFinalityUpdate): LightClientFinalityUpdate =
|
pre: altair.LightClientFinalityUpdate): LightClientFinalityUpdate =
|
||||||
LightClientFinalityUpdate(
|
LightClientFinalityUpdate(
|
||||||
@ -687,7 +687,7 @@ func upgrade_lc_finality_update_to_capella*(
|
|||||||
sync_aggregate: pre.sync_aggregate,
|
sync_aggregate: pre.sync_aggregate,
|
||||||
signature_slot: pre.signature_slot)
|
signature_slot: pre.signature_slot)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
func upgrade_lc_optimistic_update_to_capella*(
|
func upgrade_lc_optimistic_update_to_capella*(
|
||||||
pre: altair.LightClientOptimisticUpdate): LightClientOptimisticUpdate =
|
pre: altair.LightClientOptimisticUpdate): LightClientOptimisticUpdate =
|
||||||
LightClientOptimisticUpdate(
|
LightClientOptimisticUpdate(
|
||||||
@ -738,7 +738,7 @@ chronicles.formatIt LightClientUpdate: shortLog(it)
|
|||||||
chronicles.formatIt LightClientFinalityUpdate: shortLog(it)
|
chronicles.formatIt LightClientFinalityUpdate: shortLog(it)
|
||||||
chronicles.formatIt LightClientOptimisticUpdate: shortLog(it)
|
chronicles.formatIt LightClientOptimisticUpdate: shortLog(it)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/fork.md#upgrading-the-store
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/fork.md#upgrading-the-store
|
||||||
func upgrade_lc_store_to_capella*(
|
func upgrade_lc_store_to_capella*(
|
||||||
pre: altair.LightClientStore): LightClientStore =
|
pre: altair.LightClientStore): LightClientStore =
|
||||||
let best_valid_update =
|
let best_valid_update =
|
||||||
|
@ -21,7 +21,7 @@ const
|
|||||||
FAR_FUTURE_EPOCH* = Epoch(not 0'u64)
|
FAR_FUTURE_EPOCH* = Epoch(not 0'u64)
|
||||||
FAR_FUTURE_PERIOD* = SyncCommitteePeriod(not 0'u64)
|
FAR_FUTURE_PERIOD* = SyncCommitteePeriod(not 0'u64)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#domain-types
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#domain-types
|
||||||
DOMAIN_BEACON_PROPOSER* = DomainType([byte 0x00, 0x00, 0x00, 0x00])
|
DOMAIN_BEACON_PROPOSER* = DomainType([byte 0x00, 0x00, 0x00, 0x00])
|
||||||
DOMAIN_BEACON_ATTESTER* = DomainType([byte 0x01, 0x00, 0x00, 0x00])
|
DOMAIN_BEACON_ATTESTER* = DomainType([byte 0x01, 0x00, 0x00, 0x00])
|
||||||
DOMAIN_RANDAO* = DomainType([byte 0x02, 0x00, 0x00, 0x00])
|
DOMAIN_RANDAO* = DomainType([byte 0x02, 0x00, 0x00, 0x00])
|
||||||
|
@ -143,7 +143,7 @@ type
|
|||||||
ExecutePayload* = proc(
|
ExecutePayload* = proc(
|
||||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].}
|
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [Defect].}
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
beacon*: BeaconBlockHeader
|
beacon*: BeaconBlockHeader
|
||||||
## Beacon block header
|
## Beacon block header
|
||||||
@ -152,7 +152,7 @@ type
|
|||||||
## Execution payload header corresponding to `beacon.body_root` (from Capella onward)
|
## Execution payload header corresponding to `beacon.body_root` (from Capella onward)
|
||||||
execution_branch*: capella.ExecutionBranch
|
execution_branch*: capella.ExecutionBranch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
|
||||||
LightClientBootstrap* = object
|
LightClientBootstrap* = object
|
||||||
header*: LightClientHeader
|
header*: LightClientHeader
|
||||||
## Header matching the requested beacon block root
|
## Header matching the requested beacon block root
|
||||||
@ -161,7 +161,7 @@ type
|
|||||||
## Current sync committee corresponding to `header.beacon.state_root`
|
## Current sync committee corresponding to `header.beacon.state_root`
|
||||||
current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch
|
current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
||||||
LightClientUpdate* = object
|
LightClientUpdate* = object
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
## Header attested to by the sync committee
|
## Header attested to by the sync committee
|
||||||
@ -180,7 +180,7 @@ type
|
|||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
## Slot at which the aggregate signature was created (untrusted)
|
## Slot at which the aggregate signature was created (untrusted)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
||||||
LightClientFinalityUpdate* = object
|
LightClientFinalityUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
@ -194,7 +194,7 @@ type
|
|||||||
# Slot at which the aggregate signature was created (untrusted)
|
# Slot at which the aggregate signature was created (untrusted)
|
||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
|
||||||
LightClientOptimisticUpdate* = object
|
LightClientOptimisticUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
@ -220,7 +220,7 @@ type
|
|||||||
LightClientBootstrap |
|
LightClientBootstrap |
|
||||||
SomeLightClientUpdate
|
SomeLightClientUpdate
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#lightclientstore
|
||||||
LightClientStore* = object
|
LightClientStore* = object
|
||||||
finalized_header*: LightClientHeader
|
finalized_header*: LightClientHeader
|
||||||
## Header that is finalized
|
## Header that is finalized
|
||||||
@ -319,7 +319,7 @@ type
|
|||||||
data*: BeaconState
|
data*: BeaconState
|
||||||
root*: Eth2Digest # hash_tree_root(data)
|
root*: Eth2Digest # hash_tree_root(data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblock
|
||||||
BeaconBlock* = object
|
BeaconBlock* = object
|
||||||
## For each slot, a proposer is chosen from the validator pool to propose
|
## For each slot, a proposer is chosen from the validator pool to propose
|
||||||
## a new block. Once the block as been proposed, it is transmitted to
|
## a new block. Once the block as been proposed, it is transmitted to
|
||||||
@ -457,7 +457,7 @@ type
|
|||||||
bls_to_execution_changes*: SignedBLSToExecutionChangeList
|
bls_to_execution_changes*: SignedBLSToExecutionChangeList
|
||||||
blob_kzg_commitments*: KzgCommitments # [New in Deneb]
|
blob_kzg_commitments*: KzgCommitments # [New in Deneb]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
||||||
SignedBeaconBlock* = object
|
SignedBeaconBlock* = object
|
||||||
message*: BeaconBlock
|
message*: BeaconBlock
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
@ -581,7 +581,7 @@ func shortLog*(v: ExecutionPayload): auto =
|
|||||||
func shortLog*(x: seq[BlobIdentifier]): string =
|
func shortLog*(x: seq[BlobIdentifier]): string =
|
||||||
"[" & x.mapIt(shortLog(it.block_root) & "/" & $it.index).join(", ") & "]"
|
"[" & x.mapIt(shortLog(it.block_root) & "/" & $it.index).join(", ") & "]"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/light-client/sync-protocol.md#modified-get_lc_execution_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/light-client/sync-protocol.md#modified-get_lc_execution_root
|
||||||
func get_lc_execution_root*(
|
func get_lc_execution_root*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest =
|
header: LightClientHeader, cfg: RuntimeConfig): Eth2Digest =
|
||||||
let epoch = header.beacon.slot.epoch
|
let epoch = header.beacon.slot.epoch
|
||||||
@ -610,7 +610,7 @@ func get_lc_execution_root*(
|
|||||||
|
|
||||||
ZERO_HASH
|
ZERO_HASH
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/light-client/sync-protocol.md#modified-is_valid_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/light-client/sync-protocol.md#modified-is_valid_light_client_header
|
||||||
func is_valid_light_client_header*(
|
func is_valid_light_client_header*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
||||||
let epoch = header.beacon.slot.epoch
|
let epoch = header.beacon.slot.epoch
|
||||||
|
@ -22,7 +22,7 @@ import
|
|||||||
export base
|
export base
|
||||||
|
|
||||||
type
|
type
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconstate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconstate
|
||||||
BeaconState* = object
|
BeaconState* = object
|
||||||
# Versioning
|
# Versioning
|
||||||
genesis_time*: uint64
|
genesis_time*: uint64
|
||||||
@ -73,7 +73,7 @@ type
|
|||||||
current_justified_checkpoint*: Checkpoint
|
current_justified_checkpoint*: Checkpoint
|
||||||
finalized_checkpoint*: Checkpoint
|
finalized_checkpoint*: Checkpoint
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_total_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_total_balance
|
||||||
TotalBalances* = object
|
TotalBalances* = object
|
||||||
# The total effective balance of all active validators during the _current_
|
# The total effective balance of all active validators during the _current_
|
||||||
# epoch.
|
# epoch.
|
||||||
@ -111,7 +111,7 @@ type
|
|||||||
data*: BeaconState
|
data*: BeaconState
|
||||||
root*: Eth2Digest # hash_tree_root(data)
|
root*: Eth2Digest # hash_tree_root(data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblock
|
||||||
BeaconBlock* = object
|
BeaconBlock* = object
|
||||||
## For each slot, a proposer is chosen from the validator pool to propose
|
## For each slot, a proposer is chosen from the validator pool to propose
|
||||||
## a new block. Once the block as been proposed, it is transmitted to
|
## a new block. Once the block as been proposed, it is transmitted to
|
||||||
@ -167,7 +167,7 @@ type
|
|||||||
state_root*: Eth2Digest
|
state_root*: Eth2Digest
|
||||||
body*: TrustedBeaconBlockBody
|
body*: TrustedBeaconBlockBody
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beaconblockbody
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beaconblockbody
|
||||||
BeaconBlockBody* = object
|
BeaconBlockBody* = object
|
||||||
randao_reveal*: ValidatorSig
|
randao_reveal*: ValidatorSig
|
||||||
eth1_data*: Eth1Data
|
eth1_data*: Eth1Data
|
||||||
@ -219,7 +219,7 @@ type
|
|||||||
deposits*: List[Deposit, Limit MAX_DEPOSITS]
|
deposits*: List[Deposit, Limit MAX_DEPOSITS]
|
||||||
voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]
|
voluntary_exits*: List[TrustedSignedVoluntaryExit, Limit MAX_VOLUNTARY_EXITS]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#signedbeaconblock
|
||||||
SignedBeaconBlock* = object
|
SignedBeaconBlock* = object
|
||||||
message*: BeaconBlock
|
message*: BeaconBlock
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
# Consensus hash function / digest
|
# Consensus hash function / digest
|
||||||
#
|
#
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#hash
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#hash
|
||||||
#
|
#
|
||||||
# In Phase 0 the beacon chain is deployed with SHA256 (SHA2-256).
|
# In Phase 0 the beacon chain is deployed with SHA256 (SHA2-256).
|
||||||
# Note that is is different from Keccak256 (often mistakenly called SHA3-256)
|
# Note that is is different from Keccak256 (often mistakenly called SHA3-256)
|
||||||
|
@ -321,7 +321,7 @@ type
|
|||||||
of ConsensusFork.Deneb: denebBody*: deneb.BeaconBlockBody
|
of ConsensusFork.Deneb: denebBody*: deneb.BeaconBlockBody
|
||||||
|
|
||||||
RestSpec* = object
|
RestSpec* = object
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/phase0.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/phase0.yaml
|
||||||
MAX_COMMITTEES_PER_SLOT*: uint64
|
MAX_COMMITTEES_PER_SLOT*: uint64
|
||||||
TARGET_COMMITTEE_SIZE*: uint64
|
TARGET_COMMITTEE_SIZE*: uint64
|
||||||
MAX_VALIDATORS_PER_COMMITTEE*: uint64
|
MAX_VALIDATORS_PER_COMMITTEE*: uint64
|
||||||
@ -355,7 +355,7 @@ type
|
|||||||
MAX_DEPOSITS*: uint64
|
MAX_DEPOSITS*: uint64
|
||||||
MAX_VOLUNTARY_EXITS*: uint64
|
MAX_VOLUNTARY_EXITS*: uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/altair.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/altair.yaml
|
||||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64
|
INACTIVITY_PENALTY_QUOTIENT_ALTAIR*: uint64
|
||||||
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64
|
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR*: uint64
|
||||||
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64
|
PROPORTIONAL_SLASHING_MULTIPLIER_ALTAIR*: uint64
|
||||||
@ -364,7 +364,7 @@ type
|
|||||||
MIN_SYNC_COMMITTEE_PARTICIPANTS*: uint64
|
MIN_SYNC_COMMITTEE_PARTICIPANTS*: uint64
|
||||||
UPDATE_TIMEOUT*: uint64
|
UPDATE_TIMEOUT*: uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/bellatrix.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/bellatrix.yaml
|
||||||
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64
|
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX*: uint64
|
||||||
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64
|
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX*: uint64
|
||||||
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64
|
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX*: uint64
|
||||||
@ -373,7 +373,7 @@ type
|
|||||||
BYTES_PER_LOGS_BLOOM*: uint64
|
BYTES_PER_LOGS_BLOOM*: uint64
|
||||||
MAX_EXTRA_DATA_BYTES*: uint64
|
MAX_EXTRA_DATA_BYTES*: uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/capella.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/capella.yaml
|
||||||
MAX_BLS_TO_EXECUTION_CHANGES*: uint64
|
MAX_BLS_TO_EXECUTION_CHANGES*: uint64
|
||||||
MAX_WITHDRAWALS_PER_PAYLOAD*: uint64
|
MAX_WITHDRAWALS_PER_PAYLOAD*: uint64
|
||||||
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP*: uint64
|
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP*: uint64
|
||||||
@ -411,7 +411,7 @@ type
|
|||||||
DEPOSIT_NETWORK_ID*: uint64
|
DEPOSIT_NETWORK_ID*: uint64
|
||||||
DEPOSIT_CONTRACT_ADDRESS*: Eth1Address
|
DEPOSIT_CONTRACT_ADDRESS*: Eth1Address
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#constants
|
||||||
# GENESIS_SLOT
|
# GENESIS_SLOT
|
||||||
# GENESIS_EPOCH
|
# GENESIS_EPOCH
|
||||||
# FAR_FUTURE_EPOCH
|
# FAR_FUTURE_EPOCH
|
||||||
@ -453,7 +453,7 @@ type
|
|||||||
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION*: uint64
|
EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION*: uint64
|
||||||
ATTESTATION_SUBNET_COUNT*: uint64
|
ATTESTATION_SUBNET_COUNT*: uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#constants
|
||||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE*: uint64
|
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE*: uint64
|
||||||
SYNC_COMMITTEE_SUBNET_COUNT*: uint64
|
SYNC_COMMITTEE_SUBNET_COUNT*: uint64
|
||||||
|
|
||||||
|
@ -1004,7 +1004,7 @@ func readSszForkedSignedBeaconBlock*(
|
|||||||
withBlck(result):
|
withBlck(result):
|
||||||
readSszBytes(data, blck)
|
readSszBytes(data, blck)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_fork_data_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_fork_data_root
|
||||||
func compute_fork_data_root*(current_version: Version,
|
func compute_fork_data_root*(current_version: Version,
|
||||||
genesis_validators_root: Eth2Digest): Eth2Digest =
|
genesis_validators_root: Eth2Digest): Eth2Digest =
|
||||||
## Return the 32-byte fork data root for the ``current_version`` and
|
## Return the 32-byte fork data root for the ``current_version`` and
|
||||||
@ -1016,7 +1016,7 @@ func compute_fork_data_root*(current_version: Version,
|
|||||||
genesis_validators_root: genesis_validators_root
|
genesis_validators_root: genesis_validators_root
|
||||||
))
|
))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_fork_digest
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_fork_digest
|
||||||
func compute_fork_digest*(current_version: Version,
|
func compute_fork_digest*(current_version: Version,
|
||||||
genesis_validators_root: Eth2Digest): ForkDigest =
|
genesis_validators_root: Eth2Digest): ForkDigest =
|
||||||
## Return the 4-byte fork digest for the ``current_version`` and
|
## Return the 4-byte fork digest for the ``current_version`` and
|
||||||
|
@ -816,7 +816,7 @@ func migratingToDataFork*[
|
|||||||
upgradedObject.migrateToDataFork(newKind)
|
upgradedObject.migrateToDataFork(newKind)
|
||||||
upgradedObject
|
upgradedObject
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/full-node.md#block_to_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/full-node.md#block_to_light_client_header
|
||||||
func toAltairLightClientHeader(
|
func toAltairLightClientHeader(
|
||||||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
||||||
phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock |
|
phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock |
|
||||||
@ -826,7 +826,7 @@ func toAltairLightClientHeader(
|
|||||||
altair.LightClientHeader(
|
altair.LightClientHeader(
|
||||||
beacon: blck.message.toBeaconBlockHeader())
|
beacon: blck.message.toBeaconBlockHeader())
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/light-client/full-node.md#modified-block_to_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/capella/light-client/full-node.md#modified-block_to_light_client_header
|
||||||
func toCapellaLightClientHeader(
|
func toCapellaLightClientHeader(
|
||||||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
||||||
phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock |
|
phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock |
|
||||||
@ -868,7 +868,7 @@ func toCapellaLightClientHeader(
|
|||||||
execution_branch: blck.message.body.build_proof(
|
execution_branch: blck.message.body.build_proof(
|
||||||
capella.EXECUTION_PAYLOAD_INDEX).get)
|
capella.EXECUTION_PAYLOAD_INDEX).get)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/light-client/full-node.md#modified-block_to_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/deneb/light-client/full-node.md#modified-block_to_light_client_header
|
||||||
func toDenebLightClientHeader(
|
func toDenebLightClientHeader(
|
||||||
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
blck: # `SomeSignedBeaconBlock` doesn't work here (Nim 1.6)
|
||||||
phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock |
|
phase0.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock |
|
||||||
|
@ -27,7 +27,7 @@ export
|
|||||||
eth2_merkleization, forks, rlp, ssz_codec
|
eth2_merkleization, forks, rlp, ssz_codec
|
||||||
|
|
||||||
func toEther*(gwei: Gwei): Ether =
|
func toEther*(gwei: Gwei): Ether =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/weak-subjectivity.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/weak-subjectivity.md#constants
|
||||||
const ETH_TO_GWEI = 1_000_000_000
|
const ETH_TO_GWEI = 1_000_000_000
|
||||||
(gwei div ETH_TO_GWEI).Ether
|
(gwei div ETH_TO_GWEI).Ether
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ func shortLog*(v: FinalityCheckpoints): auto =
|
|||||||
|
|
||||||
chronicles.formatIt FinalityCheckpoints: it.shortLog
|
chronicles.formatIt FinalityCheckpoints: it.shortLog
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#integer_squareroot
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#integer_squareroot
|
||||||
func integer_squareroot*(n: SomeInteger): SomeInteger =
|
func integer_squareroot*(n: SomeInteger): SomeInteger =
|
||||||
## Return the largest integer ``x`` such that ``x**2 <= n``.
|
## Return the largest integer ``x`` such that ``x**2 <= n``.
|
||||||
doAssert n >= 0'u64
|
doAssert n >= 0'u64
|
||||||
@ -60,7 +60,7 @@ func integer_squareroot*(n: SomeInteger): SomeInteger =
|
|||||||
y = (x + n div x) div 2
|
y = (x + n div x) div 2
|
||||||
x
|
x
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_active_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_active_validator
|
||||||
func is_active_validator*(validator: Validator, epoch: Epoch): bool =
|
func is_active_validator*(validator: Validator, epoch: Epoch): bool =
|
||||||
## Check if ``validator`` is active.
|
## Check if ``validator`` is active.
|
||||||
validator.activation_epoch <= epoch and epoch < validator.exit_epoch
|
validator.activation_epoch <= epoch and epoch < validator.exit_epoch
|
||||||
@ -72,7 +72,7 @@ func is_exited_validator*(validator: Validator, epoch: Epoch): bool =
|
|||||||
func is_withdrawable_validator*(validator: Validator, epoch: Epoch): bool =
|
func is_withdrawable_validator*(validator: Validator, epoch: Epoch): bool =
|
||||||
epoch >= validator.withdrawable_epoch
|
epoch >= validator.withdrawable_epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_active_validator_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_active_validator_indices
|
||||||
iterator get_active_validator_indices*(state: ForkyBeaconState, epoch: Epoch):
|
iterator get_active_validator_indices*(state: ForkyBeaconState, epoch: Epoch):
|
||||||
ValidatorIndex =
|
ValidatorIndex =
|
||||||
for vidx in state.validators.vindices:
|
for vidx in state.validators.vindices:
|
||||||
@ -98,23 +98,23 @@ func get_active_validator_indices_len*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
get_active_validator_indices_len(forkyState.data, epoch)
|
get_active_validator_indices_len(forkyState.data, epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_current_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_current_epoch
|
||||||
func get_current_epoch*(state: ForkyBeaconState): Epoch =
|
func get_current_epoch*(state: ForkyBeaconState): Epoch =
|
||||||
## Return the current epoch.
|
## Return the current epoch.
|
||||||
state.slot.epoch
|
state.slot.epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_current_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_current_epoch
|
||||||
func get_current_epoch*(state: ForkedHashedBeaconState): Epoch =
|
func get_current_epoch*(state: ForkedHashedBeaconState): Epoch =
|
||||||
## Return the current epoch.
|
## Return the current epoch.
|
||||||
withState(state): get_current_epoch(forkyState.data)
|
withState(state): get_current_epoch(forkyState.data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_previous_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_previous_epoch
|
||||||
func get_previous_epoch*(
|
func get_previous_epoch*(
|
||||||
state: ForkyBeaconState | ForkedHashedBeaconState): Epoch =
|
state: ForkyBeaconState | ForkedHashedBeaconState): Epoch =
|
||||||
## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
||||||
get_previous_epoch(get_current_epoch(state))
|
get_previous_epoch(get_current_epoch(state))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_randao_mix
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_randao_mix
|
||||||
func get_randao_mix*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest =
|
func get_randao_mix*(state: ForkyBeaconState, epoch: Epoch): Eth2Digest =
|
||||||
## Return the randao mix at a recent ``epoch``.
|
## Return the randao mix at a recent ``epoch``.
|
||||||
state.randao_mixes[epoch mod EPOCHS_PER_HISTORICAL_VECTOR]
|
state.randao_mixes[epoch mod EPOCHS_PER_HISTORICAL_VECTOR]
|
||||||
@ -136,7 +136,7 @@ func uint_to_bytes*(x: uint32): array[4, byte] = toBytesLE(x)
|
|||||||
func uint_to_bytes*(x: uint16): array[2, byte] = toBytesLE(x)
|
func uint_to_bytes*(x: uint16): array[2, byte] = toBytesLE(x)
|
||||||
func uint_to_bytes*(x: uint8): array[1, byte] = toBytesLE(x)
|
func uint_to_bytes*(x: uint8): array[1, byte] = toBytesLE(x)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_domain
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_domain
|
||||||
func compute_domain*(
|
func compute_domain*(
|
||||||
domain_type: DomainType,
|
domain_type: DomainType,
|
||||||
fork_version: Version,
|
fork_version: Version,
|
||||||
@ -150,7 +150,7 @@ func compute_domain*(
|
|||||||
result[0..3] = domain_type.data
|
result[0..3] = domain_type.data
|
||||||
result[4..31] = fork_data_root.data.toOpenArray(0, 27)
|
result[4..31] = fork_data_root.data.toOpenArray(0, 27)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_domain
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_domain
|
||||||
func get_domain*(
|
func get_domain*(
|
||||||
fork: Fork,
|
fork: Fork,
|
||||||
domain_type: DomainType,
|
domain_type: DomainType,
|
||||||
@ -171,7 +171,7 @@ func get_domain*(
|
|||||||
## of a message.
|
## of a message.
|
||||||
get_domain(state.fork, domain_type, epoch, state.genesis_validators_root)
|
get_domain(state.fork, domain_type, epoch, state.genesis_validators_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_signing_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_signing_root
|
||||||
func compute_signing_root*(ssz_object: auto, domain: Eth2Domain): Eth2Digest =
|
func compute_signing_root*(ssz_object: auto, domain: Eth2Domain): Eth2Digest =
|
||||||
## Return the signing root for the corresponding signing data.
|
## Return the signing root for the corresponding signing data.
|
||||||
let domain_wrapped_object = SigningData(
|
let domain_wrapped_object = SigningData(
|
||||||
@ -180,7 +180,7 @@ func compute_signing_root*(ssz_object: auto, domain: Eth2Domain): Eth2Digest =
|
|||||||
)
|
)
|
||||||
hash_tree_root(domain_wrapped_object)
|
hash_tree_root(domain_wrapped_object)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_seed
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_seed
|
||||||
func get_seed*(
|
func get_seed*(
|
||||||
state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType,
|
state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType,
|
||||||
mix: Eth2Digest): Eth2Digest =
|
mix: Eth2Digest): Eth2Digest =
|
||||||
@ -209,7 +209,7 @@ func has_flag*(flags: ParticipationFlags, flag_index: int): bool =
|
|||||||
let flag = ParticipationFlags(1'u8 shl flag_index)
|
let flag = ParticipationFlags(1'u8 shl flag_index)
|
||||||
(flags and flag) == flag
|
(flags and flag) == flag
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#is_sync_committee_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#is_sync_committee_update
|
||||||
template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool =
|
template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool =
|
||||||
when update is SomeForkyLightClientUpdateWithSyncCommittee:
|
when update is SomeForkyLightClientUpdateWithSyncCommittee:
|
||||||
update.next_sync_committee_branch !=
|
update.next_sync_committee_branch !=
|
||||||
@ -217,25 +217,25 @@ template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool =
|
|||||||
else:
|
else:
|
||||||
false
|
false
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#is_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#is_finality_update
|
||||||
template is_finality_update*(update: SomeForkyLightClientUpdate): bool =
|
template is_finality_update*(update: SomeForkyLightClientUpdate): bool =
|
||||||
when update is SomeForkyLightClientUpdateWithFinality:
|
when update is SomeForkyLightClientUpdateWithFinality:
|
||||||
update.finality_branch != default(typeof(update.finality_branch))
|
update.finality_branch != default(typeof(update.finality_branch))
|
||||||
else:
|
else:
|
||||||
false
|
false
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
|
||||||
template is_next_sync_committee_known*(store: ForkyLightClientStore): bool =
|
template is_next_sync_committee_known*(store: ForkyLightClientStore): bool =
|
||||||
store.next_sync_committee != default(typeof(store.next_sync_committee))
|
store.next_sync_committee != default(typeof(store.next_sync_committee))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#get_safety_threshold
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#get_safety_threshold
|
||||||
func get_safety_threshold*(store: ForkyLightClientStore): uint64 =
|
func get_safety_threshold*(store: ForkyLightClientStore): uint64 =
|
||||||
max(
|
max(
|
||||||
store.previous_max_active_participants,
|
store.previous_max_active_participants,
|
||||||
store.current_max_active_participants
|
store.current_max_active_participants
|
||||||
) div 2
|
) div 2
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#is_better_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#is_better_update
|
||||||
type LightClientUpdateMetadata* = object
|
type LightClientUpdateMetadata* = object
|
||||||
attested_slot*, finalized_slot*, signature_slot*: Slot
|
attested_slot*, finalized_slot*, signature_slot*: Slot
|
||||||
has_sync_committee*, has_finality*: bool
|
has_sync_committee*, has_finality*: bool
|
||||||
@ -326,13 +326,13 @@ template is_better_update*[
|
|||||||
new_update: A, old_update: B): bool =
|
new_update: A, old_update: B): bool =
|
||||||
is_better_data(toMeta(new_update), toMeta(old_update))
|
is_better_data(toMeta(new_update), toMeta(old_update))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
||||||
func contextEpoch*(bootstrap: ForkyLightClientBootstrap): Epoch =
|
func contextEpoch*(bootstrap: ForkyLightClientBootstrap): Epoch =
|
||||||
bootstrap.header.beacon.slot.epoch
|
bootstrap.header.beacon.slot.epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
||||||
func contextEpoch*(update: SomeForkyLightClientUpdate): Epoch =
|
func contextEpoch*(update: SomeForkyLightClientUpdate): Epoch =
|
||||||
update.attested_header.beacon.slot.epoch
|
update.attested_header.beacon.slot.epoch
|
||||||
|
|
||||||
|
@ -1273,7 +1273,7 @@ func makeWithdrawalCredentials*(k: ValidatorPubKey): Eth2Digest =
|
|||||||
bytes.data[0] = BLS_WITHDRAWAL_PREFIX.uint8
|
bytes.data[0] = BLS_WITHDRAWAL_PREFIX.uint8
|
||||||
bytes
|
bytes
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/deposit-contract.md#withdrawal-credentials
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/deposit-contract.md#withdrawal-credentials
|
||||||
proc makeWithdrawalCredentials*(k: CookedPubKey): Eth2Digest =
|
proc makeWithdrawalCredentials*(k: CookedPubKey): Eth2Digest =
|
||||||
makeWithdrawalCredentials(k.toPubKey())
|
makeWithdrawalCredentials(k.toPubKey())
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import
|
|||||||
from ../consensus_object_pools/block_pools_types import VerifierError
|
from ../consensus_object_pools/block_pools_types import VerifierError
|
||||||
export block_pools_types.VerifierError
|
export block_pools_types.VerifierError
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#initialize_light_client_store
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#initialize_light_client_store
|
||||||
func initialize_light_client_store*(
|
func initialize_light_client_store*(
|
||||||
trusted_block_root: Eth2Digest,
|
trusted_block_root: Eth2Digest,
|
||||||
bootstrap: ForkyLightClientBootstrap,
|
bootstrap: ForkyLightClientBootstrap,
|
||||||
@ -42,7 +42,7 @@ func initialize_light_client_store*(
|
|||||||
current_sync_committee: bootstrap.current_sync_committee,
|
current_sync_committee: bootstrap.current_sync_committee,
|
||||||
optimistic_header: bootstrap.header))
|
optimistic_header: bootstrap.header))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#validate_light_client_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#validate_light_client_update
|
||||||
proc validate_light_client_update*(
|
proc validate_light_client_update*(
|
||||||
store: ForkyLightClientStore,
|
store: ForkyLightClientStore,
|
||||||
update: SomeForkyLightClientUpdate,
|
update: SomeForkyLightClientUpdate,
|
||||||
@ -159,7 +159,7 @@ proc validate_light_client_update*(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#apply_light_client_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#apply_light_client_update
|
||||||
func apply_light_client_update(
|
func apply_light_client_update(
|
||||||
store: var ForkyLightClientStore,
|
store: var ForkyLightClientStore,
|
||||||
update: SomeForkyLightClientUpdate): bool =
|
update: SomeForkyLightClientUpdate): bool =
|
||||||
@ -190,7 +190,7 @@ func apply_light_client_update(
|
|||||||
didProgress = true
|
didProgress = true
|
||||||
didProgress
|
didProgress
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#process_light_client_store_force_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#process_light_client_store_force_update
|
||||||
type
|
type
|
||||||
ForceUpdateResult* = enum
|
ForceUpdateResult* = enum
|
||||||
NoUpdate,
|
NoUpdate,
|
||||||
@ -223,7 +223,7 @@ func process_light_client_store_force_update*(
|
|||||||
store.best_valid_update.reset()
|
store.best_valid_update.reset()
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#process_light_client_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#process_light_client_update
|
||||||
proc process_light_client_update*(
|
proc process_light_client_update*(
|
||||||
store: var ForkyLightClientStore,
|
store: var ForkyLightClientStore,
|
||||||
update: SomeForkyLightClientUpdate,
|
update: SomeForkyLightClientUpdate,
|
||||||
|
@ -27,7 +27,7 @@ const
|
|||||||
MAX_REQUEST_BLOCKS* = 1024
|
MAX_REQUEST_BLOCKS* = 1024
|
||||||
RESP_TIMEOUT* = 10.seconds
|
RESP_TIMEOUT* = 10.seconds
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#configuration
|
||||||
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
|
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/p2p-interface.md#configuration
|
||||||
@ -110,12 +110,12 @@ func getBlobSidecarTopic*(forkDigest: ForkDigest,
|
|||||||
index: BlobIndex): string =
|
index: BlobIndex): string =
|
||||||
eth2Prefix(forkDigest) & "blob_sidecar_" & $index & "/ssz_snappy"
|
eth2Prefix(forkDigest) & "blob_sidecar_" & $index & "/ssz_snappy"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#light_client_finality_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#light_client_finality_update
|
||||||
func getLightClientFinalityUpdateTopic*(forkDigest: ForkDigest): string =
|
func getLightClientFinalityUpdateTopic*(forkDigest: ForkDigest): string =
|
||||||
## For broadcasting or obtaining the latest `LightClientFinalityUpdate`.
|
## For broadcasting or obtaining the latest `LightClientFinalityUpdate`.
|
||||||
eth2Prefix(forkDigest) & "light_client_finality_update/ssz_snappy"
|
eth2Prefix(forkDigest) & "light_client_finality_update/ssz_snappy"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update
|
||||||
func getLightClientOptimisticUpdateTopic*(forkDigest: ForkDigest): string =
|
func getLightClientOptimisticUpdateTopic*(forkDigest: ForkDigest): string =
|
||||||
## For broadcasting or obtaining the latest `LightClientOptimisticUpdate`.
|
## For broadcasting or obtaining the latest `LightClientOptimisticUpdate`.
|
||||||
eth2Prefix(forkDigest) & "light_client_optimistic_update/ssz_snappy"
|
eth2Prefix(forkDigest) & "light_client_optimistic_update/ssz_snappy"
|
||||||
@ -194,7 +194,7 @@ func getTargetGossipState*(
|
|||||||
targetForks
|
targetForks
|
||||||
|
|
||||||
func nearSyncCommitteePeriod*(epoch: Epoch): Opt[uint64] =
|
func nearSyncCommitteePeriod*(epoch: Epoch): Opt[uint64] =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#sync-committee-subnet-stability
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||||
if epoch.is_sync_committee_period():
|
if epoch.is_sync_committee_period():
|
||||||
return Opt.some 0'u64
|
return Opt.some 0'u64
|
||||||
let epochsBefore =
|
let epochsBefore =
|
||||||
@ -213,7 +213,7 @@ func getSyncSubnets*(
|
|||||||
if not nodeHasPubkey(pubkey):
|
if not nodeHasPubkey(pubkey):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#broadcast-sync-committee-message
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#broadcast-sync-committee-message
|
||||||
# The first quarter of the pubkeys map to subnet 0, the second quarter to
|
# The first quarter of the pubkeys map to subnet 0, the second quarter to
|
||||||
# subnet 1, the third quarter to subnet 2 and the final quarter to subnet
|
# subnet 1, the third quarter to subnet 2 and the final quarter to subnet
|
||||||
# 3.
|
# 3.
|
||||||
|
@ -17,7 +17,7 @@ export constants
|
|||||||
export stint, ethtypes.toHex, ethtypes.`==`
|
export stint, ethtypes.toHex, ethtypes.`==`
|
||||||
|
|
||||||
const
|
const
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#withdrawal-prefixes
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#withdrawal-prefixes
|
||||||
BLS_WITHDRAWAL_PREFIX*: byte = 0
|
BLS_WITHDRAWAL_PREFIX*: byte = 0
|
||||||
ETH1_ADDRESS_WITHDRAWAL_PREFIX*: byte = 1
|
ETH1_ADDRESS_WITHDRAWAL_PREFIX*: byte = 1
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Mainnet preset - Altair
|
# Mainnet preset - Altair
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/altair.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/altair.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Gnosis preset - Bellatrix
|
# Gnosis preset - Bellatrix
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/bellatrix.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/bellatrix.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Gnosis preset - Phase0
|
# Gnosis preset - Phase0
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/phase0.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/phase0.yaml
|
||||||
|
|
||||||
const
|
const
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Mainnet preset - Altair
|
# Mainnet preset - Altair
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/altair.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/altair.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Mainnet preset - Bellatrix
|
# Mainnet preset - Bellatrix
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/bellatrix.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/bellatrix.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Mainnet preset - Capella
|
# Mainnet preset - Capella
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/capella.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/capella.yaml
|
||||||
const
|
const
|
||||||
# Max operations per block
|
# Max operations per block
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Mainnet preset - Phase0
|
# Mainnet preset - Phase0
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/mainnet/phase0.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/mainnet/phase0.yaml
|
||||||
|
|
||||||
const
|
const
|
||||||
#
|
#
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2021-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Minimal preset - Altair
|
# Minimal preset - Altair
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/minimal/altair.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/minimal/altair.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Minimal preset - Bellatrix
|
# Minimal preset - Bellatrix
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/minimal/bellatrix.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/minimal/bellatrix.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
|
# beacon_chain
|
||||||
|
# Copyright (c) 2022-2023 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Minimal preset - Capella
|
# Minimal preset - Capella
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/minimal/capella.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/minimal/capella.yaml
|
||||||
const
|
const
|
||||||
# Max operations per block
|
# Max operations per block
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# Minimal preset - Phase0
|
# Minimal preset - Phase0
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/presets/minimal/phase0.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/presets/minimal/phase0.yaml
|
||||||
|
|
||||||
const
|
const
|
||||||
#
|
#
|
||||||
|
@ -194,7 +194,7 @@ func compute_deposit_signing_root(
|
|||||||
domain = compute_domain(DOMAIN_DEPOSIT, version)
|
domain = compute_domain(DOMAIN_DEPOSIT, version)
|
||||||
compute_signing_root(deposit_message, domain)
|
compute_signing_root(deposit_message, domain)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#deposits
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#deposits
|
||||||
func get_deposit_signature*(preset: RuntimeConfig,
|
func get_deposit_signature*(preset: RuntimeConfig,
|
||||||
deposit: DepositData,
|
deposit: DepositData,
|
||||||
privkey: ValidatorPrivKey): CookedSig =
|
privkey: ValidatorPrivKey): CookedSig =
|
||||||
@ -256,7 +256,7 @@ proc verify_voluntary_exit_signature*(
|
|||||||
|
|
||||||
blsVerify(pubkey, signing_root.data, signature)
|
blsVerify(pubkey, signing_root.data, signature)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#prepare-sync-committee-message
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||||
func compute_sync_committee_message_signing_root*(
|
func compute_sync_committee_message_signing_root*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
slot: Slot, beacon_block_root: Eth2Digest): Eth2Digest =
|
slot: Slot, beacon_block_root: Eth2Digest): Eth2Digest =
|
||||||
@ -291,7 +291,7 @@ proc verify_sync_committee_signature*(
|
|||||||
|
|
||||||
blsFastAggregateVerify(pubkeys, signing_root.data, signature)
|
blsFastAggregateVerify(pubkeys, signing_root.data, signature)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#aggregation-selection
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#aggregation-selection
|
||||||
func compute_sync_committee_selection_proof_signing_root*(
|
func compute_sync_committee_selection_proof_signing_root*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
slot: Slot, subcommittee_index: SyncSubcommitteeIndex): Eth2Digest =
|
slot: Slot, subcommittee_index: SyncSubcommitteeIndex): Eth2Digest =
|
||||||
@ -322,7 +322,7 @@ proc verify_sync_committee_selection_proof*(
|
|||||||
|
|
||||||
blsVerify(pubkey, signing_root.data, signature)
|
blsVerify(pubkey, signing_root.data, signature)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#signature
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#signature
|
||||||
func compute_contribution_and_proof_signing_root*(
|
func compute_contribution_and_proof_signing_root*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
msg: ContributionAndProof): Eth2Digest =
|
msg: ContributionAndProof): Eth2Digest =
|
||||||
@ -340,7 +340,7 @@ proc get_contribution_and_proof_signature*(
|
|||||||
|
|
||||||
blsSign(privkey, signing_root.data)
|
blsSign(privkey, signing_root.data)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#aggregation-selection
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#aggregation-selection
|
||||||
func is_sync_committee_aggregator*(signature: ValidatorSig): bool =
|
func is_sync_committee_aggregator*(signature: ValidatorSig): bool =
|
||||||
let
|
let
|
||||||
signatureDigest = eth2digest(signature.blob)
|
signatureDigest = eth2digest(signature.blob)
|
||||||
|
@ -65,7 +65,7 @@ func aggregateAttesters(
|
|||||||
# Aggregation spec requires non-empty collection
|
# Aggregation spec requires non-empty collection
|
||||||
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04
|
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04
|
||||||
# Consensus specs require at least one attesting index in attestation
|
# Consensus specs require at least one attesting index in attestation
|
||||||
# - https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
||||||
return err("aggregateAttesters: no attesting indices")
|
return err("aggregateAttesters: no attesting indices")
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -91,7 +91,7 @@ func aggregateAttesters(
|
|||||||
# Aggregation spec requires non-empty collection
|
# Aggregation spec requires non-empty collection
|
||||||
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04
|
# - https://tools.ietf.org/html/draft-irtf-cfrg-bls-signature-04
|
||||||
# Consensus specs require at least one attesting index in attestation
|
# Consensus specs require at least one attesting index in attestation
|
||||||
# - https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
|
||||||
return err("aggregateAttesters: no attesting indices")
|
return err("aggregateAttesters: no attesting indices")
|
||||||
|
|
||||||
var attestersAgg{.noinit.}: AggregatePublicKey
|
var attestersAgg{.noinit.}: AggregatePublicKey
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# State transition, as described in
|
# State transition, as described in
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
#
|
#
|
||||||
# The entry point is `state_transition` which is at the bottom of the file!
|
# The entry point is `state_transition` which is at the bottom of the file!
|
||||||
#
|
#
|
||||||
@ -51,7 +51,7 @@ import
|
|||||||
|
|
||||||
export results, extras, phase0, altair, bellatrix
|
export results, extras, phase0, altair, bellatrix
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc verify_block_signature(
|
proc verify_block_signature(
|
||||||
state: ForkyBeaconState, signed_block: SomeForkySignedBeaconBlock):
|
state: ForkyBeaconState, signed_block: SomeForkySignedBeaconBlock):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
@ -68,7 +68,7 @@ proc verify_block_signature(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
func verifyStateRoot(
|
func verifyStateRoot(
|
||||||
state: ForkyBeaconState,
|
state: ForkyBeaconState,
|
||||||
blck: ForkyBeaconBlock | ForkySigVerifiedBeaconBlock):
|
blck: ForkyBeaconBlock | ForkySigVerifiedBeaconBlock):
|
||||||
@ -98,7 +98,7 @@ func noRollback*() =
|
|||||||
# Hashed-state transition functions
|
# Hashed-state transition functions
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
func process_slot*(
|
func process_slot*(
|
||||||
state: var ForkyBeaconState, pre_state_root: Eth2Digest) =
|
state: var ForkyBeaconState, pre_state_root: Eth2Digest) =
|
||||||
# `process_slot` is the first stage of per-slot processing - it is run for
|
# `process_slot` is the first stage of per-slot processing - it is run for
|
||||||
@ -124,7 +124,7 @@ func clear_epoch_from_cache(cache: var StateCache, epoch: Epoch) =
|
|||||||
for slot in epoch.slots():
|
for slot in epoch.slots():
|
||||||
cache.beacon_proposer_indices.del slot
|
cache.beacon_proposer_indices.del slot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc advance_slot(
|
proc advance_slot(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var ForkyBeaconState, previous_slot_state_root: Eth2Digest,
|
state: var ForkyBeaconState, previous_slot_state_root: Eth2Digest,
|
||||||
@ -361,7 +361,7 @@ template partialBeaconBlock*(
|
|||||||
deposits: List[Deposit, Limit MAX_DEPOSITS](deposits),
|
deposits: List[Deposit, Limit MAX_DEPOSITS](deposits),
|
||||||
voluntary_exits: validator_changes.voluntary_exits))
|
voluntary_exits: validator_changes.voluntary_exits))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#preparing-a-beaconblock
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#preparing-a-beaconblock
|
||||||
template partialBeaconBlock*(
|
template partialBeaconBlock*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var altair.HashedBeaconState,
|
state: var altair.HashedBeaconState,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# State transition - block processing, as described in
|
# State transition - block processing, as described in
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#block-processing
|
||||||
@ -38,7 +38,7 @@ from ./datatypes/capella import
|
|||||||
|
|
||||||
export extras, phase0, altair
|
export extras, phase0, altair
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#block-header
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#block-header
|
||||||
func process_block_header*(
|
func process_block_header*(
|
||||||
state: var ForkyBeaconState, blck: SomeForkyBeaconBlock,
|
state: var ForkyBeaconState, blck: SomeForkyBeaconBlock,
|
||||||
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
||||||
@ -80,7 +80,7 @@ func `xor`[T: array](a, b: T): T =
|
|||||||
for i in 0..<result.len:
|
for i in 0..<result.len:
|
||||||
result[i] = a[i] xor b[i]
|
result[i] = a[i] xor b[i]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#randao
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#randao
|
||||||
proc process_randao(
|
proc process_randao(
|
||||||
state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody,
|
state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody,
|
||||||
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
||||||
@ -113,7 +113,7 @@ proc process_randao(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#eth1-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#eth1-data
|
||||||
func process_eth1_data(
|
func process_eth1_data(
|
||||||
state: var ForkyBeaconState,
|
state: var ForkyBeaconState,
|
||||||
body: SomeForkyBeaconBlockBody): Result[void, cstring] =
|
body: SomeForkyBeaconBlockBody): Result[void, cstring] =
|
||||||
@ -126,14 +126,14 @@ func process_eth1_data(
|
|||||||
state.eth1_data = body.eth1_data
|
state.eth1_data = body.eth1_data
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_slashable_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_slashable_validator
|
||||||
func is_slashable_validator(validator: Validator, epoch: Epoch): bool =
|
func is_slashable_validator(validator: Validator, epoch: Epoch): bool =
|
||||||
# Check if ``validator`` is slashable.
|
# Check if ``validator`` is slashable.
|
||||||
(not validator.slashed) and
|
(not validator.slashed) and
|
||||||
(validator.activation_epoch <= epoch) and
|
(validator.activation_epoch <= epoch) and
|
||||||
(epoch < validator.withdrawable_epoch)
|
(epoch < validator.withdrawable_epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#proposer-slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#proposer-slashings
|
||||||
proc check_proposer_slashing*(
|
proc check_proposer_slashing*(
|
||||||
state: ForkyBeaconState, proposer_slashing: SomeProposerSlashing,
|
state: ForkyBeaconState, proposer_slashing: SomeProposerSlashing,
|
||||||
flags: UpdateFlags):
|
flags: UpdateFlags):
|
||||||
@ -182,7 +182,7 @@ proc check_proposer_slashing*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
check_proposer_slashing(forkyState.data, proposer_slashing, flags)
|
check_proposer_slashing(forkyState.data, proposer_slashing, flags)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#proposer-slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#proposer-slashings
|
||||||
proc process_proposer_slashing*(
|
proc process_proposer_slashing*(
|
||||||
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||||
proposer_slashing: SomeProposerSlashing, flags: UpdateFlags,
|
proposer_slashing: SomeProposerSlashing, flags: UpdateFlags,
|
||||||
@ -192,7 +192,7 @@ proc process_proposer_slashing*(
|
|||||||
? slash_validator(cfg, state, proposer_index, cache)
|
? slash_validator(cfg, state, proposer_index, cache)
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_slashable_attestation_data
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_slashable_attestation_data
|
||||||
func is_slashable_attestation_data(
|
func is_slashable_attestation_data(
|
||||||
data_1: AttestationData, data_2: AttestationData): bool =
|
data_1: AttestationData, data_2: AttestationData): bool =
|
||||||
## Check if ``data_1`` and ``data_2`` are slashable according to Casper FFG
|
## Check if ``data_1`` and ``data_2`` are slashable according to Casper FFG
|
||||||
@ -204,7 +204,7 @@ func is_slashable_attestation_data(
|
|||||||
(data_1.source.epoch < data_2.source.epoch and
|
(data_1.source.epoch < data_2.source.epoch and
|
||||||
data_2.target.epoch < data_1.target.epoch)
|
data_2.target.epoch < data_1.target.epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attester-slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attester-slashings
|
||||||
proc check_attester_slashing*(
|
proc check_attester_slashing*(
|
||||||
state: ForkyBeaconState,
|
state: ForkyBeaconState,
|
||||||
attester_slashing: SomeAttesterSlashing,
|
attester_slashing: SomeAttesterSlashing,
|
||||||
@ -246,7 +246,7 @@ proc check_attester_slashing*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
check_attester_slashing(forkyState.data, attester_slashing, flags)
|
check_attester_slashing(forkyState.data, attester_slashing, flags)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attester-slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attester-slashings
|
||||||
proc process_attester_slashing*(
|
proc process_attester_slashing*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var ForkyBeaconState,
|
state: var ForkyBeaconState,
|
||||||
@ -330,7 +330,7 @@ proc process_deposit*(cfg: RuntimeConfig,
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#voluntary-exits
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#voluntary-exits
|
||||||
proc check_voluntary_exit*(
|
proc check_voluntary_exit*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: ForkyBeaconState,
|
state: ForkyBeaconState,
|
||||||
@ -379,7 +379,7 @@ proc check_voluntary_exit*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
check_voluntary_exit(cfg, forkyState.data, signed_voluntary_exit, flags)
|
check_voluntary_exit(cfg, forkyState.data, signed_voluntary_exit, flags)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#voluntary-exits
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#voluntary-exits
|
||||||
proc process_voluntary_exit*(
|
proc process_voluntary_exit*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var ForkyBeaconState,
|
state: var ForkyBeaconState,
|
||||||
@ -409,7 +409,7 @@ proc process_bls_to_execution_change*(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#operations
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#operations
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#modified-process_operations
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#modified-process_operations
|
||||||
proc process_operations(cfg: RuntimeConfig,
|
proc process_operations(cfg: RuntimeConfig,
|
||||||
state: var ForkyBeaconState,
|
state: var ForkyBeaconState,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# State transition - epoch processing, as described in
|
# State transition - epoch processing, as described in
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#epoch-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#epoch-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#epoch-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#epoch-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#epoch-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#epoch-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#epoch-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#epoch-processing
|
||||||
@ -41,7 +41,7 @@ export extras, phase0, altair
|
|||||||
logScope: topics = "consens"
|
logScope: topics = "consens"
|
||||||
|
|
||||||
# Accessors that implement the max condition in `get_total_balance`:
|
# Accessors that implement the max condition in `get_total_balance`:
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_total_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_total_balance
|
||||||
template current_epoch*(v: TotalBalances): Gwei =
|
template current_epoch*(v: TotalBalances): Gwei =
|
||||||
max(EFFECTIVE_BALANCE_INCREMENT, v.current_epoch_raw)
|
max(EFFECTIVE_BALANCE_INCREMENT, v.current_epoch_raw)
|
||||||
template previous_epoch*(v: TotalBalances): Gwei =
|
template previous_epoch*(v: TotalBalances): Gwei =
|
||||||
@ -156,7 +156,7 @@ func process_attestations*(
|
|||||||
if v.flags.contains RewardFlags.isPreviousEpochHeadAttester:
|
if v.flags.contains RewardFlags.isPreviousEpochHeadAttester:
|
||||||
info.balances.previous_epoch_head_attesters_raw += validator_balance
|
info.balances.previous_epoch_head_attesters_raw += validator_balance
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#helpers
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#helpers
|
||||||
# get_eligible_validator_indices
|
# get_eligible_validator_indices
|
||||||
func is_eligible_validator*(validator: RewardStatus): bool =
|
func is_eligible_validator*(validator: RewardStatus): bool =
|
||||||
validator.flags.contains(RewardFlags.isActiveInPreviousEpoch) or
|
validator.flags.contains(RewardFlags.isActiveInPreviousEpoch) or
|
||||||
@ -243,7 +243,7 @@ func is_unslashed_participating_index(
|
|||||||
has_flag(epoch_participation[].item(validator_index), flag_index) and
|
has_flag(epoch_participation[].item(validator_index), flag_index) and
|
||||||
not state.validators[validator_index].slashed
|
not state.validators[validator_index].slashed
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#justification-and-finalization
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#justification-and-finalization
|
||||||
type FinalityState = object
|
type FinalityState = object
|
||||||
slot: Slot
|
slot: Slot
|
||||||
current_epoch_ancestor_root: Eth2Digest
|
current_epoch_ancestor_root: Eth2Digest
|
||||||
@ -311,7 +311,7 @@ proc weigh_justification_and_finalization(
|
|||||||
## state.justification_bits[1:] = state.justification_bits[:-1]
|
## state.justification_bits[1:] = state.justification_bits[:-1]
|
||||||
## state.justification_bits[0] = 0b0
|
## state.justification_bits[0] = 0b0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#misc
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#misc
|
||||||
const JUSTIFICATION_BITS_LENGTH = 4
|
const JUSTIFICATION_BITS_LENGTH = 4
|
||||||
|
|
||||||
state.justification_bits = JustificationBits(
|
state.justification_bits = JustificationBits(
|
||||||
@ -388,7 +388,7 @@ proc weigh_justification_and_finalization(
|
|||||||
current_epoch = current_epoch,
|
current_epoch = current_epoch,
|
||||||
checkpoint = shortLog(state.finalized_checkpoint)
|
checkpoint = shortLog(state.finalized_checkpoint)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#justification-and-finalization
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#justification-and-finalization
|
||||||
proc process_justification_and_finalization*(
|
proc process_justification_and_finalization*(
|
||||||
state: var phase0.BeaconState,
|
state: var phase0.BeaconState,
|
||||||
balances: TotalBalances, flags: UpdateFlags = {}) =
|
balances: TotalBalances, flags: UpdateFlags = {}) =
|
||||||
@ -460,7 +460,7 @@ proc compute_unrealized_finality*(
|
|||||||
justified: finalityState.current_justified_checkpoint,
|
justified: finalityState.current_justified_checkpoint,
|
||||||
finalized: finalityState.finalized_checkpoint)
|
finalized: finalityState.finalized_checkpoint)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#helpers
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#helpers
|
||||||
func get_base_reward_sqrt*(state: phase0.BeaconState, index: ValidatorIndex,
|
func get_base_reward_sqrt*(state: phase0.BeaconState, index: ValidatorIndex,
|
||||||
total_balance_sqrt: auto): Gwei =
|
total_balance_sqrt: auto): Gwei =
|
||||||
# Spec function recalculates total_balance every time, which creates an
|
# Spec function recalculates total_balance every time, which creates an
|
||||||
@ -508,7 +508,7 @@ func get_attestation_component_delta(is_unslashed_attester: bool,
|
|||||||
else:
|
else:
|
||||||
RewardDelta(penalties: base_reward)
|
RewardDelta(penalties: base_reward)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#components-of-attestation-deltas
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#components-of-attestation-deltas
|
||||||
func get_source_delta*(validator: RewardStatus,
|
func get_source_delta*(validator: RewardStatus,
|
||||||
base_reward: uint64,
|
base_reward: uint64,
|
||||||
balances: TotalBalances,
|
balances: TotalBalances,
|
||||||
@ -586,7 +586,7 @@ func get_inactivity_penalty_delta*(validator: RewardStatus,
|
|||||||
|
|
||||||
delta
|
delta
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_attestation_deltas
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_attestation_deltas
|
||||||
func get_attestation_deltas(
|
func get_attestation_deltas(
|
||||||
state: phase0.BeaconState, info: var phase0.EpochInfo) =
|
state: phase0.BeaconState, info: var phase0.EpochInfo) =
|
||||||
## Update rewards with attestation reward/penalty deltas for each validator.
|
## Update rewards with attestation reward/penalty deltas for each validator.
|
||||||
@ -757,7 +757,7 @@ iterator get_inactivity_penalty_deltas*(
|
|||||||
state.inactivity_scores[vidx]
|
state.inactivity_scores[vidx]
|
||||||
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
yield (vidx, Gwei(penalty_numerator div penalty_denominator))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||||
func process_rewards_and_penalties*(
|
func process_rewards_and_penalties*(
|
||||||
state: var phase0.BeaconState, info: var phase0.EpochInfo) =
|
state: var phase0.BeaconState, info: var phase0.EpochInfo) =
|
||||||
# No rewards are applied at the end of `GENESIS_EPOCH` because rewards are
|
# No rewards are applied at the end of `GENESIS_EPOCH` because rewards are
|
||||||
@ -816,7 +816,7 @@ func process_rewards_and_penalties*(
|
|||||||
decrease_balance(balance, info.validators[vidx].delta.penalties)
|
decrease_balance(balance, info.validators[vidx].delta.penalties)
|
||||||
state.balances.asSeq()[vidx] = balance
|
state.balances.asSeq()[vidx] = balance
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#registry-updates
|
||||||
func process_registry_updates*(
|
func process_registry_updates*(
|
||||||
cfg: RuntimeConfig, state: var ForkyBeaconState, cache: var StateCache):
|
cfg: RuntimeConfig, state: var ForkyBeaconState, cache: var StateCache):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
@ -869,7 +869,7 @@ func process_registry_updates*(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func get_adjusted_total_slashing_balance*(
|
func get_adjusted_total_slashing_balance*(
|
||||||
@ -888,14 +888,14 @@ func get_adjusted_total_slashing_balance*(
|
|||||||
{.fatal: "process_slashings: incorrect BeaconState type".}
|
{.fatal: "process_slashings: incorrect BeaconState type".}
|
||||||
min(sum(state.slashings.data) * multiplier, total_balance)
|
min(sum(state.slashings.data) * multiplier, total_balance)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
||||||
validator.slashed and
|
validator.slashed and
|
||||||
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func get_slashing_penalty*(validator: Validator,
|
func get_slashing_penalty*(validator: Validator,
|
||||||
@ -907,7 +907,7 @@ func get_slashing_penalty*(validator: Validator,
|
|||||||
adjusted_total_slashing_balance
|
adjusted_total_slashing_balance
|
||||||
penalty_numerator div total_balance * increment
|
penalty_numerator div total_balance * increment
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
|
func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
|
||||||
@ -923,7 +923,7 @@ func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
|
|||||||
validator[], adjusted_total_slashing_balance, total_balance)
|
validator[], adjusted_total_slashing_balance, total_balance)
|
||||||
decrease_balance(state, vidx, penalty)
|
decrease_balance(state, vidx, penalty)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#eth1-data-votes-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#eth1-data-votes-updates
|
||||||
func process_eth1_data_reset*(state: var ForkyBeaconState) =
|
func process_eth1_data_reset*(state: var ForkyBeaconState) =
|
||||||
let next_epoch = get_current_epoch(state) + 1
|
let next_epoch = get_current_epoch(state) + 1
|
||||||
|
|
||||||
@ -931,7 +931,7 @@ func process_eth1_data_reset*(state: var ForkyBeaconState) =
|
|||||||
if next_epoch mod EPOCHS_PER_ETH1_VOTING_PERIOD == 0:
|
if next_epoch mod EPOCHS_PER_ETH1_VOTING_PERIOD == 0:
|
||||||
state.eth1_data_votes = default(type state.eth1_data_votes)
|
state.eth1_data_votes = default(type state.eth1_data_votes)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#effective-balances-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#effective-balances-updates
|
||||||
func process_effective_balance_updates*(state: var ForkyBeaconState) =
|
func process_effective_balance_updates*(state: var ForkyBeaconState) =
|
||||||
# Update effective balances with hysteresis
|
# Update effective balances with hysteresis
|
||||||
for vidx in state.validators.vindices:
|
for vidx in state.validators.vindices:
|
||||||
@ -953,14 +953,14 @@ func process_effective_balance_updates*(state: var ForkyBeaconState) =
|
|||||||
if new_effective_balance != effective_balance:
|
if new_effective_balance != effective_balance:
|
||||||
state.validators.mitem(vidx).effective_balance = new_effective_balance
|
state.validators.mitem(vidx).effective_balance = new_effective_balance
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#slashings-balances-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#slashings-balances-updates
|
||||||
func process_slashings_reset*(state: var ForkyBeaconState) =
|
func process_slashings_reset*(state: var ForkyBeaconState) =
|
||||||
let next_epoch = get_current_epoch(state) + 1
|
let next_epoch = get_current_epoch(state) + 1
|
||||||
|
|
||||||
# Reset slashings
|
# Reset slashings
|
||||||
state.slashings[int(next_epoch mod EPOCHS_PER_SLASHINGS_VECTOR)] = 0.Gwei
|
state.slashings[int(next_epoch mod EPOCHS_PER_SLASHINGS_VECTOR)] = 0.Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#randao-mixes-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#randao-mixes-updates
|
||||||
func process_randao_mixes_reset*(state: var ForkyBeaconState) =
|
func process_randao_mixes_reset*(state: var ForkyBeaconState) =
|
||||||
let
|
let
|
||||||
current_epoch = get_current_epoch(state)
|
current_epoch = get_current_epoch(state)
|
||||||
@ -973,12 +973,12 @@ func process_randao_mixes_reset*(state: var ForkyBeaconState) =
|
|||||||
func compute_historical_root*(state: var ForkyBeaconState): Eth2Digest =
|
func compute_historical_root*(state: var ForkyBeaconState): Eth2Digest =
|
||||||
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
||||||
# significant additional stack or heap.
|
# significant additional stack or heap.
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#historicalbatch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#historicalbatch
|
||||||
# In response to https://github.com/status-im/nimbus-eth2/issues/921
|
# In response to https://github.com/status-im/nimbus-eth2/issues/921
|
||||||
hash_tree_root([
|
hash_tree_root([
|
||||||
hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)])
|
hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)])
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#historical-roots-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#historical-roots-updates
|
||||||
func process_historical_roots_update*(state: var ForkyBeaconState) =
|
func process_historical_roots_update*(state: var ForkyBeaconState) =
|
||||||
## Set historical root accumulator
|
## Set historical root accumulator
|
||||||
let next_epoch = get_current_epoch(state) + 1
|
let next_epoch = get_current_epoch(state) + 1
|
||||||
@ -986,12 +986,12 @@ func process_historical_roots_update*(state: var ForkyBeaconState) =
|
|||||||
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH) == 0:
|
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH) == 0:
|
||||||
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
||||||
# significant additional stack or heap.
|
# significant additional stack or heap.
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#historicalbatch
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#historicalbatch
|
||||||
# In response to https://github.com/status-im/nimbus-eth2/issues/921
|
# In response to https://github.com/status-im/nimbus-eth2/issues/921
|
||||||
if not state.historical_roots.add state.compute_historical_root():
|
if not state.historical_roots.add state.compute_historical_root():
|
||||||
raiseAssert "no more room for historical roots, so long and thanks for the fish!"
|
raiseAssert "no more room for historical roots, so long and thanks for the fish!"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#participation-records-rotation
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#participation-records-rotation
|
||||||
func process_participation_record_updates*(state: var phase0.BeaconState) =
|
func process_participation_record_updates*(state: var phase0.BeaconState) =
|
||||||
# Rotate current/previous epoch attestations - using swap avoids copying all
|
# Rotate current/previous epoch attestations - using swap avoids copying all
|
||||||
# elements using a slow genericSeqAssign
|
# elements using a slow genericSeqAssign
|
||||||
@ -1074,7 +1074,7 @@ func process_historical_summaries_update*(
|
|||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#epoch-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#epoch-processing
|
||||||
proc process_epoch*(
|
proc process_epoch*(
|
||||||
cfg: RuntimeConfig, state: var phase0.BeaconState, flags: UpdateFlags,
|
cfg: RuntimeConfig, state: var phase0.BeaconState, flags: UpdateFlags,
|
||||||
cache: var StateCache, info: var phase0.EpochInfo): Result[void, cstring] =
|
cache: var StateCache, info: var phase0.EpochInfo): Result[void, cstring] =
|
||||||
@ -1162,7 +1162,7 @@ proc process_epoch*(
|
|||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||||
process_rewards_and_penalties(cfg, state, info) # [Modified in Altair]
|
process_rewards_and_penalties(cfg, state, info) # [Modified in Altair]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#registry-updates
|
||||||
? process_registry_updates(cfg, state, cache)
|
? process_registry_updates(cfg, state, cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
||||||
@ -1208,7 +1208,7 @@ proc process_epoch*(
|
|||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||||
process_rewards_and_penalties(cfg, state, info)
|
process_rewards_and_penalties(cfg, state, info)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#registry-updates
|
||||||
? process_registry_updates(cfg, state, cache)
|
? process_registry_updates(cfg, state, cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#slashings
|
||||||
|
@ -21,8 +21,8 @@ const
|
|||||||
PIVOT_VIEW_SIZE = SEED_SIZE + ROUND_SIZE
|
PIVOT_VIEW_SIZE = SEED_SIZE + ROUND_SIZE
|
||||||
TOTAL_SIZE = PIVOT_VIEW_SIZE + POSITION_WINDOW_SIZE
|
TOTAL_SIZE = PIVOT_VIEW_SIZE + POSITION_WINDOW_SIZE
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_shuffled_index
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_shuffled_index
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_committee
|
||||||
# Port of https://github.com/protolambda/zrnt/blob/master/eth2/beacon/shuffle.go
|
# Port of https://github.com/protolambda/zrnt/blob/master/eth2/beacon/shuffle.go
|
||||||
# Shuffles or unshuffles, depending on the `dir` (true for shuffling, false for unshuffling
|
# Shuffles or unshuffles, depending on the `dir` (true for shuffling, false for unshuffling
|
||||||
func shuffle_list*(input: var seq[ValidatorIndex], seed: Eth2Digest) =
|
func shuffle_list*(input: var seq[ValidatorIndex], seed: Eth2Digest) =
|
||||||
@ -160,13 +160,13 @@ func get_shuffled_active_validator_indices*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
cache.get_shuffled_active_validator_indices(forkyState.data, epoch)
|
cache.get_shuffled_active_validator_indices(forkyState.data, epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_active_validator_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_active_validator_indices
|
||||||
func count_active_validators*(state: ForkyBeaconState,
|
func count_active_validators*(state: ForkyBeaconState,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
cache: var StateCache): uint64 =
|
cache: var StateCache): uint64 =
|
||||||
cache.get_shuffled_active_validator_indices(state, epoch).lenu64
|
cache.get_shuffled_active_validator_indices(state, epoch).lenu64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_committee_count_per_slot
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_committee_count_per_slot
|
||||||
func get_committee_count_per_slot*(num_active_validators: uint64): uint64 =
|
func get_committee_count_per_slot*(num_active_validators: uint64): uint64 =
|
||||||
clamp(
|
clamp(
|
||||||
num_active_validators div SLOTS_PER_EPOCH div TARGET_COMMITTEE_SIZE,
|
num_active_validators div SLOTS_PER_EPOCH div TARGET_COMMITTEE_SIZE,
|
||||||
@ -191,7 +191,7 @@ iterator get_committee_indices*(committee_count_per_slot: uint64): CommitteeInde
|
|||||||
let committee_index = CommitteeIndex.init(idx).expect("value clamped")
|
let committee_index = CommitteeIndex.init(idx).expect("value clamped")
|
||||||
yield committee_index
|
yield committee_index
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_committee
|
||||||
func compute_committee_slice*(
|
func compute_committee_slice*(
|
||||||
active_validators, index, count: uint64): Slice[int] =
|
active_validators, index, count: uint64): Slice[int] =
|
||||||
doAssert active_validators <= ValidatorIndex.high.uint64
|
doAssert active_validators <= ValidatorIndex.high.uint64
|
||||||
@ -237,7 +237,7 @@ func compute_committee_len*(
|
|||||||
|
|
||||||
(slice.b - slice.a + 1).uint64
|
(slice.b - slice.a + 1).uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
iterator get_beacon_committee*(
|
iterator get_beacon_committee*(
|
||||||
state: ForkyBeaconState, slot: Slot, index: CommitteeIndex,
|
state: ForkyBeaconState, slot: Slot, index: CommitteeIndex,
|
||||||
cache: var StateCache): (int, ValidatorIndex) =
|
cache: var StateCache): (int, ValidatorIndex) =
|
||||||
@ -277,7 +277,7 @@ func get_beacon_committee*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
get_beacon_committee(forkyState.data, slot, index, cache)
|
get_beacon_committee(forkyState.data, slot, index, cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
func get_beacon_committee_len*(
|
func get_beacon_committee_len*(
|
||||||
state: ForkyBeaconState, slot: Slot, index: CommitteeIndex,
|
state: ForkyBeaconState, slot: Slot, index: CommitteeIndex,
|
||||||
cache: var StateCache): uint64 =
|
cache: var StateCache): uint64 =
|
||||||
@ -301,7 +301,7 @@ func get_beacon_committee_len*(
|
|||||||
withState(state):
|
withState(state):
|
||||||
get_beacon_committee_len(forkyState.data, slot, index, cache)
|
get_beacon_committee_len(forkyState.data, slot, index, cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_shuffled_index
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_shuffled_index
|
||||||
func compute_shuffled_index*(
|
func compute_shuffled_index*(
|
||||||
index: uint64, index_count: uint64, seed: Eth2Digest): uint64 =
|
index: uint64, index_count: uint64, seed: Eth2Digest): uint64 =
|
||||||
## Return the shuffled index corresponding to ``seed`` (and ``index_count``).
|
## Return the shuffled index corresponding to ``seed`` (and ``index_count``).
|
||||||
@ -336,7 +336,7 @@ func compute_shuffled_index*(
|
|||||||
|
|
||||||
cur_idx_permuted
|
cur_idx_permuted
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#compute_proposer_index
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#compute_proposer_index
|
||||||
func compute_proposer_index(state: ForkyBeaconState,
|
func compute_proposer_index(state: ForkyBeaconState,
|
||||||
indices: seq[ValidatorIndex], seed: Eth2Digest): Opt[ValidatorIndex] =
|
indices: seq[ValidatorIndex], seed: Eth2Digest): Opt[ValidatorIndex] =
|
||||||
## Return from ``indices`` a random index sampled by effective balance.
|
## Return from ``indices`` a random index sampled by effective balance.
|
||||||
@ -363,7 +363,7 @@ func compute_proposer_index(state: ForkyBeaconState,
|
|||||||
return Opt.some(candidate_index)
|
return Opt.some(candidate_index)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_proposer_index
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_proposer_index
|
||||||
func get_beacon_proposer_index*(
|
func get_beacon_proposer_index*(
|
||||||
state: ForkyBeaconState, cache: var StateCache, slot: Slot):
|
state: ForkyBeaconState, cache: var StateCache, slot: Slot):
|
||||||
Opt[ValidatorIndex] =
|
Opt[ValidatorIndex] =
|
||||||
@ -401,7 +401,7 @@ func get_beacon_proposer_index*(
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#get_beacon_proposer_index
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#get_beacon_proposer_index
|
||||||
func get_beacon_proposer_index*(state: ForkyBeaconState, cache: var StateCache):
|
func get_beacon_proposer_index*(state: ForkyBeaconState, cache: var StateCache):
|
||||||
Opt[ValidatorIndex] =
|
Opt[ValidatorIndex] =
|
||||||
## Return the beacon proposer index at the current slot.
|
## Return the beacon proposer index at the current slot.
|
||||||
|
@ -10,10 +10,10 @@
|
|||||||
import
|
import
|
||||||
./datatypes/base, ./beaconstate, ./forks, ./helpers
|
./datatypes/base, ./beaconstate, ./forks, ./helpers
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/weak-subjectivity.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/weak-subjectivity.md#configuration
|
||||||
const SAFETY_DECAY* = 10'u64
|
const SAFETY_DECAY* = 10'u64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/weak-subjectivity.md#compute_weak_subjectivity_period
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/weak-subjectivity.md#compute_weak_subjectivity_period
|
||||||
func compute_weak_subjectivity_period(
|
func compute_weak_subjectivity_period(
|
||||||
cfg: RuntimeConfig, state: ForkyBeaconState): uint64 =
|
cfg: RuntimeConfig, state: ForkyBeaconState): uint64 =
|
||||||
## Returns the weak subjectivity period for the current ``state``.
|
## Returns the weak subjectivity period for the current ``state``.
|
||||||
@ -49,7 +49,7 @@ func compute_weak_subjectivity_period(
|
|||||||
|
|
||||||
ws_period
|
ws_period
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/weak-subjectivity.md#is_within_weak_subjectivity_period
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/weak-subjectivity.md#is_within_weak_subjectivity_period
|
||||||
func is_within_weak_subjectivity_period*(cfg: RuntimeConfig, current_slot: Slot,
|
func is_within_weak_subjectivity_period*(cfg: RuntimeConfig, current_slot: Slot,
|
||||||
ws_state: ForkedHashedBeaconState,
|
ws_state: ForkedHashedBeaconState,
|
||||||
ws_checkpoint: Checkpoint): bool =
|
ws_checkpoint: Checkpoint): bool =
|
||||||
|
@ -113,7 +113,7 @@ proc isGossipSupported*(
|
|||||||
else:
|
else:
|
||||||
period <= finalizedPeriod
|
period <= finalizedPeriod
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
||||||
proc doRequest(
|
proc doRequest(
|
||||||
e: typedesc[Bootstrap],
|
e: typedesc[Bootstrap],
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
@ -122,7 +122,7 @@ proc doRequest(
|
|||||||
raises: [Defect, IOError].} =
|
raises: [Defect, IOError].} =
|
||||||
peer.lightClientBootstrap(blockRoot)
|
peer.lightClientBootstrap(blockRoot)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
||||||
type LightClientUpdatesByRangeResponse =
|
type LightClientUpdatesByRangeResponse =
|
||||||
NetRes[List[ForkedLightClientUpdate, MAX_REQUEST_LIGHT_CLIENT_UPDATES]]
|
NetRes[List[ForkedLightClientUpdate, MAX_REQUEST_LIGHT_CLIENT_UPDATES]]
|
||||||
proc doRequest(
|
proc doRequest(
|
||||||
@ -171,7 +171,7 @@ proc doRequest(
|
|||||||
raise newException(ResponseError, "Invalid context bytes")
|
raise newException(ResponseError, "Invalid context bytes")
|
||||||
return response
|
return response
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
||||||
proc doRequest(
|
proc doRequest(
|
||||||
e: typedesc[FinalityUpdate],
|
e: typedesc[FinalityUpdate],
|
||||||
peer: Peer
|
peer: Peer
|
||||||
@ -179,7 +179,7 @@ proc doRequest(
|
|||||||
raises: [Defect, IOError].} =
|
raises: [Defect, IOError].} =
|
||||||
peer.lightClientFinalityUpdate()
|
peer.lightClientFinalityUpdate()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
||||||
proc doRequest(
|
proc doRequest(
|
||||||
e: typedesc[OptimisticUpdate],
|
e: typedesc[OptimisticUpdate],
|
||||||
peer: Peer
|
peer: Peer
|
||||||
@ -404,7 +404,7 @@ func fetchTime(
|
|||||||
jitterDelay = chronos.seconds(self.rng[].rand(jitterSeconds).int64)
|
jitterDelay = chronos.seconds(self.rng[].rand(jitterSeconds).int64)
|
||||||
return wallTime + minDelay + jitterDelay
|
return wallTime + minDelay + jitterDelay
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/light-client.md#light-client-sync-process
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||||
proc loop(self: LightClientManager) {.async.} =
|
proc loop(self: LightClientManager) {.async.} =
|
||||||
var nextFetchTime = self.getBeaconTime()
|
var nextFetchTime = self.getBeaconTime()
|
||||||
while true:
|
while true:
|
||||||
|
@ -548,7 +548,7 @@ p2pProtocol BeaconSync(version = 1,
|
|||||||
debug "BlobSidecar range request done",
|
debug "BlobSidecar range request done",
|
||||||
peer, startSlot, count = reqCount, found
|
peer, startSlot, count = reqCount, found
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
|
||||||
proc lightClientBootstrap(
|
proc lightClientBootstrap(
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
blockRoot: Eth2Digest,
|
blockRoot: Eth2Digest,
|
||||||
@ -576,7 +576,7 @@ p2pProtocol BeaconSync(version = 1,
|
|||||||
|
|
||||||
debug "LC bootstrap request done", peer, blockRoot
|
debug "LC bootstrap request done", peer, blockRoot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
|
||||||
proc lightClientUpdatesByRange(
|
proc lightClientUpdatesByRange(
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
startPeriod: SyncCommitteePeriod,
|
startPeriod: SyncCommitteePeriod,
|
||||||
@ -621,7 +621,7 @@ p2pProtocol BeaconSync(version = 1,
|
|||||||
|
|
||||||
debug "LC updates by range request done", peer, startPeriod, count, found
|
debug "LC updates by range request done", peer, startPeriod, count, found
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
|
||||||
proc lightClientFinalityUpdate(
|
proc lightClientFinalityUpdate(
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
response: SingleChunkResponse[ForkedLightClientFinalityUpdate])
|
response: SingleChunkResponse[ForkedLightClientFinalityUpdate])
|
||||||
@ -648,7 +648,7 @@ p2pProtocol BeaconSync(version = 1,
|
|||||||
|
|
||||||
debug "LC finality update request done", peer
|
debug "LC finality update request done", peer
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
||||||
proc lightClientOptimisticUpdate(
|
proc lightClientOptimisticUpdate(
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
response: SingleChunkResponse[ForkedLightClientOptimisticUpdate])
|
response: SingleChunkResponse[ForkedLightClientOptimisticUpdate])
|
||||||
|
@ -160,7 +160,7 @@ proc doTrustedNodeSync*(
|
|||||||
let stateId =
|
let stateId =
|
||||||
case syncTarget.kind
|
case syncTarget.kind
|
||||||
of TrustedNodeSyncKind.TrustedBlockRoot:
|
of TrustedNodeSyncKind.TrustedBlockRoot:
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/light-client.md#light-client-sync-process
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||||
const lcDataFork = LightClientDataFork.high
|
const lcDataFork = LightClientDataFork.high
|
||||||
var bestViableCheckpoint: Opt[tuple[slot: Slot, state_root: Eth2Digest]]
|
var bestViableCheckpoint: Opt[tuple[slot: Slot, state_root: Eth2Digest]]
|
||||||
func trackBestViableCheckpoint(store: lcDataFork.LightClientStore) =
|
func trackBestViableCheckpoint(store: lcDataFork.LightClientStore) =
|
||||||
|
@ -1658,7 +1658,7 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async.} =
|
|||||||
updateValidatorMetrics(node) # the important stuff is done, update the vanity numbers
|
updateValidatorMetrics(node) # the important stuff is done, update the vanity numbers
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#broadcast-aggregate
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#broadcast-aggregate
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||||
# Wait 2 / 3 of the slot time to allow messages to propagate, then collect
|
# Wait 2 / 3 of the slot time to allow messages to propagate, then collect
|
||||||
# the result in aggregates
|
# the result in aggregates
|
||||||
static:
|
static:
|
||||||
|
@ -658,7 +658,7 @@ proc getAggregateAndProofSignature*(v: AttachedValidator,
|
|||||||
fork, genesis_validators_root, aggregate_and_proof)
|
fork, genesis_validators_root, aggregate_and_proof)
|
||||||
await v.signData(request)
|
await v.signData(request)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#prepare-sync-committee-message
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||||
proc getSyncCommitteeMessage*(v: AttachedValidator,
|
proc getSyncCommitteeMessage*(v: AttachedValidator,
|
||||||
fork: Fork,
|
fork: Fork,
|
||||||
genesis_validators_root: Eth2Digest,
|
genesis_validators_root: Eth2Digest,
|
||||||
@ -689,7 +689,7 @@ proc getSyncCommitteeMessage*(v: AttachedValidator,
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#aggregation-selection
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#aggregation-selection
|
||||||
proc getSyncCommitteeSelectionProof*(v: AttachedValidator, fork: Fork,
|
proc getSyncCommitteeSelectionProof*(v: AttachedValidator, fork: Fork,
|
||||||
genesis_validators_root: Eth2Digest,
|
genesis_validators_root: Eth2Digest,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
@ -709,7 +709,7 @@ proc getSyncCommitteeSelectionProof*(v: AttachedValidator, fork: Fork,
|
|||||||
)
|
)
|
||||||
await v.signData(request)
|
await v.signData(request)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||||
proc getContributionAndProofSignature*(v: AttachedValidator, fork: Fork,
|
proc getContributionAndProofSignature*(v: AttachedValidator, fork: Fork,
|
||||||
genesis_validators_root: Eth2Digest,
|
genesis_validators_root: Eth2Digest,
|
||||||
contribution_and_proof: ContributionAndProof
|
contribution_and_proof: ContributionAndProof
|
||||||
|
@ -9,7 +9,7 @@ It is important to distinguish attestation `validation` from attestation `verifi
|
|||||||
- Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
- Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
||||||
- Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
- Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||||
- Attestation `verification` is defined in the consensus specs. Verified attestations can affect fork choice and may be included in a block.
|
- Attestation `verification` is defined in the consensus specs. Verified attestations can affect fork choice and may be included in a block.
|
||||||
- https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#attestations
|
- https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#attestations
|
||||||
|
|
||||||
From the specs it seems like gossip attestation `validation` is a superset of consensus attestation `verification`.
|
From the specs it seems like gossip attestation `validation` is a superset of consensus attestation `verification`.
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ Important distinction:
|
|||||||
https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_block.
|
https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/p2p-interface.md#beacon_block.
|
||||||
A validated block can be forwarded on gossipsub.
|
A validated block can be forwarded on gossipsub.
|
||||||
- and we distinguish `verification` which is defined in consensus specs:
|
- and we distinguish `verification` which is defined in consensus specs:
|
||||||
https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#block-processing
|
https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#block-processing
|
||||||
A block needs to be verified to enter fork choice, the DAG and the BeaconChainDB
|
A block needs to be verified to enter fork choice, the DAG and the BeaconChainDB
|
||||||
|
|
||||||
In particular in terms of costly checks validating a block only requires checking:
|
In particular in terms of costly checks validating a block only requires checking:
|
||||||
|
@ -104,7 +104,7 @@ The following sections explain how to do this for certain EL clients.
|
|||||||
## Running the light client
|
## Running the light client
|
||||||
|
|
||||||
The light client starts syncing from a trusted block.
|
The light client starts syncing from a trusted block.
|
||||||
This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the light client.
|
This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the light client.
|
||||||
|
|
||||||
### 1. Obtaining a trusted block root
|
### 1. Obtaining a trusted block root
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ NOT 2022-11-21 18:04:03.982+01:00 New LC optimistic block opt
|
|||||||
```
|
```
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
The [light client protocol](https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md) depends on consensus layer (CL) full nodes to serve additional data.
|
The [light client protocol](https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md) depends on consensus layer (CL) full nodes to serve additional data.
|
||||||
As this is a new protocol, not all implementations are supporting it yet.
|
As this is a new protocol, not all implementations are supporting it yet.
|
||||||
Therefore, it may take several minutes to discover supporting peers, during which no log messages may be produced.
|
Therefore, it may take several minutes to discover supporting peers, during which no log messages may be produced.
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Nimbus is configured by default to serve data that allows light clients to stay in sync with the Ethereum network.
|
Nimbus is configured by default to serve data that allows light clients to stay in sync with the Ethereum network.
|
||||||
Light client data is imported incrementally and does not affect validator performance.
|
Light client data is imported incrementally and does not affect validator performance.
|
||||||
Information about the light client sync protocol can be found in the [Ethereum consensus specs](https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md).
|
Information about the light client sync protocol can be found in the [Ethereum consensus specs](https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md).
|
||||||
|
|
||||||
!!! note
|
!!! note
|
||||||
Nimbus also implements a [standalone light client](./el-light-client.md) that may be used to sync an execution layer (EL) client.
|
Nimbus also implements a [standalone light client](./el-light-client.md) that may be used to sync an execution layer (EL) client.
|
||||||
|
@ -125,7 +125,7 @@ If you are already using a threshold signing setup (e.g. based on Vouch and Dirk
|
|||||||
|
|
||||||
The verifying Web3Signer is an experimental extension to the [Web3Signer protocol](https://consensys.github.io/web3signer/web3signer-eth2.html#tag/Signing/operation/ETH2_SIGN) which allows the remote signer to verify certain details of the signed blocks before creating a signature (for example, the signer may require the signed block to have a particular fee recipient value).
|
The verifying Web3Signer is an experimental extension to the [Web3Signer protocol](https://consensys.github.io/web3signer/web3signer-eth2.html#tag/Signing/operation/ETH2_SIGN) which allows the remote signer to verify certain details of the signed blocks before creating a signature (for example, the signer may require the signed block to have a particular fee recipient value).
|
||||||
|
|
||||||
To enable this use case, the `BLOCK_V2` request type of the `/api/v1/eth2/sign/{identifier}` endpoint is extended with an additional array field named `proofs`. The array consists of objects with the properties `index`, `proof` and `value`, where `index` is an arbitrary [generalized index](https://github.com/ethereum/consensus-specs/blob/v1.3.0/ssz/merkle-proofs.md#generalized-merkle-tree-index) of any property nested under the block body and `proof` is its corresponding merkle proof against the block body root included in the request. The `value` property is optional and it is included only when the SSZ hash of the field included in the merkle proof doesn't match its value.
|
To enable this use case, the `BLOCK_V2` request type of the `/api/v1/eth2/sign/{identifier}` endpoint is extended with an additional array field named `proofs`. The array consists of objects with the properties `index`, `proof` and `value`, where `index` is an arbitrary [generalized index](https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/ssz/merkle-proofs.md#generalized-merkle-tree-index) of any property nested under the block body and `proof` is its corresponding merkle proof against the block body root included in the request. The `value` property is optional and it is included only when the SSZ hash of the field included in the merkle proof doesn't match its value.
|
||||||
|
|
||||||
Since the generalized index of a particular field may change in a hard-fork, in the remote keystore format the proven fields are usually specified by their name:
|
Since the generalized index of a particular field may change in a hard-fork, in the remote keystore format the proven fields are usually specified by their name:
|
||||||
|
|
||||||
@ -145,4 +145,4 @@ Since the generalized index of a particular field may change in a hard-fork, in
|
|||||||
```
|
```
|
||||||
|
|
||||||
Nimbus automatically computes the generalized index depending on the currently active fork.
|
Nimbus automatically computes the generalized index depending on the currently active fork.
|
||||||
The remote signer is expected to verify the incoming merkle proof through the standardized [is_valid_merkle_branch](https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/beacon-chain.md#is_valid_merkle_branch) function by utilizing a similar automatic mapping mechanism for the generalized index.
|
The remote signer is expected to verify the incoming merkle proof through the standardized [is_valid_merkle_branch](https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/phase0/beacon-chain.md#is_valid_merkle_branch) function by utilizing a similar automatic mapping mechanism for the generalized index.
|
||||||
|
@ -22,7 +22,7 @@ import
|
|||||||
# Test utilities
|
# Test utilities
|
||||||
../../testutil, ../../testblockutil
|
../../testutil, ../../testblockutil
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44
|
||||||
proc compute_aggregate_sync_committee_signature(
|
proc compute_aggregate_sync_committee_signature(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
forked: ForkedHashedBeaconState,
|
forked: ForkedHashedBeaconState,
|
||||||
@ -53,7 +53,7 @@ proc compute_aggregate_sync_committee_signature(
|
|||||||
aggregateSig.aggregate(signature)
|
aggregateSig.aggregate(signature)
|
||||||
aggregateSig.finish.toValidatorSig
|
aggregateSig.finish.toValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/helpers/light_client.py#L11-L41
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/helpers/light_client.py#L11-L41
|
||||||
proc get_sync_aggregate(
|
proc get_sync_aggregate(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
forked: ForkedHashedBeaconState,
|
forked: ForkedHashedBeaconState,
|
||||||
@ -137,7 +137,7 @@ let full_sync_committee_bits = block:
|
|||||||
res.bytes.fill(byte.high)
|
res.bytes.fill(byte.high)
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/light-client/sync-protocol.md#initialize_light_client_store
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/specs/altair/light-client/sync-protocol.md#initialize_light_client_store
|
||||||
func initialize_light_client_store(
|
func initialize_light_client_store(
|
||||||
state: auto, storeDataFork: static LightClientDataFork): auto =
|
state: auto, storeDataFork: static LightClientDataFork): auto =
|
||||||
storeDataFork.LightClientStore(
|
storeDataFork.LightClientStore(
|
||||||
@ -160,7 +160,7 @@ proc runTest(storeDataFork: static LightClientDataFork) =
|
|||||||
res
|
res
|
||||||
genesisState = newClone(initGenesisState(cfg = cfg))
|
genesisState = newClone(initGenesisState(cfg = cfg))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L32-L61
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L32-L61
|
||||||
test "test_process_light_client_update_not_timeout":
|
test "test_process_light_client_update_not_timeout":
|
||||||
let forked = assignClone(genesisState[])
|
let forked = assignClone(genesisState[])
|
||||||
template state(): auto = forked[].altairData.data
|
template state(): auto = forked[].altairData.data
|
||||||
@ -206,7 +206,7 @@ proc runTest(storeDataFork: static LightClientDataFork) =
|
|||||||
store.optimistic_header == update.attested_header
|
store.optimistic_header == update.attested_header
|
||||||
store.current_max_active_participants > 0
|
store.current_max_active_participants > 0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L64-L96
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L64-L96
|
||||||
test "test_process_light_client_update_at_period_boundary":
|
test "test_process_light_client_update_at_period_boundary":
|
||||||
var forked = assignClone(genesisState[])
|
var forked = assignClone(genesisState[])
|
||||||
template state(): auto = forked[].altairData.data
|
template state(): auto = forked[].altairData.data
|
||||||
@ -259,7 +259,7 @@ proc runTest(storeDataFork: static LightClientDataFork) =
|
|||||||
store.optimistic_header == update.attested_header
|
store.optimistic_header == update.attested_header
|
||||||
store.current_max_active_participants > 0
|
store.current_max_active_participants > 0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L99-L131
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L99-L131
|
||||||
test "process_light_client_update_timeout":
|
test "process_light_client_update_timeout":
|
||||||
let forked = assignClone(genesisState[])
|
let forked = assignClone(genesisState[])
|
||||||
template state(): auto = forked[].altairData.data
|
template state(): auto = forked[].altairData.data
|
||||||
@ -315,7 +315,7 @@ proc runTest(storeDataFork: static LightClientDataFork) =
|
|||||||
store.optimistic_header == update.attested_header
|
store.optimistic_header == update.attested_header
|
||||||
store.current_max_active_participants > 0
|
store.current_max_active_participants > 0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L134-L176
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L134-L176
|
||||||
test "process_light_client_update_finality_updated":
|
test "process_light_client_update_finality_updated":
|
||||||
let forked = assignClone(genesisState[])
|
let forked = assignClone(genesisState[])
|
||||||
template state(): auto = forked[].altairData.data
|
template state(): auto = forked[].altairData.data
|
||||||
|
@ -26,7 +26,7 @@ const
|
|||||||
MockPrivKeys* = MockPrivKeysT()
|
MockPrivKeys* = MockPrivKeysT()
|
||||||
MockPubKeys* = MockPubKeysT()
|
MockPubKeys* = MockPubKeysT()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/tests/core/pyspec/eth2spec/test/helpers/keys.py
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.0/tests/core/pyspec/eth2spec/test/helpers/keys.py
|
||||||
func `[]`*(_: MockPrivKeysT, index: ValidatorIndex|uint64): ValidatorPrivKey =
|
func `[]`*(_: MockPrivKeysT, index: ValidatorIndex|uint64): ValidatorPrivKey =
|
||||||
var bytes = (index.uint64 + 1'u64).toBytesLE() # Consistent with EF tests
|
var bytes = (index.uint64 + 1'u64).toBytesLE() # Consistent with EF tests
|
||||||
static: doAssert sizeof(bytes) <= sizeof(result)
|
static: doAssert sizeof(bytes) <= sizeof(result)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user