update spec ref URLs (#4005)

This commit is contained in:
tersec 2022-08-20 16:03:32 +00:00 committed by GitHub
parent bac50610fd
commit c65eaca1bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
48 changed files with 237 additions and 237 deletions

View File

@ -15,7 +15,7 @@ import
./spec/[eth2_ssz_serialization, eth2_merkleization] ./spec/[eth2_ssz_serialization, eth2_merkleization]
type type
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beaconstate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#beaconstate
# Memory-representation-equivalent to a phase0 BeaconState for in-place SSZ reading and writing # Memory-representation-equivalent to a phase0 BeaconState for in-place SSZ reading and writing
Phase0BeaconStateNoImmutableValidators* = object Phase0BeaconStateNoImmutableValidators* = object
# Versioning # Versioning
@ -66,7 +66,7 @@ type
current_justified_checkpoint*: Checkpoint current_justified_checkpoint*: Checkpoint
finalized_checkpoint*: Checkpoint finalized_checkpoint*: Checkpoint
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#beaconstate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#beaconstate
# Memory-representation-equivalent to an Altair BeaconState for in-place SSZ # Memory-representation-equivalent to an Altair BeaconState for in-place SSZ
# reading and writing # reading and writing
AltairBeaconStateNoImmutableValidators* = object AltairBeaconStateNoImmutableValidators* = object

View File

@ -29,7 +29,7 @@ type
## which blocks are valid - in particular, blocks are not valid if they ## which blocks are valid - in particular, blocks are not valid if they
## come from the future as seen from the local clock. ## come from the future as seen from the local clock.
## ##
## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#fork-choice ## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#fork-choice
## ##
# TODO consider NTP and network-adjusted timestamps as outlined here: # TODO consider NTP and network-adjusted timestamps as outlined here:
# https://ethresear.ch/t/network-adjusted-timestamps/4187 # https://ethresear.ch/t/network-adjusted-timestamps/4187

View File

@ -126,7 +126,7 @@ func link*(parent, child: BlockRef) =
func get_ancestor*(blck: BlockRef, slot: Slot, func get_ancestor*(blck: BlockRef, slot: Slot,
maxDepth = 100'i64 * 365 * 24 * 60 * 60 div SECONDS_PER_SLOT.int): maxDepth = 100'i64 * 365 * 24 * 60 * 60 div SECONDS_PER_SLOT.int):
BlockRef = BlockRef =
## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#get_ancestor ## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#get_ancestor
## Return the most recent block as of the time at `slot` that not more recent ## Return the most recent block as of the time at `slot` that not more recent
## than `blck` itself ## than `blck` itself
if isNil(blck): return nil if isNil(blck): return nil

View File

@ -2029,7 +2029,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
# Eth2 spec requires at least one attesting index in attestation # Eth2 spec requires at least one attesting index in attestation
# - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation # - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
return err("aggregate: no attesting keys") return err("aggregate: no attesting keys")
let let

View File

@ -97,7 +97,7 @@ proc runForkchoiceUpdated*(
# block hash provided by this event is stubbed with # block hash provided by this event is stubbed with
# `0x0000000000000000000000000000000000000000000000000000000000000000`." # `0x0000000000000000000000000000000000000000000000000000000000000000`."
# and # and
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/bellatrix/validator.md#executionpayload # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/bellatrix/validator.md#executionpayload
# notes "`finalized_block_hash` is the hash of the latest finalized execution # notes "`finalized_block_hash` is the hash of the latest finalized execution
# payload (`Hash32()` if none yet finalized)" # payload (`Hash32()` if none yet finalized)"
doAssert not headBlockRoot.isZero doAssert not headBlockRoot.isZero

View File

@ -28,7 +28,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_committee_count_per_slot # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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))
@ -41,7 +41,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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) =
@ -54,7 +54,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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] =
@ -67,7 +67,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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``.
@ -79,7 +79,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_attesting_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -142,7 +142,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_attesting_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -152,7 +152,7 @@ func get_attesting_indices*(shufflingRef: ShufflingRef,
for idx in get_attesting_indices(shufflingRef, slot, committee_index, bits): for idx in get_attesting_indices(shufflingRef, slot, committee_index, bits):
result.add(idx) result.add(idx)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
proc is_valid_indexed_attestation*( proc is_valid_indexed_attestation*(
fork: Fork, genesis_validators_root: Eth2Digest, fork: Fork, genesis_validators_root: Eth2Digest,
dag: ChainDAGRef, shufflingRef: EpochRef, dag: ChainDAGRef, shufflingRef: EpochRef,

View File

@ -10,7 +10,7 @@ when (NimMajor, NimMinor) < (1, 4):
else: else:
{.push raises: [].} {.push raises: [].}
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/utils/merkle_minimal.py # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
# Merkle tree helpers # Merkle tree helpers
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

@ -81,7 +81,7 @@ func extend[T](s: var seq[T], minLen: int) =
if s.len < minLen: if s.len < minLen:
s.setLen(minLen) s.setLen(minLen)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#should_update_justified_checkpoint # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#should_update_justified_checkpoint
func should_update_justified_checkpoint( func should_update_justified_checkpoint(
self: var Checkpoints, dag: ChainDAGRef, self: var Checkpoints, dag: ChainDAGRef,
new_justified_checkpoint: Checkpoint): FcResult[bool] = new_justified_checkpoint: Checkpoint): FcResult[bool] =
@ -135,7 +135,7 @@ proc update_justified(
self.update_justified(dag, blck, justified.epoch) self.update_justified(dag, blck, justified.epoch)
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#on_block # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#on_block
proc update_checkpoints( proc update_checkpoints(
self: var Checkpoints, dag: ChainDAGRef, self: var Checkpoints, dag: ChainDAGRef,
checkpoints: FinalityCheckpoints): FcResult[void] = checkpoints: FinalityCheckpoints): FcResult[void] =
@ -158,7 +158,7 @@ proc update_checkpoints(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#on_tick # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#on_tick
proc on_tick( proc on_tick(
self: var ForkChoice, dag: ChainDAGRef, time: BeaconTime): FcResult[void] = self: var ForkChoice, dag: ChainDAGRef, time: BeaconTime): FcResult[void] =
## Must be called at least once per slot. ## Must be called at least once per slot.
@ -287,7 +287,7 @@ proc on_attestation*(
block_root: beacon_block_root)) block_root: beacon_block_root))
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#on_attester_slashing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#on_attester_slashing
func process_equivocation*( func process_equivocation*(
self: var ForkChoice, self: var ForkChoice,
validator_index: ValidatorIndex validator_index: ValidatorIndex
@ -303,7 +303,7 @@ func process_equivocation*(
trace "Integrating equivocation in fork choice", trace "Integrating equivocation in fork choice",
validator_index validator_index
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#on_block # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#on_block
func process_block*(self: var ForkChoiceBackend, func process_block*(self: var ForkChoiceBackend,
block_root: Eth2Digest, block_root: Eth2Digest,
parent_root: Eth2Digest, parent_root: Eth2Digest,

View File

@ -100,7 +100,7 @@ func init*(T: type ProtoArray, checkpoints: FinalityCheckpoints): T =
nodes: ProtoNodes(buf: @[node], offset: 0), nodes: ProtoNodes(buf: @[node], offset: 0),
indices: {node.root: 0}.toTable()) indices: {node.root: 0}.toTable())
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#configuration # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#configuration
# https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#get_latest_attesting_balance # https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/fork-choice.md#get_latest_attesting_balance
const PROPOSER_SCORE_BOOST* = 40 const PROPOSER_SCORE_BOOST* = 40
func calculateProposerBoost(validatorBalances: openArray[Gwei]): int64 = func calculateProposerBoost(validatorBalances: openArray[Gwei]): int64 =
@ -517,7 +517,7 @@ func nodeLeadsToViableHead(self: ProtoArray, node: ProtoNode): FcResult[bool] =
func nodeIsViableForHead(self: ProtoArray, node: ProtoNode): bool = func nodeIsViableForHead(self: ProtoArray, node: ProtoNode): bool =
## This is the equivalent of `filter_block_tree` function in eth2 spec ## This is the equivalent of `filter_block_tree` function in eth2 spec
## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#filter_block_tree ## https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#filter_block_tree
## ##
## Any node that has a different finalized or justified epoch ## Any node that has a different finalized or justified epoch
## should not be viable for the head. ## should not be viable for the head.

View File

@ -518,7 +518,7 @@ proc runQueueProcessingLoop*(self: ref BlockProcessor) {.async.} =
self.consensusManager.eth1Monitor, executionPayload) self.consensusManager.eth1Monitor, executionPayload)
if executionPayloadStatus.isNone: if executionPayloadStatus.isNone:
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/sync/optimistic.md#execution-engine-errors # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/sync/optimistic.md#execution-engine-errors
if not blck.resfut.isNil: if not blck.resfut.isNil:
blck.resfut.complete( blck.resfut.complete(
Result[void, BlockError].err(BlockError.MissingParent)) Result[void, BlockError].err(BlockError.MissingParent))
@ -528,7 +528,7 @@ proc runQueueProcessingLoop*(self: ref BlockProcessor) {.async.} =
except CatchableError as err: except CatchableError as err:
error "runQueueProcessingLoop: newPayload failed", error "runQueueProcessingLoop: newPayload failed",
err = err.msg err = err.msg
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/sync/optimistic.md#execution-engine-errors # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/sync/optimistic.md#execution-engine-errors
if not blck.resfut.isNil: if not blck.resfut.isNil:
blck.resfut.complete( blck.resfut.complete(
Result[void, BlockError].err(BlockError.MissingParent)) Result[void, BlockError].err(BlockError.MissingParent))

View File

@ -566,7 +566,7 @@ proc processSignedContributionAndProof*(
err(v.error()) err(v.error())
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientFinalityUpdate finality_update: altair.LightClientFinalityUpdate
@ -577,7 +577,7 @@ proc processLightClientFinalityUpdate*(
self.lightClientPool[], self.dag, finality_update, wallTime) self.lightClientPool[], self.dag, finality_update, wallTime)
v v
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#process_light_client_optimistic_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientOptimisticUpdate optimistic_update: altair.LightClientOptimisticUpdate

View File

@ -178,7 +178,7 @@ template validateBeaconBlockBellatrix(
parent: BlockRef): untyped = parent: BlockRef): untyped =
discard discard
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/bellatrix/p2p-interface.md#beacon_block # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/bellatrix/p2p-interface.md#beacon_block
template validateBeaconBlockBellatrix( template validateBeaconBlockBellatrix(
signed_beacon_block: bellatrix.SignedBeaconBlock, signed_beacon_block: bellatrix.SignedBeaconBlock,
parent: BlockRef): untyped = parent: BlockRef): untyped =
@ -218,7 +218,7 @@ template validateBeaconBlockBellatrix(
return errReject("BeaconBlock: execution payload would build on optimistic parent") return errReject("BeaconBlock: execution payload would build on optimistic parent")
# https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/phase0/p2p-interface.md#beacon_block # https://github.com/ethereum/consensus-specs/blob/v1.1.9/specs/phase0/p2p-interface.md#beacon_block
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/bellatrix/p2p-interface.md#beacon_block # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/bellatrix/p2p-interface.md#beacon_block
proc validateBeaconBlock*( proc validateBeaconBlock*(
dag: ChainDAGRef, quarantine: ref Quarantine, dag: ChainDAGRef, quarantine: ref Quarantine,
signed_beacon_block: phase0.SignedBeaconBlock | altair.SignedBeaconBlock | signed_beacon_block: phase0.SignedBeaconBlock | altair.SignedBeaconBlock |
@ -297,7 +297,7 @@ proc validateBeaconBlock*(
if signed_beacon_block.message.parent_root in quarantine[].unviable: if signed_beacon_block.message.parent_root in quarantine[].unviable:
quarantine[].addUnviable(signed_beacon_block.root) quarantine[].addUnviable(signed_beacon_block.root)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/bellatrix/p2p-interface.md#beacon_block # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/bellatrix/p2p-interface.md#beacon_block
# `is_execution_enabled(state, block.body)` check, but unlike in # `is_execution_enabled(state, block.body)` check, but unlike in
# validateBeaconBlockBellatrix() don't have parent BlockRef. # validateBeaconBlockBellatrix() don't have parent BlockRef.
if signed_beacon_block.message.is_execution_block or if signed_beacon_block.message.is_execution_block or
@ -831,7 +831,7 @@ proc validateVoluntaryExit*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#sync_committee_subnet_id # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#sync_committee_subnet_id
proc validateSyncCommitteeMessage*( proc validateSyncCommitteeMessage*(
dag: ChainDAGRef, dag: ChainDAGRef,
batchCrypto: ref BatchCrypto, batchCrypto: ref BatchCrypto,
@ -1036,7 +1036,7 @@ proc validateContribution*(
return ok((sig, participants)) return ok((sig, participants))
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#light_client_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientFinalityUpdate, finality_update: altair.LightClientFinalityUpdate,
@ -1064,7 +1064,7 @@ proc validateLightClientFinalityUpdate*(
pool.latestForwardedFinalitySlot = finalized_slot pool.latestForwardedFinalitySlot = finalized_slot
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientOptimisticUpdate, optimistic_update: altair.LightClientOptimisticUpdate,

View File

@ -431,7 +431,7 @@ func toValidationError(
# `attested_header.slot` was already forwarded on the network. # `attested_header.slot` was already forwarded on the network.
errIgnore($r.error) errIgnore($r.error)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientFinalityUpdate finality_update: altair.LightClientFinalityUpdate
@ -444,7 +444,7 @@ proc processLightClientFinalityUpdate*(
self.latestFinalityUpdate = finality_update.toOptimistic self.latestFinalityUpdate = finality_update.toOptimistic
v v
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#process_light_client_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientOptimisticUpdate optimistic_update: altair.LightClientOptimisticUpdate

View File

@ -2127,7 +2127,7 @@ proc getPersistentNetKeys*(
func gossipId( func gossipId(
data: openArray[byte], altairPrefix, topic: string): seq[byte] = data: openArray[byte], altairPrefix, topic: string): seq[byte] =
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#topics-and-messages # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#topics-and-messages
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#topics-and-messages # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#topics-and-messages
const const
MESSAGE_DOMAIN_INVALID_SNAPPY = [0x00'u8, 0x00, 0x00, 0x00] MESSAGE_DOMAIN_INVALID_SNAPPY = [0x00'u8, 0x00, 0x00, 0x00]
MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00] MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
@ -2493,7 +2493,7 @@ proc broadcastAttestation*(
node: Eth2Node, subnet_id: SubnetId, attestation: Attestation): node: Eth2Node, subnet_id: SubnetId, attestation: Attestation):
Future[SendResult] = Future[SendResult] =
# Regardless of the contents of the attestation, # Regardless of the contents of the attestation,
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#transitioning-the-gossip # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#transitioning-the-gossip
# implies that pre-fork, messages using post-fork digests might be # implies that pre-fork, messages using post-fork digests might be
# ignored, whilst post-fork, there is effectively a seen_ttl-based # ignored, whilst post-fork, there is effectively a seen_ttl-based
# timer unsubscription point that means no new pre-fork-forkdigest # timer unsubscription point that means no new pre-fork-forkdigest

View File

@ -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.2.0-rc.2/presets/mainnet/phase0.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:
@ -90,7 +90,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.2.0-rc.2/presets/mainnet/altair.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:
@ -106,7 +106,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.2.0-rc.2/presets/mainnet/bellatrix.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:
@ -186,7 +186,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.2.0-rc.2/specs/phase0/beacon-chain.md#constants # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#constants
# GENESIS_SLOT # GENESIS_SLOT
# GENESIS_EPOCH # GENESIS_EPOCH
# FAR_FUTURE_EPOCH # FAR_FUTURE_EPOCH
@ -213,7 +213,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
DOMAIN_AGGREGATE_AND_PROOF: DOMAIN_AGGREGATE_AND_PROOF:
to0xHex(DOMAIN_AGGREGATE_AND_PROOF.data), to0xHex(DOMAIN_AGGREGATE_AND_PROOF.data),
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#constants # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#constants
TIMELY_SOURCE_FLAG_INDEX: TIMELY_SOURCE_FLAG_INDEX:
to0xHex([byte(TIMELY_SOURCE_FLAG_INDEX)]), to0xHex([byte(TIMELY_SOURCE_FLAG_INDEX)]),
TIMELY_TARGET_FLAG_INDEX: TIMELY_TARGET_FLAG_INDEX:

View File

@ -46,7 +46,7 @@ const
GENESIS_SLOT* = Slot(0) GENESIS_SLOT* = Slot(0)
GENESIS_EPOCH* = Epoch(0) # compute_epoch_at_slot(GENESIS_SLOT) GENESIS_EPOCH* = Epoch(0) # compute_epoch_at_slot(GENESIS_SLOT)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#constant # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#constant
INTERVALS_PER_SLOT* = 3 INTERVALS_PER_SLOT* = 3
FAR_FUTURE_BEACON_TIME* = BeaconTime(ns_since_genesis: int64.high()) FAR_FUTURE_BEACON_TIME* = BeaconTime(ns_since_genesis: int64.high())
@ -149,10 +149,10 @@ const
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/altair/validator.md#broadcast-sync-committee-contribution # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/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.2.0-rc.2/specs/altair/light-client/p2p-interface.md#sync-committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/altair/light-client/p2p-interface.md#sync-committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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)
@ -186,13 +186,13 @@ 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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_epoch_at_slot # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
else: Epoch(slot div SLOTS_PER_EPOCH) else: Epoch(slot div SLOTS_PER_EPOCH)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/fork-choice.md#compute_slots_since_epoch_start # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/fork-choice.md#compute_slots_since_epoch_start
func since_epoch_start*(slot: Slot): uint64 = # aka compute_slots_since_epoch_start func since_epoch_start*(slot: Slot): uint64 = # aka compute_slots_since_epoch_start
## How many slots since the beginning of the epoch (`[0..SLOTS_PER_EPOCH-1]`) ## How many slots since the beginning of the epoch (`[0..SLOTS_PER_EPOCH-1]`)
(slot mod SLOTS_PER_EPOCH) (slot mod SLOTS_PER_EPOCH)
@ -200,14 +200,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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#get_previous_epoch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:

View File

@ -21,7 +21,7 @@ import
export extras, forks, validator export extras, forks, validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#increase_balance # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -31,7 +31,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.2.0-rc.2/specs/phase0/beacon-chain.md#decrease_balance # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:
@ -46,8 +46,8 @@ 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.2.0-rc.2/specs/phase0/beacon-chain.md#deposits # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#deposits
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#modified-process_deposit # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#modified-process_deposit
func get_validator_from_deposit*(deposit: DepositData): func get_validator_from_deposit*(deposit: DepositData):
Validator = Validator =
let let
@ -65,13 +65,13 @@ func get_validator_from_deposit*(deposit: DepositData):
effective_balance: effective_balance effective_balance: effective_balance
) )
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#compute_activation_exit_epoch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#get_validator_churn_limit # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 =
@ -81,7 +81,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.2.0-rc.2/specs/phase0/beacon-chain.md#initiate_validator_exit # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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] =
@ -130,8 +130,8 @@ func initiate_validator_exit*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#modified-slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator
func get_slashing_penalty*(state: ForkyBeaconState, func get_slashing_penalty*(state: ForkyBeaconState,
validator_effective_balance: Gwei): Gwei = validator_effective_balance: Gwei): Gwei =
@ -146,14 +146,14 @@ func get_slashing_penalty*(state: ForkyBeaconState,
else: else:
{.fatal: "invalid BeaconState type".} {.fatal: "invalid BeaconState type".}
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#modified-slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/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.2.0-rc.2/specs/phase0/beacon-chain.md#slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#modified-slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/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 =
when state is phase0.BeaconState: when state is phase0.BeaconState:
@ -163,8 +163,8 @@ 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.2.0-rc.2/specs/phase0/beacon-chain.md#slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#modified-slash_validator
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.1/specs/bellatrix/beacon-chain.md#modified-slash_validator
proc slash_validator*( proc slash_validator*(
cfg: RuntimeConfig, state: var ForkyBeaconState, cfg: RuntimeConfig, state: var ForkyBeaconState,
@ -218,7 +218,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.2.0-rc.2/specs/phase0/beacon-chain.md#genesis # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -320,7 +320,7 @@ proc initialize_hashed_beacon_state_from_eth1*(
cfg, eth1_block_hash, eth1_timestamp, deposits, flags)) cfg, eth1_block_hash, eth1_timestamp, deposits, flags))
result.root = hash_tree_root(result.data) result.root = hash_tree_root(result.data)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#genesis-block # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -332,7 +332,7 @@ func get_initial_beacon_block*(state: phase0.HashedBeaconState):
phase0.TrustedSignedBeaconBlock( phase0.TrustedSignedBeaconBlock(
message: message, root: hash_tree_root(message)) message: message, root: hash_tree_root(message))
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#initialize-state-for-pure-altair-testnets-and-test-vectors # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#initialize-state-for-pure-altair-testnets-and-test-vectors
func get_initial_beacon_block*(state: altair.HashedBeaconState): func get_initial_beacon_block*(state: altair.HashedBeaconState):
altair.TrustedSignedBeaconBlock = altair.TrustedSignedBeaconBlock =
# The genesis block is implicitly trusted # The genesis block is implicitly trusted
@ -361,7 +361,7 @@ func get_initial_beacon_block*(state: ForkedHashedBeaconState):
withState(state): withState(state):
ForkedTrustedSignedBeaconBlock.init(get_initial_beacon_block(state)) ForkedTrustedSignedBeaconBlock.init(get_initial_beacon_block(state))
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_block_root_at_slot # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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``.
@ -379,7 +379,7 @@ func get_block_root_at_slot*(
withState(state): withState(state):
get_block_root_at_slot(state.data, slot) get_block_root_at_slot(state.data, slot)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_block_root # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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())
@ -389,7 +389,7 @@ func get_block_root*(state: ForkedHashedBeaconState, epoch: Epoch): Eth2Digest =
withState(state): withState(state):
get_block_root(state.data, epoch) get_block_root(state.data, epoch)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_total_balance # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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``.
@ -400,13 +400,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.2.0-rc.2/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#is_eligible_for_activation # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.
@ -416,7 +416,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.2.0-rc.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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] =
@ -454,7 +454,7 @@ proc is_valid_indexed_attestation*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_attesting_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -519,7 +519,7 @@ proc is_valid_indexed_attestation*(
# Attestation validation # Attestation validation
# ------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#attestations # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#attestations
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/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] =
@ -562,7 +562,7 @@ func check_attestation_index*(
Result[CommitteeIndex, cstring] = Result[CommitteeIndex, cstring] =
check_attestation_index(data.index, committees_per_slot) check_attestation_index(data.index, committees_per_slot)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices
func get_attestation_participation_flag_indices(state: altair.BeaconState | bellatrix.BeaconState, func get_attestation_participation_flag_indices(state: altair.BeaconState | bellatrix.BeaconState,
data: AttestationData, data: AttestationData,
inclusion_delay: uint64): seq[int] = inclusion_delay: uint64): seq[int] =
@ -596,7 +596,7 @@ func get_attestation_participation_flag_indices(state: altair.BeaconState | bell
# 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.2.0-rc.2/specs/phase0/beacon-chain.md#get_total_active_balance # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -607,7 +607,7 @@ func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache):
get_total_balance( get_total_balance(
state, cache.get_shuffled_active_validator_indices(state, epoch)) state, cache.get_shuffled_active_validator_indices(state, epoch))
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#get_base_reward_per_increment # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#get_base_reward_per_increment
func get_base_reward_per_increment_sqrt*( func get_base_reward_per_increment_sqrt*(
total_active_balance_sqrt: uint64): Gwei = total_active_balance_sqrt: uint64): Gwei =
EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div total_active_balance_sqrt EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div total_active_balance_sqrt
@ -616,7 +616,7 @@ func get_base_reward_per_increment*(
total_active_balance: Gwei): Gwei = total_active_balance: Gwei): Gwei =
get_base_reward_per_increment_sqrt(integer_squareroot(total_active_balance)) get_base_reward_per_increment_sqrt(integer_squareroot(total_active_balance))
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#get_base_reward # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#get_base_reward
func get_base_reward( func get_base_reward(
state: altair.BeaconState | bellatrix.BeaconState, index: ValidatorIndex, state: altair.BeaconState | bellatrix.BeaconState, index: ValidatorIndex,
base_reward_per_increment: Gwei): Gwei = base_reward_per_increment: Gwei): Gwei =
@ -626,7 +626,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.2.0-rc.2/specs/phase0/beacon-chain.md#attestations # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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] =
@ -740,7 +740,7 @@ proc process_attestation*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#get_next_sync_committee_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#get_next_sync_committee_indices
func get_next_sync_committee_keys(state: altair.BeaconState | bellatrix.BeaconState): func get_next_sync_committee_keys(state: altair.BeaconState | bellatrix.BeaconState):
array[SYNC_COMMITTEE_SIZE, ValidatorPubKey] = array[SYNC_COMMITTEE_SIZE, ValidatorPubKey] =
## Return the sequence of sync committee indices, with possible duplicates, ## Return the sequence of sync committee indices, with possible duplicates,
@ -776,7 +776,7 @@ func get_next_sync_committee_keys(state: altair.BeaconState | bellatrix.BeaconSt
i += 1'u64 i += 1'u64
res res
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#get_next_sync_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#get_next_sync_committee
func get_next_sync_committee*(state: altair.BeaconState | bellatrix.BeaconState): func get_next_sync_committee*(state: altair.BeaconState | bellatrix.BeaconState):
SyncCommittee = SyncCommittee =
## Return the *next* sync committee for a given ``state``. ## Return the *next* sync committee for a given ``state``.

View File

@ -96,7 +96,7 @@ export
# API # API
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#bls-signatures # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -204,7 +204,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.2.0-rc.2/specs/phase0/beacon-chain.md#bls-signatures # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 =
@ -217,7 +217,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.2.0-rc.2/specs/phase0/beacon-chain.md#bls-signatures # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 =

View File

@ -30,7 +30,7 @@ from ssz_serialization/proofs import GeneralizedIndex
export proofs.GeneralizedIndex export proofs.GeneralizedIndex
const const
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#incentivization-weights # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#incentivization-weights
TIMELY_SOURCE_WEIGHT* = 14 TIMELY_SOURCE_WEIGHT* = 14
TIMELY_TARGET_WEIGHT* = 26 TIMELY_TARGET_WEIGHT* = 26
TIMELY_HEAD_WEIGHT* = 14 TIMELY_HEAD_WEIGHT* = 14
@ -45,22 +45,22 @@ const
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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#constants # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/ssz/merkle-proofs.md # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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`
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#participation-flag-indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#participation-flag-indices
TIMELY_SOURCE_FLAG_INDEX* = 0 TIMELY_SOURCE_FLAG_INDEX* = 0
TIMELY_TARGET_FLAG_INDEX* = 1 TIMELY_TARGET_FLAG_INDEX* = 1
TIMELY_HEAD_FLAG_INDEX* = 2 TIMELY_HEAD_FLAG_INDEX* = 2
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#inactivity-penalties # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#inactivity-penalties
INACTIVITY_SCORE_BIAS* = 4 INACTIVITY_SCORE_BIAS* = 4
INACTIVITY_SCORE_RECOVERY_RATE* = 16 INACTIVITY_SCORE_RECOVERY_RATE* = 16
@ -74,13 +74,13 @@ static: doAssert TIMELY_SOURCE_WEIGHT + TIMELY_TARGET_WEIGHT +
type type
### New types ### New types
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#custom-types # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#custom-types
ParticipationFlags* = uint8 ParticipationFlags* = uint8
EpochParticipationFlags* = EpochParticipationFlags* =
distinct HashList[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT] distinct HashList[ParticipationFlags, Limit VALIDATOR_REGISTRY_LIMIT]
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#syncaggregate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#syncaggregate
SyncAggregate* = object SyncAggregate* = object
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE] sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
sync_committee_signature*: ValidatorSig sync_committee_signature*: ValidatorSig
@ -89,7 +89,7 @@ type
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE] sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
sync_committee_signature*: TrustedSig sync_committee_signature*: TrustedSig
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#synccommittee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#synccommittee
SyncCommittee* = object SyncCommittee* = object
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey] pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
aggregate_pubkey*: ValidatorPubKey aggregate_pubkey*: ValidatorPubKey
@ -157,7 +157,7 @@ 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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#lightclientbootstrap # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#lightclientbootstrap
LightClientBootstrap* = object LightClientBootstrap* = object
header*: BeaconBlockHeader header*: BeaconBlockHeader
## The requested beacon block header ## The requested beacon block header
@ -166,7 +166,7 @@ type
## Current sync committee corresponding to `header` ## Current sync committee corresponding to `header`
current_sync_committee_branch*: CurrentSyncCommitteeBranch current_sync_committee_branch*: CurrentSyncCommitteeBranch
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#lightclientupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#lightclientupdate
LightClientUpdate* = object LightClientUpdate* = object
attested_header*: BeaconBlockHeader attested_header*: BeaconBlockHeader
## The beacon block header that is attested to by the sync committee ## The beacon block header that is attested to by the sync committee
@ -184,7 +184,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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
LightClientFinalityUpdate* = object LightClientFinalityUpdate* = object
# The beacon block header that is attested to by the sync committee # The beacon block header that is attested to by the sync committee
attested_header*: BeaconBlockHeader attested_header*: BeaconBlockHeader
@ -198,7 +198,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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#lightclientoptimisticupdate
LightClientOptimisticUpdate* = object LightClientOptimisticUpdate* = object
# The beacon block header that is attested to by the sync committee # The beacon block header that is attested to by the sync committee
attested_header*: BeaconBlockHeader attested_header*: BeaconBlockHeader
@ -224,7 +224,7 @@ type
LightClientBootstrap | LightClientBootstrap |
SomeLightClientUpdate SomeLightClientUpdate
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#lightclientstore # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#lightclientstore
LightClientStore* = object LightClientStore* = object
finalized_header*: BeaconBlockHeader finalized_header*: BeaconBlockHeader
## Beacon block header that is finalized ## Beacon block header that is finalized
@ -244,7 +244,7 @@ type
## safety threshold) ## safety threshold)
current_max_active_participants*: uint64 current_max_active_participants*: uint64
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#beaconstate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#beaconstate
BeaconState* = object BeaconState* = object
# Versioning # Versioning
genesis_time*: uint64 genesis_time*: uint64
@ -329,7 +329,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.2.0-rc.2/specs/phase0/beacon-chain.md#beaconblock # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -386,7 +386,7 @@ type
state_root*: Eth2Digest state_root*: Eth2Digest
body*: TrustedBeaconBlockBody body*: TrustedBeaconBlockBody
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#beaconblockbody # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#beaconblockbody
BeaconBlockBody* = object BeaconBlockBody* = object
randao_reveal*: ValidatorSig randao_reveal*: ValidatorSig
eth1_data*: Eth1Data eth1_data*: Eth1Data
@ -435,7 +435,7 @@ type
SyncnetBits* = BitArray[SYNC_COMMITTEE_SUBNET_COUNT] SyncnetBits* = BitArray[SYNC_COMMITTEE_SUBNET_COUNT]
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#metadata # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#metadata
MetaData* = object MetaData* = object
seq_number*: uint64 seq_number*: uint64
attnets*: AttnetBits attnets*: AttnetBits
@ -457,7 +457,7 @@ type
# [New in Altair] # [New in Altair]
sync_aggregate*: TrustedSyncAggregate sync_aggregate*: TrustedSyncAggregate
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#signedbeaconblock # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#signedbeaconblock
SignedBeaconBlock* = object SignedBeaconBlock* = object
message*: BeaconBlock message*: BeaconBlock
signature*: ValidatorSig signature*: ValidatorSig

View File

@ -136,7 +136,7 @@ type
# --------------------------------------------------------------- # ---------------------------------------------------------------
DomainType* = distinct array[4, byte] DomainType* = distinct array[4, byte]
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#custom-types # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#custom-types
Eth2Domain* = array[32, byte] Eth2Domain* = array[32, byte]
ValidatorIndex* = distinct uint32 ValidatorIndex* = distinct uint32
@ -183,7 +183,7 @@ type
# SSZ / hashing purposes # SSZ / hashing purposes
JustificationBits* = distinct uint8 JustificationBits* = distinct uint8
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#proposerslashing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -195,7 +195,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.2.0-rc.2/specs/phase0/beacon-chain.md#attesterslashing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#attesterslashing
AttesterSlashing* = object AttesterSlashing* = object
attestation_1*: IndexedAttestation attestation_1*: IndexedAttestation
attestation_2*: IndexedAttestation attestation_2*: IndexedAttestation
@ -207,7 +207,7 @@ type
attestation_1*: TrustedIndexedAttestation attestation_1*: TrustedIndexedAttestation
attestation_2*: TrustedIndexedAttestation attestation_2*: TrustedIndexedAttestation
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#indexedattestation # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -223,7 +223,7 @@ type
CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE] CommitteeValidatorsBits* = BitList[Limit MAX_VALIDATORS_PER_COMMITTEE]
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#attestation # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#attestation
Attestation* = object Attestation* = object
aggregation_bits*: CommitteeValidatorsBits aggregation_bits*: CommitteeValidatorsBits
data*: AttestationData data*: AttestationData
@ -239,17 +239,17 @@ type
ForkDigest* = distinct array[4, byte] ForkDigest* = distinct array[4, byte]
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#forkdata # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#checkpoint # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#AttestationData # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#AttestationData
AttestationData* = object AttestationData* = object
slot*: Slot slot*: Slot
@ -262,20 +262,20 @@ type
source*: Checkpoint source*: Checkpoint
target*: Checkpoint target*: Checkpoint
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#deposit # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#depositmessage # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#depositdata # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#depositdata
DepositData* = object DepositData* = object
pubkey*: ValidatorPubKey pubkey*: ValidatorPubKey
withdrawal_credentials*: Eth2Digest withdrawal_credentials*: Eth2Digest
@ -284,7 +284,7 @@ type
# if the deposit should be added or not during processing # if the deposit should be added or not during processing
signature*: ValidatorSig # Signing over DepositMessage signature*: ValidatorSig # Signing over DepositMessage
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#voluntaryexit # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -312,7 +312,7 @@ type
pubkey*: CookedPubKey pubkey*: CookedPubKey
withdrawal_credentials*: Eth2Digest withdrawal_credentials*: Eth2Digest
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#validator
Validator* = object Validator* = object
pubkey*: ValidatorPubKey pubkey*: ValidatorPubKey
@ -334,7 +334,7 @@ type
withdrawable_epoch*: Epoch withdrawable_epoch*: Epoch
## When validator can withdraw or transfer funds ## When validator can withdraw or transfer funds
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#pendingattestation # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#pendingattestation
PendingAttestation* = object PendingAttestation* = object
aggregation_bits*: CommitteeValidatorsBits aggregation_bits*: CommitteeValidatorsBits
data*: AttestationData data*: AttestationData
@ -343,12 +343,12 @@ type
proposer_index*: uint64 # `ValidatorIndex` after validation proposer_index*: uint64 # `ValidatorIndex` after validation
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#historicalbatch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#fork # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#fork
Fork* = object Fork* = object
previous_version*: Version previous_version*: Version
current_version*: Version current_version*: Version
@ -356,13 +356,13 @@ type
epoch*: Epoch epoch*: Epoch
## Epoch of latest fork ## Epoch of latest fork
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#eth1data # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#signedvoluntaryexit # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#signedvoluntaryexit
SignedVoluntaryExit* = object SignedVoluntaryExit* = object
message*: VoluntaryExit message*: VoluntaryExit
signature*: ValidatorSig signature*: ValidatorSig
@ -371,7 +371,7 @@ type
message*: VoluntaryExit message*: VoluntaryExit
signature*: TrustedSig signature*: TrustedSig
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beaconblockheader # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -379,14 +379,14 @@ type
state_root*: Eth2Digest state_root*: Eth2Digest
body_root*: Eth2Digest body_root*: Eth2Digest
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#signingdata # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#signedbeaconblockheader # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#signedbeaconblockheader
SignedBeaconBlockHeader* = object SignedBeaconBlockHeader* = object
message*: BeaconBlockHeader message*: BeaconBlockHeader
signature*: ValidatorSig signature*: ValidatorSig
@ -418,12 +418,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.2.0-rc.2/solidity_deposit_contract/deposit_contract.sol # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -514,7 +514,7 @@ type
flags*: set[RewardFlags] flags*: set[RewardFlags]
const const
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#domain-types # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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])
@ -524,7 +524,7 @@ const
DOMAIN_AGGREGATE_AND_PROOF* = DomainType([byte 0x06, 0x00, 0x00, 0x00]) DOMAIN_AGGREGATE_AND_PROOF* = DomainType([byte 0x06, 0x00, 0x00, 0x00])
DOMAIN_APPLICATION_MASK* = DomainType([byte 0x00, 0x00, 0x00, 0x01]) DOMAIN_APPLICATION_MASK* = DomainType([byte 0x00, 0x00, 0x00, 0x01])
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#domain-types # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#domain-types
DOMAIN_SYNC_COMMITTEE* = DomainType([byte 0x07, 0x00, 0x00, 0x00]) DOMAIN_SYNC_COMMITTEE* = DomainType([byte 0x07, 0x00, 0x00, 0x00])
DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF* = DomainType([byte 0x08, 0x00, 0x00, 0x00]) DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF* = DomainType([byte 0x08, 0x00, 0x00, 0x00])
DOMAIN_CONTRIBUTION_AND_PROOF* = DomainType([byte 0x09, 0x00, 0x00, 0x00]) DOMAIN_CONTRIBUTION_AND_PROOF* = DomainType([byte 0x09, 0x00, 0x00, 0x00])

View File

@ -164,7 +164,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.2.0-rc.2/specs/phase0/beacon-chain.md#beaconblock # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -290,7 +290,7 @@ type
# Execution # Execution
execution_payload*: ExecutionPayload # [New in Bellatrix] execution_payload*: ExecutionPayload # [New in Bellatrix]
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#signedbeaconblock # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#signedbeaconblock
SignedBeaconBlock* = object SignedBeaconBlock* = object
message*: BeaconBlock message*: BeaconBlock
signature*: ValidatorSig signature*: ValidatorSig

View File

@ -25,7 +25,7 @@ import
export base export base
type type
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beaconstate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#beaconstate
BeaconState* = object BeaconState* = object
# Versioning # Versioning
genesis_time*: uint64 genesis_time*: uint64
@ -75,7 +75,7 @@ type
current_justified_checkpoint*: Checkpoint current_justified_checkpoint*: Checkpoint
finalized_checkpoint*: Checkpoint finalized_checkpoint*: Checkpoint
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_total_balance # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.
@ -112,7 +112,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.2.0-rc.2/specs/phase0/beacon-chain.md#beaconblock # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -173,7 +173,7 @@ type
state_root*: Eth2Digest state_root*: Eth2Digest
body*: TrustedBeaconBlockBody body*: TrustedBeaconBlockBody
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beaconblockbody # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#beaconblockbody
BeaconBlockBody* = object BeaconBlockBody* = object
randao_reveal*: ValidatorSig randao_reveal*: ValidatorSig
eth1_data*: Eth1Data eth1_data*: Eth1Data
@ -222,7 +222,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.2.0-rc.2/specs/phase0/beacon-chain.md#signedbeaconblock # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#signedbeaconblock
SignedBeaconBlock* = object SignedBeaconBlock* = object
message*: BeaconBlock message*: BeaconBlock
signature*: ValidatorSig signature*: ValidatorSig

View File

@ -7,7 +7,7 @@
# Serenity hash function / digest # Serenity hash function / digest
# #
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#hash # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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)

View File

@ -257,7 +257,7 @@ type
of BeaconBlockFork.Bellatrix: bellatrixBody*: bellatrix.BeaconBlockBody of BeaconBlockFork.Bellatrix: bellatrixBody*: bellatrix.BeaconBlockBody
RestSpec* = object RestSpec* = object
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/presets/mainnet/phase0.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -292,7 +292,7 @@ type
MAX_DEPOSITS*: uint64 MAX_DEPOSITS*: uint64
MAX_VOLUNTARY_EXITS*: uint64 MAX_VOLUNTARY_EXITS*: uint64
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/presets/mainnet/altair.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -301,7 +301,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.2.0-rc.2/presets/mainnet/bellatrix.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -343,7 +343,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.2.0-rc.2/specs/phase0/beacon-chain.md#constants # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#constants
# GENESIS_SLOT # GENESIS_SLOT
# GENESIS_EPOCH # GENESIS_EPOCH
# FAR_FUTURE_EPOCH # FAR_FUTURE_EPOCH
@ -361,7 +361,7 @@ type
DOMAIN_SELECTION_PROOF*: DomainType DOMAIN_SELECTION_PROOF*: DomainType
DOMAIN_AGGREGATE_AND_PROOF*: DomainType DOMAIN_AGGREGATE_AND_PROOF*: DomainType
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#constants # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#constants
TIMELY_SOURCE_FLAG_INDEX*: byte TIMELY_SOURCE_FLAG_INDEX*: byte
TIMELY_TARGET_FLAG_INDEX*: byte TIMELY_TARGET_FLAG_INDEX*: byte
TIMELY_HEAD_FLAG_INDEX*: byte TIMELY_HEAD_FLAG_INDEX*: byte

View File

@ -648,7 +648,7 @@ func toBeaconBlockFork*(fork: BeaconStateFork): BeaconBlockFork =
of BeaconStateFork.Altair: BeaconBlockFork.Altair of BeaconStateFork.Altair: BeaconBlockFork.Altair
of BeaconStateFork.Bellatrix: BeaconBlockFork.Bellatrix of BeaconStateFork.Bellatrix: BeaconBlockFork.Bellatrix
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#compute_fork_data_root # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -660,7 +660,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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_fork_digest # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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

View File

@ -43,7 +43,7 @@ func shortLog*(v: FinalityCheckpoints): auto =
chronicles.formatIt FinalityCheckpoints: it.shortLog chronicles.formatIt FinalityCheckpoints: it.shortLog
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#integer_squareroot # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -56,7 +56,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.2.0-rc.2/specs/phase0/beacon-chain.md#is_active_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -68,7 +68,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_active_validator_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:
@ -94,23 +94,23 @@ func get_active_validator_indices_len*(
withState(state): withState(state):
get_active_validator_indices_len(state.data, epoch) get_active_validator_indices_len(state.data, epoch)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_current_epoch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#get_current_epoch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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(state.data) withState(state): get_current_epoch(state.data)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_previous_epoch # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#get_randao_mix # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 =
## Returns the randao mix at a recent ``epoch``. ## Returns 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]
@ -126,7 +126,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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_domain # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -141,7 +141,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_domain # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#get_domain
func get_domain*( func get_domain*(
fork: Fork, fork: Fork,
domain_type: DomainType, domain_type: DomainType,
@ -162,7 +162,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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_signing_root # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 of an object by calculating the root of the ## Return the signing root of an object by calculating the root of the
## object-domain tree. ## object-domain tree.
@ -172,7 +172,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_seed # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#get_seed
func get_seed*(state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType): func get_seed*(state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType):
Eth2Digest = Eth2Digest =
## Return the seed at ``epoch``. ## Return the seed at ``epoch``.
@ -190,42 +190,42 @@ func get_seed*(state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType):
epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1).data epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1).data
eth2digest(seed_input) eth2digest(seed_input)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#add_flag # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#add_flag
func add_flag*(flags: ParticipationFlags, flag_index: int): ParticipationFlags = func add_flag*(flags: ParticipationFlags, flag_index: int): ParticipationFlags =
let flag = ParticipationFlags(1'u8 shl flag_index) let flag = ParticipationFlags(1'u8 shl flag_index)
flags or flag flags or flag
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#has_flag # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#has_flag
func has_flag*(flags: ParticipationFlags, flag_index: int): bool = 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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#is_sync_committee_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#is_sync_committee_update
template is_sync_committee_update*(update: SomeLightClientUpdate): bool = template is_sync_committee_update*(update: SomeLightClientUpdate): bool =
when update is SomeLightClientUpdateWithSyncCommittee: when update is SomeLightClientUpdateWithSyncCommittee:
not isZeroMemory(update.next_sync_committee_branch) not isZeroMemory(update.next_sync_committee_branch)
else: else:
false false
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#is_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#is_finality_update
template is_finality_update*(update: SomeLightClientUpdate): bool = template is_finality_update*(update: SomeLightClientUpdate): bool =
when update is SomeLightClientUpdateWithFinality: when update is SomeLightClientUpdateWithFinality:
not isZeroMemory(update.finality_branch) not isZeroMemory(update.finality_branch)
else: else:
false false
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
template is_next_sync_committee_known*(store: LightClientStore): bool = template is_next_sync_committee_known*(store: LightClientStore): bool =
not isZeroMemory(store.next_sync_committee) not isZeroMemory(store.next_sync_committee)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#get_safety_threshold # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#get_safety_threshold
func get_safety_threshold*(store: LightClientStore): uint64 = func get_safety_threshold*(store: LightClientStore): 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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#is_better_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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

View File

@ -18,7 +18,7 @@ import
from ../consensus_object_pools/block_pools_types import BlockError from ../consensus_object_pools/block_pools_types import BlockError
export block_pools_types.BlockError export block_pools_types.BlockError
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#initialize_light_client_store # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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: altair.LightClientBootstrap bootstrap: altair.LightClientBootstrap
@ -39,7 +39,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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#validate_light_client_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#validate_light_client_update
proc validate_light_client_update*( proc validate_light_client_update*(
store: LightClientStore, store: LightClientStore,
update: SomeLightClientUpdate, update: SomeLightClientUpdate,
@ -148,7 +148,7 @@ proc validate_light_client_update*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#apply_light_client_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#apply_light_client_update
func apply_light_client_update( func apply_light_client_update(
store: var LightClientStore, store: var LightClientStore,
update: SomeLightClientUpdate): bool = update: SomeLightClientUpdate): bool =
@ -179,7 +179,7 @@ func apply_light_client_update(
didProgress = true didProgress = true
didProgress didProgress
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/sync-protocol.md#process_light_client_store_force_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#process_light_client_store_force_update
type type
ForceUpdateResult* = enum ForceUpdateResult* = enum
NoUpdate, NoUpdate,
@ -207,7 +207,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.2.0-rc.2/specs/altair/light-client/sync-protocol.md#process_light_client_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/sync-protocol.md#process_light_client_update
proc process_light_client_update*( proc process_light_client_update*(
store: var LightClientStore, store: var LightClientStore,
update: SomeLightClientUpdate, update: SomeLightClientUpdate,

View File

@ -30,7 +30,7 @@ const
TTFB_TIMEOUT* = 5.seconds TTFB_TIMEOUT* = 5.seconds
RESP_TIMEOUT* = 10.seconds RESP_TIMEOUT* = 10.seconds
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/bellatrix/p2p-interface.md#configuration # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/bellatrix/p2p-interface.md#configuration
GOSSIP_MAX_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes GOSSIP_MAX_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
MAX_CHUNK_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes MAX_CHUNK_SIZE_BELLATRIX* = 10 * 1024 * 1024 # bytes
@ -85,23 +85,23 @@ func getAttestationTopic*(forkDigest: ForkDigest,
## For subscribing and unsubscribing to/from a subnet. ## For subscribing and unsubscribing to/from a subnet.
eth2Prefix(forkDigest) & "beacon_attestation_" & $(subnetId) & "/ssz_snappy" eth2Prefix(forkDigest) & "beacon_attestation_" & $(subnetId) & "/ssz_snappy"
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#topics-and-messages # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#topics-and-messages
func getSyncCommitteeTopic*(forkDigest: ForkDigest, func getSyncCommitteeTopic*(forkDigest: ForkDigest,
subcommitteeIdx: SyncSubcommitteeIndex): string = subcommitteeIdx: SyncSubcommitteeIndex): string =
## For subscribing and unsubscribing to/from a subnet. ## For subscribing and unsubscribing to/from a subnet.
eth2Prefix(forkDigest) & "sync_committee_" & $subcommitteeIdx & "/ssz_snappy" eth2Prefix(forkDigest) & "sync_committee_" & $subcommitteeIdx & "/ssz_snappy"
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#topics-and-messages # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#topics-and-messages
func getSyncCommitteeContributionAndProofTopic*(forkDigest: ForkDigest): string = func getSyncCommitteeContributionAndProofTopic*(forkDigest: ForkDigest): string =
## For subscribing and unsubscribing to/from a subnet. ## For subscribing and unsubscribing to/from a subnet.
eth2Prefix(forkDigest) & "sync_committee_contribution_and_proof/ssz_snappy" eth2Prefix(forkDigest) & "sync_committee_contribution_and_proof/ssz_snappy"
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#light_client_finality_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/altair/light-client/p2p-interface.md#light_client_optimistic_update # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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"
@ -138,7 +138,7 @@ func getDiscoveryForkID*(cfg: RuntimeConfig,
next_fork_version: current_fork_version, next_fork_version: current_fork_version,
next_fork_epoch: FAR_FUTURE_EPOCH) next_fork_epoch: FAR_FUTURE_EPOCH)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/p2p-interface.md#transitioning-the-gossip # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/p2p-interface.md#transitioning-the-gossip
type GossipState* = set[BeaconStateFork] type GossipState* = set[BeaconStateFork]
func getTargetGossipState*( func getTargetGossipState*(
epoch, ALTAIR_FORK_EPOCH, BELLATRIX_FORK_EPOCH: Epoch, isBehind: bool): epoch, ALTAIR_FORK_EPOCH, BELLATRIX_FORK_EPOCH: Epoch, isBehind: bool):

View File

@ -15,7 +15,7 @@ import
stew/[byteutils], stint, web3/[ethtypes] stew/[byteutils], stint, web3/[ethtypes]
const const
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#withdrawal-prefixes # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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

View File

@ -1,5 +1,5 @@
# Mainnet preset - Altair # Mainnet preset - Altair
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/presets/mainnet/altair.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/presets/mainnet/altair.yaml
const const
# Updated penalty values # Updated penalty values
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

@ -1,5 +1,5 @@
# Mainnet preset - Bellatrix # Mainnet preset - Bellatrix
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/presets/mainnet/bellatrix.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/presets/mainnet/bellatrix.yaml
const const
# Updated penalty values # Updated penalty values
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

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

View File

@ -1,5 +1,5 @@
# Minimal preset - Altair # Minimal preset - Altair
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/presets/minimal/altair.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/presets/minimal/altair.yaml
const const
# Updated penalty values # Updated penalty values
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

@ -1,5 +1,5 @@
# Minimal preset - Bellatrix # Minimal preset - Bellatrix
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/presets/minimal/bellatrix.yaml # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/presets/minimal/bellatrix.yaml
const const
# Updated penalty values # Updated penalty values
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

@ -184,7 +184,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.2.0-rc.2/specs/phase0/beacon-chain.md#deposits # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 =

View File

@ -77,7 +77,7 @@ proc 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
# Eth2 spec requires at least one attesting index in attestation # Eth2 spec requires at least one attesting index in attestation
# - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation # - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#is_valid_indexed_attestation
return err("aggregateAttesters: no attesting indices") return err("aggregateAttesters: no attesting indices")
let let
@ -106,7 +106,7 @@ proc 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
# Eth2 spec requires at least one attesting index in attestation # Eth2 spec requires at least one attesting index in attestation
# - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#is_valid_indexed_attestation # - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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

View File

@ -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.2.0-rc.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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!
# #
@ -54,7 +54,7 @@ import
export results, extras, phase0, altair, bellatrix export results, extras, phase0, altair, bellatrix
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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] =
@ -71,7 +71,7 @@ proc verify_block_signature(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
func verifyStateRoot( func verifyStateRoot(
state: ForkyBeaconState, blck: ForkyBeaconBlock | ForkySigVerifiedBeaconBlock): state: ForkyBeaconState, blck: ForkyBeaconBlock | ForkySigVerifiedBeaconBlock):
Result[void, cstring] = Result[void, cstring] =
@ -100,7 +100,7 @@ func noRollback*() =
# Hashed-state transition functions # Hashed-state transition functions
# --------------------------------------------------------------- # ---------------------------------------------------------------
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -125,7 +125,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.2.0-rc.2/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,

View File

@ -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.2.0-rc.2/specs/phase0/beacon-chain.md#block-processing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#block-processing
# #
# The entry point is `process_block` which is at the bottom of this file. # The entry point is `process_block` which is at the bottom of this file.
# #
@ -31,7 +31,7 @@ import
export extras, phase0, altair export extras, phase0, altair
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#block-header # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#block-header
func process_block_header*( func process_block_header*(
state: var ForkyBeaconState, blck: SomeForkyBeaconBlock, flags: UpdateFlags, state: var ForkyBeaconState, blck: SomeForkyBeaconBlock, flags: UpdateFlags,
cache: var StateCache): Result[void, cstring] = cache: var StateCache): Result[void, cstring] =
@ -74,7 +74,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.2.0-rc.2/specs/phase0/beacon-chain.md#randao # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#randao
proc process_randao( proc process_randao(
state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody, flags: UpdateFlags, state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody, flags: UpdateFlags,
cache: var StateCache): Result[void, cstring] = cache: var StateCache): Result[void, cstring] =
@ -107,7 +107,7 @@ proc process_randao(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#eth1-data # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#eth1-data
func process_eth1_data(state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody): Result[void, cstring]= func process_eth1_data(state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody): Result[void, cstring]=
if not state.eth1_data_votes.add body.eth1_data: if not state.eth1_data_votes.add body.eth1_data:
# Count is reset in process_final_updates, so this should never happen # Count is reset in process_final_updates, so this should never happen
@ -118,14 +118,14 @@ func process_eth1_data(state: var ForkyBeaconState, body: SomeForkyBeaconBlockBo
state.eth1_data = body.eth1_data state.eth1_data = body.eth1_data
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#is_slashable_validator # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#proposer-slashings # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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):
@ -174,7 +174,7 @@ proc check_proposer_slashing*(
withState(state): withState(state):
check_proposer_slashing(state.data, proposer_slashing, flags) check_proposer_slashing(state.data, proposer_slashing, flags)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#proposer-slashings # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -184,7 +184,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.2.0-rc.2/specs/phase0/beacon-chain.md#is_slashable_attestation_data # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -196,7 +196,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.2.0-rc.2/specs/phase0/beacon-chain.md#attester-slashings # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -238,7 +238,7 @@ proc check_attester_slashing*(
withState(state): withState(state):
check_attester_slashing(state.data, attester_slashing, flags) check_attester_slashing(state.data, attester_slashing, flags)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#attester-slashings # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -321,7 +321,7 @@ proc process_deposit*(cfg: RuntimeConfig,
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#voluntary-exits # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#voluntary-exits
proc check_voluntary_exit*( proc check_voluntary_exit*(
cfg: RuntimeConfig, cfg: RuntimeConfig,
state: ForkyBeaconState, state: ForkyBeaconState,
@ -370,7 +370,7 @@ proc check_voluntary_exit*(
withState(state): withState(state):
check_voluntary_exit(cfg, state.data, signed_voluntary_exit, flags) check_voluntary_exit(cfg, state.data, signed_voluntary_exit, flags)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#voluntary-exits # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -382,7 +382,7 @@ proc process_voluntary_exit*(
? initiate_validator_exit(cfg, state, exited_validator, cache) ? initiate_validator_exit(cfg, state, exited_validator, cache)
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#operations # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#operations
proc process_operations(cfg: RuntimeConfig, proc process_operations(cfg: RuntimeConfig,
state: var ForkyBeaconState, state: var ForkyBeaconState,
body: SomeForkyBeaconBlockBody, body: SomeForkyBeaconBlockBody,
@ -412,7 +412,7 @@ proc process_operations(cfg: RuntimeConfig,
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#sync-committee-processing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#sync-committee-processing
func get_participant_reward*(total_active_balance: Gwei): Gwei = func get_participant_reward*(total_active_balance: Gwei): Gwei =
let let
total_active_increments = total_active_increments =
@ -427,7 +427,7 @@ func get_participant_reward*(total_active_balance: Gwei): Gwei =
func get_proposer_reward*(participant_reward: Gwei): Gwei = func get_proposer_reward*(participant_reward: Gwei): Gwei =
participant_reward * PROPOSER_WEIGHT div (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) participant_reward * PROPOSER_WEIGHT div (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#sync-committee-processing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#sync-committee-processing
proc process_sync_aggregate*( proc process_sync_aggregate*(
state: var (altair.BeaconState | bellatrix.BeaconState), state: var (altair.BeaconState | bellatrix.BeaconState),
sync_aggregate: SomeSyncAggregate, total_active_balance: Gwei, sync_aggregate: SomeSyncAggregate, total_active_balance: Gwei,
@ -525,7 +525,7 @@ proc process_execution_payload*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#block-processing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#block-processing
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095 # TODO workaround for https://github.com/nim-lang/Nim/issues/18095
# copy of datatypes/phase0.nim # copy of datatypes/phase0.nim
type SomePhase0Block = type SomePhase0Block =
@ -545,7 +545,7 @@ proc process_block*(
ok() ok()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/beacon-chain.md#block-processing # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/beacon-chain.md#block-processing
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095 # TODO workaround for https://github.com/nim-lang/Nim/issues/18095
# copy of datatypes/altair.nim # copy of datatypes/altair.nim
type SomeAltairBlock = type SomeAltairBlock =

View File

@ -25,8 +25,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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_shuffled_index # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#compute_shuffled_index
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#compute_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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) =
@ -156,13 +156,13 @@ func get_shuffled_active_validator_indices*(
withState(state): withState(state):
cache.get_shuffled_active_validator_indices(state.data, epoch) cache.get_shuffled_active_validator_indices(state.data, epoch)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_active_validator_indices # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/specs/phase0/beacon-chain.md#get_committee_count_per_slot # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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,
@ -187,7 +187,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.2.0-rc.2/specs/phase0/beacon-chain.md#compute_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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
@ -233,7 +233,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.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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) =
@ -273,7 +273,7 @@ func get_beacon_committee*(
withState(state): withState(state):
get_beacon_committee(state.data, slot, index, cache) get_beacon_committee(state.data, slot, index, cache)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_committee # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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 =
@ -296,7 +296,7 @@ func get_beacon_committee_len*(
withState(state): withState(state):
get_beacon_committee_len(state.data, slot, index, cache) get_beacon_committee_len(state.data, slot, index, cache)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#compute_shuffled_index # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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``).
@ -331,7 +331,7 @@ func compute_shuffled_index*(
cur_idx_permuted cur_idx_permuted
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#compute_proposer_index # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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): Option[ValidatorIndex] = indices: seq[ValidatorIndex], seed: Eth2Digest): Option[ValidatorIndex] =
## Return from ``indices`` a random index sampled by effective balance. ## Return from ``indices`` a random index sampled by effective balance.
@ -358,7 +358,7 @@ func compute_proposer_index(state: ForkyBeaconState,
return some(candidate_index) return some(candidate_index)
i += 1 i += 1
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_proposer_index # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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):
Option[ValidatorIndex] = Option[ValidatorIndex] =
@ -396,7 +396,7 @@ func get_beacon_proposer_index*(
return res return res
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#get_beacon_proposer_index # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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):
Option[ValidatorIndex] = Option[ValidatorIndex] =
get_beacon_proposer_index(state, cache, state.slot) get_beacon_proposer_index(state, cache, state.slot)

View File

@ -29,7 +29,7 @@ func compute_weak_subjectivity_period(
SAFETY_DECAY * validator_count div (2 * 100 * cfg.MIN_PER_EPOCH_CHURN_LIMIT) SAFETY_DECAY * validator_count div (2 * 100 * cfg.MIN_PER_EPOCH_CHURN_LIMIT)
return weak_subjectivity_period return weak_subjectivity_period
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/weak-subjectivity.md#checking-for-stale-weak-subjectivity-checkpoint # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/weak-subjectivity.md#checking-for-stale-weak-subjectivity-checkpoint
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 =

View File

@ -116,7 +116,7 @@ proc isGossipSupported*(
else: else:
period <= finalizedPeriod period <= finalizedPeriod
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
proc doRequest( proc doRequest(
e: typedesc[Bootstrap], e: typedesc[Bootstrap],
peer: Peer, peer: Peer,
@ -125,7 +125,7 @@ proc doRequest(
raises: [Defect, IOError].} = raises: [Defect, IOError].} =
peer.lightClientBootstrap(blockRoot) peer.lightClientBootstrap(blockRoot)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
type LightClientUpdatesByRangeResponse = NetRes[seq[altair.LightClientUpdate]] type LightClientUpdatesByRangeResponse = NetRes[seq[altair.LightClientUpdate]]
proc doRequest( proc doRequest(
e: typedesc[UpdatesByRange], e: typedesc[UpdatesByRange],
@ -165,7 +165,7 @@ proc doRequest(
inc expectedPeriod inc expectedPeriod
return response return response
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
proc doRequest( proc doRequest(
e: typedesc[FinalityUpdate], e: typedesc[FinalityUpdate],
peer: Peer peer: Peer
@ -173,7 +173,7 @@ proc doRequest(
raises: [Defect, IOError].} = raises: [Defect, IOError].} =
peer.lightClientFinalityUpdate() peer.lightClientFinalityUpdate()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
proc doRequest( proc doRequest(
e: typedesc[OptimisticUpdate], e: typedesc[OptimisticUpdate],
peer: Peer peer: Peer
@ -387,7 +387,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.2.0-rc.2/specs/altair/light-client/light-client.md#light-client-sync-process # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:

View File

@ -30,7 +30,7 @@ const
blockResponseCost = allowedOpsPerSecondCost(100) blockResponseCost = allowedOpsPerSecondCost(100)
blockByRangeLookupCost = allowedOpsPerSecondCost(20) blockByRangeLookupCost = allowedOpsPerSecondCost(20)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#configuration # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#configuration
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128 MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
lightClientEmptyResponseCost = allowedOpsPerSecondCost(50) lightClientEmptyResponseCost = allowedOpsPerSecondCost(50)
lightClientBootstrapLookupCost = allowedOpsPerSecondCost(5) lightClientBootstrapLookupCost = allowedOpsPerSecondCost(5)
@ -544,7 +544,7 @@ p2pProtocol BeaconSync(version = 1,
debug "Block root request done", debug "Block root request done",
peer, roots = blockRoots.len, count, found peer, roots = blockRoots.len, count, found
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#getlightclientbootstrap
proc lightClientBootstrap( proc lightClientBootstrap(
peer: Peer, peer: Peer,
blockRoot: Eth2Digest, blockRoot: Eth2Digest,
@ -572,7 +572,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.2.0-rc.2/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#lightclientupdatesbyrange
proc lightClientUpdatesByRange( proc lightClientUpdatesByRange(
peer: Peer, peer: Peer,
startPeriod: SyncCommitteePeriod, startPeriod: SyncCommitteePeriod,
@ -614,7 +614,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.2.0-rc.2/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#getlightclientfinalityupdate
proc lightClientFinalityUpdate( proc lightClientFinalityUpdate(
peer: Peer, peer: Peer,
response: SingleChunkResponse[altair.LightClientFinalityUpdate]) response: SingleChunkResponse[altair.LightClientFinalityUpdate])
@ -640,7 +640,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.2.0-rc.2/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
proc lightClientOptimisticUpdate( proc lightClientOptimisticUpdate(
peer: Peer, peer: Peer,
response: SingleChunkResponse[altair.LightClientOptimisticUpdate]) response: SingleChunkResponse[altair.LightClientOptimisticUpdate])

View File

@ -9,7 +9,7 @@ It is important to distinguish attestation `validation` from attestation `verifi
- Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof - Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
- Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id - Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/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.2.0-rc.2/specs/phase0/beacon-chain.md#attestations - https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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`.

View File

@ -9,7 +9,7 @@ Important distinction:
https://github.com/ethereum/consensus-specs/blob/v1.1.10/specs/phase0/p2p-interface.md#beacon_block. https://github.com/ethereum/consensus-specs/blob/v1.1.10/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.2.0-rc.2/specs/phase0/beacon-chain.md#block-processing https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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:

View File

@ -22,7 +22,7 @@ import
# Test utilities # Test utilities
../../testutil, ../../testblockutil ../../testutil, ../../testblockutil
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/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.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/light_client.py#L32-L62 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/helpers/light_client.py#L32-L62
proc get_sync_aggregate( proc get_sync_aggregate(
cfg: RuntimeConfig, cfg: RuntimeConfig,
forked: ForkedHashedBeaconState, forked: ForkedHashedBeaconState,
@ -157,7 +157,7 @@ suite "EF - Altair - Unittests - Light client - Sync protocol" & preset():
res res
genesisState = newClone(initGenesisState(cfg = cfg)) genesisState = newClone(initGenesisState(cfg = cfg))
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L23-L60 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L23-L60
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
@ -203,7 +203,7 @@ suite "EF - Altair - Unittests - Light client - Sync protocol" & preset():
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.2.0-rc.2/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L63-L104 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L63-L104
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
@ -256,7 +256,7 @@ suite "EF - Altair - Unittests - Light client - Sync protocol" & preset():
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.2.0-rc.2/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L107-L149 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L107-L149
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
@ -312,7 +312,7 @@ suite "EF - Altair - Unittests - Light client - Sync protocol" & preset():
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.2.0-rc.2/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L152-L201 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/altair/unittests/light_client/test_sync_protocol.py#L152-L201
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

View File

@ -16,7 +16,7 @@ import
# Routines for mocking blocks # Routines for mocking blocks
# --------------------------------------------------------------- # ---------------------------------------------------------------
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/block.py#L26-L35 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/helpers/block.py#L26-L35
func apply_randao_reveal(state: ForkyBeaconState, blck: var ForkySignedBeaconBlock) = func apply_randao_reveal(state: ForkyBeaconState, blck: var ForkySignedBeaconBlock) =
doAssert state.slot <= blck.message.slot doAssert state.slot <= blck.message.slot
let let
@ -29,7 +29,7 @@ func apply_randao_reveal(state: ForkyBeaconState, blck: var ForkySignedBeaconBlo
blck.message.slot.epoch, blck.message.slot.epoch,
privkey).toValidatorSig() privkey).toValidatorSig()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/block.py#L38-L54 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/helpers/block.py#L38-L54
func sign_block(state: ForkyBeaconState, blck: var ForkySignedBeaconBlock) = func sign_block(state: ForkyBeaconState, blck: var ForkySignedBeaconBlock) =
let let
proposer_index = blck.message.proposer_index.ValidatorIndex proposer_index = blck.message.proposer_index.ValidatorIndex
@ -43,7 +43,7 @@ func sign_block(state: ForkyBeaconState, blck: var ForkySignedBeaconBlock) =
blck.root, blck.root,
privkey).toValidatorSig() privkey).toValidatorSig()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/block.py#L75-L104 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/helpers/block.py#L75-L104
proc mockBlock*( proc mockBlock*(
state: ForkedHashedBeaconState, state: ForkedHashedBeaconState,
slot: Slot, slot: Slot,
@ -83,7 +83,7 @@ proc mockBlock*(
sign_block(state.data, blck) sign_block(state.data, blck)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/block.py#L107-L108 # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/helpers/block.py#L107-L108
proc mockBlockForNextSlot*( proc mockBlockForNextSlot*(
state: ForkedHashedBeaconState): ForkedSignedBeaconBlock = state: ForkedHashedBeaconState): ForkedSignedBeaconBlock =
## Mock a BeaconBlock for the next slot ## Mock a BeaconBlock for the next slot

View File

@ -7,7 +7,7 @@
# process_deposit (beaconstate.nim) # process_deposit (beaconstate.nim)
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/specs/phase0/beacon-chain.md#deposits # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/specs/phase0/beacon-chain.md#deposits
# --------------------------------------------------------------- # ---------------------------------------------------------------
{.used.} {.used.}

View File

@ -22,7 +22,7 @@ const
MockPrivKeys* = MockPrivKeysT() MockPrivKeys* = MockPrivKeysT()
MockPubKeys* = MockPubKeysT() MockPubKeys* = MockPubKeysT()
# https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.2/tests/core/pyspec/eth2spec/test/helpers/keys.py # https://github.com/ethereum/consensus-specs/blob/v1.2.0-rc.3/tests/core/pyspec/eth2spec/test/helpers/keys.py
func `[]`*(_: MockPrivKeysT, index: ValidatorIndex): ValidatorPrivKey = func `[]`*(_: MockPrivKeysT, index: ValidatorIndex): ValidatorPrivKey =
# 0 is not a valid BLS private key - 1000 helps interop with rust BLS library, # 0 is not a valid BLS private key - 1000 helps interop with rust BLS library,
# lighthouse. EF tests use 1 instead of 1000. # lighthouse. EF tests use 1 instead of 1000.