update some spec refs to v1.1.0-alpha.8 (#2689)
This commit is contained in:
parent
32702d37a3
commit
c9cec88a23
|
@ -1504,8 +1504,7 @@ proc getPersistentNetKeys*(rng: var BrHmacDrbgContext,
|
||||||
|
|
||||||
func gossipId(data: openArray[byte], topic: string, valid: bool): seq[byte] =
|
func gossipId(data: openArray[byte], topic: string, valid: bool): seq[byte] =
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#topics-and-messages
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/p2p-interface.md#topics-and-messages
|
||||||
# and
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/p2p-interface.md#topics-and-messages
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/p2p-interface.md#topics-and-messages
|
|
||||||
const
|
const
|
||||||
MESSAGE_DOMAIN_INVALID_SNAPPY = [0x00'u8, 0x00, 0x00, 0x00]
|
MESSAGE_DOMAIN_INVALID_SNAPPY = [0x00'u8, 0x00, 0x00, 0x00]
|
||||||
MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
|
MESSAGE_DOMAIN_VALID_SNAPPY = [0x01'u8, 0x00, 0x00, 0x00]
|
||||||
|
|
|
@ -649,12 +649,13 @@ func get_total_active_balance*(state: SomeBeaconState, cache: var StateCache): G
|
||||||
get_total_balance(
|
get_total_balance(
|
||||||
state, cache.get_shuffled_active_validator_indices(state, epoch))
|
state, cache.get_shuffled_active_validator_indices(state, epoch))
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#get_base_reward_per_increment
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#get_base_reward_per_increment
|
||||||
func get_base_reward_per_increment*(state: altair.BeaconState, cache: var StateCache): Gwei =
|
func get_base_reward_per_increment*(
|
||||||
|
state: altair.BeaconState, cache: var StateCache): Gwei =
|
||||||
EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div
|
EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div
|
||||||
integer_squareroot(get_total_active_balance(state, cache))
|
integer_squareroot(get_total_active_balance(state, cache))
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#get_base_reward
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#get_base_reward
|
||||||
func get_base_reward(
|
func get_base_reward(
|
||||||
state: altair.BeaconState, index: ValidatorIndex,
|
state: altair.BeaconState, index: ValidatorIndex,
|
||||||
base_reward_per_increment: Gwei): Gwei =
|
base_reward_per_increment: Gwei): Gwei =
|
||||||
|
@ -848,7 +849,7 @@ func translate_participation(
|
||||||
proc upgrade_to_altair*(pre: phase0.BeaconState): ref altair.BeaconState =
|
proc upgrade_to_altair*(pre: phase0.BeaconState): ref altair.BeaconState =
|
||||||
let epoch = get_current_epoch(pre)
|
let epoch = get_current_epoch(pre)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/fork.md#configuration
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/fork.md#configuration
|
||||||
const ALTAIR_FORK_VERSION = Version [byte 1, 0, 0, 0]
|
const ALTAIR_FORK_VERSION = Version [byte 1, 0, 0, 0]
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
|
@ -38,7 +38,7 @@ import ./base, ./phase0
|
||||||
export base
|
export base
|
||||||
|
|
||||||
const
|
const
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#incentivization-weights
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#incentivization-weights
|
||||||
TIMELY_SOURCE_WEIGHT* = 14
|
TIMELY_SOURCE_WEIGHT* = 14
|
||||||
TIMELY_TARGET_WEIGHT* = 26
|
TIMELY_TARGET_WEIGHT* = 26
|
||||||
TIMELY_HEAD_WEIGHT* = 14
|
TIMELY_HEAD_WEIGHT* = 14
|
||||||
|
@ -53,16 +53,16 @@ const
|
||||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 4
|
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 4
|
||||||
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/setup.py#L473
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/setup.py#L473
|
||||||
FINALIZED_ROOT_INDEX* = 105'u16
|
FINALIZED_ROOT_INDEX* = 105'u16
|
||||||
NEXT_SYNC_COMMITTEE_INDEX* = 55'u16
|
NEXT_SYNC_COMMITTEE_INDEX* = 55'u16
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#participation-flag-indices
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#participation-flag-indices
|
||||||
TIMELY_SOURCE_FLAG_INDEX* = 0
|
TIMELY_SOURCE_FLAG_INDEX* = 0
|
||||||
TIMELY_TARGET_FLAG_INDEX* = 1
|
TIMELY_TARGET_FLAG_INDEX* = 1
|
||||||
TIMELY_HEAD_FLAG_INDEX* = 2
|
TIMELY_HEAD_FLAG_INDEX* = 2
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#inactivity-penalties
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#inactivity-penalties
|
||||||
INACTIVITY_SCORE_BIAS* = 4
|
INACTIVITY_SCORE_BIAS* = 4
|
||||||
INACTIVITY_SCORE_RECOVERY_RATE* = 16
|
INACTIVITY_SCORE_RECOVERY_RATE* = 16
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ type
|
||||||
# TODO could be distinct
|
# TODO could be distinct
|
||||||
ParticipationFlags* = uint8
|
ParticipationFlags* = uint8
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#syncaggregate
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#syncaggregate
|
||||||
SyncAggregate* = object
|
SyncAggregate* = object
|
||||||
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
||||||
sync_committee_signature*: ValidatorSig
|
sync_committee_signature*: ValidatorSig
|
||||||
|
@ -88,7 +88,7 @@ type
|
||||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||||
aggregate_pubkey*: ValidatorPubKey
|
aggregate_pubkey*: ValidatorPubKey
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#synccommitteemessage
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#synccommitteemessage
|
||||||
SyncCommitteeMessage* = object
|
SyncCommitteeMessage* = object
|
||||||
slot*: Slot ##\
|
slot*: Slot ##\
|
||||||
## Slot to which this contribution pertains
|
## Slot to which this contribution pertains
|
||||||
|
@ -102,7 +102,7 @@ type
|
||||||
signature*: ValidatorSig ##\
|
signature*: ValidatorSig ##\
|
||||||
## Signature by the validator over the block root of `slot`
|
## Signature by the validator over the block root of `slot`
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#synccommitteecontribution
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#synccommitteecontribution
|
||||||
SyncCommitteeContribution* = object
|
SyncCommitteeContribution* = object
|
||||||
slot*: Slot ##\
|
slot*: Slot ##\
|
||||||
## Slot to which this contribution pertains
|
## Slot to which this contribution pertains
|
||||||
|
@ -122,7 +122,7 @@ type
|
||||||
signature*: ValidatorSig ##\
|
signature*: ValidatorSig ##\
|
||||||
## Signature by the validator(s) over the block root of `slot`
|
## Signature by the validator(s) over the block root of `slot`
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#contributionandproof
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#contributionandproof
|
||||||
ContributionAndProof* = object
|
ContributionAndProof* = object
|
||||||
aggregator_index*: uint64
|
aggregator_index*: uint64
|
||||||
contribution*: SyncCommitteeContribution
|
contribution*: SyncCommitteeContribution
|
||||||
|
@ -172,7 +172,7 @@ type
|
||||||
fork_version*: Version ##\
|
fork_version*: Version ##\
|
||||||
## Fork version for the aggregate signature
|
## Fork version for the aggregate signature
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#beaconstate
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#beaconstate
|
||||||
BeaconState* = object
|
BeaconState* = object
|
||||||
# Versioning
|
# Versioning
|
||||||
genesis_time*: uint64
|
genesis_time*: uint64
|
||||||
|
|
|
@ -121,7 +121,7 @@ type
|
||||||
DOMAIN_SELECTION_PROOF = 5
|
DOMAIN_SELECTION_PROOF = 5
|
||||||
DOMAIN_AGGREGATE_AND_PROOF = 6
|
DOMAIN_AGGREGATE_AND_PROOF = 6
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#domain-types
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#domain-types
|
||||||
DOMAIN_SYNC_COMMITTEE = 7
|
DOMAIN_SYNC_COMMITTEE = 7
|
||||||
DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF = 8
|
DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF = 8
|
||||||
DOMAIN_CONTRIBUTION_AND_PROOF = 9
|
DOMAIN_CONTRIBUTION_AND_PROOF = 9
|
||||||
|
|
|
@ -180,7 +180,7 @@ func get_seed*(state: SomeBeaconState, epoch: Epoch, domain_type: DomainType):
|
||||||
epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1).data
|
epoch + EPOCHS_PER_HISTORICAL_VECTOR - MIN_SEED_LOOKAHEAD - 1).data
|
||||||
eth2digest(seed_input)
|
eth2digest(seed_input)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#add_flag
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#add_flag
|
||||||
func add_flag*(flags: ParticipationFlags, flag_index: int): ParticipationFlags =
|
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
|
||||||
|
|
|
@ -22,7 +22,7 @@ const
|
||||||
|
|
||||||
# Sync Committee
|
# Sync Committee
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/presets/mainnet/altair.yaml#L13
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/presets/mainnet/altair.yaml#L13
|
||||||
SYNC_COMMITTEE_SIZE* = 512
|
SYNC_COMMITTEE_SIZE* = 512
|
||||||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* = 256
|
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* = 256
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
const
|
const
|
||||||
# Updated penalty values
|
# Updated penalty values
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/presets/minimal/altair.yaml#L3
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/presets/minimal/altair.yaml#L3
|
||||||
CONFIG_NAME* = "minimal"
|
CONFIG_NAME* = "minimal"
|
||||||
|
|
||||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR* = 50331648 ##\
|
INACTIVITY_PENALTY_QUOTIENT_ALTAIR* = 50331648 ##\
|
||||||
|
@ -22,7 +22,7 @@ const
|
||||||
|
|
||||||
# Sync protocol
|
# Sync protocol
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/presets/minimal/altair.yaml#L13
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/presets/minimal/altair.yaml#L13
|
||||||
SYNC_COMMITTEE_SIZE* = 32
|
SYNC_COMMITTEE_SIZE* = 32
|
||||||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* = 8
|
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* = 8
|
||||||
|
|
||||||
|
|
|
@ -382,7 +382,7 @@ proc process_justification_and_finalization*(state: var altair.BeaconState,
|
||||||
return
|
return
|
||||||
let
|
let
|
||||||
# these ultimately differ from phase0 only in these lines
|
# these ultimately differ from phase0 only in these lines
|
||||||
# ref: https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/phase0/beacon-chain.md#justification-and-finalization
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/phase0/beacon-chain.md#justification-and-finalization
|
||||||
previous_indices = get_unslashed_participating_indices(
|
previous_indices = get_unslashed_participating_indices(
|
||||||
state, TIMELY_TARGET_FLAG_INDEX, get_previous_epoch(state))
|
state, TIMELY_TARGET_FLAG_INDEX, get_previous_epoch(state))
|
||||||
current_indices = get_unslashed_participating_indices(
|
current_indices = get_unslashed_participating_indices(
|
||||||
|
@ -559,7 +559,7 @@ func get_attestation_deltas(state: phase0.BeaconState, rewards: var RewardInfo)
|
||||||
rewards.statuses[proposer_index].delta.add(
|
rewards.statuses[proposer_index].delta.add(
|
||||||
proposer_delta.get()[1])
|
proposer_delta.get()[1])
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#get_base_reward_per_increment
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#get_base_reward_per_increment
|
||||||
func get_base_reward_per_increment(
|
func get_base_reward_per_increment(
|
||||||
state: altair.BeaconState, total_active_balance: Gwei): Gwei =
|
state: altair.BeaconState, total_active_balance: Gwei): Gwei =
|
||||||
# TODO hoist this integer_squareroot, as with phase 0
|
# TODO hoist this integer_squareroot, as with phase 0
|
||||||
|
@ -798,7 +798,7 @@ func process_participation_flag_updates*(state: var altair.BeaconState) =
|
||||||
|
|
||||||
state.current_epoch_participation.resetCache()
|
state.current_epoch_participation.resetCache()
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#sync-committee-updates
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#sync-committee-updates
|
||||||
proc process_sync_committee_updates*(state: var altair.BeaconState) =
|
proc process_sync_committee_updates*(state: var altair.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:
|
||||||
|
|
Loading…
Reference in New Issue