mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-17 00:47:03 +00:00
use v1.3.0-alpha.2 EF consensus spec test vectors (#4430)
This commit is contained in:
parent
e7706768c3
commit
d269d82b71
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -77,7 +77,7 @@ export
|
|||||||
tables, results, json_serialization, timer, sszTypes, beacon_time, crypto,
|
tables, results, json_serialization, timer, sszTypes, beacon_time, crypto,
|
||||||
digest, presets
|
digest, presets
|
||||||
|
|
||||||
const SPEC_VERSION* = "1.3.0-alpha.1"
|
const SPEC_VERSION* = "1.3.0-alpha.2"
|
||||||
## Spec version we're aiming to be compatible with, right now
|
## Spec version we're aiming to be compatible with, right now
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Mainnet preset - Capella
|
# Mainnet preset - Capella
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/presets/mainnet/capella.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/presets/mainnet/capella.yaml
|
||||||
const
|
const
|
||||||
# Max operations per block
|
# Max operations per block
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
@ -11,3 +11,9 @@ const
|
|||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# 2**4 (= 16) withdrawals
|
# 2**4 (= 16) withdrawals
|
||||||
MAX_WITHDRAWALS_PER_PAYLOAD* = 16
|
MAX_WITHDRAWALS_PER_PAYLOAD* = 16
|
||||||
|
|
||||||
|
|
||||||
|
# Withdrawals processing
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# 2**14 (= 16384) validators
|
||||||
|
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP* = 16384
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Mainnet preset - EIP-4844
|
# Mainnet preset - EIP-4844
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/presets/mainnet/eip4844.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/presets/mainnet/eip4844.yaml
|
||||||
const
|
const
|
||||||
# `uint64(4096)`
|
# `uint64(4096)`
|
||||||
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096
|
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4096
|
||||||
# `uint64(2**4)` (= 16)
|
# `uint64(2**2)` (= 4)
|
||||||
MAX_BLOBS_PER_BLOCK*: uint64 = 16
|
MAX_BLOBS_PER_BLOCK*: uint64 = 4
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Minimal preset - Capella
|
# Minimal preset - Capella
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/presets/minimal/capella.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/presets/minimal/capella.yaml
|
||||||
const
|
const
|
||||||
# Max operations per block
|
# Max operations per block
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
@ -11,3 +11,9 @@ const
|
|||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
# [customized] 2**2 (= 4)
|
# [customized] 2**2 (= 4)
|
||||||
MAX_WITHDRAWALS_PER_PAYLOAD* = 4
|
MAX_WITHDRAWALS_PER_PAYLOAD* = 4
|
||||||
|
|
||||||
|
|
||||||
|
# Withdrawals processing
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# [customized] 2**4 (= 16) validators
|
||||||
|
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP* = 16
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Minimal preset - EIP-4844
|
# Minimal preset - EIP-4844
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/presets/minimal/eip4844.yaml
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/presets/minimal/eip4844.yaml
|
||||||
const
|
const
|
||||||
# [customized]
|
# [customized]
|
||||||
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4
|
FIELD_ELEMENTS_PER_BLOB*: uint64 = 4
|
||||||
# `uint64(2**4)` (= 16)
|
# `uint64(2**2)` (= 4)
|
||||||
MAX_BLOBS_PER_BLOCK*: uint64 = 16
|
MAX_BLOBS_PER_BLOCK*: uint64 = 4
|
||||||
|
@ -702,14 +702,15 @@ func is_partially_withdrawable_validator(
|
|||||||
has_eth1_withdrawal_credential(validator) and
|
has_eth1_withdrawal_credential(validator) and
|
||||||
has_max_effective_balance and has_excess_balance
|
has_max_effective_balance and has_excess_balance
|
||||||
|
|
||||||
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.1/specs/capella/beacon-chain.md#new-get_expected_withdrawals
|
# https://github.com/ethereum/consensus-specs/blob/v1.3.0-alpha.2/specs/capella/beacon-chain.md#new-get_expected_withdrawals
|
||||||
func get_expected_withdrawals(state: capella.BeaconState): seq[Withdrawal] =
|
func get_expected_withdrawals(state: capella.BeaconState): seq[Withdrawal] =
|
||||||
let epoch = get_current_epoch(state)
|
let epoch = get_current_epoch(state)
|
||||||
var
|
var
|
||||||
withdrawal_index = state.next_withdrawal_index
|
withdrawal_index = state.next_withdrawal_index
|
||||||
validator_index = state.next_withdrawal_validator_index
|
validator_index = state.next_withdrawal_validator_index
|
||||||
withdrawals: seq[Withdrawal] = @[]
|
withdrawals: seq[Withdrawal] = @[]
|
||||||
for _ in 0 ..< len(state.validators):
|
bound = min(len(state.validators), MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP)
|
||||||
|
for _ in 0 ..< bound:
|
||||||
let
|
let
|
||||||
validator = state.validators[validator_index]
|
validator = state.validators[validator_index]
|
||||||
balance = state.balances[validator_index]
|
balance = state.balances[validator_index]
|
||||||
@ -762,11 +763,26 @@ func process_withdrawals*(
|
|||||||
return err("process_withdrawals: invalid validator index")
|
return err("process_withdrawals: invalid validator index")
|
||||||
decrease_balance(
|
decrease_balance(
|
||||||
state, validator_index, expected_withdrawals[i].amount)
|
state, validator_index, expected_withdrawals[i].amount)
|
||||||
if len(expected_withdrawals) > 0:
|
|
||||||
|
# Update the next withdrawal index if this block contained withdrawals
|
||||||
|
if len(expected_withdrawals) != 0:
|
||||||
let latest_withdrawal = expected_withdrawals[^1]
|
let latest_withdrawal = expected_withdrawals[^1]
|
||||||
state.next_withdrawal_index = WithdrawalIndex(latest_withdrawal.index + 1)
|
state.next_withdrawal_index = WithdrawalIndex(latest_withdrawal.index + 1)
|
||||||
|
|
||||||
|
# Update the next validator index to start the next withdrawal sweep
|
||||||
|
if len(expected_withdrawals) == MAX_WITHDRAWALS_PER_PAYLOAD:
|
||||||
|
# Next sweep starts after the latest withdrawal's validator index
|
||||||
let next_validator_index =
|
let next_validator_index =
|
||||||
(latest_withdrawal.validator_index + 1) mod lenu64(state.validators)
|
(expected_withdrawals[^1].validator_index + 1) mod
|
||||||
|
lenu64(state.validators)
|
||||||
|
state.next_withdrawal_validator_index = next_validator_index
|
||||||
|
else:
|
||||||
|
# Advance sweep by the max length of the sweep if there was not a full set
|
||||||
|
# of withdrawals
|
||||||
|
let next_index =
|
||||||
|
state.next_withdrawal_validator_index +
|
||||||
|
MAX_VALIDATORS_PER_WITHDRAWALS_SWEEP
|
||||||
|
let next_validator_index = next_index mod lenu64(state.validators)
|
||||||
state.next_withdrawal_validator_index = next_validator_index
|
state.next_withdrawal_validator_index = next_validator_index
|
||||||
|
|
||||||
ok()
|
ok()
|
||||||
@ -808,15 +824,6 @@ func tx_peek_blob_versioned_hashes(opaque_tx: Transaction):
|
|||||||
for x in countup(blob_versioned_hashes_offset.int, len(opaque_tx) - 1, 32):
|
for x in countup(blob_versioned_hashes_offset.int, len(opaque_tx) - 1, 32):
|
||||||
var versionedHash: VersionedHash
|
var versionedHash: VersionedHash
|
||||||
versionedHash[0 .. 31] = opaque_tx.asSeq.toOpenArray(x, x + 31)
|
versionedHash[0 .. 31] = opaque_tx.asSeq.toOpenArray(x, x + 31)
|
||||||
|
|
||||||
# TODO there's otherwise a mismatch here where test vectors show valid but
|
|
||||||
# the first byte is 0?
|
|
||||||
# `kzg_commitment_to_versioned_hash` is very clear about the equivalent
|
|
||||||
# first byte having to be 0x01 for it ever to match
|
|
||||||
# this is not in spec per se though
|
|
||||||
if versionedHash[0] == 0:
|
|
||||||
versionedHash[0] = 0x01'u8
|
|
||||||
|
|
||||||
res.add versionedHash
|
res.add versionedHash
|
||||||
ok res
|
ok res
|
||||||
|
|
||||||
|
2
vendor/nim-eth2-scenarios
vendored
2
vendor/nim-eth2-scenarios
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 9706d8ebb1dbbb2939f100fc189a5c853bbffe06
|
Subproject commit 9a1398ab6409e8bceebdd9aeec659e7e8d1a3538
|
Loading…
x
Reference in New Issue
Block a user