mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 17:53:52 +00:00
update some v1.1.0 alpha1 to alpha2 (#2457)
* update some v1.1.0 alpha1 to alpha2 * remove unused getDepositMessage overload and move other out of datatypes/base * bump nim-eth2-scenarios to download v1.1.0-alpha.2 test vectors * construct object rather than result
This commit is contained in:
parent
1af07ad124
commit
49a5667288
@ -74,6 +74,13 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
+ parent sanity [Preset: mainnet] OK
|
||||
```
|
||||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## Eth2 specific discovery tests
|
||||
```diff
|
||||
+ Invalid attnets field OK
|
||||
+ Subnet query OK
|
||||
+ Subnet query after ENR update OK
|
||||
```
|
||||
OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
## Exit pool testing suite
|
||||
```diff
|
||||
+ addExitMessage/getAttesterSlashingMessage OK
|
||||
@ -282,4 +289,4 @@ OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
|
||||
---TOTAL---
|
||||
OK: 151/160 Fail: 0/160 Skip: 9/160
|
||||
OK: 154/163 Fail: 0/163 Skip: 9/163
|
||||
|
116
beacon_chain/spec/datatypes/altair.nim
Normal file
116
beacon_chain/spec/datatypes/altair.nim
Normal file
@ -0,0 +1,116 @@
|
||||
# beacon_chain
|
||||
# Copyright (c) 2021 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * 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.
|
||||
|
||||
# This file contains data types that are part of the spec and thus subject to
|
||||
# serialization and spec updates.
|
||||
#
|
||||
# The spec folder in general contains code that has been hoisted from the
|
||||
# specification and that follows the spec as closely as possible, so as to make
|
||||
# it easy to keep up-to-date.
|
||||
#
|
||||
# These datatypes are used as specifications for serialization - thus should not
|
||||
# be altered outside of what the spec says. Likewise, they should not be made
|
||||
# `ref` - this can be achieved by wrapping them in higher-level
|
||||
# types / composition
|
||||
|
||||
# TODO Careful, not nil analysis is broken / incomplete and the semantics will
|
||||
# likely change in future versions of the language:
|
||||
# https://github.com/nim-lang/RFCs/issues/250
|
||||
{.experimental: "notnil".}
|
||||
|
||||
{.push raises: [Defect].}
|
||||
|
||||
import
|
||||
std/macros,
|
||||
stew/assign2,
|
||||
json_serialization/types as jsonTypes,
|
||||
../../ssz/types as sszTypes, ../crypto, ../digest, ../presets
|
||||
|
||||
import ./base
|
||||
export base
|
||||
|
||||
const
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/beacon-chain.md#incentivization-weights
|
||||
TIMELY_HEAD_WEIGHT* = 12
|
||||
TIMELY_SOURCE_WEIGHT* = 12
|
||||
TIMELY_TARGET_WEIGHT* = 24
|
||||
SYNC_REWARD_WEIGHT* = 8
|
||||
WEIGHT_DENOMINATOR* = 64
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/validator.md#misc
|
||||
TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE* = 4
|
||||
SYNC_COMMITTEE_SUBNET_COUNT* = 8
|
||||
|
||||
type
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/beacon-chain.md#syncaggregate
|
||||
SyncAggregate* = object
|
||||
sync_committee_bits*: BitArray[SYNC_COMMITTEE_SIZE]
|
||||
sync_committee_signature*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/beacon-chain.md#synccommittee
|
||||
SyncCommittee* = object
|
||||
pubkeys*: HashArray[Limit SYNC_COMMITTEE_SIZE, ValidatorPubKey]
|
||||
pubkey_aggregates*:
|
||||
HashArray[
|
||||
Limit SYNC_COMMITTEE_SIZE div SYNC_PUBKEYS_PER_AGGREGATE,
|
||||
ValidatorPubKey]
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/validator.md#synccommitteesignature
|
||||
SyncCommitteeSignature* = object
|
||||
slot*: Slot ##\
|
||||
## Slot to which this contribution pertains
|
||||
|
||||
beacon_block_root*: Eth2Digest ##\
|
||||
## Block root for this signature
|
||||
|
||||
validator_index*: uint64 ##\
|
||||
## Index of the validator that produced this signature
|
||||
|
||||
signature*: ValidatorSig ##\
|
||||
## Signature by the validator over the block root of `slot`
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/validator.md#synccommitteecontribution
|
||||
SyncCommitteeContribution* = object
|
||||
slot*: Slot ##\
|
||||
## Slot to which this contribution pertains
|
||||
|
||||
beacon_block_root*: Eth2Digest ##\
|
||||
## Block root for this contribution
|
||||
|
||||
subcommittee_index*: uint64 ##\
|
||||
## The subcommittee this contribution pertains to out of the broader sync
|
||||
## committee
|
||||
|
||||
aggregation_bits*:
|
||||
BitArray[SYNC_COMMITTEE_SIZE div SYNC_COMMITTEE_SUBNET_COUNT] ##\
|
||||
## A bit is set if a signature from the validator at the corresponding
|
||||
## index in the subcommittee is present in the aggregate `signature`.
|
||||
|
||||
signature*: ValidatorSig ##\
|
||||
## Signature by the validator(s) over the block root of `slot`
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/validator.md#contributionandproof
|
||||
ContributionAndProof* = object
|
||||
aggregator_index*: uint64
|
||||
contribution*: SyncCommitteeContribution
|
||||
selection_proof*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/validator.md#signedcontributionandproof
|
||||
SignedContributionAndProof* = object
|
||||
message*: ContributionAndProof
|
||||
signature*: ValidatorSig
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/validator.md#synccommitteesigningdata
|
||||
SyncCommitteeSigningData* = object
|
||||
slot*: Slot
|
||||
subcommittee_index*: uint64
|
||||
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/specs/altair/beacon-chain.md#participation-flag-indices
|
||||
ValidatorFlag* = enum
|
||||
TIMELY_HEAD_FLAG = 0
|
||||
TIMELY_SOURCE_FLAG = 1
|
||||
TIMELY_TARGET_FLAG = 2
|
@ -659,14 +659,6 @@ func getImmutableValidatorData*(validator: Validator): ImmutableValidatorData =
|
||||
pubkey: validator.pubkey,
|
||||
withdrawal_credentials: validator.withdrawal_credentials)
|
||||
|
||||
func getDepositMessage*(depositData: DepositData): DepositMessage =
|
||||
result.pubkey = depositData.pubkey
|
||||
result.amount = depositData.amount
|
||||
result.withdrawal_credentials = depositData.withdrawal_credentials
|
||||
|
||||
func getDepositMessage*(deposit: Deposit): DepositMessage =
|
||||
deposit.data.getDepositMessage
|
||||
|
||||
# TODO when https://github.com/nim-lang/Nim/issues/14440 lands in Status's Nim,
|
||||
# switch proc {.noSideEffect.} to func.
|
||||
template ethTimeUnit(typ: type) {.dirty.} =
|
||||
|
@ -152,13 +152,29 @@ const
|
||||
|
||||
when const_preset == "mainnet":
|
||||
template defaultRuntimePreset*: auto = mainnetRuntimePreset
|
||||
import ./presets/v1_0_1/mainnet
|
||||
export mainnet
|
||||
import
|
||||
./presets/v1_0_1/mainnet as phase0Mainnet,
|
||||
./presets/altair/mainnet as altairMainnet
|
||||
|
||||
# https://github.com/nim-lang/Nim/issues/17511 workaround
|
||||
static:
|
||||
discard phase0Mainnet.CONFIG_NAME
|
||||
discard altairMainnet.CONFIG_NAME
|
||||
|
||||
export phase0Mainnet, altairMainnet
|
||||
|
||||
elif const_preset == "minimal":
|
||||
template defaultRuntimePreset*: auto = minimalRuntimePreset
|
||||
import ./presets/v1_0_1/minimal
|
||||
export minimal
|
||||
import
|
||||
./presets/v1_0_1/minimal as phase0Minimal,
|
||||
./presets/altair/minimal as altairMinimal
|
||||
|
||||
# https://github.com/nim-lang/Nim/issues/17511 workaround
|
||||
static:
|
||||
discard phase0Minimal.CONFIG_NAME
|
||||
discard altairMinimal.CONFIG_NAME
|
||||
|
||||
export phase0Minimal, altairMinimal
|
||||
|
||||
else:
|
||||
macro createConstantsFromPreset*(path: static string): untyped =
|
||||
|
@ -11,7 +11,7 @@
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/mainnet/altair.yaml#L5
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/mainnet/altair.yaml#L5
|
||||
CONFIG_NAME* = "mainnet"
|
||||
|
||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR* = 50331648 ##\
|
||||
@ -22,21 +22,21 @@ const
|
||||
|
||||
# Misc
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/mainnet/altair.yaml#L15
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/mainnet/altair.yaml#L15
|
||||
SYNC_COMMITTEE_SIZE* = 1024
|
||||
SYNC_SUBCOMMITTEE_SIZE* = 64
|
||||
SYNC_PUBKEYS_PER_AGGREGATE* = 64
|
||||
INACTIVITY_SCORE_BIAS* = 4
|
||||
|
||||
# Time parameters
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/mainnet/altair.yaml#L25
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/mainnet/altair.yaml#L25
|
||||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* = 256
|
||||
|
||||
# Signature domains (DOMAIN_SYNC_COMMITTEE) in spec/datatypes/base
|
||||
|
||||
# Fork
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/mainnet/altair.yaml#L36
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/mainnet/altair.yaml#L36
|
||||
|
||||
# ALTAIR_FORK_VERSION is a runtime preset
|
||||
|
||||
@ -44,7 +44,7 @@ const
|
||||
|
||||
# Sync protocol
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/mainnet/altair.yaml#L43
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/mainnet/altair.yaml#L43
|
||||
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
|
||||
MAX_VALID_LIGHT_CLIENT_UPDATES* = 8192
|
||||
LIGHT_CLIENT_UPDATE_TIMEOUT* = 8192
|
||||
|
@ -11,7 +11,7 @@
|
||||
const
|
||||
# Updated penalty values
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/minimal/altair.yaml#L5
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/minimal/altair.yaml#L5
|
||||
CONFIG_NAME* = "minimal"
|
||||
|
||||
INACTIVITY_PENALTY_QUOTIENT_ALTAIR* = 50331648 ##\
|
||||
@ -22,21 +22,21 @@ const
|
||||
|
||||
# Misc
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/minimal/altair.yaml#L15
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/minimal/altair.yaml#L15
|
||||
SYNC_COMMITTEE_SIZE* = 32
|
||||
SYNC_SUBCOMMITTEE_SIZE* = 16
|
||||
SYNC_PUBKEYS_PER_AGGREGATE* = 16
|
||||
INACTIVITY_SCORE_BIAS* = 4
|
||||
|
||||
# Time parameters
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/minimal/altair.yaml#L25
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/minimal/altair.yaml#L25
|
||||
EPOCHS_PER_SYNC_COMMITTEE_PERIOD* = 8
|
||||
|
||||
# Signature domains (DOMAIN_SYNC_COMMITTEE) in spec/datatypes/base
|
||||
|
||||
# Fork
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/minimal/altair.yaml#L36
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/minimal/altair.yaml#L36
|
||||
|
||||
# ALTAIR_FORK_VERSION is a runtime preset
|
||||
|
||||
@ -44,7 +44,7 @@ const
|
||||
|
||||
# Sync protocol
|
||||
# ---------------------------------------------------------------
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.1/configs/minimal/altair.yaml#L43
|
||||
# https://github.com/ethereum/eth2.0-specs/blob/v1.1.0-alpha.2/configs/minimal/altair.yaml#L43
|
||||
MIN_SYNC_COMMITTEE_PARTICIPANTS* = 1
|
||||
MAX_VALID_LIGHT_CLIENT_UPDATES* = 32
|
||||
LIGHT_CLIENT_UPDATE_TIMEOUT* = 32
|
||||
|
@ -17,6 +17,12 @@ template withTrust(sig: SomeSig, body: untyped): bool =
|
||||
else:
|
||||
body
|
||||
|
||||
func getDepositMessage(depositData: DepositData): DepositMessage =
|
||||
DepositMessage(
|
||||
pubkey: depositData.pubkey,
|
||||
amount: depositData.amount,
|
||||
withdrawal_credentials: depositData.withdrawal_credentials)
|
||||
|
||||
func compute_slot_root*(
|
||||
fork: Fork, genesis_validators_root: Eth2Digest, slot: Slot
|
||||
): Eth2Digest =
|
||||
|
@ -1,3 +1,5 @@
|
||||
{.used.}
|
||||
|
||||
import
|
||||
std/unittest,
|
||||
chronos, stew/shims/net, eth/keys, eth/p2p/discoveryv5/enr,
|
||||
|
2
vendor/nim-eth2-scenarios
vendored
2
vendor/nim-eth2-scenarios
vendored
@ -1 +1 @@
|
||||
Subproject commit 26cd96259aa8047096589361d96b86673f8a3ecd
|
||||
Subproject commit 26f2b9153d295584ccbe6a32aa681497e49b4da7
|
Loading…
x
Reference in New Issue
Block a user