mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-09 22:06:21 +00:00
70a03658e3
* bump nim-blscurve * Outline the block validation flow * introduce the SigVerified types, pass the tests * Split clearance/quarantine to prepare for batch crypto verif * Add a batch signature collector * Make clearance use SigVerified block and split verification between crypto and state transition * Always use signedBeaconBlock for the onBlockAdded callback * RANDAO signing_root is the epoch instead of the full block * Support skipping BLS for testing * Fix compilation of the validator client * Try to fix strange errors MacOS and Jenkins (Clang, unknown type name br_hmac_drbg_context in stdlib_assertions.nim.c) * address https://github.com/status-im/nimbus-eth2/pull/2250#discussion_r561819858 * address https://github.com/status-im/nimbus-eth2/pull/2250#discussion_r561828025 * onBlockAdded callback should use TrustedSignedBeaconBlock https://github.com/status-im/nimbus-eth2/pull/2250#discussion_r561837261 * address https://github.com/status-im/nimbus-eth2/pull/2250#discussion_r561828946 * Use the application RNG: https://github.com/status-im/nimbus-eth2/pull/2250#discussion_r561815336 * Improve codegen of conversion zero-cost) * Quick fixes with loadWithCache after #2259 (TODO: graceful error since pubkey validations is now done first in signatures_batch) * Graceful handle rogue pubkeys and signatures now that those are lazy-loaded
59 lines
2.4 KiB
Nim
59 lines
2.4 KiB
Nim
# beacon_chain
|
|
# Copyright (c) 2020 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.
|
|
|
|
{.used.}
|
|
|
|
import std/unittest
|
|
import chronicles, chronos, testutil
|
|
import eth/keys
|
|
import ../beacon_chain/spec/[datatypes, presets]
|
|
import ../beacon_chain/exit_pool
|
|
import ../beacon_chain/block_pools/[quarantine, chain_dag]
|
|
|
|
proc getExitPool(): auto =
|
|
let chainDag =
|
|
init(ChainDAGRef, defaultRuntimePreset, makeTestDB(SLOTS_PER_EPOCH * 3))
|
|
newClone(ExitPool.init(chainDag, QuarantineRef.init(keys.newRng())))
|
|
|
|
suiteReport "Exit pool testing suite":
|
|
setup:
|
|
let pool = getExitPool()
|
|
timedTest "addExitMessage/getProposerSlashingMessage":
|
|
for i in 0'u64 .. MAX_PROPOSER_SLASHINGS + 5:
|
|
for j in 0'u64 .. i:
|
|
pool.proposer_slashings.addExitMessage(
|
|
ProposerSlashing(), MAX_PROPOSER_SLASHINGS)
|
|
check:
|
|
pool[].getProposerSlashingsForBlock().lenu64 ==
|
|
min(i + 1, MAX_PROPOSER_SLASHINGS)
|
|
pool[].getProposerSlashingsForBlock().len == 0
|
|
|
|
timedTest "addExitMessage/getAttesterSlashingMessage":
|
|
for i in 0'u64 .. MAX_ATTESTER_SLASHINGS + 5:
|
|
for j in 0'u64 .. i:
|
|
pool.attester_slashings.addExitMessage(
|
|
AttesterSlashing(
|
|
attestation_1: IndexedAttestation(attesting_indices:
|
|
List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE](@[0'u64])),
|
|
attestation_2: IndexedAttestation(attesting_indices:
|
|
List[uint64, Limit MAX_VALIDATORS_PER_COMMITTEE](@[0'u64]))),
|
|
MAX_ATTESTER_SLASHINGS)
|
|
check:
|
|
pool[].getAttesterSlashingsForBlock().lenu64 ==
|
|
min(i + 1, MAX_ATTESTER_SLASHINGS)
|
|
pool[].getAttesterSlashingsForBlock().len == 0
|
|
|
|
timedTest "addExitMessage/getVoluntaryExitMessage":
|
|
for i in 0'u64 .. MAX_VOLUNTARY_EXITS + 5:
|
|
for j in 0'u64 .. i:
|
|
pool.voluntary_exits.addExitMessage(
|
|
SignedVoluntaryExit(), MAX_VOLUNTARY_EXITS)
|
|
check:
|
|
pool[].getVoluntaryExitsForBlock().lenu64 ==
|
|
min(i + 1, MAX_VOLUNTARY_EXITS)
|
|
pool[].getProposerSlashingsForBlock().len == 0
|