mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-18 09:27:05 +00:00
update 20 more spec refs to v1.1.0-alpha.8 (#2690)
This commit is contained in:
parent
c9cec88a23
commit
68ca600d89
@ -72,7 +72,7 @@ type
|
|||||||
current_justified_checkpoint*: Checkpoint
|
current_justified_checkpoint*: Checkpoint
|
||||||
finalized_checkpoint*: Checkpoint
|
finalized_checkpoint*: Checkpoint
|
||||||
|
|
||||||
# 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
|
||||||
# Memory-representation-equivalent to an Altair BeaconState for in-place SSZ
|
# Memory-representation-equivalent to an Altair BeaconState for in-place SSZ
|
||||||
# reading and writing
|
# reading and writing
|
||||||
AltairBeaconStateNoImmutableValidators* = object
|
AltairBeaconStateNoImmutableValidators* = object
|
||||||
|
@ -49,7 +49,7 @@ const
|
|||||||
PARTICIPATION_FLAG_WEIGHTS* =
|
PARTICIPATION_FLAG_WEIGHTS* =
|
||||||
[TIMELY_SOURCE_WEIGHT, TIMELY_TARGET_WEIGHT, TIMELY_HEAD_WEIGHT]
|
[TIMELY_SOURCE_WEIGHT, TIMELY_TARGET_WEIGHT, TIMELY_HEAD_WEIGHT]
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#misc
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#misc
|
||||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 4
|
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 4
|
||||||
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
SYNC_COMMITTEE_SUBNET_COUNT* = 4
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ static: doAssert TIMELY_SOURCE_WEIGHT + TIMELY_TARGET_WEIGHT +
|
|||||||
type
|
type
|
||||||
### New types
|
### New types
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#custom-types
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#custom-types
|
||||||
# TODO could be distinct
|
# TODO could be distinct
|
||||||
ParticipationFlags* = uint8
|
ParticipationFlags* = uint8
|
||||||
|
|
||||||
@ -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/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#synccommittee
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/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
|
||||||
@ -128,19 +128,19 @@ type
|
|||||||
contribution*: SyncCommitteeContribution
|
contribution*: SyncCommitteeContribution
|
||||||
selection_proof*: ValidatorSig
|
selection_proof*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#signedcontributionandproof
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#signedcontributionandproof
|
||||||
SignedContributionAndProof* = object
|
SignedContributionAndProof* = object
|
||||||
message*: ContributionAndProof
|
message*: ContributionAndProof
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/validator.md#syncaggregatorselectiondata
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/validator.md#syncaggregatorselectiondata
|
||||||
SyncAggregatorSelectionData* = object
|
SyncAggregatorSelectionData* = object
|
||||||
slot*: Slot
|
slot*: Slot
|
||||||
subcommittee_index*: uint64
|
subcommittee_index*: uint64
|
||||||
|
|
||||||
### Modified/overloaded
|
### Modified/overloaded
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/sync-protocol.md#lightclientsnapshot
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/sync-protocol.md#lightclientsnapshot
|
||||||
LightClientSnapshot* = object
|
LightClientSnapshot* = object
|
||||||
header*: BeaconBlockHeader ##\
|
header*: BeaconBlockHeader ##\
|
||||||
## Beacon block header
|
## Beacon block header
|
||||||
@ -150,7 +150,7 @@ type
|
|||||||
|
|
||||||
next_sync_committee*: SyncCommittee
|
next_sync_committee*: SyncCommittee
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/sync-protocol.md#lightclientupdate
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/sync-protocol.md#lightclientupdate
|
||||||
LightClientUpdate* = object
|
LightClientUpdate* = object
|
||||||
header*: BeaconBlockHeader ##\
|
header*: BeaconBlockHeader ##\
|
||||||
## Update beacon block header
|
## Update beacon block header
|
||||||
@ -308,7 +308,7 @@ type
|
|||||||
state_root*: Eth2Digest ##\
|
state_root*: Eth2Digest ##\
|
||||||
body*: TrustedBeaconBlockBody
|
body*: TrustedBeaconBlockBody
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#beaconblockbody
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#beaconblockbody
|
||||||
BeaconBlockBody* = object
|
BeaconBlockBody* = object
|
||||||
randao_reveal*: ValidatorSig
|
randao_reveal*: ValidatorSig
|
||||||
eth1_data*: Eth1Data ##\
|
eth1_data*: Eth1Data ##\
|
||||||
@ -369,7 +369,7 @@ type
|
|||||||
# [New in Altair]
|
# [New in Altair]
|
||||||
sync_aggregate*: SyncAggregate
|
sync_aggregate*: SyncAggregate
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/phase0/beacon-chain.md#signedbeaconblock
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/phase0/beacon-chain.md#signedbeaconblock
|
||||||
SignedBeaconBlock* = object
|
SignedBeaconBlock* = object
|
||||||
message*: BeaconBlock
|
message*: BeaconBlock
|
||||||
signature*: ValidatorSig
|
signature*: ValidatorSig
|
||||||
|
@ -185,7 +185,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/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#has_flag
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/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
|
||||||
|
@ -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/mainnet/altair.yaml#L3
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/presets/mainnet/altair.yaml#L3
|
||||||
CONFIG_NAME* = "mainnet"
|
CONFIG_NAME* = "mainnet"
|
||||||
|
|
||||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR* = 50331648 ##\
|
INACTIVITY_PENALTY_QUOTIENT_ALTAIR* = 50331648 ##\
|
||||||
@ -30,5 +30,5 @@ const
|
|||||||
|
|
||||||
# Sync protocol
|
# Sync protocol
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/presets/mainnet/altair.yaml#L21
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/presets/mainnet/altair.yaml#L21
|
||||||
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
|
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
|
||||||
|
@ -28,5 +28,5 @@ const
|
|||||||
|
|
||||||
# Sync protocol
|
# Sync protocol
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/presets/minimal/altair.yaml#L21
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/presets/minimal/altair.yaml#L21
|
||||||
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
|
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
|
||||||
|
@ -422,7 +422,7 @@ proc process_block*(
|
|||||||
# The transition-triggering block creates, not acts on, an Altair state
|
# The transition-triggering block creates, not acts on, an Altair state
|
||||||
err("process_block: Altair state with Phase 0 block")
|
err("process_block: Altair state with Phase 0 block")
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#block-processing
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#block-processing
|
||||||
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
# TODO workaround for https://github.com/nim-lang/Nim/issues/18095
|
||||||
# copy of datatypes/altair.nim
|
# copy of datatypes/altair.nim
|
||||||
type SomeAltairBlock =
|
type SomeAltairBlock =
|
||||||
|
@ -412,7 +412,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/eth2.0-specs/blob/v1.1.0-alpha.7/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/phase0/beacon-chain.md#rewards-and-penalties-1
|
||||||
func is_in_inactivity_leak(state: altair.BeaconState): bool =
|
func is_in_inactivity_leak(state: altair.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
|
||||||
@ -566,7 +566,7 @@ func get_base_reward_per_increment(
|
|||||||
EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div
|
EFFECTIVE_BALANCE_INCREMENT * BASE_REWARD_FACTOR div
|
||||||
integer_squareroot(total_active_balance)
|
integer_squareroot(total_active_balance)
|
||||||
|
|
||||||
# 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, total_active_balance: Gwei):
|
state: altair.BeaconState, index: ValidatorIndex, total_active_balance: Gwei):
|
||||||
Gwei =
|
Gwei =
|
||||||
@ -661,7 +661,7 @@ func process_rewards_and_penalties(
|
|||||||
increase_balance(state.balances.asSeq()[idx], v.delta.rewards)
|
increase_balance(state.balances.asSeq()[idx], v.delta.rewards)
|
||||||
decrease_balance(state.balances.asSeq()[idx], v.delta.penalties)
|
decrease_balance(state.balances.asSeq()[idx], v.delta.penalties)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#rewards-and-penalties
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#rewards-and-penalties
|
||||||
func process_rewards_and_penalties(
|
func process_rewards_and_penalties(
|
||||||
state: var altair.BeaconState, total_active_balance: Gwei) {.nbench.} =
|
state: var altair.BeaconState, total_active_balance: Gwei) {.nbench.} =
|
||||||
if get_current_epoch(state) == GENESIS_EPOCH:
|
if get_current_epoch(state) == GENESIS_EPOCH:
|
||||||
@ -691,7 +691,7 @@ func process_rewards_and_penalties(
|
|||||||
decrease_balance(state, ValidatorIndex(index), penalties[index])
|
decrease_balance(state, ValidatorIndex(index), penalties[index])
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#slashings
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.0.1/specs/phase0/beacon-chain.md#slashings
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#slashings
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#slashings
|
||||||
func process_slashings*(state: var SomeBeaconState, total_balance: Gwei) {.nbench.}=
|
func process_slashings*(state: var SomeBeaconState, total_balance: Gwei) {.nbench.}=
|
||||||
let
|
let
|
||||||
epoch = get_current_epoch(state)
|
epoch = get_current_epoch(state)
|
||||||
@ -805,7 +805,7 @@ proc process_sync_committee_updates*(state: var altair.BeaconState) =
|
|||||||
state.current_sync_committee = state.next_sync_committee
|
state.current_sync_committee = state.next_sync_committee
|
||||||
state.next_sync_committee = get_next_sync_committee(state)
|
state.next_sync_committee = get_next_sync_committee(state)
|
||||||
|
|
||||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.7/specs/altair/beacon-chain.md#inactivity-scores
|
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.8/specs/altair/beacon-chain.md#inactivity-scores
|
||||||
func process_inactivity_updates*(state: var altair.BeaconState) =
|
func process_inactivity_updates*(state: var altair.BeaconState) =
|
||||||
# Score updates based on previous epoch participation, skip genesis epoch
|
# Score updates based on previous epoch participation, skip genesis epoch
|
||||||
if get_current_epoch(state) == GENESIS_EPOCH:
|
if get_current_epoch(state) == GENESIS_EPOCH:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user