mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-21 02:38:23 +00:00
v1.1.3 spec refs URLs (#3036)
This commit is contained in:
parent
7c9a6b7170
commit
36e37bda40
@ -131,7 +131,7 @@ type
|
|||||||
current_sync_committee*: SyncCommittee # [New in Altair]
|
current_sync_committee*: SyncCommittee # [New in Altair]
|
||||||
next_sync_committee*: SyncCommittee # [New in Altair]
|
next_sync_committee*: SyncCommittee # [New in Altair]
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.2/specs/merge/beacon-chain.md#beaconstate
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/merge/beacon-chain.md#beaconstate
|
||||||
# Memory-representation-equivalent to a Merge BeaconState for in-place SSZ
|
# Memory-representation-equivalent to a Merge BeaconState for in-place SSZ
|
||||||
# reading and writing
|
# reading and writing
|
||||||
MergeBeaconStateNoImmutableValidators* = object
|
MergeBeaconStateNoImmutableValidators* = object
|
||||||
|
@ -8,8 +8,8 @@ to specs:
|
|||||||
- aggregate attestations: https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
- aggregate attestations: https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
|
||||||
- unaggregated attestation: https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
- unaggregated attestation: https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#beacon_attestation_subnet_id
|
||||||
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#voluntary_exit
|
- voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#voluntary_exit
|
||||||
- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/p2p-interface.md#attester_slashing
|
- Attester slashings: https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#attester_slashing
|
||||||
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/p2p-interface.md#proposer_slashing
|
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#proposer_slashing
|
||||||
|
|
||||||
After "gossip validation" the consensus objects can be rebroadcasted as they are optimistically good, however for internal processing further verification is needed.
|
After "gossip validation" the consensus objects can be rebroadcasted as they are optimistically good, however for internal processing further verification is needed.
|
||||||
For blocks, this means verifying state transition and all contained cryptographic signatures (instead of just the proposer signature).
|
For blocks, this means verifying state transition and all contained cryptographic signatures (instead of just the proposer signature).
|
||||||
|
@ -30,7 +30,7 @@ iterator get_committee_indices*(epochRef: EpochRef): CommitteeIndex =
|
|||||||
for i in 0'u64..<get_committee_count_per_slot(epochRef):
|
for i in 0'u64..<get_committee_count_per_slot(epochRef):
|
||||||
yield CommitteeIndex(i)
|
yield CommitteeIndex(i)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#get_beacon_committee
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#get_beacon_committee
|
||||||
iterator get_beacon_committee*(
|
iterator get_beacon_committee*(
|
||||||
epochRef: EpochRef, slot: Slot, index: CommitteeIndex): ValidatorIndex =
|
epochRef: EpochRef, slot: Slot, index: CommitteeIndex): ValidatorIndex =
|
||||||
## Return the beacon committee at ``slot`` for ``index``.
|
## Return the beacon committee at ``slot`` for ``index``.
|
||||||
@ -70,7 +70,7 @@ func get_beacon_committee_len*(
|
|||||||
committees_per_slot * SLOTS_PER_EPOCH
|
committees_per_slot * SLOTS_PER_EPOCH
|
||||||
)
|
)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#get_attesting_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#get_attesting_indices
|
||||||
iterator get_attesting_indices*(epochRef: EpochRef,
|
iterator get_attesting_indices*(epochRef: EpochRef,
|
||||||
data: AttestationData,
|
data: AttestationData,
|
||||||
bits: CommitteeValidatorsBits):
|
bits: CommitteeValidatorsBits):
|
||||||
@ -105,7 +105,7 @@ func get_attesting_indices_one*(epochRef: EpochRef,
|
|||||||
inc i
|
inc i
|
||||||
res
|
res
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/beacon-chain.md#get_attesting_indices
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#get_attesting_indices
|
||||||
func get_attesting_indices*(epochRef: EpochRef,
|
func get_attesting_indices*(epochRef: EpochRef,
|
||||||
data: AttestationData,
|
data: AttestationData,
|
||||||
bits: CommitteeValidatorsBits):
|
bits: CommitteeValidatorsBits):
|
||||||
|
@ -19,7 +19,7 @@ import
|
|||||||
|
|
||||||
export extras, phase0, altair, merge
|
export extras, phase0, altair, merge
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#increase_balance
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#increase_balance
|
||||||
func increase_balance*(balance: var Gwei, delta: Gwei) =
|
func increase_balance*(balance: var Gwei, delta: Gwei) =
|
||||||
balance += delta
|
balance += delta
|
||||||
|
|
||||||
@ -797,7 +797,7 @@ proc upgrade_to_altair*(cfg: RuntimeConfig, pre: phase0.BeaconState): ref altair
|
|||||||
|
|
||||||
post
|
post
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.2/specs/merge/fork.md#upgrading-the-state
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/merge/fork.md#upgrading-the-state
|
||||||
func upgrade_to_merge*(cfg: RuntimeConfig, pre: altair.BeaconState):
|
func upgrade_to_merge*(cfg: RuntimeConfig, pre: altair.BeaconState):
|
||||||
ref merge.BeaconState =
|
ref merge.BeaconState =
|
||||||
let epoch = get_current_epoch(pre)
|
let epoch = get_current_epoch(pre)
|
||||||
|
@ -83,7 +83,7 @@ type
|
|||||||
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
||||||
sync_committee_signature*: ValidatorSig
|
sync_committee_signature*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/altair/beacon-chain.md#synccommittee
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/beacon-chain.md#synccommittee
|
||||||
SyncCommittee* = object
|
SyncCommittee* = object
|
||||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||||
aggregate_pubkey*: ValidatorPubKey
|
aggregate_pubkey*: ValidatorPubKey
|
||||||
|
@ -335,7 +335,7 @@ type
|
|||||||
deposit_count*: uint64
|
deposit_count*: uint64
|
||||||
block_hash*: Eth2Digest
|
block_hash*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/beacon-chain.md#signedvoluntaryexit
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#signedvoluntaryexit
|
||||||
SignedVoluntaryExit* = object
|
SignedVoluntaryExit* = object
|
||||||
message*: VoluntaryExit
|
message*: VoluntaryExit
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
@ -368,7 +368,7 @@ type
|
|||||||
message*: BeaconBlockHeader
|
message*: BeaconBlockHeader
|
||||||
signature*: TrustedSig
|
signature*: TrustedSig
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/validator.md#aggregateandproof
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/validator.md#aggregateandproof
|
||||||
AggregateAndProof* = object
|
AggregateAndProof* = object
|
||||||
aggregator_index*: uint64
|
aggregator_index*: uint64
|
||||||
aggregate*: Attestation
|
aggregate*: Attestation
|
||||||
|
@ -48,7 +48,7 @@ template epoch*(slot: Slot): Epoch =
|
|||||||
template isEpoch*(slot: Slot): bool =
|
template isEpoch*(slot: Slot): bool =
|
||||||
(slot mod SLOTS_PER_EPOCH) == 0
|
(slot mod SLOTS_PER_EPOCH) == 0
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.2/ssz/merkle-proofs.md#generalized_index_sibling
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/ssz/merkle-proofs.md#generalized_index_sibling
|
||||||
template generalized_index_sibling*(
|
template generalized_index_sibling*(
|
||||||
index: GeneralizedIndex): GeneralizedIndex =
|
index: GeneralizedIndex): GeneralizedIndex =
|
||||||
index xor 1.GeneralizedIndex
|
index xor 1.GeneralizedIndex
|
||||||
@ -279,7 +279,7 @@ func verify_merkle_multiproof*(
|
|||||||
if calc.isErr: return false
|
if calc.isErr: return false
|
||||||
calc.get == root
|
calc.get == root
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#is_valid_merkle_branch
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#is_valid_merkle_branch
|
||||||
func is_valid_merkle_branch*(leaf: Eth2Digest, branch: openArray[Eth2Digest],
|
func is_valid_merkle_branch*(leaf: Eth2Digest, branch: openArray[Eth2Digest],
|
||||||
depth: int, index: uint64,
|
depth: int, index: uint64,
|
||||||
root: Eth2Digest): bool =
|
root: Eth2Digest): bool =
|
||||||
@ -396,7 +396,7 @@ func get_current_epoch*(state: SomeBeaconState): Epoch =
|
|||||||
doAssert state.slot >= GENESIS_SLOT, $state.slot
|
doAssert state.slot >= GENESIS_SLOT, $state.slot
|
||||||
compute_epoch_at_slot(state.slot)
|
compute_epoch_at_slot(state.slot)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/beacon-chain.md#get_randao_mix
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#get_randao_mix
|
||||||
func get_randao_mix*(state: SomeBeaconState, epoch: Epoch): Eth2Digest =
|
func get_randao_mix*(state: SomeBeaconState, epoch: Epoch): Eth2Digest =
|
||||||
## Returns the randao mix at a recent ``epoch``.
|
## Returns the randao mix at a recent ``epoch``.
|
||||||
state.randao_mixes[epoch mod EPOCHS_PER_HISTORICAL_VECTOR]
|
state.randao_mixes[epoch mod EPOCHS_PER_HISTORICAL_VECTOR]
|
||||||
@ -433,7 +433,7 @@ func compute_fork_data_root(current_version: Version,
|
|||||||
genesis_validators_root: genesis_validators_root
|
genesis_validators_root: genesis_validators_root
|
||||||
))
|
))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#compute_fork_digest
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#compute_fork_digest
|
||||||
func compute_fork_digest*(current_version: Version,
|
func compute_fork_digest*(current_version: Version,
|
||||||
genesis_validators_root: Eth2Digest): ForkDigest =
|
genesis_validators_root: Eth2Digest): ForkDigest =
|
||||||
## Return the 4-byte fork digest for the ``current_version`` and
|
## Return the 4-byte fork digest for the ``current_version`` and
|
||||||
@ -509,7 +509,7 @@ func add_flag*(flags: ParticipationFlags, flag_index: int): ParticipationFlags =
|
|||||||
let flag = ParticipationFlags(1'u8 shl flag_index)
|
let flag = ParticipationFlags(1'u8 shl flag_index)
|
||||||
flags or flag
|
flags or flag
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/altair/beacon-chain.md#has_flag
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/beacon-chain.md#has_flag
|
||||||
func has_flag*(flags: ParticipationFlags, flag_index: int): bool =
|
func has_flag*(flags: ParticipationFlags, flag_index: int): bool =
|
||||||
let flag = ParticipationFlags(1'u8 shl flag_index)
|
let flag = ParticipationFlags(1'u8 shl flag_index)
|
||||||
(flags and flag) == flag
|
(flags and flag) == flag
|
||||||
@ -519,7 +519,7 @@ func get_subtree_index*(idx: GeneralizedIndex): uint64 =
|
|||||||
doAssert idx > 0
|
doAssert idx > 0
|
||||||
uint64(idx mod (type(idx)(1) shl log2trunc(idx)))
|
uint64(idx mod (type(idx)(1) shl log2trunc(idx)))
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/merge/beacon-chain.md#is_merge_complete
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/merge/beacon-chain.md#is_merge_complete
|
||||||
func is_merge_complete*(state: merge.BeaconState): bool =
|
func is_merge_complete*(state: merge.BeaconState): bool =
|
||||||
state.latest_execution_payload_header != default(ExecutionPayloadHeader)
|
state.latest_execution_payload_header != default(ExecutionPayloadHeader)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ const
|
|||||||
topicAttesterSlashingsSuffix* = "attester_slashing/ssz_snappy"
|
topicAttesterSlashingsSuffix* = "attester_slashing/ssz_snappy"
|
||||||
topicAggregateAndProofsSuffix* = "beacon_aggregate_and_proof/ssz_snappy"
|
topicAggregateAndProofsSuffix* = "beacon_aggregate_and_proof/ssz_snappy"
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#eth2-network-interaction-domains
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#configuration
|
||||||
MAX_CHUNK_SIZE* = 1 * 1024 * 1024 # bytes
|
MAX_CHUNK_SIZE* = 1 * 1024 * 1024 # bytes
|
||||||
GOSSIP_MAX_SIZE* = 1 * 1024 * 1024 # bytes
|
GOSSIP_MAX_SIZE* = 1 * 1024 * 1024 # bytes
|
||||||
TTFB_TIMEOUT* = 5.seconds
|
TTFB_TIMEOUT* = 5.seconds
|
||||||
|
@ -157,7 +157,7 @@ when const_preset == "mainnet":
|
|||||||
# TODO Move this to RuntimeConfig
|
# TODO Move this to RuntimeConfig
|
||||||
const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 12
|
const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 12
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.2/configs/mainnet.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/configs/mainnet.yaml
|
||||||
# TODO Read these from yaml file
|
# TODO Read these from yaml file
|
||||||
const defaultRuntimeConfig* = RuntimeConfig(
|
const defaultRuntimeConfig* = RuntimeConfig(
|
||||||
PRESET_BASE: "mainnet",
|
PRESET_BASE: "mainnet",
|
||||||
@ -245,7 +245,7 @@ elif const_preset == "minimal":
|
|||||||
|
|
||||||
const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 6
|
const SECONDS_PER_SLOT* {.intdefine.}: uint64 = 6
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.1/configs/minimal.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/configs/minimal.yaml
|
||||||
const defaultRuntimeConfig* = RuntimeConfig(
|
const defaultRuntimeConfig* = RuntimeConfig(
|
||||||
# Minimal config
|
# Minimal config
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Minimal preset - Altair
|
# Minimal preset - Altair
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.5/presets/minimal/altair.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/presets/minimal/altair.yaml
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -56,7 +56,7 @@ export extras, phase0, altair
|
|||||||
|
|
||||||
type Foo = phase0.SignedBeaconBlock | altair.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock | altair.TrustedSignedBeaconBlock | phase0.SigVerifiedSignedBeaconBlock | altair.SigVerifiedSignedBeaconBlock | merge.TrustedSignedBeaconBlock | merge.SigVerifiedSignedBeaconBlock | merge.SignedBeaconBlock
|
type Foo = phase0.SignedBeaconBlock | altair.SignedBeaconBlock | phase0.TrustedSignedBeaconBlock | altair.TrustedSignedBeaconBlock | phase0.SigVerifiedSignedBeaconBlock | altair.SigVerifiedSignedBeaconBlock | merge.TrustedSignedBeaconBlock | merge.SigVerifiedSignedBeaconBlock | merge.SignedBeaconBlock
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc verify_block_signature(
|
proc verify_block_signature(
|
||||||
#state: SomeBeaconState, signed_block: SomeSomeSignedBeaconBlock): bool {.nbench.} =
|
#state: SomeBeaconState, signed_block: SomeSomeSignedBeaconBlock): bool {.nbench.} =
|
||||||
state: SomeBeaconState, signed_block: Foo): bool {.nbench.} =
|
state: SomeBeaconState, signed_block: Foo): bool {.nbench.} =
|
||||||
|
@ -29,7 +29,7 @@ import
|
|||||||
|
|
||||||
export extras, phase0, altair
|
export extras, phase0, altair
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#block-header
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#block-header
|
||||||
func process_block_header*(
|
func process_block_header*(
|
||||||
state: var SomeBeaconState, blck: SomeSomeBeaconBlock, flags: UpdateFlags,
|
state: var SomeBeaconState, blck: SomeSomeBeaconBlock, flags: UpdateFlags,
|
||||||
cache: var StateCache): Result[void, cstring] {.nbench.} =
|
cache: var StateCache): Result[void, cstring] {.nbench.} =
|
||||||
|
@ -464,7 +464,7 @@ func is_in_inactivity_leak(finality_delay: uint64): bool =
|
|||||||
func get_finality_delay(state: SomeBeaconState): uint64 =
|
func get_finality_delay(state: SomeBeaconState): uint64 =
|
||||||
get_previous_epoch(state) - state.finalized_checkpoint.epoch
|
get_previous_epoch(state) - state.finalized_checkpoint.epoch
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-alpha.8/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||||
func is_in_inactivity_leak(state: altair.BeaconState | merge.BeaconState): bool =
|
func is_in_inactivity_leak(state: altair.BeaconState | merge.BeaconState): bool =
|
||||||
# TODO remove this, see above
|
# TODO remove this, see above
|
||||||
get_finality_delay(state) > MIN_EPOCHS_TO_INACTIVITY_PENALTY
|
get_finality_delay(state) > MIN_EPOCHS_TO_INACTIVITY_PENALTY
|
||||||
@ -902,7 +902,7 @@ func process_participation_flag_updates*(state: var (altair.BeaconState | merge.
|
|||||||
|
|
||||||
state.current_epoch_participation.resetCache()
|
state.current_epoch_participation.resetCache()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/altair/beacon-chain.md#sync-committee-updates
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/beacon-chain.md#sync-committee-updates
|
||||||
proc process_sync_committee_updates*(state: var (altair.BeaconState | merge.BeaconState)) =
|
proc process_sync_committee_updates*(state: var (altair.BeaconState | merge.BeaconState)) =
|
||||||
let next_epoch = get_current_epoch(state) + 1
|
let next_epoch = get_current_epoch(state) + 1
|
||||||
if next_epoch mod EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0:
|
if next_epoch mod EPOCHS_PER_SYNC_COMMITTEE_PERIOD == 0:
|
||||||
|
@ -153,7 +153,7 @@ func count_active_validators*(state: SomeBeaconState,
|
|||||||
cache: var StateCache): uint64 =
|
cache: var StateCache): uint64 =
|
||||||
cache.get_shuffled_active_validator_indices(state, epoch).lenu64
|
cache.get_shuffled_active_validator_indices(state, epoch).lenu64
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/beacon-chain.md#get_committee_count_per_slot
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#get_committee_count_per_slot
|
||||||
func get_committee_count_per_slot*(num_active_validators: uint64): uint64 =
|
func get_committee_count_per_slot*(num_active_validators: uint64): uint64 =
|
||||||
clamp(
|
clamp(
|
||||||
num_active_validators div SLOTS_PER_EPOCH div TARGET_COMMITTEE_SIZE,
|
num_active_validators div SLOTS_PER_EPOCH div TARGET_COMMITTEE_SIZE,
|
||||||
@ -162,7 +162,7 @@ func get_committee_count_per_slot*(num_active_validators: uint64): uint64 =
|
|||||||
func get_committee_count_per_slot*(state: SomeBeaconState,
|
func get_committee_count_per_slot*(state: SomeBeaconState,
|
||||||
epoch: Epoch,
|
epoch: Epoch,
|
||||||
cache: var StateCache): uint64 =
|
cache: var StateCache): uint64 =
|
||||||
# Return the number of committees at ``slot``.
|
## Return the number of committees at ``slot``.
|
||||||
|
|
||||||
let
|
let
|
||||||
active_validator_count = count_active_validators(state, epoch, cache)
|
active_validator_count = count_active_validators(state, epoch, cache)
|
||||||
@ -182,7 +182,7 @@ func get_committee_count_per_slot*(state: SomeBeaconState,
|
|||||||
cache: var StateCache): uint64 =
|
cache: var StateCache): uint64 =
|
||||||
get_committee_count_per_slot(state, slot.compute_epoch_at_slot, cache)
|
get_committee_count_per_slot(state, slot.compute_epoch_at_slot, cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/beacon-chain.md#get_previous_epoch
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#get_previous_epoch
|
||||||
func get_previous_epoch*(current_epoch: Epoch): Epoch =
|
func get_previous_epoch*(current_epoch: Epoch): Epoch =
|
||||||
## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
## Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
||||||
if current_epoch == GENESIS_EPOCH:
|
if current_epoch == GENESIS_EPOCH:
|
||||||
|
@ -238,7 +238,7 @@ proc getSyncCommitteeSelectionProof*(
|
|||||||
of ValidatorKind.Remote:
|
of ValidatorKind.Remote:
|
||||||
await signWithRemoteValidator(v, signing_root)
|
await signWithRemoteValidator(v, signing_root)
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.0-beta.4/specs/altair/validator.md#signature
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/altair/validator.md#signature
|
||||||
proc sign*(
|
proc sign*(
|
||||||
v: AttachedValidator,
|
v: AttachedValidator,
|
||||||
msg: ref SignedContributionAndProof,
|
msg: ref SignedContributionAndProof,
|
||||||
|
@ -6,7 +6,7 @@ This is a WIP document to explain the beacon block flows.
|
|||||||
|
|
||||||
Important distinction:
|
Important distinction:
|
||||||
- We distinguish block `validation` which is defined in the P2P specs:
|
- We distinguish block `validation` which is defined in the P2P specs:
|
||||||
https://github.com/ethereum/consensus-specs/blob/v1.1.0/specs/phase0/p2p-interface.md#beacon_block.
|
https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/p2p-interface.md#beacon_block.
|
||||||
A validated block can be forwarded on gossipsub.
|
A validated block can be forwarded on gossipsub.
|
||||||
- and we distinguish `verification` which is defined in consensus specs:
|
- and we distinguish `verification` which is defined in consensus specs:
|
||||||
https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#block-processing
|
https://github.com/ethereum/consensus-specs/blob/v1.1.3/specs/phase0/beacon-chain.md#block-processing
|
||||||
|
@ -16,7 +16,7 @@ import
|
|||||||
# Routines for mocking blocks
|
# Routines for mocking blocks
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.1/tests/core/pyspec/eth2spec/test/helpers/block.py#L26-L35
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/tests/core/pyspec/eth2spec/test/helpers/block.py#L26-L35
|
||||||
func apply_randao_reveal(
|
func apply_randao_reveal(
|
||||||
state: SomeBeaconState,
|
state: SomeBeaconState,
|
||||||
blck: var (phase0.SignedBeaconBlock | altair.SignedBeaconBlock |
|
blck: var (phase0.SignedBeaconBlock | altair.SignedBeaconBlock |
|
||||||
@ -49,7 +49,7 @@ func sign_block(
|
|||||||
blck.root,
|
blck.root,
|
||||||
privkey).toValidatorSig()
|
privkey).toValidatorSig()
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.1.1/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py#L1-L31
|
# https://github.com/ethereum/consensus-specs/blob/v1.1.3/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py#L1-L31
|
||||||
func build_empty_execution_payload(
|
func build_empty_execution_payload(
|
||||||
state: merge.BeaconState): ExecutionPayload =
|
state: merge.BeaconState): ExecutionPayload =
|
||||||
## Assuming a pre-state of the same slot, build a valid ExecutionPayload
|
## Assuming a pre-state of the same slot, build a valid ExecutionPayload
|
||||||
|
Loading…
x
Reference in New Issue
Block a user