Update 36 spec refs from 0.11.x to 0.12.1
This commit is contained in:
parent
78b767f645
commit
1d1e90adf4
|
@ -5,7 +5,7 @@
|
||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
|
||||||
|
|
||||||
# Merkle tree helpers
|
# Merkle tree helpers
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
|
@ -111,7 +111,7 @@ proc process_deposit*(
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#compute_activation_exit_epoch
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#compute_activation_exit_epoch
|
||||||
func compute_activation_exit_epoch(epoch: Epoch): Epoch =
|
func compute_activation_exit_epoch(epoch: Epoch): Epoch =
|
||||||
## Return the epoch during which validator activations and exits initiated in
|
## Return the epoch during which validator activations and exits initiated in
|
||||||
## ``epoch`` take effect.
|
## ``epoch`` take effect.
|
||||||
|
@ -300,7 +300,7 @@ func get_initial_beacon_block*(state: BeaconState): SignedBeaconBlock =
|
||||||
# parent_root, randao_reveal, eth1_data, signature, and body automatically
|
# parent_root, randao_reveal, eth1_data, signature, and body automatically
|
||||||
# initialized to default values.
|
# initialized to default values.
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_block_root_at_slot
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_block_root_at_slot
|
||||||
func get_block_root_at_slot*(state: BeaconState,
|
func get_block_root_at_slot*(state: BeaconState,
|
||||||
slot: Slot): Eth2Digest =
|
slot: Slot): Eth2Digest =
|
||||||
# Return the block root at a recent ``slot``.
|
# Return the block root at a recent ``slot``.
|
||||||
|
@ -341,7 +341,7 @@ func is_eligible_for_activation(state: BeaconState, validator: Validator):
|
||||||
# Has not yet been activated
|
# Has not yet been activated
|
||||||
validator.activation_epoch == FAR_FUTURE_EPOCH
|
validator.activation_epoch == FAR_FUTURE_EPOCH
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#registry-updates
|
||||||
proc process_registry_updates*(state: var BeaconState,
|
proc process_registry_updates*(state: var BeaconState,
|
||||||
cache: var StateCache) {.nbench.}=
|
cache: var StateCache) {.nbench.}=
|
||||||
## Process activation eligibility and ejections
|
## Process activation eligibility and ejections
|
||||||
|
|
|
@ -114,7 +114,7 @@ func aggregate*(x: var ValidatorSig, other: ValidatorSig) =
|
||||||
## This assumes that they are real signatures
|
## This assumes that they are real signatures
|
||||||
x.blsValue.aggregate(other.blsValue)
|
x.blsValue.aggregate(other.blsValue)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#bls-signatures
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#bls-signatures
|
||||||
func blsVerify*(
|
func blsVerify*(
|
||||||
pubkey: ValidatorPubKey, message: openArray[byte],
|
pubkey: ValidatorPubKey, message: openArray[byte],
|
||||||
signature: ValidatorSig): bool =
|
signature: ValidatorSig): bool =
|
||||||
|
|
|
@ -143,12 +143,12 @@ type
|
||||||
Gwei* = uint64
|
Gwei* = uint64
|
||||||
CommitteeIndex* = distinct uint64
|
CommitteeIndex* = distinct uint64
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#proposerslashing
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#proposerslashing
|
||||||
ProposerSlashing* = object
|
ProposerSlashing* = object
|
||||||
signed_header_1*: SignedBeaconBlockHeader
|
signed_header_1*: SignedBeaconBlockHeader
|
||||||
signed_header_2*: SignedBeaconBlockHeader
|
signed_header_2*: SignedBeaconBlockHeader
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#attesterslashing
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#attesterslashing
|
||||||
AttesterSlashing* = object
|
AttesterSlashing* = object
|
||||||
attestation_1*: IndexedAttestation
|
attestation_1*: IndexedAttestation
|
||||||
attestation_2*: IndexedAttestation
|
attestation_2*: IndexedAttestation
|
||||||
|
@ -181,7 +181,7 @@ type
|
||||||
epoch*: Epoch
|
epoch*: Epoch
|
||||||
root*: Eth2Digest
|
root*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#AttestationData
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#AttestationData
|
||||||
AttestationData* = object
|
AttestationData* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ type
|
||||||
source*: Checkpoint
|
source*: Checkpoint
|
||||||
target*: Checkpoint
|
target*: Checkpoint
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#deposit
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/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
|
||||||
|
@ -209,7 +209,7 @@ type
|
||||||
withdrawal_credentials*: Eth2Digest
|
withdrawal_credentials*: Eth2Digest
|
||||||
amount*: Gwei
|
amount*: Gwei
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#depositdata
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#depositdata
|
||||||
DepositData* = object
|
DepositData* = object
|
||||||
pubkey*: ValidatorPubKey
|
pubkey*: ValidatorPubKey
|
||||||
withdrawal_credentials*: Eth2Digest
|
withdrawal_credentials*: Eth2Digest
|
||||||
|
@ -367,13 +367,13 @@ type
|
||||||
epoch*: Epoch ##\
|
epoch*: Epoch ##\
|
||||||
## Epoch of latest fork
|
## Epoch of latest fork
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#eth1data
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#eth1data
|
||||||
Eth1Data* = object
|
Eth1Data* = object
|
||||||
deposit_root*: Eth2Digest
|
deposit_root*: Eth2Digest
|
||||||
deposit_count*: uint64
|
deposit_count*: uint64
|
||||||
block_hash*: Eth2Digest
|
block_hash*: Eth2Digest
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#signedvoluntaryexit
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#signedvoluntaryexit
|
||||||
SignedVoluntaryExit* = object
|
SignedVoluntaryExit* = object
|
||||||
message*: VoluntaryExit
|
message*: VoluntaryExit
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
# Serenity hash function / digest
|
# Serenity hash function / digest
|
||||||
#
|
#
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#hash
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#hash
|
||||||
#
|
#
|
||||||
# In Phase 0 the beacon chain is deployed with SHA256 (SHA2-256).
|
# In Phase 0 the beacon chain is deployed with SHA256 (SHA2-256).
|
||||||
# Note that is is different from Keccak256 (often mistakenly called SHA3-256)
|
# Note that is is different from Keccak256 (often mistakenly called SHA3-256)
|
||||||
|
|
|
@ -22,7 +22,7 @@ type
|
||||||
# (other candidate is nativesockets.Domain)
|
# (other candidate is nativesockets.Domain)
|
||||||
Domain = datatypes.Domain
|
Domain = datatypes.Domain
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#integer_squareroot
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#integer_squareroot
|
||||||
func integer_squareroot*(n: SomeInteger): SomeInteger =
|
func integer_squareroot*(n: SomeInteger): SomeInteger =
|
||||||
# Return the largest integer ``x`` such that ``x**2 <= n``.
|
# Return the largest integer ``x`` such that ``x**2 <= n``.
|
||||||
doAssert n >= 0'u64
|
doAssert n >= 0'u64
|
||||||
|
@ -35,7 +35,7 @@ func integer_squareroot*(n: SomeInteger): SomeInteger =
|
||||||
y = (x + n div x) div 2
|
y = (x + n div x) div 2
|
||||||
x
|
x
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#compute_epoch_at_slot
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#compute_epoch_at_slot
|
||||||
func compute_epoch_at_slot*(slot: Slot|uint64): Epoch =
|
func compute_epoch_at_slot*(slot: Slot|uint64): Epoch =
|
||||||
# Return the epoch number at ``slot``.
|
# Return the epoch number at ``slot``.
|
||||||
(slot div SLOTS_PER_EPOCH).Epoch
|
(slot div SLOTS_PER_EPOCH).Epoch
|
||||||
|
@ -46,12 +46,12 @@ 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/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#compute_start_slot_at_epoch
|
||||||
func compute_start_slot_at_epoch*(epoch: Epoch): Slot =
|
func compute_start_slot_at_epoch*(epoch: Epoch): Slot =
|
||||||
# Return the start slot of ``epoch``.
|
# Return the start slot of ``epoch``.
|
||||||
(epoch * SLOTS_PER_EPOCH).Slot
|
(epoch * SLOTS_PER_EPOCH).Slot
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#is_active_validator
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#is_active_validator
|
||||||
func is_active_validator*(validator: Validator, epoch: Epoch): bool =
|
func is_active_validator*(validator: Validator, epoch: Epoch): bool =
|
||||||
### Check if ``validator`` is active
|
### Check if ``validator`` is active
|
||||||
validator.activation_epoch <= epoch and epoch < validator.exit_epoch
|
validator.activation_epoch <= epoch and epoch < validator.exit_epoch
|
||||||
|
@ -152,7 +152,7 @@ func compute_fork_digest*(current_version: Version,
|
||||||
compute_fork_data_root(
|
compute_fork_data_root(
|
||||||
current_version, genesis_validators_root).data.toOpenArray(0, 3)
|
current_version, genesis_validators_root).data.toOpenArray(0, 3)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#compute_domain
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#compute_domain
|
||||||
func compute_domain*(
|
func compute_domain*(
|
||||||
domain_type: DomainType,
|
domain_type: DomainType,
|
||||||
fork_version: Version = Version(GENESIS_FORK_VERSION),
|
fork_version: Version = Version(GENESIS_FORK_VERSION),
|
||||||
|
|
|
@ -134,14 +134,14 @@ proc process_randao(
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#eth1-data
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#eth1-data
|
||||||
func process_eth1_data(state: var BeaconState, body: BeaconBlockBody) {.nbench.}=
|
func process_eth1_data(state: var BeaconState, body: BeaconBlockBody) {.nbench.}=
|
||||||
state.eth1_data_votes.add body.eth1_data
|
state.eth1_data_votes.add body.eth1_data
|
||||||
|
|
||||||
if state.eth1_data_votes.asSeq.count(body.eth1_data) * 2 > SLOTS_PER_ETH1_VOTING_PERIOD.int:
|
if state.eth1_data_votes.asSeq.count(body.eth1_data) * 2 > SLOTS_PER_ETH1_VOTING_PERIOD.int:
|
||||||
state.eth1_data = body.eth1_data
|
state.eth1_data = body.eth1_data
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#is_slashable_validator
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#is_slashable_validator
|
||||||
func is_slashable_validator(validator: Validator, epoch: Epoch): bool =
|
func is_slashable_validator(validator: Validator, epoch: Epoch): bool =
|
||||||
# Check if ``validator`` is slashable.
|
# Check if ``validator`` is slashable.
|
||||||
(not validator.slashed) and
|
(not validator.slashed) and
|
||||||
|
@ -213,7 +213,7 @@ func is_slashable_attestation_data(
|
||||||
(data_1.source.epoch < data_2.source.epoch and
|
(data_1.source.epoch < data_2.source.epoch and
|
||||||
data_2.target.epoch < data_1.target.epoch)
|
data_2.target.epoch < data_1.target.epoch)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#attester-slashings
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#attester-slashings
|
||||||
proc process_attester_slashing*(
|
proc process_attester_slashing*(
|
||||||
state: var BeaconState,
|
state: var BeaconState,
|
||||||
attester_slashing: AttesterSlashing,
|
attester_slashing: AttesterSlashing,
|
||||||
|
|
|
@ -576,7 +576,7 @@ func process_final_updates*(state: var BeaconState) {.nbench.}=
|
||||||
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH).uint64 == 0:
|
if next_epoch mod (SLOTS_PER_HISTORICAL_ROOT div SLOTS_PER_EPOCH).uint64 == 0:
|
||||||
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
# Equivalent to hash_tree_root(foo: HistoricalBatch), but without using
|
||||||
# significant additional stack or heap.
|
# significant additional stack or heap.
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#historicalbatch
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#historicalbatch
|
||||||
# In response to https://github.com/status-im/nim-beacon-chain/issues/921
|
# In response to https://github.com/status-im/nim-beacon-chain/issues/921
|
||||||
state.historical_roots.add hash_tree_root(
|
state.historical_roots.add hash_tree_root(
|
||||||
[hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)])
|
[hash_tree_root(state.block_roots), hash_tree_root(state.state_roots)])
|
||||||
|
@ -585,14 +585,14 @@ func process_final_updates*(state: var BeaconState) {.nbench.}=
|
||||||
state.previous_epoch_attestations = state.current_epoch_attestations
|
state.previous_epoch_attestations = state.current_epoch_attestations
|
||||||
state.current_epoch_attestations = default(type state.current_epoch_attestations)
|
state.current_epoch_attestations = default(type state.current_epoch_attestations)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#epoch-processing
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#epoch-processing
|
||||||
proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags,
|
proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags,
|
||||||
per_epoch_cache: var StateCache) {.nbench.} =
|
per_epoch_cache: var StateCache) {.nbench.} =
|
||||||
let currentEpoch = get_current_epoch(state)
|
let currentEpoch = get_current_epoch(state)
|
||||||
trace "process_epoch",
|
trace "process_epoch",
|
||||||
current_epoch = currentEpoch
|
current_epoch = currentEpoch
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#justification-and-finalization
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#justification-and-finalization
|
||||||
process_justification_and_finalization(state, per_epoch_cache, updateFlags)
|
process_justification_and_finalization(state, per_epoch_cache, updateFlags)
|
||||||
|
|
||||||
# state.slot hasn't been incremented yet.
|
# state.slot hasn't been incremented yet.
|
||||||
|
@ -602,16 +602,16 @@ proc process_epoch*(state: var BeaconState, updateFlags: UpdateFlags,
|
||||||
# the finalization rules triggered.
|
# the finalization rules triggered.
|
||||||
doAssert state.finalized_checkpoint.epoch + 3 >= currentEpoch
|
doAssert state.finalized_checkpoint.epoch + 3 >= currentEpoch
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||||
process_rewards_and_penalties(state, per_epoch_cache)
|
process_rewards_and_penalties(state, per_epoch_cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#registry-updates
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#registry-updates
|
||||||
process_registry_updates(state, per_epoch_cache)
|
process_registry_updates(state, per_epoch_cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#slashings
|
||||||
process_slashings(state, per_epoch_cache)
|
process_slashings(state, per_epoch_cache)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#final-updates
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#final-updates
|
||||||
process_final_updates(state)
|
process_final_updates(state)
|
||||||
|
|
||||||
# Once per epoch metrics
|
# Once per epoch metrics
|
||||||
|
|
|
@ -90,7 +90,7 @@ func get_shuffled_active_validator_indices*(state: BeaconState, epoch: Epoch):
|
||||||
active_validator_indices.len.uint64),
|
active_validator_indices.len.uint64),
|
||||||
active_validator_indices[it])
|
active_validator_indices[it])
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#get_previous_epoch
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#get_previous_epoch
|
||||||
func get_previous_epoch*(state: BeaconState): Epoch =
|
func get_previous_epoch*(state: BeaconState): Epoch =
|
||||||
# Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
# Return the previous epoch (unless the current epoch is ``GENESIS_EPOCH``).
|
||||||
let current_epoch = get_current_epoch(state)
|
let current_epoch = get_current_epoch(state)
|
||||||
|
@ -232,7 +232,7 @@ func get_beacon_proposer_index*(state: BeaconState, cache: var StateCache):
|
||||||
Option[ValidatorIndex] =
|
Option[ValidatorIndex] =
|
||||||
get_beacon_proposer_index(state, cache, state.slot)
|
get_beacon_proposer_index(state, cache, state.slot)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/validator.md#validator-assignments
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md#validator-assignments
|
||||||
func get_committee_assignment*(
|
func get_committee_assignment*(
|
||||||
state: BeaconState, epoch: Epoch, validator_index: ValidatorIndex):
|
state: BeaconState, epoch: Epoch, validator_index: ValidatorIndex):
|
||||||
Option[tuple[a: seq[ValidatorIndex], b: CommitteeIndex, c: Slot]] {.used.} =
|
Option[tuple[a: seq[ValidatorIndex], b: CommitteeIndex, c: Slot]] {.used.} =
|
||||||
|
|
|
@ -62,7 +62,7 @@ func get_epoch_validator_count(state: BeaconState): int64 {.nbench.} =
|
||||||
validator.withdrawable_epoch > get_current_epoch(state):
|
validator.withdrawable_epoch > get_current_epoch(state):
|
||||||
result += 1
|
result += 1
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#verify_block_signature
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc verify_block_signature*(
|
proc verify_block_signature*(
|
||||||
state: BeaconState, signedBlock: SignedBeaconBlock): bool {.nbench.} =
|
state: BeaconState, signedBlock: SignedBeaconBlock): bool {.nbench.} =
|
||||||
if signedBlock.message.proposer_index >= state.validators.len.uint64:
|
if signedBlock.message.proposer_index >= state.validators.len.uint64:
|
||||||
|
@ -85,7 +85,7 @@ proc verify_block_signature*(
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc verifyStateRoot(state: BeaconState, blck: BeaconBlock): bool =
|
proc verifyStateRoot(state: BeaconState, blck: BeaconBlock): bool =
|
||||||
# This is inlined in state_transition(...) in spec.
|
# This is inlined in state_transition(...) in spec.
|
||||||
let state_root = hash_tree_root(state)
|
let state_root = hash_tree_root(state)
|
||||||
|
@ -108,7 +108,7 @@ type
|
||||||
# Hashed-state transition functions
|
# Hashed-state transition functions
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
func process_slot*(state: var HashedBeaconState) {.nbench.} =
|
func process_slot*(state: var HashedBeaconState) {.nbench.} =
|
||||||
# Cache state root
|
# Cache state root
|
||||||
let previous_slot_state_root = state.root
|
let previous_slot_state_root = state.root
|
||||||
|
@ -123,7 +123,7 @@ func process_slot*(state: var HashedBeaconState) {.nbench.} =
|
||||||
state.data.block_roots[state.data.slot mod SLOTS_PER_HISTORICAL_ROOT] =
|
state.data.block_roots[state.data.slot mod SLOTS_PER_HISTORICAL_ROOT] =
|
||||||
hash_tree_root(state.data.latest_block_header)
|
hash_tree_root(state.data.latest_block_header)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc advance_slot*(state: var HashedBeaconState,
|
proc advance_slot*(state: var HashedBeaconState,
|
||||||
nextStateRoot: Opt[Eth2Digest], updateFlags: UpdateFlags,
|
nextStateRoot: Opt[Eth2Digest], updateFlags: UpdateFlags,
|
||||||
epochCache: var StateCache) {.nbench.} =
|
epochCache: var StateCache) {.nbench.} =
|
||||||
|
@ -145,7 +145,7 @@ proc advance_slot*(state: var HashedBeaconState,
|
||||||
else:
|
else:
|
||||||
state.root = hash_tree_root(state.data)
|
state.root = hash_tree_root(state.data)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.3/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/beacon-chain.md#beacon-chain-state-transition-function
|
||||||
proc process_slots*(state: var HashedBeaconState, slot: Slot,
|
proc process_slots*(state: var HashedBeaconState, slot: Slot,
|
||||||
updateFlags: UpdateFlags = {}): bool {.nbench.} =
|
updateFlags: UpdateFlags = {}): bool {.nbench.} =
|
||||||
# TODO this function is not _really_ necessary: when replaying states, we
|
# TODO this function is not _really_ necessary: when replaying states, we
|
||||||
|
|
|
@ -80,7 +80,7 @@ proc signAggregateAndProof*(v: AttachedValidator,
|
||||||
error "Out of process signAggregateAndProof not implemented"
|
error "Out of process signAggregateAndProof not implemented"
|
||||||
quit 1
|
quit 1
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v0.11.1/specs/phase0/validator.md#randao-reveal
|
# https://github.com/ethereum/eth2.0-specs/blob/v0.12.1/specs/phase0/validator.md#randao-reveal
|
||||||
func genRandaoReveal*(k: ValidatorPrivKey, fork: Fork,
|
func genRandaoReveal*(k: ValidatorPrivKey, fork: Fork,
|
||||||
genesis_validators_root: Eth2Digest, slot: Slot): ValidatorSig =
|
genesis_validators_root: Eth2Digest, slot: Slot): ValidatorSig =
|
||||||
get_epoch_signature(fork, genesis_validators_root, slot, k)
|
get_epoch_signature(fork, genesis_validators_root, slot, k)
|
||||||
|
|
Loading…
Reference in New Issue