some manual updates to EF consensus-specs v1.5.0-alpha.7 URLs (#6604)
This commit is contained in:
parent
50eed81dcf
commit
b370112fe0
|
@ -1074,7 +1074,7 @@ proc forkchoiceUpdated*(
|
||||||
# block hash provided by this event is stubbed with
|
# block hash provided by this event is stubbed with
|
||||||
# `0x0000000000000000000000000000000000000000000000000000000000000000`."
|
# `0x0000000000000000000000000000000000000000000000000000000000000000`."
|
||||||
# and
|
# and
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/bellatrix/validator.md#executionpayload
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/validator.md#executionpayload
|
||||||
# notes "`finalized_block_hash` is the hash of the latest finalized execution
|
# notes "`finalized_block_hash` is the hash of the latest finalized execution
|
||||||
# payload (`Hash32()` if none yet finalized)"
|
# payload (`Hash32()` if none yet finalized)"
|
||||||
|
|
||||||
|
|
|
@ -82,11 +82,11 @@ type
|
||||||
deposits*: seq[Deposit]
|
deposits*: seq[Deposit]
|
||||||
hasMissingDeposits*: bool
|
hasMissingDeposits*: bool
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#get_eth1_data
|
||||||
func compute_time_at_slot(genesis_time: uint64, slot: Slot): uint64 =
|
func compute_time_at_slot(genesis_time: uint64, slot: Slot): uint64 =
|
||||||
genesis_time + slot * SECONDS_PER_SLOT
|
genesis_time + slot * SECONDS_PER_SLOT
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#get_eth1_data
|
||||||
func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
|
func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
|
||||||
let eth1_voting_period_start_slot =
|
let eth1_voting_period_start_slot =
|
||||||
getStateField(state, slot) - getStateField(state, slot) mod
|
getStateField(state, slot) - getStateField(state, slot) mod
|
||||||
|
@ -94,7 +94,7 @@ func voting_period_start_time(state: ForkedHashedBeaconState): uint64 =
|
||||||
compute_time_at_slot(
|
compute_time_at_slot(
|
||||||
getStateField(state, genesis_time), eth1_voting_period_start_slot)
|
getStateField(state, genesis_time), eth1_voting_period_start_slot)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#get_eth1_data
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#get_eth1_data
|
||||||
func is_candidate_block(cfg: RuntimeConfig,
|
func is_candidate_block(cfg: RuntimeConfig,
|
||||||
blk: Eth1Block,
|
blk: Eth1Block,
|
||||||
period_start: uint64): bool =
|
period_start: uint64): bool =
|
||||||
|
|
|
@ -9,7 +9,7 @@ This folder holds a collection of modules to:
|
||||||
|
|
||||||
Gossip validation is different from consensus verification in particular for blocks.
|
Gossip validation is different from consensus verification in particular for blocks.
|
||||||
|
|
||||||
- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#beacon_block
|
- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#beacon_block
|
||||||
- Attestations (aggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
- Attestations (aggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
||||||
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#attestation-subnets
|
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#attestation-subnets
|
||||||
- Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#voluntary_exit
|
- Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#voluntary_exit
|
||||||
|
|
|
@ -614,7 +614,7 @@ bool ETHLightClientStoreIsNextSyncCommitteeKnown(const ETHLightClientStore *stor
|
||||||
*
|
*
|
||||||
* @return Latest optimistic header.
|
* @return Latest optimistic header.
|
||||||
*
|
*
|
||||||
* @see https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/capella/light-client/sync-protocol.md#modified-lightclientheader
|
||||||
*/
|
*/
|
||||||
ETH_RESULT_USE_CHECK
|
ETH_RESULT_USE_CHECK
|
||||||
const ETHLightClientHeader *ETHLightClientStoreGetOptimisticHeader(
|
const ETHLightClientHeader *ETHLightClientStoreGetOptimisticHeader(
|
||||||
|
|
|
@ -863,7 +863,7 @@ func ETHLightClientHeaderGetBeacon(
|
||||||
## * Beacon block header.
|
## * Beacon block header.
|
||||||
##
|
##
|
||||||
## See:
|
## See:
|
||||||
## * 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.7/specs/phase0/beacon-chain.md#beaconblockheader
|
||||||
addr header[].beacon
|
addr header[].beacon
|
||||||
|
|
||||||
func ETHBeaconBlockHeaderGetSlot(
|
func ETHBeaconBlockHeaderGetSlot(
|
||||||
|
|
|
@ -2229,7 +2229,7 @@ proc getPersistentNetKeys*(
|
||||||
|
|
||||||
func gossipId(
|
func gossipId(
|
||||||
data: openArray[byte], phase0Prefix, topic: string): seq[byte] =
|
data: openArray[byte], phase0Prefix, topic: string): seq[byte] =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#topics-and-messages
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#topics-and-messages
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/p2p-interface.md#topics-and-messages
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/p2p-interface.md#topics-and-messages
|
||||||
const MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
|
const MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
|
||||||
let messageDigest = withEth2Hash:
|
let messageDigest = withEth2Hash:
|
||||||
|
@ -2524,7 +2524,7 @@ proc broadcast(node: Eth2Node, topic: string, msg: auto):
|
||||||
|
|
||||||
proc subscribeAttestationSubnets*(
|
proc subscribeAttestationSubnets*(
|
||||||
node: Eth2Node, subnets: AttnetBits, forkDigest: ForkDigest) =
|
node: Eth2Node, subnets: AttnetBits, forkDigest: ForkDigest) =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#attestations-and-aggregation
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#attestations-and-aggregation
|
||||||
# Nimbus won't score attestation subnets for now, we just rely on block and
|
# Nimbus won't score attestation subnets for now, we just rely on block and
|
||||||
# aggregate which are more stable and reliable
|
# aggregate which are more stable and reliable
|
||||||
|
|
||||||
|
|
|
@ -167,11 +167,6 @@ p2pProtocol PeerSync(version = 1,
|
||||||
{.libp2pProtocol("ping", 1).} =
|
{.libp2pProtocol("ping", 1).} =
|
||||||
peer.network.metadata.seq_number
|
peer.network.metadata.seq_number
|
||||||
|
|
||||||
# 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")
|
|
||||||
|
|
||||||
proc getMetadata_v2(peer: Peer): altair.MetaData
|
proc getMetadata_v2(peer: Peer): altair.MetaData
|
||||||
{.libp2pProtocol("metadata", 2).} =
|
{.libp2pProtocol("metadata", 2).} =
|
||||||
peer.network.metadata
|
peer.network.metadata
|
||||||
|
|
|
@ -136,7 +136,7 @@ const
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#attesting
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#attesting
|
||||||
attestationSlotOffset* = TimeDiff(nanoseconds:
|
attestationSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 div INTERVALS_PER_SLOT)
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#broadcast-aggregate
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#broadcast-aggregate
|
||||||
aggregateSlotOffset* = TimeDiff(nanoseconds:
|
aggregateSlotOffset* = TimeDiff(nanoseconds:
|
||||||
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
NANOSECONDS_PER_SLOT.int64 * 2 div INTERVALS_PER_SLOT)
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/validator.md#prepare-sync-committee-message
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/validator.md#prepare-sync-committee-message
|
||||||
|
|
|
@ -232,7 +232,7 @@ func initiate_validator_exit*(
|
||||||
|
|
||||||
func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache): Gwei
|
func get_total_active_balance*(state: ForkyBeaconState, cache: var StateCache): Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#new-get_balance_churn_limit
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#new-get_balance_churn_limit
|
||||||
func get_balance_churn_limit(
|
func get_balance_churn_limit(
|
||||||
cfg: RuntimeConfig, state: electra.BeaconState,
|
cfg: RuntimeConfig, state: electra.BeaconState,
|
||||||
cache: var StateCache): Gwei =
|
cache: var StateCache): Gwei =
|
||||||
|
@ -347,7 +347,7 @@ func initiate_validator_exit*(
|
||||||
ok(static(default(ExitQueueInfo)))
|
ok(static(default(ExitQueueInfo)))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#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.5.0-alpha.7/specs/phase0/beacon-chain.md#slash_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#modified-slash_validator
|
||||||
# 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.0/specs/electra/beacon-chain.md#updated-slash_validator
|
||||||
func get_slashing_penalty*(
|
func get_slashing_penalty*(
|
||||||
|
@ -547,7 +547,7 @@ func get_block_root(state: ForkedHashedBeaconState, epoch: Epoch): Eth2Digest =
|
||||||
withState(state):
|
withState(state):
|
||||||
get_block_root(forkyState.data, epoch)
|
get_block_root(forkyState.data, epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#get_total_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#get_total_balance
|
||||||
template get_total_balance(
|
template get_total_balance(
|
||||||
state: ForkyBeaconState, validator_indices: untyped): Gwei =
|
state: ForkyBeaconState, validator_indices: untyped): Gwei =
|
||||||
## Return the combined effective balance of the ``indices``.
|
## Return the combined effective balance of the ``indices``.
|
||||||
|
@ -558,7 +558,7 @@ template get_total_balance(
|
||||||
res += state.validators[validator_index].effective_balance
|
res += state.validators[validator_index].effective_balance
|
||||||
max(EFFECTIVE_BALANCE_INCREMENT.Gwei, res)
|
max(EFFECTIVE_BALANCE_INCREMENT.Gwei, res)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#is_eligible_for_activation_queue
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#updated-is_eligible_for_activation_queue
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#updated-is_eligible_for_activation_queue
|
||||||
func is_eligible_for_activation_queue*(
|
func is_eligible_for_activation_queue*(
|
||||||
fork: static ConsensusFork, validator: Validator): bool =
|
fork: static ConsensusFork, validator: Validator): bool =
|
||||||
|
@ -571,7 +571,7 @@ func is_eligible_for_activation_queue*(
|
||||||
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
validator.activation_eligibility_epoch == FAR_FUTURE_EPOCH and
|
||||||
validator.effective_balance >= MIN_ACTIVATION_BALANCE.Gwei
|
validator.effective_balance >= MIN_ACTIVATION_BALANCE.Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#is_eligible_for_activation
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#is_eligible_for_activation
|
||||||
func is_eligible_for_activation*(
|
func is_eligible_for_activation*(
|
||||||
state: ForkyBeaconState, validator: Validator): bool =
|
state: ForkyBeaconState, validator: Validator): bool =
|
||||||
## Check if ``validator`` is eligible for activation.
|
## Check if ``validator`` is eligible for activation.
|
||||||
|
@ -1015,7 +1015,7 @@ proc check_attestation*(
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#new-process_bls_to_execution_change
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/capella/beacon-chain.md#new-process_bls_to_execution_change
|
||||||
proc check_bls_to_execution_change*(
|
proc check_bls_to_execution_change*(
|
||||||
genesisFork: Fork,
|
genesisFork: Fork,
|
||||||
state: capella.BeaconState | deneb.BeaconState | electra.BeaconState,
|
state: capella.BeaconState | deneb.BeaconState | electra.BeaconState,
|
||||||
|
@ -1246,7 +1246,7 @@ func is_fully_withdrawable_validator(
|
||||||
validator.withdrawable_epoch <= epoch and balance > 0.Gwei
|
validator.withdrawable_epoch <= epoch and balance > 0.Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#is_partially_withdrawable_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#is_partially_withdrawable_validator
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#updated-is_partially_withdrawable_validator
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#modified-is_partially_withdrawable_validator
|
||||||
func is_partially_withdrawable_validator(
|
func is_partially_withdrawable_validator(
|
||||||
fork: static ConsensusFork, validator: Validator, balance: Gwei): bool =
|
fork: static ConsensusFork, validator: Validator, balance: Gwei): bool =
|
||||||
## Check if ``validator`` is partially withdrawable.
|
## Check if ``validator`` is partially withdrawable.
|
||||||
|
@ -1292,7 +1292,7 @@ func switch_to_compounding_validator*(
|
||||||
validator.withdrawal_credentials.data[0] = COMPOUNDING_WITHDRAWAL_PREFIX
|
validator.withdrawal_credentials.data[0] = COMPOUNDING_WITHDRAWAL_PREFIX
|
||||||
queue_excess_active_balance(state, index.uint64)
|
queue_excess_active_balance(state, index.uint64)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#new-get_pending_balance_to_withdraw
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#new-get_pending_balance_to_withdraw
|
||||||
func get_pending_balance_to_withdraw*(
|
func get_pending_balance_to_withdraw*(
|
||||||
state: electra.BeaconState, validator_index: ValidatorIndex): Gwei =
|
state: electra.BeaconState, validator_index: ValidatorIndex): Gwei =
|
||||||
var pending_balance: Gwei
|
var pending_balance: Gwei
|
||||||
|
|
|
@ -207,7 +207,7 @@ func finish*(agg: AggregateSignature): CookedSig {.inline.} =
|
||||||
sig.finish(agg)
|
sig.finish(agg)
|
||||||
CookedSig(sig)
|
CookedSig(sig)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#bls-signatures
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#bls-signatures
|
||||||
func blsVerify*(
|
func blsVerify*(
|
||||||
pubkey: CookedPubKey, message: openArray[byte],
|
pubkey: CookedPubKey, message: openArray[byte],
|
||||||
signature: CookedSig): bool =
|
signature: CookedSig): bool =
|
||||||
|
|
|
@ -34,7 +34,7 @@ type
|
||||||
|
|
||||||
static:
|
static:
|
||||||
# Verify that ordinals follow spec values (the spec uses these as shifts for bit flags)
|
# 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/specs/altair/beacon-chain.md#participation-flag-indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#participation-flag-indices
|
||||||
doAssert ord(TIMELY_SOURCE_FLAG_INDEX) == 0
|
doAssert ord(TIMELY_SOURCE_FLAG_INDEX) == 0
|
||||||
doAssert ord(TIMELY_TARGET_FLAG_INDEX) == 1
|
doAssert ord(TIMELY_TARGET_FLAG_INDEX) == 1
|
||||||
doAssert ord(TIMELY_HEAD_FLAG_INDEX) == 2
|
doAssert ord(TIMELY_HEAD_FLAG_INDEX) == 2
|
||||||
|
@ -78,7 +78,7 @@ static: doAssert TIMELY_SOURCE_WEIGHT + TIMELY_TARGET_WEIGHT +
|
||||||
type
|
type
|
||||||
### New types
|
### New types
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/altair/beacon-chain.md#custom-types
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#custom-types
|
||||||
ParticipationFlags* = uint8
|
ParticipationFlags* = uint8
|
||||||
|
|
||||||
EpochParticipationFlags* =
|
EpochParticipationFlags* =
|
||||||
|
|
|
@ -249,7 +249,7 @@ type
|
||||||
source*: Checkpoint
|
source*: Checkpoint
|
||||||
target*: Checkpoint
|
target*: Checkpoint
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#deposit
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#deposit
|
||||||
Deposit* = object
|
Deposit* = object
|
||||||
proof*: array[DEPOSIT_CONTRACT_TREE_DEPTH + 1, Eth2Digest]
|
proof*: array[DEPOSIT_CONTRACT_TREE_DEPTH + 1, Eth2Digest]
|
||||||
## Merkle path to deposit root
|
## Merkle path to deposit root
|
||||||
|
@ -340,7 +340,7 @@ type
|
||||||
block_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
block_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
||||||
state_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
state_roots* : array[SLOTS_PER_HISTORICAL_ROOT, Eth2Digest]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#fork
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#fork
|
||||||
Fork* = object
|
Fork* = object
|
||||||
previous_version*: Version
|
previous_version*: Version
|
||||||
current_version*: Version
|
current_version*: Version
|
||||||
|
|
|
@ -95,7 +95,7 @@ type
|
||||||
executionPayload*: ExecutionPayload
|
executionPayload*: ExecutionPayload
|
||||||
blockValue*: Wei
|
blockValue*: Wei
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#executionpayloadheader
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/capella/beacon-chain.md#executionpayloadheader
|
||||||
ExecutionPayloadHeader* = object
|
ExecutionPayloadHeader* = object
|
||||||
# Execution block header fields
|
# Execution block header fields
|
||||||
parent_hash*: Eth2Digest
|
parent_hash*: Eth2Digest
|
||||||
|
@ -659,7 +659,7 @@ func get_lc_execution_root*(
|
||||||
|
|
||||||
ZERO_HASH
|
ZERO_HASH
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/light-client/sync-protocol.md#modified-is_valid_light_client_header
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/capella/light-client/sync-protocol.md#modified-is_valid_light_client_header
|
||||||
func is_valid_light_client_header*(
|
func is_valid_light_client_header*(
|
||||||
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
header: LightClientHeader, cfg: RuntimeConfig): bool =
|
||||||
let epoch = header.beacon.slot.epoch
|
let epoch = header.beacon.slot.epoch
|
||||||
|
|
|
@ -14,13 +14,13 @@ type
|
||||||
Epoch* = distinct uint64
|
Epoch* = distinct uint64
|
||||||
SyncCommitteePeriod* = distinct uint64
|
SyncCommitteePeriod* = distinct uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/capella/beacon-chain.md#custom-types
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/capella/beacon-chain.md#custom-types
|
||||||
WithdrawalIndex* = uint64
|
WithdrawalIndex* = uint64
|
||||||
|
|
||||||
DomainType* = distinct array[4, byte]
|
DomainType* = distinct array[4, byte]
|
||||||
|
|
||||||
const
|
const
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/phase0/p2p-interface.md#constants
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#constants
|
||||||
NODE_ID_BITS* = 256
|
NODE_ID_BITS* = 256
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#configuration
|
||||||
|
@ -77,7 +77,7 @@ const
|
||||||
GOSSIP_MAX_SIZE* = 10'u64 * 1024 * 1024 # bytes
|
GOSSIP_MAX_SIZE* = 10'u64 * 1024 * 1024 # bytes
|
||||||
MAX_CHUNK_SIZE* = 10'u64 * 1024 * 1024 # bytes
|
MAX_CHUNK_SIZE* = 10'u64 * 1024 * 1024 # bytes
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/p2p-interface.md#configuration
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/deneb/p2p-interface.md#configuration
|
||||||
MAX_REQUEST_BLOCKS_DENEB*: uint64 = 128 # TODO Make use of in request code
|
MAX_REQUEST_BLOCKS_DENEB*: uint64 = 128 # TODO Make use of in request code
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#misc
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/electra/beacon-chain.md#misc
|
||||||
|
|
|
@ -36,7 +36,7 @@ const
|
||||||
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
|
BLS_MODULUS* = "52435875175126190479447740508185965837690552500527637822603658699938581184513".u256
|
||||||
|
|
||||||
type
|
type
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#beaconblockbody
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/deneb/beacon-chain.md#beaconblockbody
|
||||||
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
KzgCommitments* = List[KzgCommitment, Limit MAX_BLOB_COMMITMENTS_PER_BLOCK]
|
||||||
|
|
||||||
# TODO this apparently is suppposed to be SSZ-equivalent to Bytes32, but
|
# TODO this apparently is suppposed to be SSZ-equivalent to Bytes32, but
|
||||||
|
@ -50,7 +50,7 @@ type
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/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
|
BlobIndex* = uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/polynomial-commitments.md#custom-types
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/deneb/polynomial-commitments.md#custom-types
|
||||||
Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte]
|
Blob* = array[BYTES_PER_FIELD_ELEMENT * FIELD_ELEMENTS_PER_BLOB, byte]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/deneb/p2p-interface.md#blobsidecar
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/deneb/p2p-interface.md#blobsidecar
|
||||||
|
|
|
@ -60,7 +60,7 @@ const
|
||||||
type
|
type
|
||||||
DataColumn* = List[KzgCell, Limit(MAX_BLOB_COMMITMENTS_PER_BLOCK)]
|
DataColumn* = List[KzgCell, Limit(MAX_BLOB_COMMITMENTS_PER_BLOCK)]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.5/specs/_features/eip7594/das-core.md#datacolumnsidecar
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/_features/eip7594/das-core.md#datacolumnsidecar
|
||||||
DataColumnSidecar* = object
|
DataColumnSidecar* = object
|
||||||
index*: ColumnIndex # Index of column in extended matrix
|
index*: ColumnIndex # Index of column in extended matrix
|
||||||
column*: DataColumn
|
column*: DataColumn
|
||||||
|
|
|
@ -155,7 +155,7 @@ type
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#pendingpartialwithdrawal
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#pendingpartialwithdrawal
|
||||||
PendingPartialWithdrawal* = object
|
PendingPartialWithdrawal* = object
|
||||||
index*: uint64
|
index*: uint64
|
||||||
amount*: Gwei
|
amount*: Gwei
|
||||||
|
@ -184,7 +184,7 @@ type
|
||||||
aggregate*: Attestation
|
aggregate*: Attestation
|
||||||
selection_proof*: ValidatorSig
|
selection_proof*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/validator.md#signedaggregateandproof
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/validator.md#signedaggregateandproof
|
||||||
SignedAggregateAndProof* = object
|
SignedAggregateAndProof* = object
|
||||||
message*: AggregateAndProof
|
message*: AggregateAndProof
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
@ -597,7 +597,7 @@ type
|
||||||
|
|
||||||
AttestationCommitteeBits* = BitArray[MAX_COMMITTEES_PER_SLOT.int]
|
AttestationCommitteeBits* = BitArray[MAX_COMMITTEES_PER_SLOT.int]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#attestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#attestation
|
||||||
Attestation* = object
|
Attestation* = object
|
||||||
aggregation_bits*: ElectraCommitteeValidatorsBits
|
aggregation_bits*: ElectraCommitteeValidatorsBits
|
||||||
data*: AttestationData
|
data*: AttestationData
|
||||||
|
|
|
@ -259,7 +259,7 @@ type
|
||||||
|
|
||||||
root* {.dontSerialize.}: Eth2Digest # cached root of signed beacon block
|
root* {.dontSerialize.}: Eth2Digest # cached root of signed beacon block
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#attesterslashing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#attesterslashing
|
||||||
AttesterSlashing* = object
|
AttesterSlashing* = object
|
||||||
attestation_1*: IndexedAttestation
|
attestation_1*: IndexedAttestation
|
||||||
attestation_2*: IndexedAttestation
|
attestation_2*: IndexedAttestation
|
||||||
|
|
|
@ -164,7 +164,7 @@ proc recover_matrix*(partial_matrix: seq[MatrixEntry],
|
||||||
|
|
||||||
ok(extended_matrix)
|
ok(extended_matrix)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/_features/eip7594/das-core.md#get_data_column_sidecars
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/_features/eip7594/das-core.md#get_data_column_sidecars
|
||||||
proc get_data_column_sidecars*(signed_beacon_block: electra.TrustedSignedBeaconBlock,
|
proc get_data_column_sidecars*(signed_beacon_block: electra.TrustedSignedBeaconBlock,
|
||||||
cellsAndProofs: seq[CellsAndProofs]):
|
cellsAndProofs: seq[CellsAndProofs]):
|
||||||
seq[DataColumnSidecar] =
|
seq[DataColumnSidecar] =
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
# State transition, as described in
|
# State transition, as described in
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
#
|
#
|
||||||
# The entry point is `state_transition` which is at the bottom of the file!
|
# The entry point is `state_transition` which is at the bottom of the file!
|
||||||
#
|
#
|
||||||
|
@ -53,7 +53,7 @@ export results, extras, state_transition_block
|
||||||
logScope:
|
logScope:
|
||||||
topics = "state_transition"
|
topics = "state_transition"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc verify_block_signature(
|
proc verify_block_signature(
|
||||||
state: ForkyBeaconState, signed_block: SomeForkySignedBeaconBlock):
|
state: ForkyBeaconState, signed_block: SomeForkySignedBeaconBlock):
|
||||||
Result[void, cstring] =
|
Result[void, cstring] =
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
{.push raises: [].}
|
{.push raises: [].}
|
||||||
|
|
||||||
# State transition - block processing, as described in
|
# 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.5.0-alpha.7/specs/phase0/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.5.0-alpha.7/specs/altair/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.3/specs/capella/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/capella/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/deneb/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/deneb/beacon-chain.md#block-processing
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#block-processing
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#block-processing
|
||||||
#
|
#
|
||||||
# The entry point is `process_block` which is at the bottom of this file.
|
# The entry point is `process_block` which is at the bottom of this file.
|
||||||
#
|
#
|
||||||
|
@ -40,7 +40,7 @@ from ./datatypes/electra import PendingPartialWithdrawal
|
||||||
|
|
||||||
export extras, phase0, altair
|
export extras, phase0, altair
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#block-header
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#block-header
|
||||||
func process_block_header*(
|
func process_block_header*(
|
||||||
state: var ForkyBeaconState, blck: SomeForkyBeaconBlock,
|
state: var ForkyBeaconState, blck: SomeForkyBeaconBlock,
|
||||||
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
flags: UpdateFlags, cache: var StateCache): Result[void, cstring] =
|
||||||
|
@ -444,7 +444,7 @@ proc check_voluntary_exit*(
|
||||||
withState(state):
|
withState(state):
|
||||||
check_voluntary_exit(cfg, forkyState.data, signed_voluntary_exit, flags)
|
check_voluntary_exit(cfg, forkyState.data, signed_voluntary_exit, flags)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.7/specs/phase0/beacon-chain.md#voluntary-exits
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#voluntary-exits
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#updated-process_voluntary_exit
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#updated-process_voluntary_exit
|
||||||
proc process_voluntary_exit*(
|
proc process_voluntary_exit*(
|
||||||
cfg: RuntimeConfig,
|
cfg: RuntimeConfig,
|
||||||
|
|
|
@ -461,7 +461,7 @@ proc compute_unrealized_finality*(
|
||||||
justified: jfRes.current_justified_checkpoint,
|
justified: jfRes.current_justified_checkpoint,
|
||||||
finalized: jfRes.finalized_checkpoint)
|
finalized: jfRes.finalized_checkpoint)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#helpers
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#helpers
|
||||||
func get_base_reward_sqrt*(state: phase0.BeaconState, index: ValidatorIndex,
|
func get_base_reward_sqrt*(state: phase0.BeaconState, index: ValidatorIndex,
|
||||||
total_balance_sqrt: auto): Gwei =
|
total_balance_sqrt: auto): Gwei =
|
||||||
# Spec function recalculates total_balance every time, which creates an
|
# Spec function recalculates total_balance every time, which creates an
|
||||||
|
@ -649,7 +649,7 @@ func get_base_reward_increment*(
|
||||||
EFFECTIVE_BALANCE_INCREMENT.Gwei
|
EFFECTIVE_BALANCE_INCREMENT.Gwei
|
||||||
increments * base_reward_per_increment
|
increments * base_reward_per_increment
|
||||||
|
|
||||||
# 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.5.0-alpha.7/specs/altair/beacon-chain.md#get_flag_index_deltas
|
||||||
func get_flag_index_reward*(
|
func get_flag_index_reward*(
|
||||||
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
state: altair.BeaconState | bellatrix.BeaconState | capella.BeaconState |
|
||||||
deneb.BeaconState | electra.BeaconState,
|
deneb.BeaconState | electra.BeaconState,
|
||||||
|
@ -995,7 +995,7 @@ func get_adjusted_total_slashing_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/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#modified-process_slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#modified-process_slashings
|
||||||
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
||||||
validator.slashed and
|
validator.slashed and
|
||||||
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
epoch + EPOCHS_PER_SLASHINGS_VECTOR div 2 == validator.withdrawable_epoch
|
||||||
|
@ -1003,7 +1003,7 @@ func slashing_penalty_applies*(validator: Validator, epoch: Epoch): bool =
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#modified-process_slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#modified-process_slashings
|
||||||
func get_slashing_penalty*(
|
func get_slashing_penalty*(
|
||||||
consensusFork: static ConsensusFork, validator: Validator,
|
consensusFork: static ConsensusFork, validator: Validator,
|
||||||
adjusted_total_slashing_balance, total_balance: Gwei): Gwei =
|
adjusted_total_slashing_balance, total_balance: Gwei): Gwei =
|
||||||
|
@ -1028,7 +1028,7 @@ func get_slashing_penalty*(
|
||||||
# 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.5.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/bellatrix/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.6/specs/electra/beacon-chain.md#modified-process_slashings
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/beacon-chain.md#modified-process_slashings
|
||||||
func get_slashing(
|
func get_slashing(
|
||||||
state: ForkyBeaconState, total_balance: Gwei, vidx: ValidatorIndex): Gwei =
|
state: ForkyBeaconState, total_balance: Gwei, vidx: ValidatorIndex): Gwei =
|
||||||
# For efficiency reasons, it doesn't make sense to have process_slashings use
|
# For efficiency reasons, it doesn't make sense to have process_slashings use
|
||||||
|
@ -1084,7 +1084,7 @@ func process_effective_balance_updates*(state: var ForkyBeaconState) =
|
||||||
if new_effective_balance != effective_balance:
|
if new_effective_balance != effective_balance:
|
||||||
state.validators.mitem(vidx).effective_balance = new_effective_balance
|
state.validators.mitem(vidx).effective_balance = new_effective_balance
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#slashings-balances-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#slashings-balances-updates
|
||||||
func process_slashings_reset*(state: var ForkyBeaconState) =
|
func process_slashings_reset*(state: var ForkyBeaconState) =
|
||||||
let next_epoch = get_current_epoch(state) + 1
|
let next_epoch = get_current_epoch(state) + 1
|
||||||
|
|
||||||
|
@ -1122,7 +1122,7 @@ func process_historical_roots_update*(state: var ForkyBeaconState) =
|
||||||
if not state.historical_roots.add state.compute_historical_root():
|
if not state.historical_roots.add state.compute_historical_root():
|
||||||
raiseAssert "no more room for historical roots, so long and thanks for the fish!"
|
raiseAssert "no more room for historical roots, so long and thanks for the fish!"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#participation-records-rotation
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#participation-records-rotation
|
||||||
func process_participation_record_updates*(state: var phase0.BeaconState) =
|
func process_participation_record_updates*(state: var phase0.BeaconState) =
|
||||||
# Rotate current/previous epoch attestations - using swap avoids copying all
|
# Rotate current/previous epoch attestations - using swap avoids copying all
|
||||||
# elements using a slow genericSeqAssign
|
# elements using a slow genericSeqAssign
|
||||||
|
@ -1446,7 +1446,7 @@ proc process_epoch*(
|
||||||
let epoch = get_current_epoch(state)
|
let epoch = get_current_epoch(state)
|
||||||
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.7/specs/altair/beacon-chain.md#justification-and-finalization
|
||||||
# [Modified in Altair]
|
# [Modified in Altair]
|
||||||
process_justification_and_finalization(state, info.balances, flags)
|
process_justification_and_finalization(state, info.balances, flags)
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ proc process_epoch*(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/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.7/specs/altair/beacon-chain.md#slashings
|
||||||
process_slashings(state, info.balances.current_epoch) # [Modified in Altair]
|
process_slashings(state, info.balances.current_epoch) # [Modified in Altair]
|
||||||
|
|
||||||
process_eth1_data_reset(state)
|
process_eth1_data_reset(state)
|
||||||
|
@ -1552,7 +1552,7 @@ proc process_epoch*(
|
||||||
# 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.4.0/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||||
process_rewards_and_penalties(cfg, state, info)
|
process_rewards_and_penalties(cfg, state, info)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#registry-updates
|
||||||
? process_registry_updates(cfg, state, cache) # [Modified in Electra:EIP7251]
|
? process_registry_updates(cfg, state, cache) # [Modified in Electra:EIP7251]
|
||||||
|
|
||||||
# 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/altair/beacon-chain.md#slashings
|
||||||
|
|
|
@ -235,7 +235,7 @@ func compute_committee_len*(
|
||||||
|
|
||||||
(slice.b - slice.a + 1).uint64
|
(slice.b - slice.a + 1).uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
iterator get_beacon_committee*(
|
iterator get_beacon_committee*(
|
||||||
state: ForkyBeaconState, slot: Slot, index: CommitteeIndex,
|
state: ForkyBeaconState, slot: Slot, index: CommitteeIndex,
|
||||||
cache: var StateCache): (int, ValidatorIndex) =
|
cache: var StateCache): (int, ValidatorIndex) =
|
||||||
|
|
|
@ -187,7 +187,7 @@ func getBeaconStateDiffSummary*(state0: capella.BeaconState):
|
||||||
if state0.eth1_data_votes.len > 0:
|
if state0.eth1_data_votes.len > 0:
|
||||||
# replaceOrAddEncodeEth1Votes will check whether it needs to replace or add
|
# replaceOrAddEncodeEth1Votes will check whether it needs to replace or add
|
||||||
# the votes. Which happens is a function of effectively external data, i.e.
|
# the votes. Which happens is a function of effectively external data, i.e.
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#eth1-data
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/beacon-chain.md#eth1-data
|
||||||
# notes it depends on things not deterministic, from a pure consensus-layer
|
# notes it depends on things not deterministic, from a pure consensus-layer
|
||||||
# perspective. It thus must distinguish between adding and replacing votes,
|
# perspective. It thus must distinguish between adding and replacing votes,
|
||||||
# which it accomplishes by checking lengths and the most recent votes. This
|
# which it accomplishes by checking lengths and the most recent votes. This
|
||||||
|
|
|
@ -7,7 +7,7 @@ This is a WIP document to explain the attestation flows.
|
||||||
It is important to distinguish attestation `validation` from attestation `verification`.
|
It is important to distinguish attestation `validation` from attestation `verification`.
|
||||||
- Attestation `validation` is defined in the P2P specs. Validated attestations can be forwarded on GossipSub.
|
- Attestation `validation` is defined in the P2P specs. Validated attestations can be forwarded on GossipSub.
|
||||||
- Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
- Aggregated: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
||||||
- Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
- Unaggregated: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||||
- Attestation `verification` is defined in the consensus specs. Verified attestations can affect fork choice and may be included in a block.
|
- Attestation `verification` is defined in the consensus specs. Verified attestations can affect fork choice and may be included in a block.
|
||||||
- https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attestations
|
- https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.6/specs/phase0/beacon-chain.md#attestations
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ cli do(slots = SLOTS_PER_EPOCH * 7,
|
||||||
fork, genesis_validators_root, data,
|
fork, genesis_validators_root, data,
|
||||||
MockPrivKeys[validator_index])
|
MockPrivKeys[validator_index])
|
||||||
attestation = electra.Attestation(
|
attestation = electra.Attestation(
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.1/specs/electra/validator.md#construct-attestation
|
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.7/specs/electra/validator.md#construct-attestation
|
||||||
aggregation_bits: aggregation_bits,
|
aggregation_bits: aggregation_bits,
|
||||||
data: data,
|
data: data,
|
||||||
committee_bits: committee_bits,
|
committee_bits: committee_bits,
|
||||||
|
|
Loading…
Reference in New Issue