Kagome
Polkadot Runtime Engine in C++17
|
#include <babe_block_validator.hpp>
Public Member Functions | |
~BabeBlockValidator () override=default | |
BabeBlockValidator (std::shared_ptr< blockchain::BlockTree > block_tree, std::shared_ptr< runtime::TaggedTransactionQueue > tx_queue, std::shared_ptr< crypto::Hasher > hasher, std::shared_ptr< crypto::VRFProvider > vrf_provider, std::shared_ptr< crypto::Sr25519Provider > sr25519_provider) | |
outcome::result< void > | validateHeader (const primitives::BlockHeader &header, const EpochNumber epoch_number, const primitives::AuthorityId &authority_id, const Threshold &threshold, const primitives::BabeConfiguration &babe_config) const override |
Public Member Functions inherited from kagome::consensus::BlockValidator | |
virtual | ~BlockValidator ()=default |
Private Member Functions | |
bool | verifySignature (const primitives::BlockHeader &header, const BabeBlockHeader &babe_header, const Seal &seal, const primitives::BabeSessionKey &public_key) const |
bool | verifyVRF (const BabeBlockHeader &babe_header, const EpochNumber epoch_number, const primitives::BabeSessionKey &public_key, const Threshold &threshold, const Randomness &randomness, const bool checkThreshold) const |
Private Attributes | |
std::shared_ptr< blockchain::BlockTree > | block_tree_ |
std::shared_ptr< runtime::TaggedTransactionQueue > | tx_queue_ |
std::shared_ptr< crypto::Hasher > | hasher_ |
std::shared_ptr< crypto::VRFProvider > | vrf_provider_ |
std::shared_ptr< crypto::Sr25519Provider > | sr25519_provider_ |
std::unordered_map< BabeSlotNumber, std::unordered_set< primitives::AuthorityIndex > > | blocks_producers_ |
log::Logger | log_ |
Validation of blocks in BABE system. Based on the algorithm described here: https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#2-normal-phase
Definition at line 36 of file babe_block_validator.hpp.
Enumerator | |
---|---|
NO_AUTHORITIES | |
INVALID_SIGNATURE | |
INVALID_VRF | |
TWO_BLOCKS_IN_SLOT | |
SECONDARY_SLOT_ASSIGNMENTS_DISABLED |
Definition at line 55 of file babe_block_validator.hpp.
|
overridedefault |
kagome::consensus::BabeBlockValidator::BabeBlockValidator | ( | std::shared_ptr< blockchain::BlockTree > | block_tree, |
std::shared_ptr< runtime::TaggedTransactionQueue > | tx_queue, | ||
std::shared_ptr< crypto::Hasher > | hasher, | ||
std::shared_ptr< crypto::VRFProvider > | vrf_provider, | ||
std::shared_ptr< crypto::Sr25519Provider > | sr25519_provider | ||
) |
Create an instance of BabeBlockValidator
block_tree | to be used by this instance |
tx_queue | to validate the extrinsics |
hasher | to take hashes |
vrf_provider | for VRF-specific operations |
configuration | Babe configuration from genesis |
Definition at line 41 of file babe_block_validator.cpp.
|
overridevirtual |
Validate the block header
block | to be validated |
authority_id | authority that sent this block |
threshold | is vrf threshold for this epoch |
config | is babe config for this epoch |
Implements kagome::consensus::BlockValidator.
Definition at line 60 of file babe_block_validator.cpp.
|
private |
Verify that block is signed by valid signature
header | Header to be checked |
babe_header | BabeBlockHeader corresponding to (fetched from) header |
seal | Seal corresponding to (fetched from) header |
public_key | public key that corresponds to the authority by authority index |
Definition at line 123 of file babe_block_validator.cpp.
|
private |
Verify that vrf value contained in babe_header is less than threshold and was generated by the creator of the block
babe_header | BabeBlockHeader corresponding to (fetched from) header |
public_key | Public key of creator of the block |
threshold | threshold value for that epoch |
randomness | randomness for that epoch |
Definition at line 143 of file babe_block_validator.cpp.
|
private |
Definition at line 101 of file babe_block_validator.hpp.
|
mutableprivate |
Definition at line 109 of file babe_block_validator.hpp.
|
private |
Definition at line 103 of file babe_block_validator.hpp.
|
private |
Definition at line 111 of file babe_block_validator.hpp.
|
private |
Definition at line 105 of file babe_block_validator.hpp.
|
private |
Definition at line 102 of file babe_block_validator.hpp.
|
private |
Definition at line 104 of file babe_block_validator.hpp.