some v1.5.0-alpha.4 consensus spec URL updates (#6485)
This commit is contained in:
parent
904318cf83
commit
f258cba816
|
@ -373,7 +373,7 @@ proc get_head*(self: var ForkChoice,
|
||||||
self.checkpoints.justified.balances,
|
self.checkpoints.justified.balances,
|
||||||
self.checkpoints.proposer_boost_root)
|
self.checkpoints.proposer_boost_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/fork_choice/safe-block.md#get_safe_beacon_block_root
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/fork_choice/safe-block.md#get_safe_beacon_block_root
|
||||||
func get_safe_beacon_block_root*(self: ForkChoice): Eth2Digest =
|
func get_safe_beacon_block_root*(self: ForkChoice): Eth2Digest =
|
||||||
# Use most recent justified block as a stopgap
|
# Use most recent justified block as a stopgap
|
||||||
self.checkpoints.justified.checkpoint.root
|
self.checkpoints.justified.checkpoint.root
|
||||||
|
|
|
@ -695,7 +695,7 @@ typedef struct ETHBeaconBlockHeader ETHBeaconBlockHeader;
|
||||||
*
|
*
|
||||||
* @return Beacon block header.
|
* @return Beacon block header.
|
||||||
*
|
*
|
||||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#beaconblockheader
|
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#beaconblockheader
|
||||||
*/
|
*/
|
||||||
ETH_RESULT_USE_CHECK
|
ETH_RESULT_USE_CHECK
|
||||||
const ETHBeaconBlockHeader *ETHLightClientHeaderGetBeacon(
|
const ETHBeaconBlockHeader *ETHLightClientHeaderGetBeacon(
|
||||||
|
|
|
@ -841,7 +841,7 @@ proc ETHLightClientHeaderCopyBeaconRoot(
|
||||||
## * Pointer to a copy of the given header's beacon block root.
|
## * Pointer to a copy of the given header's beacon block root.
|
||||||
##
|
##
|
||||||
## See:
|
## See:
|
||||||
## * https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#hash_tree_root
|
## * https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#hash_tree_root
|
||||||
discard cfg # Future-proof against new fields, see `get_lc_execution_root`.
|
discard cfg # Future-proof against new fields, see `get_lc_execution_root`.
|
||||||
let root = Eth2Digest.new()
|
let root = Eth2Digest.new()
|
||||||
root[] = header[].beacon.hash_tree_root()
|
root[] = header[].beacon.hash_tree_root()
|
||||||
|
|
|
@ -176,7 +176,7 @@ type
|
||||||
MounterProc* = proc(network: Eth2Node) {.gcsafe, raises: [].}
|
MounterProc* = proc(network: Eth2Node) {.gcsafe, raises: [].}
|
||||||
MessageContentPrinter* = proc(msg: pointer): string {.gcsafe, raises: [].}
|
MessageContentPrinter* = proc(msg: pointer): string {.gcsafe, raises: [].}
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#goodbye
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/p2p-interface.md#goodbye
|
||||||
DisconnectionReason* = enum
|
DisconnectionReason* = enum
|
||||||
# might see other values on the wire!
|
# might see other values on the wire!
|
||||||
ClientShutDown = 1
|
ClientShutDown = 1
|
||||||
|
@ -2556,7 +2556,7 @@ proc updateStabilitySubnetMetadata*(node: Eth2Node, attnets: AttnetBits) =
|
||||||
node.metadata.attnets = attnets
|
node.metadata.attnets = attnets
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/p2p-interface.md#attestation-subnet-subscription
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/p2p-interface.md#attestation-subnet-subscription
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#attestation-subnet-bitfield
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/p2p-interface.md#attestation-subnet-bitfield
|
||||||
let res = node.discovery.updateRecord({
|
let res = node.discovery.updateRecord({
|
||||||
enrAttestationSubnetsField: SSZ.encode(node.metadata.attnets)
|
enrAttestationSubnetsField: SSZ.encode(node.metadata.attnets)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1789,7 +1789,7 @@ proc installMessageValidators(node: BeaconNode) =
|
||||||
let digest = forkDigests[].atConsensusFork(consensusFork)
|
let digest = forkDigests[].atConsensusFork(consensusFork)
|
||||||
|
|
||||||
# beacon_block
|
# beacon_block
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_block
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/p2p-interface.md#beacon_block
|
||||||
node.network.addValidator(
|
node.network.addValidator(
|
||||||
getBeaconBlocksTopic(digest), proc (
|
getBeaconBlocksTopic(digest), proc (
|
||||||
signedBlock: consensusFork.SignedBeaconBlock
|
signedBlock: consensusFork.SignedBeaconBlock
|
||||||
|
|
|
@ -96,7 +96,7 @@ func get_validator_churn_limit*(
|
||||||
count_active_validators(
|
count_active_validators(
|
||||||
state, state.get_current_epoch(), cache) div cfg.CHURN_LIMIT_QUOTIENT)
|
state, state.get_current_epoch(), cache) div cfg.CHURN_LIMIT_QUOTIENT)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#new-get_validator_activation_churn_limit
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/deneb/beacon-chain.md#new-get_validator_activation_churn_limit
|
||||||
func get_validator_activation_churn_limit*(
|
func get_validator_activation_churn_limit*(
|
||||||
cfg: RuntimeConfig, state: deneb.BeaconState | electra.BeaconState,
|
cfg: RuntimeConfig, state: deneb.BeaconState | electra.BeaconState,
|
||||||
cache: var StateCache): uint64 =
|
cache: var StateCache): uint64 =
|
||||||
|
@ -270,7 +270,7 @@ func compute_consolidation_epoch_and_update_churn*(
|
||||||
|
|
||||||
state.earliest_consolidation_epoch
|
state.earliest_consolidation_epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#updated--initiate_validator_exit
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/electra/beacon-chain.md#modified-initiate_validator_exit
|
||||||
func initiate_validator_exit*(
|
func initiate_validator_exit*(
|
||||||
cfg: RuntimeConfig, state: var electra.BeaconState,
|
cfg: RuntimeConfig, state: var electra.BeaconState,
|
||||||
index: ValidatorIndex, exit_queue_info: ExitQueueInfo,
|
index: ValidatorIndex, exit_queue_info: ExitQueueInfo,
|
||||||
|
@ -326,7 +326,7 @@ func get_whistleblower_reward*(
|
||||||
validator_effective_balance: Gwei): Gwei =
|
validator_effective_balance: Gwei): Gwei =
|
||||||
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT
|
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#updated-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/electra/beacon-chain.md#modified-slash_validator
|
||||||
func get_whistleblower_reward*(
|
func get_whistleblower_reward*(
|
||||||
state: electra.BeaconState, validator_effective_balance: Gwei): Gwei =
|
state: electra.BeaconState, validator_effective_balance: Gwei): Gwei =
|
||||||
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
|
validator_effective_balance div WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
|
||||||
|
@ -407,7 +407,7 @@ func get_initial_beacon_block*(state: phase0.HashedBeaconState):
|
||||||
phase0.TrustedSignedBeaconBlock(
|
phase0.TrustedSignedBeaconBlock(
|
||||||
message: message, root: hash_tree_root(message))
|
message: message, root: hash_tree_root(message))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0/specs/altair/beacon-chain.md#initialize-state-for-pure-altair-testnets-and-test-vectors
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#initialize-state-for-pure-altair-testnets-and-test-vectors
|
||||||
func get_initial_beacon_block*(state: altair.HashedBeaconState):
|
func get_initial_beacon_block*(state: altair.HashedBeaconState):
|
||||||
altair.TrustedSignedBeaconBlock =
|
altair.TrustedSignedBeaconBlock =
|
||||||
# The genesis block is implicitly trusted
|
# The genesis block is implicitly trusted
|
||||||
|
@ -1128,7 +1128,7 @@ proc process_attestation*(
|
||||||
|
|
||||||
ok(proposer_reward)
|
ok(proposer_reward)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#get_next_sync_committee_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#get_next_sync_committee_indices
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#modified-get_next_sync_committee_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#modified-get_next_sync_committee_indices
|
||||||
func get_next_sync_committee_keys(
|
func get_next_sync_committee_keys(
|
||||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||||
|
@ -1173,7 +1173,7 @@ func get_next_sync_committee_keys(
|
||||||
i += 1'u64
|
i += 1'u64
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/capella/beacon-chain.md#has_eth1_withdrawal_credential
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/capella/beacon-chain.md#has_eth1_withdrawal_credential
|
||||||
func has_eth1_withdrawal_credential*(validator: Validator): bool =
|
func has_eth1_withdrawal_credential*(validator: Validator): bool =
|
||||||
## Check if ``validator`` has an 0x01 prefixed "eth1" withdrawal credential.
|
## Check if ``validator`` has an 0x01 prefixed "eth1" withdrawal credential.
|
||||||
validator.withdrawal_credentials.data[0] == ETH1_ADDRESS_WITHDRAWAL_PREFIX
|
validator.withdrawal_credentials.data[0] == ETH1_ADDRESS_WITHDRAWAL_PREFIX
|
||||||
|
@ -1195,7 +1195,7 @@ func has_execution_withdrawal_credential*(validator: Validator): bool =
|
||||||
has_compounding_withdrawal_credential(validator) or
|
has_compounding_withdrawal_credential(validator) or
|
||||||
has_eth1_withdrawal_credential(validator)
|
has_eth1_withdrawal_credential(validator)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/capella/beacon-chain.md#is_fully_withdrawable_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/capella/beacon-chain.md#is_fully_withdrawable_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#updated-is_fully_withdrawable_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#updated-is_fully_withdrawable_validator
|
||||||
func is_fully_withdrawable_validator(
|
func is_fully_withdrawable_validator(
|
||||||
fork: static ConsensusFork, validator: Validator, balance: Gwei,
|
fork: static ConsensusFork, validator: Validator, balance: Gwei,
|
||||||
|
|
|
@ -304,7 +304,7 @@ type
|
||||||
HashedValidatorPubKey* = object
|
HashedValidatorPubKey* = object
|
||||||
value*: ptr HashedValidatorPubKeyItem
|
value*: ptr HashedValidatorPubKeyItem
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#validator
|
||||||
Validator* = object
|
Validator* = object
|
||||||
pubkeyData*{.serializedFieldName: "pubkey".}: HashedValidatorPubKey
|
pubkeyData*{.serializedFieldName: "pubkey".}: HashedValidatorPubKey
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ type
|
||||||
message*: VoluntaryExit
|
message*: VoluntaryExit
|
||||||
signature*: TrustedSig
|
signature*: TrustedSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#beaconblockheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#beaconblockheader
|
||||||
BeaconBlockHeader* = object
|
BeaconBlockHeader* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
proposer_index*: uint64 # `ValidatorIndex` after validation
|
proposer_index*: uint64 # `ValidatorIndex` after validation
|
||||||
|
|
|
@ -32,7 +32,7 @@ const
|
||||||
# This index is rooted in `BeaconBlockBody`.
|
# This index is rooted in `BeaconBlockBody`.
|
||||||
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
# The first member (`randao_reveal`) is 16, subsequent members +1 each.
|
||||||
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
# If there are ever more than 16 members in `BeaconBlockBody`, indices change!
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/ssz/merkle-proofs.md
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/ssz/merkle-proofs.md
|
||||||
# execution_payload
|
# execution_payload
|
||||||
EXECUTION_PAYLOAD_GINDEX* = 25.GeneralizedIndex
|
EXECUTION_PAYLOAD_GINDEX* = 25.GeneralizedIndex
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ type
|
||||||
ExecutionBranch* =
|
ExecutionBranch* =
|
||||||
array[log2trunc(EXECUTION_PAYLOAD_GINDEX), Eth2Digest]
|
array[log2trunc(EXECUTION_PAYLOAD_GINDEX), Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
||||||
LightClientHeader* = object
|
LightClientHeader* = object
|
||||||
beacon*: BeaconBlockHeader
|
beacon*: BeaconBlockHeader
|
||||||
## Beacon block header
|
## Beacon block header
|
||||||
|
@ -358,7 +358,7 @@ type
|
||||||
state_root*: Eth2Digest
|
state_root*: Eth2Digest
|
||||||
body*: TrustedBeaconBlockBody
|
body*: TrustedBeaconBlockBody
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#beaconblockbody
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/capella/beacon-chain.md#beaconblockbody
|
||||||
BeaconBlockBody* = object
|
BeaconBlockBody* = object
|
||||||
randao_reveal*: ValidatorSig
|
randao_reveal*: ValidatorSig
|
||||||
eth1_data*: Eth1Data
|
eth1_data*: Eth1Data
|
||||||
|
@ -699,7 +699,7 @@ func upgrade_lc_bootstrap_to_capella*(
|
||||||
current_sync_committee: pre.current_sync_committee,
|
current_sync_committee: pre.current_sync_committee,
|
||||||
current_sync_committee_branch: pre.current_sync_committee_branch)
|
current_sync_committee_branch: pre.current_sync_committee_branch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/capella/light-client/fork.md#upgrading-light-client-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/capella/light-client/fork.md#upgrading-light-client-data
|
||||||
func upgrade_lc_update_to_capella*(
|
func upgrade_lc_update_to_capella*(
|
||||||
pre: altair.LightClientUpdate): LightClientUpdate =
|
pre: altair.LightClientUpdate): LightClientUpdate =
|
||||||
LightClientUpdate(
|
LightClientUpdate(
|
||||||
|
|
|
@ -87,5 +87,5 @@ const
|
||||||
UNSET_DEPOSIT_REQUESTS_START_INDEX*: uint64 = not 0'u64
|
UNSET_DEPOSIT_REQUESTS_START_INDEX*: uint64 = not 0'u64
|
||||||
FULL_EXIT_REQUEST_AMOUNT*: uint64 = 0
|
FULL_EXIT_REQUEST_AMOUNT*: uint64 = 0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#withdrawal-prefixes
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/electra/beacon-chain.md#withdrawal-prefixes
|
||||||
COMPOUNDING_WITHDRAWAL_PREFIX* = 0x02
|
COMPOUNDING_WITHDRAWAL_PREFIX* = 0x02
|
||||||
|
|
|
@ -167,7 +167,7 @@ type
|
||||||
## Current sync committee corresponding to `header.beacon.state_root`
|
## Current sync committee corresponding to `header.beacon.state_root`
|
||||||
current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch
|
current_sync_committee_branch*: altair.CurrentSyncCommitteeBranch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/light-client/sync-protocol.md#lightclientupdate
|
||||||
LightClientUpdate* = object
|
LightClientUpdate* = object
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
## Header attested to by the sync committee
|
## Header attested to by the sync committee
|
||||||
|
|
|
@ -158,7 +158,7 @@ type
|
||||||
ExecutePayload* = proc(
|
ExecutePayload* = proc(
|
||||||
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
execution_payload: ExecutionPayload): bool {.gcsafe, raises: [].}
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/82133085a1295e93394ebdf71df8f2f6e0962588/specs/electra/beacon-chain.md#depositreceipt
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/electra/beacon-chain.md#pendingbalancedeposit
|
||||||
PendingBalanceDeposit* = object
|
PendingBalanceDeposit* = object
|
||||||
index*: uint64
|
index*: uint64
|
||||||
amount*: Gwei
|
amount*: Gwei
|
||||||
|
@ -243,7 +243,7 @@ type
|
||||||
signature_slot*: Slot
|
signature_slot*: Slot
|
||||||
## Slot at which the aggregate signature was created (untrusted)
|
## Slot at which the aggregate signature was created (untrusted)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/light-client/sync-protocol.md#lightclientfinalityupdate
|
||||||
LightClientFinalityUpdate* = object
|
LightClientFinalityUpdate* = object
|
||||||
# Header attested to by the sync committee
|
# Header attested to by the sync committee
|
||||||
attested_header*: LightClientHeader
|
attested_header*: LightClientHeader
|
||||||
|
|
|
@ -258,7 +258,7 @@ func create_blob_sidecars*(
|
||||||
res.add(sidecar)
|
res.add(sidecar)
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/altair/light-client/sync-protocol.md#is_sync_committee_update
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/light-client/sync-protocol.md#is_sync_committee_update
|
||||||
template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool =
|
template is_sync_committee_update*(update: SomeForkyLightClientUpdate): bool =
|
||||||
when update is SomeForkyLightClientUpdateWithSyncCommittee:
|
when update is SomeForkyLightClientUpdateWithSyncCommittee:
|
||||||
update.next_sync_committee_branch !=
|
update.next_sync_committee_branch !=
|
||||||
|
|
|
@ -27,7 +27,7 @@ const
|
||||||
# The spec now includes this as a bare uint64 as `RESP_TIMEOUT`
|
# The spec now includes this as a bare uint64 as `RESP_TIMEOUT`
|
||||||
RESP_TIMEOUT_DUR* = RESP_TIMEOUT.int64.seconds
|
RESP_TIMEOUT_DUR* = RESP_TIMEOUT.int64.seconds
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/light-client/p2p-interface.md#configuration
|
||||||
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
|
MAX_REQUEST_LIGHT_CLIENT_UPDATES* = 128
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#configuration
|
||||||
|
|
|
@ -143,7 +143,7 @@ func compute_attestation_signing_root*(
|
||||||
fork, DOMAIN_BEACON_ATTESTER, epoch, genesis_validators_root)
|
fork, DOMAIN_BEACON_ATTESTER, epoch, genesis_validators_root)
|
||||||
compute_signing_root(attestation_data, domain)
|
compute_signing_root(attestation_data, domain)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#aggregate-signature
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/validator.md#aggregate-signature
|
||||||
func get_attestation_signature*(
|
func get_attestation_signature*(
|
||||||
fork: Fork, genesis_validators_root: Eth2Digest,
|
fork: Fork, genesis_validators_root: Eth2Digest,
|
||||||
attestation_data: AttestationData,
|
attestation_data: AttestationData,
|
||||||
|
|
|
@ -82,7 +82,7 @@ func `xor`[T: array](a, b: T): T =
|
||||||
for i in 0..<result.len:
|
for i in 0..<result.len:
|
||||||
result[i] = a[i] xor b[i]
|
result[i] = a[i] xor b[i]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#randao
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#randao
|
||||||
proc process_randao(
|
proc process_randao(
|
||||||
state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody,
|
state: var ForkyBeaconState, body: SomeForkyBeaconBlockBody,
|
||||||
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
||||||
|
@ -348,7 +348,7 @@ proc apply_deposit(
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/phase0/beacon-chain.md#deposits
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#deposits
|
||||||
proc process_deposit*(
|
proc process_deposit*(
|
||||||
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
cfg: RuntimeConfig, state: var ForkyBeaconState,
|
||||||
bucketSortedValidators: var BucketSortedValidators,
|
bucketSortedValidators: var BucketSortedValidators,
|
||||||
|
@ -371,7 +371,7 @@ proc process_deposit*(
|
||||||
|
|
||||||
apply_deposit(cfg, state, bucketSortedValidators, deposit.data, flags)
|
apply_deposit(cfg, state, bucketSortedValidators, deposit.data, flags)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#new-process_deposit_request
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/electra/beacon-chain.md#new-process_deposit_request
|
||||||
func process_deposit_request*(
|
func process_deposit_request*(
|
||||||
cfg: RuntimeConfig, state: var electra.BeaconState,
|
cfg: RuntimeConfig, state: var electra.BeaconState,
|
||||||
bucketSortedValidators: var BucketSortedValidators,
|
bucketSortedValidators: var BucketSortedValidators,
|
||||||
|
@ -748,11 +748,11 @@ func get_participant_reward*(total_active_balance: Gwei): Gwei =
|
||||||
WEIGHT_DENOMINATOR div SLOTS_PER_EPOCH
|
WEIGHT_DENOMINATOR div SLOTS_PER_EPOCH
|
||||||
max_participant_rewards div SYNC_COMMITTEE_SIZE
|
max_participant_rewards div SYNC_COMMITTEE_SIZE
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#sync-aggregate-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||||
func get_proposer_reward*(participant_reward: Gwei): Gwei =
|
func get_proposer_reward*(participant_reward: Gwei): Gwei =
|
||||||
participant_reward * PROPOSER_WEIGHT div (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
|
participant_reward * PROPOSER_WEIGHT div (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#sync-aggregate-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#sync-aggregate-processing
|
||||||
proc process_sync_aggregate*(
|
proc process_sync_aggregate*(
|
||||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||||
capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
capella.BeaconState | deneb.BeaconState | electra.BeaconState),
|
||||||
|
@ -1109,7 +1109,7 @@ proc process_block*(
|
||||||
|
|
||||||
ok(? process_operations(cfg, state, blck.body, 0.Gwei, flags, cache))
|
ok(? process_operations(cfg, state, blck.body, 0.Gwei, flags, cache))
|
||||||
|
|
||||||
# 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.5.0-alpha.4/specs/altair/beacon-chain.md#block-processing
|
||||||
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
||||||
# copy of datatypes/altair.nim
|
# copy of datatypes/altair.nim
|
||||||
type SomeAltairBlock =
|
type SomeAltairBlock =
|
||||||
|
|
|
@ -700,7 +700,7 @@ func get_active_increments*(
|
||||||
info.balances.current_epoch div EFFECTIVE_BALANCE_INCREMENT.Gwei
|
info.balances.current_epoch div EFFECTIVE_BALANCE_INCREMENT.Gwei
|
||||||
|
|
||||||
# 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#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.5.0-alpha.4/specs/altair/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/bellatrix/beacon-chain.md#modified-get_inactivity_penalty_deltas
|
||||||
# Combines get_flag_index_deltas() and get_inactivity_penalty_deltas()
|
# Combines get_flag_index_deltas() and get_inactivity_penalty_deltas()
|
||||||
template get_flag_and_inactivity_delta(
|
template get_flag_and_inactivity_delta(
|
||||||
|
@ -843,7 +843,7 @@ func get_flag_and_inactivity_delta_for_validator(
|
||||||
active_increments, penalty_denominator, epoch_participation,
|
active_increments, penalty_denominator, epoch_participation,
|
||||||
participating_increments, info, vidx, inactivity_score.uint64)
|
participating_increments, info, vidx, inactivity_score.uint64)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||||
func process_rewards_and_penalties*(
|
func process_rewards_and_penalties*(
|
||||||
state: var phase0.BeaconState, info: var phase0.EpochInfo) =
|
state: var phase0.BeaconState, info: var phase0.EpochInfo) =
|
||||||
# No rewards are applied at the end of `GENESIS_EPOCH` because rewards are
|
# No rewards are applied at the end of `GENESIS_EPOCH` because rewards are
|
||||||
|
@ -866,7 +866,7 @@ func process_rewards_and_penalties*(
|
||||||
decrease_balance(balance, v.delta.penalties)
|
decrease_balance(balance, v.delta.penalties)
|
||||||
state.balances.asSeq()[idx] = balance
|
state.balances.asSeq()[idx] = balance
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/altair/beacon-chain.md#rewards-and-penalties
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||||
func process_rewards_and_penalties*(
|
func process_rewards_and_penalties*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var (altair.BeaconState | bellatrix.BeaconState |
|
state: var (altair.BeaconState | bellatrix.BeaconState |
|
||||||
|
@ -902,7 +902,7 @@ func process_rewards_and_penalties*(
|
||||||
|
|
||||||
from std/heapqueue import HeapQueue, `[]`, len, push, replace
|
from std/heapqueue import HeapQueue, `[]`, len, push, replace
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/beacon-chain.md#registry-updates
|
||||||
func process_registry_updates*(
|
func process_registry_updates*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
state: var (phase0.BeaconState | altair.BeaconState |
|
state: var (phase0.BeaconState | altair.BeaconState |
|
||||||
|
@ -971,7 +971,7 @@ func process_registry_updates*(
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#updated--process_registry_updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/electra/beacon-chain.md#modified-process_registry_updates
|
||||||
func process_registry_updates*(
|
func process_registry_updates*(
|
||||||
cfg: RuntimeConfig, state: var electra.BeaconState, cache: var StateCache):
|
cfg: RuntimeConfig, state: var electra.BeaconState, cache: var StateCache):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
|
@ -1036,7 +1036,7 @@ func get_slashing_penalty*(validator: Validator,
|
||||||
penalty_numerator div total_balance * increment
|
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/phase0/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.5.0-alpha.4/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/bellatrix/beacon-chain.md#slashings
|
||||||
func get_slashing(
|
func get_slashing(
|
||||||
state: ForkyBeaconState, total_balance: Gwei, vidx: ValidatorIndex): Gwei =
|
state: ForkyBeaconState, total_balance: Gwei, vidx: ValidatorIndex): Gwei =
|
||||||
|
@ -1411,7 +1411,7 @@ proc process_epoch*(
|
||||||
|
|
||||||
process_inactivity_updates(cfg, state, info) # [New in Altair]
|
process_inactivity_updates(cfg, state, info) # [New in Altair]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||||
process_rewards_and_penalties(cfg, state, info) # [Modified in Altair]
|
process_rewards_and_penalties(cfg, state, info) # [Modified in Altair]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#registry-updates
|
||||||
|
@ -1463,7 +1463,7 @@ proc process_epoch*(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#registry-updates
|
# 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)
|
? process_registry_updates(cfg, state, cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#slashings
|
||||||
process_slashings(state, info.balances.current_epoch)
|
process_slashings(state, info.balances.current_epoch)
|
||||||
|
|
||||||
process_eth1_data_reset(state)
|
process_eth1_data_reset(state)
|
||||||
|
@ -1486,7 +1486,7 @@ proc process_epoch*(
|
||||||
|
|
||||||
info.init(state)
|
info.init(state)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#justification-and-finalization
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/beacon-chain.md#justification-and-finalization
|
||||||
process_justification_and_finalization(state, info.balances, flags)
|
process_justification_and_finalization(state, info.balances, flags)
|
||||||
|
|
||||||
# state.slot hasn't been incremented yet.
|
# state.slot hasn't been incremented yet.
|
||||||
|
|
|
@ -160,7 +160,7 @@ p2pProtocol LightClientSync(version = 1,
|
||||||
|
|
||||||
debug "LC finality update request done", peer
|
debug "LC finality update request done", peer
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/light-client/p2p-interface.md#getlightclientoptimisticupdate
|
||||||
proc lightClientOptimisticUpdate(
|
proc lightClientOptimisticUpdate(
|
||||||
peer: Peer,
|
peer: Peer,
|
||||||
response: SingleChunkResponse[ForkedLightClientOptimisticUpdate])
|
response: SingleChunkResponse[ForkedLightClientOptimisticUpdate])
|
||||||
|
|
|
@ -133,7 +133,7 @@ proc block_for_next_slot(
|
||||||
addTestBlock(
|
addTestBlock(
|
||||||
forked, cache, attestations = attestations, cfg = cfg)
|
forked, cache, attestations = attestations, cfg = cfg)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/altair/light-client/sync-protocol.md#initialize_light_client_store
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/altair/light-client/sync-protocol.md#initialize_light_client_store
|
||||||
func initialize_light_client_store(
|
func initialize_light_client_store(
|
||||||
state: auto, storeDataFork: static LightClientDataFork): auto =
|
state: auto, storeDataFork: static LightClientDataFork): auto =
|
||||||
storeDataFork.LightClientStore(
|
storeDataFork.LightClientStore(
|
||||||
|
|
|
@ -83,7 +83,7 @@ type
|
||||||
rewards*: List[Gwei, Limit VALIDATOR_REGISTRY_LIMIT]
|
rewards*: List[Gwei, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||||
penalties*: List[Gwei, Limit VALIDATOR_REGISTRY_LIMIT]
|
penalties*: List[Gwei, Limit VALIDATOR_REGISTRY_LIMIT]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/validator.md#eth1block
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.4/specs/phase0/validator.md#eth1block
|
||||||
Eth1Block* = object
|
Eth1Block* = object
|
||||||
timestamp*: uint64
|
timestamp*: uint64
|
||||||
deposit_root*: Eth2Digest
|
deposit_root*: Eth2Digest
|
||||||
|
|
Loading…
Reference in New Issue