Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
12073cd
bump nim-blscurve
mratsim Jan 8, 2021
37d00aa
Outline the block validation flow
mratsim Dec 18, 2020
4c7891b
introduce the SigVerified types, pass the tests
mratsim Jan 18, 2021
02e2d55
Split clearance/quarantine to prepare for batch crypto verif
mratsim Jan 18, 2021
208ec77
Add a batch signature collector
mratsim Jan 19, 2021
25679b7
Make clearance use SigVerified block and split verification between c…
mratsim Jan 20, 2021
ba3ccbc
Always use signedBeaconBlock for the onBlockAdded callback
mratsim Jan 20, 2021
0af30dc
RANDAO signing_root is the epoch instead of the full block
mratsim Jan 20, 2021
7b75044
Support skipping BLS for testing
mratsim Jan 20, 2021
f7f51d2
Fix compilation of the validator client
mratsim Jan 20, 2021
dc6d857
Try to fix strange errors MacOS and Jenkins (Clang, unknown type name…
mratsim Jan 21, 2021
97c3be6
address https://github.com/status-im/nimbus-eth2/pull/2250#discussion…
mratsim Jan 21, 2021
b5a2835
address https://github.com/status-im/nimbus-eth2/pull/2250#discussion…
mratsim Jan 21, 2021
5391baf
onBlockAdded callback should use TrustedSignedBeaconBlock https://git…
mratsim Jan 21, 2021
66bd2f5
address https://github.com/status-im/nimbus-eth2/pull/2250#discussion…
mratsim Jan 21, 2021
2ed532e
Use the application RNG: https://github.com/status-im/nimbus-eth2/pul…
mratsim Jan 21, 2021
2ba3795
Improve codegen of conversion zero-cost)
mratsim Jan 21, 2021
2378ccc
Quick fixes with loadWithCache after #2259 (TODO: graceful error sinc…
mratsim Jan 25, 2021
11fa3e0
Graceful handle rogue pubkeys and signatures now that those are lazy-…
mratsim Jan 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion beacon_chain/attestation_pool.nim
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ proc addAttestation*(pool: var AttestationPool,
proc addForkChoice*(pool: var AttestationPool,
epochRef: EpochRef,
blckRef: BlockRef,
blck: BeaconBlock,
blck: TrustedBeaconBlock,
wallSlot: Slot) =
## Add a verified block to the fork choice context
let state = pool.forkChoice.process_block(
Expand Down
4 changes: 4 additions & 0 deletions beacon_chain/beacon_chain_db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,16 @@ func toBeaconBlockSummary(v: SomeBeaconBlock): BeaconBlockSummary =
parent_root: v.parent_root,
)

# TODO: we should only store TrustedSignedBeaconBlock in the DB.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the new asTrusted where memory layout is the same for all block kinds, this should actually be a simple change

proc putBlock*(db: BeaconChainDB, value: SignedBeaconBlock) =
db.put(subkey(type value, value.root), value)
db.put(subkey(BeaconBlockSummary, value.root), value.message.toBeaconBlockSummary())
proc putBlock*(db: BeaconChainDB, value: TrustedSignedBeaconBlock) =
db.put(subkey(SignedBeaconBlock, value.root), value)
db.put(subkey(BeaconBlockSummary, value.root), value.message.toBeaconBlockSummary())
proc putBlock*(db: BeaconChainDB, value: SigVerifiedSignedBeaconBlock) =
db.put(subkey(SignedBeaconBlock, value.root), value)
db.put(subkey(BeaconBlockSummary, value.root), value.message.toBeaconBlockSummary())

proc putState*(db: BeaconChainDB, key: Eth2Digest, value: BeaconState) =
# TODO prune old states - this is less easy than it seems as we never know
Expand Down
11 changes: 9 additions & 2 deletions beacon_chain/block_pools/block_pools_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import
std/[deques, strformat, tables, hashes],
# Status libraries
stew/[endians2, byteutils], chronicles,
eth/keys,
# Internals
../spec/[datatypes, crypto, digest],
../spec/[datatypes, crypto, digest, signatures_batch],
../beacon_chain_db, ../extras

from libp2p/protocols/pubsub/pubsub import ValidationResult
Expand Down Expand Up @@ -65,6 +66,11 @@ type
## Roots of blocks that we would like to have (either parent_root of
## unresolved blocks or block roots of attestations)

sigVerifCache*: BatchedBLSVerifierCache ##\
## A cache for batch BLS signature verification contexts
rng*: ref BrHmacDrbgContext ##\
## A reference to the Nimbus application-wide RNG

inAdd*: bool

MissingBlock* = object
Expand Down Expand Up @@ -200,8 +206,9 @@ type
## has advanced without blocks

OnBlockAdded* = proc(
blckRef: BlockRef, blck: SignedBeaconBlock,
blckRef: BlockRef, blck: TrustedSignedBeaconBlock,
epochRef: EpochRef, state: HashedBeaconState) {.raises: [Defect], gcsafe.}
# The `{.gcsafe.}` annotation is needed to shut up the compiler.

template validator_keys*(e: EpochRef): untyped = e.validator_key_store[1][]

Expand Down
2 changes: 1 addition & 1 deletion beacon_chain/block_pools/chain_dag.nim
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ declareGauge beacon_processed_deposits_total, "Number of total deposits included
logScope: topics = "chaindag"

proc putBlock*(
dag: var ChainDAGRef, signedBlock: SignedBeaconBlock) =
dag: var ChainDAGRef, signedBlock: TrustedSignedBeaconBlock) =
dag.db.putBlock(signedBlock)

proc updateStateData*(
Expand Down
Loading