use EF consensus spec v1.5.0-alpha.1 test vectors (#6249)
This commit is contained in:
parent
6119389c3a
commit
302f645a01
|
@ -2399,8 +2399,9 @@ OK: 4/4 Fail: 0/4 Skip: 0/4
|
|||
## EF - Electra - Epoch Processing - Effective balance updates [Preset: mainnet]
|
||||
```diff
|
||||
+ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK
|
||||
+ Effective balance updates - effective_balance_hysteresis_with_compounding_credentials [Pre OK
|
||||
```
|
||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## EF - Electra - Epoch Processing - Eth1 data reset [Preset: mainnet]
|
||||
```diff
|
||||
+ Eth1 data reset - eth1_vote_no_reset [Preset: mainnet] OK
|
||||
|
@ -2658,10 +2659,8 @@ OK: 6/6 Fail: 0/6 Skip: 0/6
|
|||
+ [Invalid] EF - Electra - Operations - Consolidation - invalid_no_execution_withdrawal_cred OK
|
||||
+ [Invalid] EF - Electra - Operations - Consolidation - invalid_not_enough_consolidation_chu OK
|
||||
+ [Invalid] EF - Electra - Operations - Consolidation - invalid_source_equals_target OK
|
||||
+ [Invalid] EF - Electra - Operations - Consolidation - invalid_source_signature OK
|
||||
+ [Invalid] EF - Electra - Operations - Consolidation - invalid_target_signature OK
|
||||
```
|
||||
OK: 11/11 Fail: 0/11 Skip: 0/11
|
||||
OK: 9/9 Fail: 0/9 Skip: 0/9
|
||||
## EF - Electra - Operations - Deposit [Preset: mainnet]
|
||||
```diff
|
||||
+ [Invalid] EF - Electra - Operations - Deposit - invalid_bad_merkle_proof OK
|
||||
|
@ -3026,12 +3025,13 @@ OK: 6/6 Fail: 0/6 Skip: 0/6
|
|||
OK: 14/14 Fail: 0/14 Skip: 0/14
|
||||
## EF - Merkle proof [Preset: mainnet]
|
||||
```diff
|
||||
Merkle proof - Single merkle proof - eip7594 Skip
|
||||
+ Merkle proof - Single merkle proof - mainnet/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
+ Merkle proof - Single merkle proof - mainnet/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
+ Merkle proof - Single merkle proof - mainnet/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
+ Merkle proof - Single merkle proof - mainnet/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
```
|
||||
OK: 4/4 Fail: 0/4 Skip: 0/4
|
||||
OK: 4/5 Fail: 0/5 Skip: 1/5
|
||||
## EF - Phase 0 - Epoch Processing - Effective balance updates [Preset: mainnet]
|
||||
```diff
|
||||
+ Effective balance updates - effective_balance_hysteresis [Preset: mainnet] OK
|
||||
|
@ -3534,4 +3534,4 @@ OK: 69/88 Fail: 0/88 Skip: 19/88
|
|||
OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
|
||||
---TOTAL---
|
||||
OK: 2837/2856 Fail: 0/2856 Skip: 19/2856
|
||||
OK: 2836/2856 Fail: 0/2856 Skip: 20/2856
|
||||
|
|
|
@ -2508,8 +2508,9 @@ OK: 4/4 Fail: 0/4 Skip: 0/4
|
|||
## EF - Electra - Epoch Processing - Effective balance updates [Preset: minimal]
|
||||
```diff
|
||||
+ Effective balance updates - effective_balance_hysteresis [Preset: minimal] OK
|
||||
+ Effective balance updates - effective_balance_hysteresis_with_compounding_credentials [Pre OK
|
||||
```
|
||||
OK: 1/1 Fail: 0/1 Skip: 0/1
|
||||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## EF - Electra - Epoch Processing - Eth1 data reset [Preset: minimal]
|
||||
```diff
|
||||
+ Eth1 data reset - eth1_vote_no_reset [Preset: minimal] OK
|
||||
|
@ -2795,9 +2796,8 @@ OK: 6/6 Fail: 0/6 Skip: 0/6
|
|||
+ [Valid] EF - Electra - Operations - Consolidation - consolidation_balance_larger_than_ch OK
|
||||
+ [Valid] EF - Electra - Operations - Consolidation - consolidation_balance_through_two_ch OK
|
||||
+ [Valid] EF - Electra - Operations - Consolidation - consolidation_churn_limit_balance OK
|
||||
+ [Valid] EF - Electra - Operations - Consolidation - multiple_consolidations_above_churn OK
|
||||
```
|
||||
OK: 20/20 Fail: 0/20 Skip: 0/20
|
||||
OK: 19/19 Fail: 0/19 Skip: 0/19
|
||||
## EF - Electra - Operations - Deposit [Preset: minimal]
|
||||
```diff
|
||||
+ [Invalid] EF - Electra - Operations - Deposit - invalid_bad_merkle_proof OK
|
||||
|
@ -3199,12 +3199,13 @@ OK: 20/20 Fail: 0/20 Skip: 0/20
|
|||
OK: 4/4 Fail: 0/4 Skip: 0/4
|
||||
## EF - Merkle proof [Preset: minimal]
|
||||
```diff
|
||||
Merkle proof - Single merkle proof - eip7594 Skip
|
||||
+ Merkle proof - Single merkle proof - minimal/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
+ Merkle proof - Single merkle proof - minimal/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
+ Merkle proof - Single merkle proof - minimal/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
+ Merkle proof - Single merkle proof - minimal/deneb/merkle_proof/single_merkle_proof/Beacon OK
|
||||
```
|
||||
OK: 4/4 Fail: 0/4 Skip: 0/4
|
||||
OK: 4/5 Fail: 0/5 Skip: 1/5
|
||||
## EF - Phase 0 - Epoch Processing - Effective balance updates [Preset: minimal]
|
||||
```diff
|
||||
+ Effective balance updates - effective_balance_hysteresis [Preset: minimal] OK
|
||||
|
@ -3836,4 +3837,4 @@ OK: 185/207 Fail: 0/207 Skip: 22/207
|
|||
OK: 3/3 Fail: 0/3 Skip: 0/3
|
||||
|
||||
---TOTAL---
|
||||
OK: 3108/3130 Fail: 0/3130 Skip: 22/3130
|
||||
OK: 3108/3131 Fail: 0/3131 Skip: 23/3131
|
||||
|
|
|
@ -74,7 +74,7 @@ export
|
|||
tables, results, endians2, json_serialization, sszTypes, beacon_time, crypto,
|
||||
digest, presets
|
||||
|
||||
const SPEC_VERSION* = "1.5.0-alpha.0"
|
||||
const SPEC_VERSION* = "1.5.0-alpha.1"
|
||||
## Spec version we're aiming to be compatible with, right now
|
||||
|
||||
const
|
||||
|
|
|
@ -462,6 +462,10 @@ proc collectSignatureSets*(
|
|||
genesis_fork, genesis_validators_root, bls_change.message,
|
||||
validator_pubkey, sig)
|
||||
|
||||
block:
|
||||
# 9. Consolidations
|
||||
debugRaiseAssert "check consolidations signatures"
|
||||
|
||||
ok()
|
||||
|
||||
proc batchVerify*(verifier: var BatchVerifier, sigs: openArray[SignatureSet]): bool =
|
||||
|
|
|
@ -1000,7 +1000,7 @@ func process_execution_layer_withdrawal_request*(
|
|||
))
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.0/specs/electra/beacon-chain.md#consolidations
|
||||
func process_consolidation*(
|
||||
proc process_consolidation*(
|
||||
cfg: RuntimeConfig, state: var electra.BeaconState,
|
||||
signed_consolidation: SignedConsolidation, cache: var StateCache):
|
||||
Result[void, cstring] =
|
||||
|
@ -1055,14 +1055,18 @@ func process_consolidation*(
|
|||
target_validator.withdrawal_credentials.data.toOpenArray(12, 31)):
|
||||
return err("Consolidation: source and target don't have same withdrawal address")
|
||||
|
||||
debugRaiseAssert "add signature checking for process_consolidation, which oddly isn't tested"
|
||||
debugRaiseAssert "this is per spec, near-verbatim, but Nimbus generally factors this out into spec/signatures.nim. so, create verify_consolidation_signature infra there, call here"
|
||||
# Verify consolidation is signed by the source and the target
|
||||
#let
|
||||
# domain = compute_domain(
|
||||
# DOMAIN_CONSOLIDATION, genesis_validators_root=state.genesis_validators_root)
|
||||
# signing_root = compute_signing_root(consolidation, domain)
|
||||
# pubkeys = [source_validator.pubkey, target_validator.pubkey]
|
||||
#assert bls.FastAggregateVerify(pubkeys, signing_root, signed_consolidation.signature)
|
||||
let
|
||||
domain = compute_domain(
|
||||
DOMAIN_CONSOLIDATION, cfg.GENESIS_FORK_VERSION,
|
||||
genesis_validators_root=state.genesis_validators_root)
|
||||
signing_root = compute_signing_root(consolidation, domain)
|
||||
pubkeys = [source_validator[].pubkey, target_validator.pubkey]
|
||||
|
||||
if not blsFastAggregateVerify(
|
||||
pubkeys, signing_root.data, signed_consolidation.signature):
|
||||
return err("Consolidation: invalid signature")
|
||||
|
||||
# Initiate source validator exit and append pending consolidation
|
||||
source_validator[].exit_epoch = compute_consolidation_epoch_and_update_churn(
|
||||
|
|
|
@ -1033,7 +1033,10 @@ template effective_balance_might_update*(
|
|||
effective_balance + UPWARD_THRESHOLD < balance
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#effective-balances-updates
|
||||
func process_effective_balance_updates*(state: var ForkyBeaconState) =
|
||||
func process_effective_balance_updates*(
|
||||
state: var (phase0.BeaconState | altair.BeaconState |
|
||||
bellatrix.BeaconState | capella.BeaconState |
|
||||
deneb.BeaconState)) =
|
||||
# Update effective balances with hysteresis
|
||||
for vidx in state.validators.vindices:
|
||||
let
|
||||
|
@ -1048,6 +1051,35 @@ func process_effective_balance_updates*(state: var ForkyBeaconState) =
|
|||
if new_effective_balance != effective_balance:
|
||||
state.validators.mitem(vidx).effective_balance = new_effective_balance
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.1/specs/electra/beacon-chain.md#updated-process_effective_balance_updates
|
||||
func process_effective_balance_updates*(state: var electra.BeaconState) =
|
||||
# Update effective balances with hysteresis
|
||||
for vidx in state.validators.vindices:
|
||||
let
|
||||
balance = state.balances.item(vidx)
|
||||
effective_balance = state.validators.item(vidx).effective_balance
|
||||
if effective_balance_might_update(balance, effective_balance):
|
||||
debugRaiseAssert "amortize validator read access"
|
||||
# Wrapping MAX_EFFECTIVE_BALANCE_ELECTRA.Gwei and
|
||||
# MIN_ACTIVATION_BALANCE.Gwei in static() results
|
||||
# in
|
||||
# beacon_chain/spec/state_transition_epoch.nim(1067, 20) Error: expected: ':', but got: '('
|
||||
# even though it'd be better to statically verify safety
|
||||
let
|
||||
effective_balance_limit =
|
||||
if has_compounding_withdrawal_credential(
|
||||
state.validators.item(vidx)):
|
||||
MAX_EFFECTIVE_BALANCE_ELECTRA.Gwei
|
||||
else:
|
||||
MIN_ACTIVATION_BALANCE.Gwei
|
||||
new_effective_balance =
|
||||
min(
|
||||
balance - balance mod EFFECTIVE_BALANCE_INCREMENT.Gwei,
|
||||
effective_balance_limit)
|
||||
# Protect against unnecessary cache invalidation
|
||||
if new_effective_balance != effective_balance:
|
||||
state.validators.mitem(vidx).effective_balance = new_effective_balance
|
||||
|
||||
# https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/beacon-chain.md#slashings-balances-updates
|
||||
func process_slashings_reset*(state: var ForkyBeaconState) =
|
||||
let next_epoch = get_current_epoch(state) + 1
|
||||
|
|
|
@ -147,7 +147,7 @@ suite baseDescription & "BLS to execution change " & preset():
|
|||
applyBlsToExecutionChange, path)
|
||||
|
||||
suite baseDescription & "Consolidation " & preset():
|
||||
func applyConsolidation(
|
||||
proc applyConsolidation(
|
||||
preState: var electra.BeaconState,
|
||||
signed_consolidation: SignedConsolidation):
|
||||
Result[void, cstring] =
|
||||
|
@ -157,9 +157,6 @@ suite baseDescription & "Consolidation " & preset():
|
|||
|
||||
for path in walkTests(OpConsolidationDir):
|
||||
if path in [
|
||||
"multiple_consolidations_below_churn", # missing consolidation.ssz
|
||||
"multiple_consolidations_equal_churn", # missing consolidation.ssz
|
||||
"multiple_consolidations_equal_twice_churn", # missing consolidation.ssz
|
||||
"invalid_exceed_pending_consolidations_limit", # apparently invalid prestate SSZ
|
||||
]:
|
||||
continue
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 1c29412737b0228a20b410fceb7767d9e787eed0
|
||||
Subproject commit 67f8fa8506e3b97b5e68a9c60e38157507aeec61
|
Loading…
Reference in New Issue