mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-13 15:55:20 +00:00
automated consensus spec URL updating to v1.4.0 (#6074)
This commit is contained in:
parent
72c844534f
commit
0a6d189161
@ -69,7 +69,7 @@ type
|
||||
current_justified_checkpoint*: Checkpoint
|
||||
finalized_checkpoint*: Checkpoint
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#beaconstate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#beaconstate
|
||||
# Memory-representation-equivalent to an Altair BeaconState for in-place SSZ
|
||||
# reading and writing
|
||||
AltairBeaconStateNoImmutableValidators* = object
|
||||
@ -127,7 +127,7 @@ type
|
||||
current_sync_committee*: SyncCommittee # [New in Altair]
|
||||
next_sync_committee*: SyncCommittee # [New in Altair]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
# Memory-representation-equivalent to a Bellatrix BeaconState for in-place SSZ
|
||||
# reading and writing
|
||||
BellatrixBeaconStateNoImmutableValidators* = object
|
||||
|
@ -4,10 +4,10 @@ This folder holds the various consensus object pools needed for a blockchain cli
|
||||
|
||||
Object in those pools have passed the "gossip validation" filter according
|
||||
to specs:
|
||||
- blocks: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/p2p-interface.md#beacon_block
|
||||
- blocks: https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#beacon_block
|
||||
- aggregate attestations: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
||||
- unaggregated attestation: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/p2p-interface.md#voluntary_exit
|
||||
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#voluntary_exit
|
||||
- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#attester_slashing
|
||||
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#proposer_slashing
|
||||
|
||||
|
@ -558,7 +558,7 @@ proc getAttestationsForBlock*(pool: var AttestationPool,
|
||||
cache: var StateCache): seq[Attestation] =
|
||||
## Retrieve attestations that may be added to a new block at the slot of the
|
||||
## given state
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#attestations
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#attestations
|
||||
let newBlockSlot = state.data.slot.uint64
|
||||
|
||||
if newBlockSlot < MIN_ATTESTATION_INCLUSION_DELAY:
|
||||
@ -740,7 +740,7 @@ func getAggregatedAttestation*(pool: var AttestationPool,
|
||||
index: CommitteeIndex): Opt[Attestation] =
|
||||
## Select the attestation that has the most votes going for it in the given
|
||||
## slot/index
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#construct-aggregate
|
||||
## https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#construct-aggregate
|
||||
let candidateIdx = pool.candidateIdx(slot)
|
||||
if candidateIdx.isNone:
|
||||
return Opt.none(Attestation)
|
||||
@ -771,7 +771,7 @@ proc getBeaconHead*(
|
||||
pool.dag.loadExecutionBlockHash(pool.dag.finalizedHead.blck)
|
||||
.get(ZERO_HASH)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/fork_choice/safe-block.md#get_safe_execution_payload_hash
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/fork_choice/safe-block.md#get_safe_execution_payload_hash
|
||||
safeBlockRoot = pool.forkChoice.get_safe_beacon_block_root()
|
||||
safeBlock = pool.dag.getBlockRef(safeBlockRoot)
|
||||
safeExecutionBlockHash =
|
||||
|
@ -1168,7 +1168,7 @@ proc init*(T: type ChainDAGRef, cfg: RuntimeConfig, db: BeaconChainDB,
|
||||
# should have `previous_version` set to `current_version` while
|
||||
# this doesn't happen to be the case in network that go through
|
||||
# regular hard-fork upgrades. See for example:
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#testing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#testing
|
||||
if stateFork.current_version != configFork.current_version:
|
||||
error "State from database does not match network, check --network parameter",
|
||||
tail = dag.tail, headRef, stateFork, configFork
|
||||
@ -1959,7 +1959,7 @@ proc pruneBlocksDAG(dag: ChainDAGRef) =
|
||||
prunedHeads = hlen - dag.heads.len,
|
||||
dagPruneDur = Moment.now() - startTick
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/sync/optimistic.md#helpers
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/sync/optimistic.md#helpers
|
||||
template is_optimistic*(dag: ChainDAGRef, bid: BlockId): bool =
|
||||
let blck =
|
||||
if bid.slot <= dag.finalizedHead.slot:
|
||||
|
@ -188,7 +188,7 @@ func makeAttestationData*(
|
||||
|
||||
doAssert current_epoch == epochRef.epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#attestation-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#attestation-data
|
||||
AttestationData(
|
||||
slot: slot,
|
||||
index: committee_index.asUInt64,
|
||||
@ -198,7 +198,7 @@ func makeAttestationData*(
|
||||
epoch: current_epoch,
|
||||
root: epoch_boundary_block.blck.root))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#validator-assignments
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#validator-assignments
|
||||
iterator get_committee_assignments*(
|
||||
shufflingRef: ShufflingRef, validator_indices: HashSet[ValidatorIndex]):
|
||||
tuple[committee_index: CommitteeIndex,
|
||||
|
@ -349,7 +349,7 @@ proc produceSyncAggregate*(
|
||||
|
||||
proc isEpochLeadTime*(
|
||||
pool: SyncCommitteeMsgPool, epochsToSyncPeriod: uint64): bool =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# This ensures a uniform distribution without requiring additional state:
|
||||
# (1/4) = 1/4, 4 slots out
|
||||
# (3/4) * (1/3) = 1/4, 3 slots out
|
||||
|
@ -1138,7 +1138,7 @@ proc forkchoiceUpdated*(m: ELManager,
|
||||
# block hash provided by this event is stubbed with
|
||||
# `0x0000000000000000000000000000000000000000000000000000000000000000`."
|
||||
# and
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/validator.md#executionpayload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/validator.md#executionpayload
|
||||
# notes "`finalized_block_hash` is the hash of the latest finalized execution
|
||||
# payload (`Hash32()` if none yet finalized)"
|
||||
|
||||
|
@ -83,11 +83,11 @@ func asEth2Digest*(x: BlockHash): Eth2Digest =
|
||||
template asBlockHash*(x: Eth2Digest): BlockHash =
|
||||
BlockHash(x.data)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#get_eth1_data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
||||
func compute_time_at_slot(genesis_time: uint64, slot: Slot): uint64 =
|
||||
genesis_time + slot * SECONDS_PER_SLOT
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#get_eth1_data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
||||
func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
|
||||
let eth1_voting_period_start_slot =
|
||||
getStateField(state, slot) - getStateField(state, slot) mod
|
||||
@ -95,7 +95,7 @@ func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
|
||||
compute_time_at_slot(
|
||||
getStateField(state, genesis_time), eth1_voting_period_start_slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#get_eth1_data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
||||
func is_candidate_block(cfg: RuntimeConfig,
|
||||
blk: Eth1Block,
|
||||
period_start: uint64): bool =
|
||||
@ -275,7 +275,7 @@ proc trackFinalizedState*(chain: var Eth1Chain,
|
||||
if result:
|
||||
chain.pruneOldBlocks(finalizedStateDepositIndex)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#get_eth1_data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
||||
proc getBlockProposalData*(chain: var Eth1Chain,
|
||||
state: ForkedHashedBeaconState,
|
||||
finalizedEth1Data: Eth1Data,
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
{.push raises: [].}
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
|
||||
|
||||
# Merkle tree helpers
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -377,7 +377,7 @@ proc get_head*(self: var ForkChoice,
|
||||
self.checkpoints.justified.balances,
|
||||
self.checkpoints.proposer_boost_root)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/fork_choice/safe-block.md#get_safe_beacon_block_root
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/fork_choice/safe-block.md#get_safe_beacon_block_root
|
||||
func get_safe_beacon_block_root*(self: ForkChoice): Eth2Digest =
|
||||
# Use most recent justified block as a stopgap
|
||||
self.checkpoints.justified.checkpoint.root
|
||||
|
@ -795,7 +795,7 @@ proc processBlock(
|
||||
# - MUST NOT optimistically import the block.
|
||||
# - MUST NOT apply the block to the fork choice store.
|
||||
# - MAY queue the block for later processing.
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/sync/optimistic.md#execution-engine-errors
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/sync/optimistic.md#execution-engine-errors
|
||||
await sleepAsync(chronos.seconds(1))
|
||||
self[].enqueueBlock(
|
||||
entry.src, entry.blck, entry.blobs, entry.resfut, entry.maybeFinalized,
|
||||
|
@ -282,7 +282,7 @@ template validateBeaconBlockBellatrix(
|
||||
#
|
||||
# `is_merge_transition_complete(state)` tests for
|
||||
# `state.latest_execution_payload_header != ExecutionPayloadHeader()`, while
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#block-processing
|
||||
# shows that `state.latest_execution_payload_header` being default or not is
|
||||
# exactly equivalent to whether that block's execution payload is default or
|
||||
# not, so test cached block information rather than reconstructing a state.
|
||||
@ -1030,7 +1030,7 @@ proc validateAggregate*(
|
||||
|
||||
return ok((attesting_indices, sig))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/p2p-interface.md#bls_to_execution_change
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/p2p-interface.md#bls_to_execution_change
|
||||
proc validateBlsToExecutionChange*(
|
||||
pool: ValidatorChangePool, batchCrypto: ref BatchCrypto,
|
||||
signed_address_change: SignedBLSToExecutionChange,
|
||||
|
@ -94,7 +94,7 @@ typedef struct ETHConsensusConfig ETHConsensusConfig;
|
||||
* based on the given `config.yaml` file content - If successful.
|
||||
* @return `NULL` - If the given `config.yaml` is malformed or incompatible.
|
||||
*
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/configs/README.md
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/configs/README.md
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
ETHConsensusConfig *ETHConsensusConfigCreateFromYaml(const char *configFileContent);
|
||||
@ -150,10 +150,10 @@ typedef struct ETHBeaconState ETHBeaconState;
|
||||
* @return `NULL` - If the given `sszBytes` is malformed.
|
||||
*
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#beaconstate
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#beaconstate
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#beaconstate
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#beaconstate
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/configs/README.md
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/configs/README.md
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
ETHBeaconState *ETHBeaconStateCreateFromSsz(
|
||||
@ -325,8 +325,8 @@ typedef struct ETHLightClientStore ETHLightClientStore;
|
||||
*
|
||||
* @see https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Beacon/getLightClientBootstrap
|
||||
* @see https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Events/eventstream
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/light-client.md
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md#weak-subjectivity-period
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/light-client.md
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md#weak-subjectivity-period
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
ETHLightClientStore *ETHLightClientStoreCreateFromBootstrap(
|
||||
@ -598,7 +598,7 @@ const ETHLightClientHeader *ETHLightClientStoreGetFinalizedHeader(
|
||||
* @return Whether or not the next sync committee is currently known.
|
||||
*
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/light-client.md
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/light-client.md
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
bool ETHLightClientStoreIsNextSyncCommitteeKnown(const ETHLightClientStore *store);
|
||||
@ -775,7 +775,7 @@ const ETHRoot *ETHBeaconBlockHeaderGetBodyRoot(const ETHBeaconBlockHeader *beaco
|
||||
*
|
||||
* @return Pointer to a copy of the given header's execution block hash.
|
||||
*
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
ETHRoot *ETHLightClientHeaderCopyExecutionHash(
|
||||
@ -798,7 +798,7 @@ typedef struct ETHExecutionPayloadHeader ETHExecutionPayloadHeader;
|
||||
*
|
||||
* @return Execution payload header.
|
||||
*
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
*/
|
||||
ETH_RESULT_USE_CHECK
|
||||
const ETHExecutionPayloadHeader *ETHLightClientHeaderGetExecution(
|
||||
|
@ -78,7 +78,7 @@ proc ETHConsensusConfigCreateFromYaml(
|
||||
## * `NULL` - If the given `config.yaml` is malformed or incompatible.
|
||||
##
|
||||
## See:
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/configs/README.md
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/configs/README.md
|
||||
let cfg = RuntimeConfig.new()
|
||||
try:
|
||||
cfg[] = readRuntimeConfig($configFileContent, "config.yaml")[0]
|
||||
@ -143,10 +143,10 @@ proc ETHBeaconStateCreateFromSsz(
|
||||
##
|
||||
## See:
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#beaconstate
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#beaconstate
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#beaconstate
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#beaconstate
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/configs/README.md
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/configs/README.md
|
||||
let
|
||||
consensusFork = ConsensusFork.decodeString($consensusVersion).valueOr:
|
||||
return nil
|
||||
@ -329,8 +329,8 @@ proc ETHLightClientStoreCreateFromBootstrap(
|
||||
## See:
|
||||
## * https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Beacon/getLightClientBootstrap
|
||||
## * https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Events/eventstream
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/light-client.md
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md#weak-subjectivity-period
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/light-client.md
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md#weak-subjectivity-period
|
||||
let
|
||||
mediaType = MediaType.init($mediaType)
|
||||
consensusFork = ConsensusFork.decodeString($consensusVersion).valueOr:
|
||||
@ -756,7 +756,7 @@ func ETHLightClientStoreIsNextSyncCommitteeKnown(
|
||||
##
|
||||
## See:
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#is_next_sync_committee_known
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/light-client.md
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/light-client.md
|
||||
store[].is_next_sync_committee_known
|
||||
|
||||
func ETHLightClientStoreGetOptimisticHeader(
|
||||
@ -977,7 +977,7 @@ func ETHLightClientHeaderGetExecution(
|
||||
## * Execution payload header.
|
||||
##
|
||||
## See:
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
addr header[].execution
|
||||
|
||||
func ETHExecutionPayloadHeaderGetParentHash(
|
||||
|
@ -2197,7 +2197,7 @@ proc getPersistentNetKeys*(
|
||||
func gossipId(
|
||||
data: openArray[byte], phase0Prefix, topic: string): seq[byte] =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#topics-and-messages
|
||||
const MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
|
||||
let messageDigest = withEth2Hash:
|
||||
h.update(MESSAGE_DOMAIN_VALID_SNAPPY)
|
||||
@ -2493,7 +2493,7 @@ proc subscribeAttestationSubnets*(
|
||||
|
||||
proc unsubscribeAttestationSubnets*(
|
||||
node: Eth2Node, subnets: AttnetBits, forkDigest: ForkDigest) =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/p2p-interface.md#attestations-and-aggregation
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#attestations-and-aggregation
|
||||
# Nimbus won't score attestation subnets for now; we just rely on block and
|
||||
# aggregate which are more stable and reliable
|
||||
|
||||
@ -2522,7 +2522,7 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) =
|
||||
debug "Stability subnets changed; updated ENR attnets", attnets
|
||||
|
||||
proc updateSyncnetsMetadata*(node: Eth2Node, syncnets: SyncnetBits) =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
if node.metadata.syncnets == syncnets:
|
||||
return
|
||||
|
||||
|
@ -58,7 +58,7 @@ func forkDigestAtEpoch(state: PeerSyncNetworkState,
|
||||
epoch: Epoch): ForkDigest =
|
||||
state.forkDigests[].atEpoch(epoch, state.cfg)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/p2p-interface.md#status
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#status
|
||||
proc getCurrentStatus(state: PeerSyncNetworkState): StatusMsg =
|
||||
let
|
||||
dag = state.dag
|
||||
@ -103,7 +103,7 @@ proc checkStatusMsg(state: PeerSyncNetworkState, status: StatusMsg):
|
||||
if state.forkDigestAtEpoch(wallSlot.epoch) != status.forkDigest:
|
||||
return err("fork digests differ")
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/p2p-interface.md#status
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#status
|
||||
if dag != nil:
|
||||
if status.finalizedEpoch <= dag.finalizedHead.slot.epoch:
|
||||
let blockId = dag.getBlockIdAtSlot(status.finalizedEpoch.start_slot())
|
||||
@ -170,7 +170,7 @@ p2pProtocol PeerSync(version = 1,
|
||||
{.libp2pProtocol("ping", 1).} =
|
||||
peer.network.metadata.seq_number
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#transitioning-from-v1-to-v2
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#transitioning-from-v1-to-v2
|
||||
proc getMetaData(peer: Peer): uint64
|
||||
{.libp2pProtocol("metadata", 1).} =
|
||||
raise newException(InvalidInputsError, "GetMetaData v1 unsupported")
|
||||
|
@ -1780,7 +1780,7 @@ proc installMessageValidators(node: BeaconNode) =
|
||||
|
||||
when consensusFork >= ConsensusFork.Altair:
|
||||
# sync_committee_{subnet_id}
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#sync_committee_subnet_id
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#sync_committee_subnet_id
|
||||
for subcommitteeIdx in SyncSubcommitteeIndex:
|
||||
closureScope: # Needed for inner `proc`; don't lift it out of loop.
|
||||
let idx = subcommitteeIdx
|
||||
@ -1793,7 +1793,7 @@ proc installMessageValidators(node: BeaconNode) =
|
||||
MsgSource.gossip, msg, idx)))
|
||||
|
||||
# sync_committee_contribution_and_proof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#sync_committee_contribution_and_proof
|
||||
node.network.addAsyncValidator(
|
||||
getSyncCommitteeContributionAndProofTopic(digest), proc (
|
||||
msg: SignedContributionAndProof
|
||||
@ -1803,7 +1803,7 @@ proc installMessageValidators(node: BeaconNode) =
|
||||
MsgSource.gossip, msg)))
|
||||
|
||||
when consensusFork >= ConsensusFork.Capella:
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/p2p-interface.md#bls_to_execution_change
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/p2p-interface.md#bls_to_execution_change
|
||||
node.network.addAsyncValidator(
|
||||
getBlsToExecutionChangeTopic(digest), proc (
|
||||
msg: SignedBLSToExecutionChange
|
||||
|
@ -90,7 +90,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
MAX_VOLUNTARY_EXITS:
|
||||
Base10.toString(MAX_VOLUNTARY_EXITS),
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/altair.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/altair.yaml
|
||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR:
|
||||
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_ALTAIR),
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_ALTAIR:
|
||||
@ -106,7 +106,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
UPDATE_TIMEOUT:
|
||||
Base10.toString(UPDATE_TIMEOUT),
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/bellatrix.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/bellatrix.yaml
|
||||
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX:
|
||||
Base10.toString(INACTIVITY_PENALTY_QUOTIENT_BELLATRIX),
|
||||
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX:
|
||||
@ -122,7 +122,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
MAX_EXTRA_DATA_BYTES:
|
||||
Base10.toString(uint64(MAX_EXTRA_DATA_BYTES)),
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/capella.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/capella.yaml
|
||||
MAX_BLS_TO_EXECUTION_CHANGES:
|
||||
Base10.toString(uint64(MAX_BLS_TO_EXECUTION_CHANGES)),
|
||||
MAX_WITHDRAWALS_PER_PAYLOAD:
|
||||
@ -130,7 +130,7 @@ proc installConfigApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
||||
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP:
|
||||
Base10.toString(uint64(MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP)),
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/deneb.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/deneb.yaml
|
||||
FIELD_ELEMENTS_PER_BLOB:
|
||||
Base10.toString(deneb_preset.FIELD_ELEMENTS_PER_BLOB),
|
||||
MAX_BLOB_COMMITMENTS_PER_BLOCK:
|
||||
|
@ -43,7 +43,7 @@ const
|
||||
GENESIS_SLOT* = Slot(0)
|
||||
GENESIS_EPOCH* = Epoch(0) # compute_epoch_at_slot(GENESIS_SLOT)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/fork-choice.md#constant
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/fork-choice.md#constant
|
||||
INTERVALS_PER_SLOT* = 3
|
||||
|
||||
FAR_FUTURE_BEACON_TIME* = BeaconTime(ns_since_genesis: int64.high())
|
||||
@ -133,22 +133,22 @@ template `+`*(a: TimeDiff, b: Duration): TimeDiff =
|
||||
const
|
||||
# Offsets from the start of the slot to when the corresponding message should
|
||||
# be sent
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#attesting
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#attesting
|
||||
attestationSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#broadcast-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
||||
aggregateSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#prepare-sync-committee-message
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||
syncCommitteeMessageSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
syncContributionSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||
lightClientFinalityUpdateSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/p2p-interface.md#sync-committee
|
||||
lightClientOptimisticUpdateSlotOffset* = TimeDiff(nanoseconds:
|
||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||
|
||||
@ -188,7 +188,7 @@ func epoch*(slot: Slot): Epoch = # aka compute_epoch_at_slot
|
||||
if slot == FAR_FUTURE_SLOT: FAR_FUTURE_EPOCH
|
||||
else: Epoch(slot div SLOTS_PER_EPOCH)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/fork-choice.md#compute_slots_since_epoch_start
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/fork-choice.md#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]`)
|
||||
(slot mod SLOTS_PER_EPOCH)
|
||||
@ -216,7 +216,7 @@ iterator slots*(epoch: Epoch): Slot =
|
||||
for slot in start_slot ..< start_slot + SLOTS_PER_EPOCH:
|
||||
yield slot
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#sync-committee
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#sync-committee
|
||||
template sync_committee_period*(epoch: Epoch): SyncCommitteePeriod =
|
||||
if epoch == FAR_FUTURE_EPOCH: FAR_FUTURE_PERIOD
|
||||
else: SyncCommitteePeriod(epoch div EPOCHS_PER_SYNC_COMMITTEE_PERIOD)
|
||||
|
@ -82,7 +82,7 @@ func get_validator_churn_limit*(
|
||||
count_active_validators(
|
||||
state, state.get_current_epoch(), cache) div cfg.CHURN_LIMIT_QUOTIENT)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#new-get_validator_activation_churn_limit
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#new-get_validator_activation_churn_limit
|
||||
func get_validator_activation_churn_limit*(
|
||||
cfg: RuntimeConfig, state: deneb.BeaconState | electra.BeaconState,
|
||||
cache: var StateCache): uint64 =
|
||||
@ -143,8 +143,8 @@ func initiate_validator_exit*(
|
||||
from ./datatypes/deneb import BeaconState
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
func get_slashing_penalty*(state: ForkyBeaconState,
|
||||
validator_effective_balance: Gwei): Gwei =
|
||||
# TODO Consider whether this is better than splitting the functions apart; in
|
||||
@ -160,14 +160,14 @@ func get_slashing_penalty*(state: ForkyBeaconState,
|
||||
{.fatal: "invalid BeaconState type".}
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
func get_whistleblower_reward*(validator_effective_balance: Gwei): Gwei =
|
||||
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): Gwei =
|
||||
when state is phase0.BeaconState:
|
||||
whistleblower_reward div PROPOSER_REWARD_QUOTIENT
|
||||
@ -179,8 +179,8 @@ func get_proposer_reward(state: ForkyBeaconState, whistleblower_reward: Gwei): G
|
||||
{.fatal: "invalid BeaconState type".}
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#modified-slash_validator
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||
proc slash_validator*(
|
||||
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||
slashed_index: ValidatorIndex, cache: var StateCache):
|
||||
@ -257,7 +257,7 @@ func get_initial_beacon_block*(state: altair.HashedBeaconState):
|
||||
altair.TrustedSignedBeaconBlock(
|
||||
message: message, root: hash_tree_root(message))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#testing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#testing
|
||||
func get_initial_beacon_block*(state: bellatrix.HashedBeaconState):
|
||||
bellatrix.TrustedSignedBeaconBlock =
|
||||
# The genesis block is implicitly trusted
|
||||
@ -497,7 +497,7 @@ func check_attestation_target_epoch(
|
||||
ok(data.target.epoch)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attestations
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#modified-process_attestation
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#modified-process_attestation
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.0/specs/deneb/beacon-chain.md#modified-process_attestation
|
||||
func check_attestation_inclusion(
|
||||
consensusFork: static ConsensusFork, attestation_slot: Slot,
|
||||
@ -527,7 +527,7 @@ func check_attestation_index(
|
||||
Result[CommitteeIndex, cstring] =
|
||||
check_attestation_index(data.index, committees_per_slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_attestation_participation_flag_indices
|
||||
func get_attestation_participation_flag_indices(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState,
|
||||
data: AttestationData, inclusion_delay: uint64): set[TimelyFlag] =
|
||||
@ -562,7 +562,7 @@ func get_attestation_participation_flag_indices(
|
||||
|
||||
participation_flag_indices
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#modified-get_attestation_participation_flag_indices
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#modified-get_attestation_participation_flag_indices
|
||||
func get_attestation_participation_flag_indices(
|
||||
state: deneb.BeaconState | electra.BeaconState,
|
||||
data: AttestationData, inclusion_delay: uint64): set[TimelyFlag] =
|
||||
@ -616,7 +616,7 @@ func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache):
|
||||
cache.total_active_balance[epoch] = tab
|
||||
return tab
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_base_reward_per_increment
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_base_reward_per_increment
|
||||
func get_base_reward_per_increment_sqrt(
|
||||
total_active_balance_sqrt: uint64): Gwei =
|
||||
EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div total_active_balance_sqrt
|
||||
@ -625,7 +625,7 @@ func get_base_reward_per_increment*(
|
||||
total_active_balance: Gwei): Gwei =
|
||||
get_base_reward_per_increment_sqrt(integer_squareroot(total_active_balance))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_base_reward
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_base_reward
|
||||
func get_base_reward(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState,
|
||||
@ -779,7 +779,7 @@ proc process_attestation*(
|
||||
|
||||
ok(proposer_reward)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_next_sync_committee_indices
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_next_sync_committee_indices
|
||||
func get_next_sync_committee_keys(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState):
|
||||
@ -877,7 +877,7 @@ func get_expected_withdrawals*(
|
||||
validator_index = (validator_index + 1) mod num_validators
|
||||
withdrawals
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_next_sync_committee
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_next_sync_committee
|
||||
func get_next_sync_committee*(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState):
|
||||
@ -998,7 +998,7 @@ proc initialize_hashed_beacon_state_from_eth1*(
|
||||
cfg, eth1_block_hash, eth1_timestamp, deposits, flags))
|
||||
result.root = hash_tree_root(result.data)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#testing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#testing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#testing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/deneb/beacon-chain.md#testing
|
||||
proc initialize_beacon_state_from_eth1*(
|
||||
|
@ -34,13 +34,13 @@ type
|
||||
|
||||
static:
|
||||
# Verify that ordinals follow spec values (the spec uses these as shifts for bit flags)
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#participation-flag-indices
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#participation-flag-indices
|
||||
doAssert ord(TIMELY_SOURCE_FLAG_INDEX) == 0
|
||||
doAssert ord(TIMELY_TARGET_FLAG_INDEX) == 1
|
||||
doAssert ord(TIMELY_HEAD_FLAG_INDEX) == 2
|
||||
|
||||
const
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#incentivization-weights
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#incentivization-weights
|
||||
TIMELY_SOURCE_WEIGHT* = 14
|
||||
TIMELY_TARGET_WEIGHT* = 26
|
||||
TIMELY_HEAD_WEIGHT* = 14
|
||||
@ -51,7 +51,7 @@ const
|
||||
PARTICIPATION_FLAG_WEIGHTS*: array[TimelyFlag, uint64] =
|
||||
[uint64 TIMELY_SOURCE_WEIGHT, TIMELY_TARGET_WEIGHT, TIMELY_HEAD_WEIGHT]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#misc
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#misc
|
||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 16
|
||||
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
||||
|
||||
@ -60,12 +60,12 @@ const
|
||||
# The first member (`genesis_time`) is 32, subsequent members +1 each.
|
||||
# If there are ever more than 32 members in `BeaconState`, indices change!
|
||||
# `FINALIZED_ROOT_GINDEX` is one layer deeper, i.e., `52 * 2 + 1`.
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/ssz/merkle-proofs.md
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/ssz/merkle-proofs.md
|
||||
FINALIZED_ROOT_GINDEX* = 105.GeneralizedIndex # finalized_checkpoint > root
|
||||
CURRENT_SYNC_COMMITTEE_GINDEX* = 54.GeneralizedIndex # current_sync_committee
|
||||
NEXT_SYNC_COMMITTEE_GINDEX* = 55.GeneralizedIndex # next_sync_committee
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#inactivity-penalties
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#inactivity-penalties
|
||||
INACTIVITY_SCORE_BIAS* = 4
|
||||
INACTIVITY_SCORE_RECOVERY_RATE* = 16
|
||||
|
||||
@ -79,7 +79,7 @@ static: doAssert TIMELY_SOURCE_WEIGHT + TIMELY_TARGET_WEIGHT +
|
||||
type
|
||||
### New types
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#custom-types
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#custom-types
|
||||
ParticipationFlags* = uint8
|
||||
|
||||
EpochParticipationFlags* =
|
||||
@ -88,7 +88,7 @@ type
|
||||
## effectively making the cost of clearing the cache higher than the typical
|
||||
## gains
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#syncaggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#syncaggregate
|
||||
SyncAggregate* = object
|
||||
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
||||
sync_committee_signature*: ValidatorSig
|
||||
@ -97,12 +97,12 @@ type
|
||||
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
||||
sync_committee_signature*: TrustedSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#synccommittee
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#synccommittee
|
||||
SyncCommittee* = object
|
||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||
aggregate_pubkey*: ValidatorPubKey
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#synccommitteemessage
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#synccommitteemessage
|
||||
SyncCommitteeMessage* = object
|
||||
slot*: Slot
|
||||
## Slot to which this contribution pertains
|
||||
@ -116,7 +116,7 @@ type
|
||||
signature*: ValidatorSig
|
||||
## Signature by the validator over the block root of `slot`
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#synccommitteecontribution
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#synccommitteecontribution
|
||||
SyncCommitteeAggregationBits* =
|
||||
BitArray[SYNC_SUBCOMMITTEE_SIZE]
|
||||
|
||||
@ -138,18 +138,18 @@ type
|
||||
signature*: ValidatorSig
|
||||
## Signature by the validator(s) over the block root of `slot`
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#contributionandproof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#contributionandproof
|
||||
ContributionAndProof* = object
|
||||
aggregator_index*: uint64 # `ValidatorIndex` after validation
|
||||
contribution*: SyncCommitteeContribution
|
||||
selection_proof*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#signedcontributionandproof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#signedcontributionandproof
|
||||
SignedContributionAndProof* = object
|
||||
message*: ContributionAndProof
|
||||
signature*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#syncaggregatorselectiondata
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#syncaggregatorselectiondata
|
||||
SyncAggregatorSelectionData* = object
|
||||
slot*: Slot
|
||||
subcommittee_index*: uint64 # `SyncSubcommitteeIndex` after validation
|
||||
@ -261,7 +261,7 @@ type
|
||||
|
||||
InactivityScores* = HashList[uint64, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#beaconstate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#beaconstate
|
||||
BeaconState* = object
|
||||
# Versioning
|
||||
genesis_time*: uint64
|
||||
@ -404,7 +404,7 @@ type
|
||||
state_root*: Eth2Digest
|
||||
body*: TrustedBeaconBlockBody
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#beaconblockbody
|
||||
BeaconBlockBody* = object
|
||||
randao_reveal*: ValidatorSig
|
||||
eth1_data*: Eth1Data
|
||||
@ -456,7 +456,7 @@ type
|
||||
|
||||
SyncnetBits* = BitArray[SYNC_COMMITTEE_SUBNET_COUNT]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#metadata
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#metadata
|
||||
MetaData* = object
|
||||
seq_number*: uint64
|
||||
attnets*: AttnetBits
|
||||
|
@ -413,13 +413,13 @@ type
|
||||
message*: BeaconBlockHeader
|
||||
signature*: TrustedSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregateandproof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregateandproof
|
||||
AggregateAndProof* = object
|
||||
aggregator_index*: uint64 # `ValidatorIndex` after validation
|
||||
aggregate*: Attestation
|
||||
selection_proof*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#signedaggregateandproof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#signedaggregateandproof
|
||||
SignedAggregateAndProof* = object
|
||||
message*: AggregateAndProof
|
||||
signature*: ValidatorSig
|
||||
@ -437,7 +437,7 @@ type
|
||||
sync_committees*: Table[SyncCommitteePeriod, SyncCommitteeCache]
|
||||
|
||||
# This matches the mutable state of the Solidity deposit contract
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/solidity_deposit_contract/deposit_contract.sol
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/solidity_deposit_contract/deposit_contract.sol
|
||||
DepositContractState* = object
|
||||
branch*: array[DEPOSIT_CONTRACT_TREE_DEPTH, Eth2Digest]
|
||||
deposit_count*: array[32, byte] # Uint256
|
||||
|
@ -35,7 +35,7 @@ const
|
||||
NEWPAYLOAD_TIMEOUT* = 8.seconds
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#custom-types
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#custom-types
|
||||
Transaction* = List[byte, Limit MAX_BYTES_PER_TRANSACTION]
|
||||
|
||||
ExecutionAddress* = object
|
||||
@ -46,7 +46,7 @@ type
|
||||
|
||||
PayloadID* = array[8, byte]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#executionpayload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#executionpayload
|
||||
ExecutionPayload* = object
|
||||
# Execution block header fields
|
||||
parent_hash*: Eth2Digest
|
||||
@ -74,7 +74,7 @@ type
|
||||
executionPayload*: ExecutionPayload
|
||||
blockValue*: Wei
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#executionpayloadheader
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#executionpayloadheader
|
||||
ExecutionPayloadHeader* = object
|
||||
# Execution block header fields
|
||||
parent_hash*: Eth2Digest
|
||||
@ -98,13 +98,13 @@ type
|
||||
ExecutePayload* = proc(
|
||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/fork-choice.md#powblock
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/fork-choice.md#powblock
|
||||
PowBlock* = object
|
||||
block_hash*: Eth2Digest
|
||||
parent_hash*: Eth2Digest
|
||||
total_difficulty*: Eth2Digest # uint256
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#beaconstate
|
||||
BeaconState* = object
|
||||
# Versioning
|
||||
genesis_time*: uint64
|
||||
@ -229,7 +229,7 @@ type
|
||||
state_root*: Eth2Digest
|
||||
body*: TrustedBeaconBlockBody
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#beaconblockbody
|
||||
BeaconBlockBody* = object
|
||||
randao_reveal*: ValidatorSig
|
||||
eth1_data*: Eth1Data
|
||||
|
@ -32,7 +32,7 @@ const
|
||||
# This index is rooted in `BeaconBlockBody`.
|
||||
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
||||
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/ssz/merkle-proofs.md
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/ssz/merkle-proofs.md
|
||||
EXECUTION_PAYLOAD_GINDEX* = 25.GeneralizedIndex # execution_payload
|
||||
|
||||
type
|
||||
@ -680,13 +680,13 @@ func is_valid_light_client_header*(
|
||||
get_subtree_index(EXECUTION_PAYLOAD_GINDEX),
|
||||
header.beacon.body_root)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_header_to_capella*(
|
||||
pre: altair.LightClientHeader): LightClientHeader =
|
||||
LightClientHeader(
|
||||
beacon: pre.beacon)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_bootstrap_to_capella*(
|
||||
pre: altair.LightClientBootstrap): LightClientBootstrap =
|
||||
LightClientBootstrap(
|
||||
@ -694,7 +694,7 @@ func upgrade_lc_bootstrap_to_capella*(
|
||||
current_sync_committee: pre.current_sync_committee,
|
||||
current_sync_committee_branch: pre.current_sync_committee_branch)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_update_to_capella*(
|
||||
pre: altair.LightClientUpdate): LightClientUpdate =
|
||||
LightClientUpdate(
|
||||
@ -706,7 +706,7 @@ func upgrade_lc_update_to_capella*(
|
||||
sync_aggregate: pre.sync_aggregate,
|
||||
signature_slot: pre.signature_slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_finality_update_to_capella*(
|
||||
pre: altair.LightClientFinalityUpdate): LightClientFinalityUpdate =
|
||||
LightClientFinalityUpdate(
|
||||
@ -716,7 +716,7 @@ func upgrade_lc_finality_update_to_capella*(
|
||||
sync_aggregate: pre.sync_aggregate,
|
||||
signature_slot: pre.signature_slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_optimistic_update_to_capella*(
|
||||
pre: altair.LightClientOptimisticUpdate): LightClientOptimisticUpdate =
|
||||
LightClientOptimisticUpdate(
|
||||
@ -767,7 +767,7 @@ chronicles.formatIt LightClientUpdate: shortLog(it)
|
||||
chronicles.formatIt LightClientFinalityUpdate: shortLog(it)
|
||||
chronicles.formatIt LightClientOptimisticUpdate: shortLog(it)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/light-client/fork.md#upgrading-the-store
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/light-client/fork.md#upgrading-the-store
|
||||
func upgrade_lc_store_to_capella*(
|
||||
pre: altair.LightClientStore): LightClientStore =
|
||||
let best_valid_update =
|
||||
|
@ -23,7 +23,7 @@ const
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#constants
|
||||
NODE_ID_BITS* = 256
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/p2p-interface.md#configuration
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#configuration
|
||||
EPOCHS_PER_SUBNET_SUBSCRIPTION* = 256'u64
|
||||
SUBNETS_PER_NODE* = 2'u64
|
||||
ATTESTATION_SUBNET_COUNT*: uint64 = 64
|
||||
@ -50,7 +50,7 @@ const
|
||||
DOMAIN_AGGREGATE_AND_PROOF* = DomainType([byte 0x06, 0x00, 0x00, 0x00])
|
||||
DOMAIN_APPLICATION_MASK* = DomainType([byte 0x00, 0x00, 0x00, 0x01])
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#domain-types
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#domain-types
|
||||
DOMAIN_SYNC_COMMITTEE* = DomainType([byte 0x07, 0x00, 0x00, 0x00])
|
||||
DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF* = DomainType([byte 0x08, 0x00, 0x00, 0x00])
|
||||
DOMAIN_CONTRIBUTION_AND_PROOF* = DomainType([byte 0x09, 0x00, 0x00, 0x00])
|
||||
|
@ -36,7 +36,7 @@ const
|
||||
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||
|
||||
# TODO this apparently is suppposed to be SSZ-equivalent to Bytes32, but
|
||||
@ -47,7 +47,7 @@ type
|
||||
# field manually
|
||||
VersionedHash* = array[32, byte]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#custom-types
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#custom-types
|
||||
BlobIndex* = uint64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/polynomial-commitments.md#custom-types
|
||||
@ -80,7 +80,7 @@ type
|
||||
block_root*: Eth2Digest
|
||||
index*: BlobIndex
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayload
|
||||
ExecutionPayload* = object
|
||||
# Execution block header fields
|
||||
parent_hash*: Eth2Digest
|
||||
@ -106,7 +106,7 @@ type
|
||||
blob_gas_used*: uint64 # [New in Deneb]
|
||||
excess_blob_gas*: uint64 # [New in Deneb]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/validator.md#blobsbundle
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/validator.md#blobsbundle
|
||||
KzgProofs* = List[KzgProof, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||
Blobs* = List[Blob, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||
BlobRoots* = List[Eth2Digest, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||
@ -121,7 +121,7 @@ type
|
||||
blockValue*: Wei
|
||||
blobsBundle*: BlobsBundle
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
ExecutionPayloadHeader* = object
|
||||
# Execution block header fields
|
||||
parent_hash*: Eth2Digest
|
||||
@ -381,7 +381,7 @@ type
|
||||
state_root*: Eth2Digest
|
||||
body*: TrustedBeaconBlockBody
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
BeaconBlockBody* = object
|
||||
randao_reveal*: ValidatorSig
|
||||
eth1_data*: Eth1Data
|
||||
@ -602,7 +602,7 @@ func kzg_commitment_inclusion_proof_gindex*(
|
||||
# This index is rooted in `BeaconBlockBody`.
|
||||
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
||||
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/ssz/merkle-proofs.md
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/ssz/merkle-proofs.md
|
||||
const
|
||||
# blob_kzg_commitments
|
||||
BLOB_KZG_COMMITMENTS_GINDEX =
|
||||
@ -673,7 +673,7 @@ func is_valid_light_client_header*(
|
||||
get_subtree_index(EXECUTION_PAYLOAD_GINDEX),
|
||||
header.beacon.body_root)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_header_to_deneb*(
|
||||
pre: capella.LightClientHeader): LightClientHeader =
|
||||
LightClientHeader(
|
||||
@ -698,7 +698,7 @@ func upgrade_lc_header_to_deneb*(
|
||||
excess_blob_gas: 0), # [New in Deneb:EIP4844]
|
||||
execution_branch: pre.execution_branch)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_bootstrap_to_deneb*(
|
||||
pre: capella.LightClientBootstrap): LightClientBootstrap =
|
||||
LightClientBootstrap(
|
||||
@ -706,7 +706,7 @@ func upgrade_lc_bootstrap_to_deneb*(
|
||||
current_sync_committee: pre.current_sync_committee,
|
||||
current_sync_committee_branch: pre.current_sync_committee_branch)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_update_to_deneb*(
|
||||
pre: capella.LightClientUpdate): LightClientUpdate =
|
||||
LightClientUpdate(
|
||||
@ -718,7 +718,7 @@ func upgrade_lc_update_to_deneb*(
|
||||
sync_aggregate: pre.sync_aggregate,
|
||||
signature_slot: pre.signature_slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_finality_update_to_deneb*(
|
||||
pre: capella.LightClientFinalityUpdate): LightClientFinalityUpdate =
|
||||
LightClientFinalityUpdate(
|
||||
@ -728,7 +728,7 @@ func upgrade_lc_finality_update_to_deneb*(
|
||||
sync_aggregate: pre.sync_aggregate,
|
||||
signature_slot: pre.signature_slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/light-client/fork.md#upgrading-light-client-data
|
||||
func upgrade_lc_optimistic_update_to_deneb*(
|
||||
pre: capella.LightClientOptimisticUpdate): LightClientOptimisticUpdate =
|
||||
LightClientOptimisticUpdate(
|
||||
@ -779,7 +779,7 @@ chronicles.formatIt LightClientUpdate: shortLog(it)
|
||||
chronicles.formatIt LightClientFinalityUpdate: shortLog(it)
|
||||
chronicles.formatIt LightClientOptimisticUpdate: shortLog(it)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/light-client/fork.md#upgrading-the-store
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/light-client/fork.md#upgrading-the-store
|
||||
func upgrade_lc_store_to_deneb*(
|
||||
pre: capella.LightClientStore): LightClientStore =
|
||||
let best_valid_update =
|
||||
|
@ -31,7 +31,7 @@ from ./deneb import Blobs, BlobsBundle, KzgCommitments, KzgProofs
|
||||
export json_serialization, base, kzg4844
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayload
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayload
|
||||
ExecutionPayload* = object
|
||||
# Execution block header fields
|
||||
parent_hash*: Eth2Digest
|
||||
@ -62,7 +62,7 @@ type
|
||||
blockValue*: Wei
|
||||
blobsBundle*: BlobsBundle
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#executionpayloadheader
|
||||
ExecutionPayloadHeader* = object
|
||||
# Execution block header fields
|
||||
parent_hash*: Eth2Digest
|
||||
@ -322,7 +322,7 @@ type
|
||||
state_root*: Eth2Digest
|
||||
body*: TrustedBeaconBlockBody
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
BeaconBlockBody* = object
|
||||
randao_reveal*: ValidatorSig
|
||||
eth1_data*: Eth1Data
|
||||
|
@ -26,7 +26,7 @@ export
|
||||
eth2_merkleization, forks, rlp, ssz_codec
|
||||
|
||||
func toEther*(gwei: Gwei): Ether =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md#constants
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md#constants
|
||||
const ETH_TO_GWEI = 1_000_000_000
|
||||
(gwei div ETH_TO_GWEI).Ether
|
||||
|
||||
@ -204,12 +204,12 @@ func get_seed*(state: ForkyBeaconState, epoch: Epoch, domain_type: DomainType):
|
||||
epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1)
|
||||
state.get_seed(epoch, domain_type, mix)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#add_flag
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#add_flag
|
||||
func add_flag*(flags: ParticipationFlags, flag_index: TimelyFlag): ParticipationFlags =
|
||||
let flag = ParticipationFlags(1'u8 shl ord(flag_index))
|
||||
flags or flag
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#has_flag
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#has_flag
|
||||
func has_flag*(flags: ParticipationFlags, flag_index: TimelyFlag): bool =
|
||||
let flag = ParticipationFlags(1'u8 shl ord(flag_index))
|
||||
(flags and flag) == flag
|
||||
@ -380,7 +380,7 @@ func contextEpoch*(bootstrap: ForkyLightClientBootstrap): Epoch =
|
||||
func contextEpoch*(update: SomeForkyLightClientUpdate): Epoch =
|
||||
update.attested_header.beacon.slot.epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#is_merge_transition_complete
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#is_merge_transition_complete
|
||||
func is_merge_transition_complete*(
|
||||
state: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState |
|
||||
electra.BeaconState): bool =
|
||||
@ -388,7 +388,7 @@ func is_merge_transition_complete*(
|
||||
default(typeof(state.latest_execution_payload_header))
|
||||
state.latest_execution_payload_header != defaultExecutionPayloadHeader
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/sync/optimistic.md#helpers
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/sync/optimistic.md#helpers
|
||||
func is_execution_block*(blck: SomeForkyBeaconBlock): bool =
|
||||
when typeof(blck).kind >= ConsensusFork.Bellatrix:
|
||||
const defaultExecutionPayload =
|
||||
@ -397,7 +397,7 @@ func is_execution_block*(blck: SomeForkyBeaconBlock): bool =
|
||||
else:
|
||||
false
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#is_merge_transition_block
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#is_merge_transition_block
|
||||
func is_merge_transition_block(
|
||||
state: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState |
|
||||
electra.BeaconState,
|
||||
@ -413,7 +413,7 @@ func is_merge_transition_block(
|
||||
not is_merge_transition_complete(state) and
|
||||
body.execution_payload != defaultExecutionPayload
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#is_execution_enabled
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#is_execution_enabled
|
||||
func is_execution_enabled*(
|
||||
state: bellatrix.BeaconState | capella.BeaconState | deneb.BeaconState |
|
||||
electra.BeaconState,
|
||||
@ -427,7 +427,7 @@ func is_execution_enabled*(
|
||||
electra.SigVerifiedBeaconBlockBody): bool =
|
||||
is_merge_transition_block(state, body) or is_merge_transition_complete(state)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#compute_timestamp_at_slot
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#compute_timestamp_at_slot
|
||||
func compute_timestamp_at_slot*(state: ForkyBeaconState, slot: Slot): uint64 =
|
||||
# Note: This function is unsafe with respect to overflows and underflows.
|
||||
let slots_since_genesis = slot - GENESIS_SLOT
|
||||
|
@ -1379,13 +1379,13 @@ proc createWallet*(kdfKind: KdfKind,
|
||||
crypto: crypto,
|
||||
nextAccount: nextAccount.get(0))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#bls_withdrawal_prefix
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#bls_withdrawal_prefix
|
||||
func makeWithdrawalCredentials*(k: ValidatorPubKey): Eth2Digest =
|
||||
var bytes = eth2digest(k.toRaw())
|
||||
bytes.data[0] = BLS_WITHDRAWAL_PREFIX.uint8
|
||||
bytes
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/deposit-contract.md#withdrawal-credentials
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/deposit-contract.md#withdrawal-credentials
|
||||
proc makeWithdrawalCredentials*(k: CookedPubKey): Eth2Digest =
|
||||
makeWithdrawalCredentials(k.toPubKey())
|
||||
|
||||
|
@ -15,7 +15,7 @@ export base
|
||||
|
||||
const
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/p2p-interface.md#topics-and-messages
|
||||
topicBeaconBlocksSuffix* = "beacon_block/ssz_snappy"
|
||||
topicVoluntaryExitsSuffix* = "voluntary_exit/ssz_snappy"
|
||||
topicProposerSlashingsSuffix* = "proposer_slashing/ssz_snappy"
|
||||
@ -63,7 +63,7 @@ func getAttesterSlashingsTopic*(forkDigest: ForkDigest): string =
|
||||
func getAggregateAndProofsTopic*(forkDigest: ForkDigest): string =
|
||||
eth2Prefix(forkDigest) & topicAggregateAndProofsSuffix
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/p2p-interface.md#topics-and-messages
|
||||
func getBlsToExecutionChangeTopic*(forkDigest: ForkDigest): string =
|
||||
eth2Prefix(forkDigest) & topicBlsToExecutionChangeSuffix
|
||||
|
||||
@ -83,19 +83,19 @@ func compute_subnet_for_attestation*(
|
||||
(committees_since_epoch_start + committee_index.asUInt64) mod
|
||||
ATTESTATION_SUBNET_COUNT)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#broadcast-attestation
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-attestation
|
||||
func getAttestationTopic*(forkDigest: ForkDigest,
|
||||
subnetId: SubnetId): string =
|
||||
## For subscribing and unsubscribing to/from a subnet.
|
||||
eth2Prefix(forkDigest) & "beacon_attestation_" & $(subnetId) & "/ssz_snappy"
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#topics-and-messages
|
||||
func getSyncCommitteeTopic*(forkDigest: ForkDigest,
|
||||
subcommitteeIdx: SyncSubcommitteeIndex): string =
|
||||
## For subscribing and unsubscribing to/from a subnet.
|
||||
eth2Prefix(forkDigest) & "sync_committee_" & $subcommitteeIdx & "/ssz_snappy"
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#topics-and-messages
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#topics-and-messages
|
||||
func getSyncCommitteeContributionAndProofTopic*(forkDigest: ForkDigest): string =
|
||||
## For subscribing and unsubscribing to/from a subnet.
|
||||
eth2Prefix(forkDigest) & "sync_committee_contribution_and_proof/ssz_snappy"
|
||||
@ -105,7 +105,7 @@ func getBlobSidecarTopic*(forkDigest: ForkDigest,
|
||||
subnet_id: BlobId): string =
|
||||
eth2Prefix(forkDigest) & "blob_sidecar_" & $subnet_id & "/ssz_snappy"
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/validator.md#sidecar
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/validator.md#sidecar
|
||||
func compute_subnet_for_blob_sidecar*(blob_index: BlobIndex): BlobId =
|
||||
BlobId(blob_index mod BLOB_SIDECAR_SUBNET_COUNT)
|
||||
|
||||
@ -151,7 +151,7 @@ func getDiscoveryForkID*(cfg: RuntimeConfig,
|
||||
next_fork_version: current_fork_version,
|
||||
next_fork_epoch: FAR_FUTURE_EPOCH)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/p2p-interface.md#transitioning-the-gossip
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/p2p-interface.md#transitioning-the-gossip
|
||||
type GossipState* = set[ConsensusFork]
|
||||
func getTargetGossipState*(
|
||||
epoch, ALTAIR_FORK_EPOCH, BELLATRIX_FORK_EPOCH, CAPELLA_FORK_EPOCH,
|
||||
@ -193,7 +193,7 @@ func getTargetGossipState*(
|
||||
targetForks
|
||||
|
||||
func nearSyncCommitteePeriod*(epoch: Epoch): Opt[uint64] =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#sync-committee-subnet-stability
|
||||
if epoch.is_sync_committee_period():
|
||||
return Opt.some 0'u64
|
||||
let epochsBefore =
|
||||
@ -212,7 +212,7 @@ func getSyncSubnets*(
|
||||
if not nodeHasPubkey(pubkey):
|
||||
continue
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#broadcast-sync-committee-message
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#broadcast-sync-committee-message
|
||||
# The first quarter of the pubkeys map to subnet 0, the second quarter to
|
||||
# subnet 1, the third quarter to subnet 2 and the final quarter to subnet
|
||||
# 3.
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Mainnet preset - Altair
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/altair.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/altair.yaml
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Mainnet preset - Bellatrix
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/bellatrix.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/bellatrix.yaml
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Mainnet preset - Capella
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/capella.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/capella.yaml
|
||||
const
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Mainnet preset - Deneb
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/mainnet/deneb.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/mainnet/deneb.yaml
|
||||
const
|
||||
# `uint64(4096)`
|
||||
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Minimal preset - Altair
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/minimal/altair.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/minimal/altair.yaml
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Minimal preset - Bellatrix
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/minimal/bellatrix.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/minimal/bellatrix.yaml
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Minimal preset - Capella
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/minimal/capella.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/minimal/capella.yaml
|
||||
const
|
||||
# Max operations per block
|
||||
# ---------------------------------------------------------------
|
||||
|
@ -8,7 +8,7 @@
|
||||
{.push raises: [].}
|
||||
|
||||
# Minimal preset - Deneb
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/presets/minimal/deneb.yaml
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/presets/minimal/deneb.yaml
|
||||
const
|
||||
# `uint64(4096)`
|
||||
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096
|
||||
|
@ -59,7 +59,7 @@ func compute_epoch_signing_root*(
|
||||
let domain = get_domain(fork, DOMAIN_RANDAO, epoch, genesis_validators_root)
|
||||
compute_signing_root(epoch, domain)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#randao-reveal
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#randao-reveal
|
||||
func get_epoch_signature*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, epoch: Epoch,
|
||||
privkey: ValidatorPrivKey): CookedSig =
|
||||
@ -86,7 +86,7 @@ func compute_block_signing_root*(
|
||||
fork, DOMAIN_BEACON_PROPOSER, epoch, genesis_validators_root)
|
||||
compute_signing_root(blck, domain)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#signature
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#signature
|
||||
func get_block_signature*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot,
|
||||
root: Eth2Digest, privkey: ValidatorPrivKey): CookedSig =
|
||||
@ -115,7 +115,7 @@ func compute_aggregate_and_proof_signing_root*(
|
||||
fork, DOMAIN_AGGREGATE_AND_PROOF, epoch, genesis_validators_root)
|
||||
compute_signing_root(aggregate_and_proof, domain)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#broadcast-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
||||
func get_aggregate_and_proof_signature*(fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
aggregate_and_proof: AggregateAndProof,
|
||||
privkey: ValidatorPrivKey): CookedSig =
|
||||
@ -143,7 +143,7 @@ func compute_attestation_signing_root*(
|
||||
fork, DOMAIN_BEACON_ATTESTER, epoch, genesis_validators_root)
|
||||
compute_signing_root(attestation_data, domain)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregate-signature
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregate-signature
|
||||
func get_attestation_signature*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
attestation_data: AttestationData,
|
||||
@ -268,7 +268,7 @@ proc verify_voluntary_exit_signature*(
|
||||
|
||||
blsVerify(pubkey, signing_root.data, signature)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#prepare-sync-committee-message
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||
func compute_sync_committee_message_signing_root*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
slot: Slot, beacon_block_root: Eth2Digest): Eth2Digest =
|
||||
@ -303,7 +303,7 @@ proc verify_sync_committee_signature*(
|
||||
|
||||
blsFastAggregateVerify(pubkeys, signing_root.data, signature)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#aggregation-selection
|
||||
func compute_sync_committee_selection_proof_signing_root*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
slot: Slot, subcommittee_index: SyncSubcommitteeIndex): Eth2Digest =
|
||||
@ -334,7 +334,7 @@ proc verify_sync_committee_selection_proof*(
|
||||
|
||||
blsVerify(pubkey, signing_root.data, signature)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#signature
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#signature
|
||||
func compute_contribution_and_proof_signing_root*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||
msg: ContributionAndProof): Eth2Digest =
|
||||
@ -352,7 +352,7 @@ proc get_contribution_and_proof_signature*(
|
||||
|
||||
blsSign(privkey, signing_root.data)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#aggregation-selection
|
||||
func is_sync_committee_aggregator*(signature: ValidatorSig): bool =
|
||||
let
|
||||
signatureDigest = eth2digest(signature.blob)
|
||||
|
@ -398,7 +398,7 @@ proc collectSignatureSets*(
|
||||
|
||||
sigs.add voluntary_exit_signature_set(
|
||||
# https://eips.ethereum.org/EIPS/eip-7044
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#modified-process_voluntary_exit
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#modified-process_voluntary_exit
|
||||
voluntary_exit_fork, genesis_validators_root, volex.message, key,
|
||||
volex.signature.load.valueOr do:
|
||||
return err(
|
||||
|
@ -371,7 +371,7 @@ func partialBeaconBlock*(
|
||||
when consensusFork >= ConsensusFork.Bellatrix:
|
||||
res.body.execution_payload = execution_payload.executionPayload
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/validator.md#block-proposal
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/validator.md#block-proposal
|
||||
when consensusFork >= ConsensusFork.Capella:
|
||||
res.body.bls_to_execution_changes =
|
||||
validator_changes.bls_to_execution_changes
|
||||
@ -440,7 +440,7 @@ proc makeBeaconBlockWithRewards*(
|
||||
transactions_root.get
|
||||
|
||||
when executionPayload is deneb.ExecutionPayloadForSigning:
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
||||
forkyState.data.latest_block_header.body_root = hash_tree_root(
|
||||
[hash_tree_root(randao_reveal),
|
||||
hash_tree_root(eth1_data),
|
||||
|
@ -9,10 +9,10 @@
|
||||
|
||||
# State transition - block processing, as described in
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#block-processing
|
||||
#
|
||||
# The entry point is `process_block` which is at the bottom of this file.
|
||||
#
|
||||
@ -485,7 +485,7 @@ proc process_operations(cfg: RuntimeConfig,
|
||||
|
||||
ok(operations_rewards)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||
func get_participant_reward*(total_active_balance: Gwei): Gwei =
|
||||
let
|
||||
total_active_increments =
|
||||
@ -498,11 +498,11 @@ func get_participant_reward*(total_active_balance: Gwei): Gwei =
|
||||
WEIGHT_DENOMINATOR div SLOTS_PER_EPOCH
|
||||
max_participant_rewards div SYNC_COMMITTEE_SIZE
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||
func get_proposer_reward*(participant_reward: Gwei): Gwei =
|
||||
participant_reward * PROPOSER_WEIGHT div (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||
proc process_sync_aggregate*(
|
||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||
capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
||||
@ -760,7 +760,7 @@ proc process_execution_payload*(
|
||||
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/capella/beacon-chain.md#new-process_withdrawals
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/capella/beacon-chain.md#new-process_withdrawals
|
||||
func process_withdrawals*(
|
||||
state: var (capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
||||
payload: capella.ExecutionPayload | deneb.ExecutionPayload |
|
||||
@ -803,10 +803,10 @@ func process_withdrawals*(
|
||||
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#kzg_commitment_to_versioned_hash
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#kzg_commitment_to_versioned_hash
|
||||
func kzg_commitment_to_versioned_hash*(
|
||||
kzg_commitment: KzgCommitment): VersionedHash =
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/deneb/beacon-chain.md#blob
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#blob
|
||||
const VERSIONED_HASH_VERSION_KZG = 0x01'u8
|
||||
|
||||
var res: VersionedHash
|
||||
@ -843,7 +843,7 @@ proc process_block*(
|
||||
|
||||
ok(? process_operations(cfg, state, blck.body, 0.Gwei, flags, cache))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#block-processing
|
||||
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
||||
# copy of datatypes/altair.nim
|
||||
type SomeAltairBlock =
|
||||
@ -872,7 +872,7 @@ proc process_block*(
|
||||
|
||||
ok(operations_rewards)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#block-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#block-processing
|
||||
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
||||
type SomeBellatrixBlock =
|
||||
bellatrix.BeaconBlock | bellatrix.SigVerifiedBeaconBlock | bellatrix.TrustedBeaconBlock
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
# State transition - epoch processing, as described in
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#epoch-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#epoch-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#epoch-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#epoch-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#epoch-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/capella/beacon-chain.md#epoch-processing
|
||||
#
|
||||
# The entry point is `process_epoch`, which is at the bottom of this file.
|
||||
@ -174,7 +174,7 @@ func is_eligible_validator*(validator: ParticipationInfo): bool =
|
||||
|
||||
from ./datatypes/deneb import BeaconState
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_unslashed_participating_indices
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_unslashed_participating_indices
|
||||
func get_unslashed_participating_balances*(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState):
|
||||
@ -443,7 +443,7 @@ proc compute_unrealized_finality*(
|
||||
justified: jfRes.current_justified_checkpoint,
|
||||
finalized: jfRes.finalized_checkpoint)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#justification-and-finalization
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#justification-and-finalization
|
||||
proc process_justification_and_finalization*(
|
||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||
capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
||||
@ -656,7 +656,7 @@ func get_attestation_deltas(
|
||||
info.validators[proposer_index].delta.add(
|
||||
proposer_delta.get()[1])
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_base_reward
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_base_reward
|
||||
func get_base_reward_increment*(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState,
|
||||
@ -667,7 +667,7 @@ func get_base_reward_increment*(
|
||||
state.validators[index].effective_balance div EFFECTIVE_BALANCE_INCREMENT
|
||||
increments * base_reward_per_increment
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
func get_flag_index_reward*(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState,
|
||||
@ -681,19 +681,19 @@ func get_flag_index_reward*(
|
||||
else:
|
||||
0.Gwei
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
func get_unslashed_participating_increment*(
|
||||
info: altair.EpochInfo | bellatrix.BeaconState, flag_index: TimelyFlag): Gwei =
|
||||
info.balances.previous_epoch[flag_index] div EFFECTIVE_BALANCE_INCREMENT
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
func get_active_increments*(
|
||||
info: altair.EpochInfo | bellatrix.BeaconState): Gwei =
|
||||
info.balances.current_epoch div EFFECTIVE_BALANCE_INCREMENT
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||
# Combines get_flag_index_deltas() and get_inactivity_penalty_deltas()
|
||||
template get_flag_and_inactivity_delta(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
@ -918,8 +918,8 @@ func process_registry_updates*(
|
||||
ok()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#slashings
|
||||
func get_adjusted_total_slashing_balance*(
|
||||
state: ForkyBeaconState, total_balance: Gwei): Gwei =
|
||||
const multiplier =
|
||||
@ -937,15 +937,15 @@ func get_adjusted_total_slashing_balance*(
|
||||
min(sum(state.slashings.data) * multiplier, total_balance)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#slashings
|
||||
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
||||
validator.slashed and
|
||||
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#slashings
|
||||
func get_slashing_penalty*(validator: Validator,
|
||||
adjusted_total_slashing_balance,
|
||||
total_balance: Gwei): Gwei =
|
||||
@ -956,8 +956,8 @@ func get_slashing_penalty*(validator: Validator,
|
||||
penalty_numerator div total_balance * increment
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/bellatrix/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/beacon-chain.md#slashings
|
||||
func process_slashings*(state: var ForkyBeaconState, total_balance: Gwei) =
|
||||
let
|
||||
epoch = get_current_epoch(state)
|
||||
@ -1050,7 +1050,7 @@ func process_participation_record_updates*(state: var phase0.BeaconState) =
|
||||
state.previous_epoch_attestations.clear()
|
||||
swap(state.previous_epoch_attestations, state.current_epoch_attestations)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#participation-flags-updates
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#participation-flags-updates
|
||||
func process_participation_flag_updates*(
|
||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||
capella.BeaconState | deneb.BeaconState |
|
||||
@ -1065,7 +1065,7 @@ func process_participation_flag_updates*(
|
||||
# grows. New elements are automatically initialized to 0, as required.
|
||||
doAssert state.current_epoch_participation.asList.setLen(state.validators.len)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#sync-committee-updates
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#sync-committee-updates
|
||||
func process_sync_committee_updates*(
|
||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||
capella.BeaconState | deneb.BeaconState |
|
||||
@ -1075,7 +1075,7 @@ func process_sync_committee_updates*(
|
||||
state.current_sync_committee = state.next_sync_committee
|
||||
state.next_sync_committee = get_next_sync_committee(state)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#inactivity-scores
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#inactivity-scores
|
||||
template compute_inactivity_update(
|
||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState | electra.BeaconState,
|
||||
@ -1097,7 +1097,7 @@ template compute_inactivity_update(
|
||||
inactivity_score -= min(INACTIVITY_SCORE_RECOVERY_RATE.uint64, inactivity_score)
|
||||
inactivity_score
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#inactivity-scores
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#inactivity-scores
|
||||
func process_inactivity_updates*(
|
||||
cfg: RuntimeConfig,
|
||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||
@ -1198,7 +1198,7 @@ func init*(
|
||||
deneb.BeaconState): T =
|
||||
init(result, state)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#epoch-processing
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#epoch-processing
|
||||
proc process_epoch*(
|
||||
cfg: RuntimeConfig,
|
||||
state: var (altair.BeaconState | bellatrix.BeaconState),
|
||||
@ -1209,7 +1209,7 @@ proc process_epoch*(
|
||||
|
||||
info.init(state)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#justification-and-finalization
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#justification-and-finalization
|
||||
# [Modified in Altair]
|
||||
process_justification_and_finalization(state, info.balances, flags)
|
||||
|
||||
@ -1225,13 +1225,13 @@ proc process_epoch*(
|
||||
|
||||
process_inactivity_updates(cfg, state, info) # [New in Altair]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||
process_rewards_and_penalties(cfg, state, info) # [Modified in Altair]
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#registry-updates
|
||||
? process_registry_updates(cfg, state, cache)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
||||
process_slashings(state, info.balances.current_epoch) # [Modified in Altair]
|
||||
|
||||
process_eth1_data_reset(state)
|
||||
@ -1255,7 +1255,7 @@ proc process_epoch*(
|
||||
|
||||
info.init(state)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#justification-and-finalization
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#justification-and-finalization
|
||||
process_justification_and_finalization(state, info.balances, flags)
|
||||
|
||||
# state.slot hasn't been incremented yet.
|
||||
@ -1271,13 +1271,13 @@ proc process_epoch*(
|
||||
|
||||
process_inactivity_updates(cfg, state, info)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||
process_rewards_and_penalties(cfg, state, info)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#registry-updates
|
||||
? process_registry_updates(cfg, state, cache)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/beacon-chain.md#slashings
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
||||
process_slashings(state, info.balances.current_epoch)
|
||||
|
||||
process_eth1_data_reset(state)
|
||||
|
@ -455,7 +455,7 @@ func get_beacon_proposer_index*(state: ForkedHashedBeaconState,
|
||||
withState(state):
|
||||
get_beacon_proposer_index(forkyState.data, cache, slot)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregation-selection
|
||||
func is_aggregator*(committee_len: uint64, slot_signature: ValidatorSig): bool =
|
||||
let modulo = max(1'u64, committee_len div TARGET_AGGREGATORS_PER_COMMITTEE)
|
||||
bytes_to_uint64(eth2digest(
|
||||
|
@ -10,10 +10,10 @@
|
||||
import
|
||||
./datatypes/base, ./beaconstate, ./forks, ./helpers
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md#configuration
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md#configuration
|
||||
const SAFETY_DECAY* = 10'u64
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md#compute_weak_subjectivity_period
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md#compute_weak_subjectivity_period
|
||||
func compute_weak_subjectivity_period(
|
||||
cfg: RuntimeConfig, state: ForkyBeaconState): uint64 =
|
||||
## Returns the weak subjectivity period for the current ``state``.
|
||||
@ -49,7 +49,7 @@ func compute_weak_subjectivity_period(
|
||||
|
||||
ws_period
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md#is_within_weak_subjectivity_period
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md#is_within_weak_subjectivity_period
|
||||
func is_within_weak_subjectivity_period*(cfg: RuntimeConfig, current_slot: Slot,
|
||||
ws_state: ForkedHashedBeaconState,
|
||||
ws_checkpoint: Checkpoint): bool =
|
||||
|
@ -328,7 +328,7 @@ template query[E](
|
||||
): Future[bool].Raising([CancelledError]) =
|
||||
self.query(e, Nothing())
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||
proc loop(self: LightClientManager) {.async: (raises: [CancelledError]).} =
|
||||
var nextSyncTaskTime = self.getBeaconTime()
|
||||
while true:
|
||||
|
@ -171,7 +171,7 @@ proc doTrustedNodeSync*(
|
||||
let stateId =
|
||||
case syncTarget.kind
|
||||
of TrustedNodeSyncKind.TrustedBlockRoot:
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/light-client.md#light-client-sync-process
|
||||
const lcDataFork = LightClientDataFork.high
|
||||
var bestViableCheckpoint: Opt[tuple[slot: Slot, state_root: Eth2Digest]]
|
||||
func trackBestViableCheckpoint(store: lcDataFork.LightClientStore) =
|
||||
|
@ -1378,7 +1378,7 @@ proc sendAttestations(node: BeaconNode, head: BlockRef, slot: Slot) =
|
||||
# We need to run attestations exactly for the slot that we're attesting to.
|
||||
# In case blocks went missing, this means advancing past the latest block
|
||||
# using empty slots as fillers.
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#validator-assignments
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#validator-assignments
|
||||
let
|
||||
epochRef = node.dag.getEpochRef(
|
||||
attestationHead.blck, slot.epoch, false).valueOr:
|
||||
@ -1572,13 +1572,13 @@ proc signAndSendAggregate(
|
||||
return
|
||||
res.get()
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregation-selection
|
||||
if not is_aggregator(
|
||||
shufflingRef, slot, committee_index, selectionProof):
|
||||
return
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/phase0/validator.md#construct-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregateandproof
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregateandproof
|
||||
var
|
||||
msg = SignedAggregateAndProof(
|
||||
message: AggregateAndProof(
|
||||
@ -1939,8 +1939,8 @@ proc handleValidatorDuties*(node: BeaconNode, lastSlot, slot: Slot) {.async: (ra
|
||||
|
||||
updateValidatorMetrics(node) # the important stuff is done, update the vanity numbers
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#broadcast-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# Wait 2 / 3 of the slot time to allow messages to propagate, then collect
|
||||
# the result in aggregates
|
||||
static:
|
||||
|
@ -36,7 +36,7 @@ export results
|
||||
# - https://notes.ethereum.org/@djrtwo/Bkn3zpwxB#Validator-responsibilities
|
||||
#
|
||||
# Phase 0 spec - Honest Validator - how to avoid slashing
|
||||
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#how-to-avoid-slashing
|
||||
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#how-to-avoid-slashing
|
||||
#
|
||||
# In-depth reading on slashing conditions
|
||||
#
|
||||
@ -58,7 +58,7 @@ export results
|
||||
# 2. An attester can get slashed for signing
|
||||
# two attestations that together violate
|
||||
# the Casper FFG slashing conditions.
|
||||
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#ffg-vote
|
||||
# - https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#ffg-vote
|
||||
# The "source" is the current_justified_epoch
|
||||
# The "target" is the current_epoch
|
||||
#
|
||||
|
@ -496,7 +496,7 @@ proc signData(v: AttachedValidator,
|
||||
else:
|
||||
v.signWithDistributedKey(request)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#signature
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#signature
|
||||
proc getBlockSignature*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest, slot: Slot,
|
||||
block_root: Eth2Digest,
|
||||
@ -645,7 +645,7 @@ proc getBlockSignature*(v: AttachedValidator, fork: Fork,
|
||||
proofs)
|
||||
await v.signData(web3signerRequest)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregate-signature
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregate-signature
|
||||
proc getAttestationSignature*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
data: AttestationData
|
||||
@ -661,7 +661,7 @@ proc getAttestationSignature*(v: AttachedValidator, fork: Fork,
|
||||
let request = Web3SignerRequest.init(fork, genesis_validators_root, data)
|
||||
await v.signData(request)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#broadcast-aggregate
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
||||
proc getAggregateAndProofSignature*(v: AttachedValidator,
|
||||
fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
@ -680,7 +680,7 @@ proc getAggregateAndProofSignature*(v: AttachedValidator,
|
||||
fork, genesis_validators_root, aggregate_and_proof)
|
||||
await v.signData(request)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#prepare-sync-committee-message
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#prepare-sync-committee-message
|
||||
proc getSyncCommitteeMessage*(v: AttachedValidator,
|
||||
fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
@ -711,7 +711,7 @@ proc getSyncCommitteeMessage*(v: AttachedValidator,
|
||||
)
|
||||
)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#aggregation-selection
|
||||
proc getSyncCommitteeSelectionProof*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
slot: Slot,
|
||||
@ -731,7 +731,7 @@ proc getSyncCommitteeSelectionProof*(v: AttachedValidator, fork: Fork,
|
||||
)
|
||||
await v.signData(request)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/validator.md#broadcast-sync-committee-contribution
|
||||
proc getContributionAndProofSignature*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest,
|
||||
contribution_and_proof: ContributionAndProof
|
||||
@ -747,7 +747,7 @@ proc getContributionAndProofSignature*(v: AttachedValidator, fork: Fork,
|
||||
fork, genesis_validators_root, contribution_and_proof)
|
||||
await v.signData(request)
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#randao-reveal
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#randao-reveal
|
||||
proc getEpochSignature*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest, epoch: Epoch
|
||||
): Future[SignatureResult]
|
||||
@ -772,7 +772,7 @@ proc getEpochSignature*(v: AttachedValidator, fork: Fork,
|
||||
v.epochSignature = Opt.some((epoch, signature.get))
|
||||
signature
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#aggregation-selection
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregation-selection
|
||||
proc getSlotSignature*(v: AttachedValidator, fork: Fork,
|
||||
genesis_validators_root: Eth2Digest, slot: Slot
|
||||
): Future[SignatureResult]
|
||||
|
@ -104,7 +104,7 @@ The following sections explain how to do this for certain EL clients.
|
||||
## Running the light client
|
||||
|
||||
The light client starts syncing from a trusted block.
|
||||
This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the light client.
|
||||
This trusted block should be somewhat recent ([~1-2 weeks](https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/weak-subjectivity.md)) and needs to be configured each time when starting the light client.
|
||||
|
||||
### 1. Obtaining a trusted block root
|
||||
|
||||
@ -188,7 +188,7 @@ NTC 2022-11-21 18:04:03.982+01:00 New LC optimistic block opt
|
||||
```
|
||||
|
||||
!!! note
|
||||
The [light client protocol](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/altair/light-client/sync-protocol.md) depends on consensus layer (CL) full nodes to serve additional data.
|
||||
The [light client protocol](https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/light-client/sync-protocol.md) depends on consensus layer (CL) full nodes to serve additional data.
|
||||
As this is a new protocol, not all implementations are supporting it yet.
|
||||
Therefore, it may take several minutes to discover supporting peers, during which no log messages may be produced.
|
||||
|
||||
|
@ -135,7 +135,7 @@ If you are already using a threshold signing setup (e.g. based on Vouch and Dirk
|
||||
|
||||
The verifying Web3Signer is an experimental extension to the [Web3Signer protocol](https://consensys.github.io/web3signer/web3signer-eth2.html#tag/Signing/operation/ETH2_SIGN) which allows the remote signer to verify certain details of the signed blocks before creating a signature (for example, the signer may require the signed block to have a particular fee recipient value).
|
||||
|
||||
To enable this use case, the `BLOCK_V2` request type of the `/api/v1/eth2/sign/{identifier}` endpoint is extended with an additional array field named `proofs`. The array consists of objects with the properties `index`, `proof` and `value`, where `index` is an arbitrary [generalized index](https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/ssz/merkle-proofs.md#generalized-merkle-tree-index) of any property nested under the block body and `proof` is its corresponding Merkle proof against the block body root included in the request. The `value` property is optional and it is included only when the SSZ hash of the field included in the Merkle proof doesn't match its value.
|
||||
To enable this use case, the `BLOCK_V2` request type of the `/api/v1/eth2/sign/{identifier}` endpoint is extended with an additional array field named `proofs`. The array consists of objects with the properties `index`, `proof` and `value`, where `index` is an arbitrary [generalized index](https://github.com/ethereum/consensus-specs/blob/v1.4.0/ssz/merkle-proofs.md#generalized-merkle-tree-index) of any property nested under the block body and `proof` is its corresponding Merkle proof against the block body root included in the request. The `value` property is optional and it is included only when the SSZ hash of the field included in the Merkle proof doesn't match its value.
|
||||
|
||||
Since the generalized index of a particular field may change in a hard-fork, in the remote keystore format the proven fields are usually specified by their name:
|
||||
|
||||
|
@ -23,7 +23,7 @@ import
|
||||
# Test utilities
|
||||
../../testutil, ../../testblockutil
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/tests/core/pyspec/eth2spec/test/helpers/sync_committee.py#L27-L44
|
||||
proc compute_aggregate_sync_committee_signature(
|
||||
cfg: RuntimeConfig,
|
||||
forked: ForkedHashedBeaconState,
|
||||
|
@ -270,7 +270,7 @@ func makeAttestationData*(
|
||||
"Computed epoch was " & $slot.epoch &
|
||||
" while the state current_epoch was " & $current_epoch
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/validator.md#attestation-data
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#attestation-data
|
||||
AttestationData(
|
||||
slot: slot,
|
||||
index: committee_index.uint64,
|
||||
|
Loading…
x
Reference in New Issue
Block a user