Kagome
Polkadot Runtime Engine in C++17
|
#include <parachain_processor.hpp>
Classes | |
struct | AttestingData |
struct | FetchedCollationState |
struct | ImportStatementSummary |
struct | ValidateAndSecondResult |
Public Types | |
enum | Error { Error::RESPONSE_ALREADY_RECEIVED = 1, Error::COLLATION_NOT_FOUND, Error::KEY_NOT_PRESENT } |
Public Member Functions | |
ParachainProcessorImpl (std::shared_ptr< network::PeerManager > pm, std::shared_ptr< crypto::Sr25519Provider > crypto_provider, std::shared_ptr< network::Router > router, std::shared_ptr< boost::asio::io_context > this_context, std::shared_ptr< crypto::Sr25519Keypair > keypair, std::shared_ptr< crypto::Hasher > hasher) | |
~ParachainProcessorImpl () | |
bool | start () |
void | stop () |
bool | prepare () |
void | requestCollations (network::PendingCollation const &pending_collation) |
void | setAssignedParachain (std::optional< network::ParachainId > para_id) |
void | handleStatement (libp2p::peer::PeerId const &peer_id, primitives::BlockHash const &relay_parent, std::shared_ptr< network::Statement > const &statement) |
Static Public Attributes | |
static constexpr uint64_t | kBackgroundWorkers = 5 |
Private Types | |
enum | CollationState { CollationState::kFetched, CollationState::kSeconded } |
enum | PoVDataState { PoVDataState::kComplete, PoVDataState::kFetchFromValidator } |
enum | StatementType { StatementType::kSeconded = 0, StatementType::kValid } |
using | FetchedCollation = std::shared_ptr< FetchedCollationState > |
using | Commitments = std::shared_ptr< network::CandidateCommitments > |
using | PeerMap = std::unordered_map< libp2p::peer::PeerId, FetchedCollation > |
using | RelayParentMap = std::unordered_map< primitives::BlockHash, PeerMap > |
using | ParachainMap = std::unordered_map< network::ParachainId, RelayParentMap > |
using | BackgroundTask = std::function< void()> |
using | WorkersContext = boost::asio::io_context |
using | WorkGuard = boost::asio::executor_work_guard< boost::asio::io_context::executor_type > |
Private Member Functions | |
outcome::result< void > | validateCandidate (FetchedCollation &fetched_collation) |
outcome::result< void > | validateErasureCoding (FetchedCollation &fetched_collation) |
template<typename F > | |
void | validateAndMakeAvailable (libp2p::peer::PeerId const &peer_id, primitives::BlockHash const &relay_parent, FetchedCollation fetched_collation, F &&callback) |
void | requestPoV () |
void | onValidationComplete (libp2p::peer::PeerId const &peer_id, ValidateAndSecondResult &&result) |
void | onAttestComplete (libp2p::peer::PeerId const &peer_id, ValidateAndSecondResult &&result) |
void | onAttestNoPoVComplete (libp2p::peer::PeerId const &peer_id, ValidateAndSecondResult &&result) |
void | appendAsyncValidationTask (network::ParachainId id, primitives::BlockHash const &relay_parent, libp2p::peer::PeerId const &peer_id) |
void | kickOffValidationWork (AttestingData &attesting_data) |
void | handleFetchedCollation (network::ParachainId id, primitives::BlockHash const &relay_parent, libp2p::peer::PeerId const &peer_id, network::CollationFetchingResponse &&response) |
template<StatementType kStatementType> | |
std::shared_ptr< network::Statement > | createAndSignStatement (ValidateAndSecondResult &validation_result) |
std::optional< ImportStatementSummary > | importStatement (std::shared_ptr< network::Statement > const &statement) |
std::optional< network::ValidatorIndex > | getOurIndex () |
primitives::BlockHash | candidateHashFrom (FetchedCollationState const &fetched_collation_state) |
network::CandidateDescriptor const & | candidateDescriptorFrom (FetchedCollationState const &fetched_collation_state) |
std::optional< std::reference_wrapper< network::CandidateDescriptor const > > | candidateDescriptorFrom (std::shared_ptr< network::Statement > const &statement) |
network::CollatorPublicKey const & | collatorIdFromDescriptor (network::CandidateDescriptor const &descriptor) |
primitives::BlockHash | candidateHashFrom (std::shared_ptr< network::Statement > const &statement) |
template<typename F > | |
void | notify_internal (std::shared_ptr< WorkersContext > &context, F &&func) |
void | notifyBackedCandidate (std::shared_ptr< network::Statement > const &statement) |
void | notifyAvailableData () |
void | notifyStatementDistributionSystem (std::shared_ptr< network::Statement > const &statement) |
void | notify (libp2p::peer::PeerId const &peer_id, primitives::BlockHash const &relay_parent, std::shared_ptr< network::Statement > const &statement) |
void | handleNotify (libp2p::peer::PeerId const &peer_id, primitives::BlockHash const &relay_parent) |
outcome::result< FetchedCollation > | loadIntoResponseSlot (network::ParachainId id, primitives::BlockHash const &relay_parent, libp2p::peer::PeerId const &peer_id, network::CollationFetchingResponse &&response) |
outcome::result< FetchedCollation > | getFromSlot (network::ParachainId id, primitives::BlockHash const &relay_parent, libp2p::peer::PeerId const &peer_id) |
template<typename T > | |
outcome::result< network::Signature > | sign (T const &t) const |
std::optional< ImportStatementSummary > | importStatementToTable (primitives::BlockHash const &candidate_hash, std::shared_ptr< network::Statement > const &statement) |
Private Attributes | |
std::shared_ptr< network::PeerManager > | pm_ |
std::shared_ptr< crypto::Sr25519Provider > | crypto_provider_ |
std::shared_ptr< network::Router > | router_ |
log::Logger | logger_ |
struct { | |
std::optional< network::ParachainId > | assignment |
std::optional< primitives::BlockHash > | seconded |
std::optional< network::CollatorPublicKey > | required_collator |
std::unordered_set< primitives::BlockHash > | awaiting_validation |
std::unordered_set< primitives::BlockHash > | issued_statements |
std::unordered_map< primitives::BlockHash, AttestingData > | fallbacks |
std::unordered_map< libp2p::peer::PeerId, std::deque< std::shared_ptr< network::Statement > > > | seconded_statements |
} | our_current_state_ |
std::shared_ptr< WorkersContext > | context_ |
std::shared_ptr< WorkGuard > | work_guard_ |
std::unique_ptr< std::thread > | workers_ [kBackgroundWorkers] |
SafeObject< ParachainMap > | collations_ |
std::shared_ptr< WorkersContext > | this_context_ |
std::shared_ptr< crypto::Sr25519Keypair > | keypair_ |
std::shared_ptr< crypto::Hasher > | hasher_ |
Definition at line 43 of file parachain_processor.hpp.
struct kagome::parachain::ParachainProcessorImpl::AttestingData |
Definition at line 117 of file parachain_processor.hpp.
Class Members | ||
---|---|---|
queue< ValidatorIndex > | backing | |
BlockHash | candidate_hash | |
ValidatorIndex | from_validator | |
BlockHash | pov_hash | |
shared_ptr< Statement > | statement |
struct kagome::parachain::ParachainProcessorImpl::ImportStatementSummary |
Definition at line 52 of file parachain_processor.hpp.
struct kagome::parachain::ParachainProcessorImpl::ValidateAndSecondResult |
Definition at line 110 of file parachain_processor.hpp.
Class Members | ||
---|---|---|
Commitments | commitments | |
FetchedCollation | fetched_collation | |
BlockHash | relay_parent | |
result< void > | result |
|
private |
Definition at line 105 of file parachain_processor.hpp.
|
private |
Definition at line 100 of file parachain_processor.hpp.
|
private |
Definition at line 99 of file parachain_processor.hpp.
|
private |
Definition at line 104 of file parachain_processor.hpp.
|
private |
Definition at line 101 of file parachain_processor.hpp.
|
private |
Definition at line 102 of file parachain_processor.hpp.
|
private |
Definition at line 106 of file parachain_processor.hpp.
|
private |
Definition at line 108 of file parachain_processor.hpp.
|
strongprivate |
Enumerator | |
---|---|
kFetched | |
kSeconded |
Definition at line 82 of file parachain_processor.hpp.
|
strong |
Enumerator | |
---|---|
RESPONSE_ALREADY_RECEIVED | |
COLLATION_NOT_FOUND | |
KEY_NOT_PRESENT |
Definition at line 45 of file parachain_processor.hpp.
|
strongprivate |
Enumerator | |
---|---|
kComplete | |
kFetchFromValidator |
Definition at line 83 of file parachain_processor.hpp.
|
strongprivate |
Enumerator | |
---|---|
kSeconded | |
kValid |
Definition at line 84 of file parachain_processor.hpp.
kagome::parachain::ParachainProcessorImpl::ParachainProcessorImpl | ( | std::shared_ptr< network::PeerManager > | pm, |
std::shared_ptr< crypto::Sr25519Provider > | crypto_provider, | ||
std::shared_ptr< network::Router > | router, | ||
std::shared_ptr< boost::asio::io_context > | this_context, | ||
std::shared_ptr< crypto::Sr25519Keypair > | keypair, | ||
std::shared_ptr< crypto::Hasher > | hasher | ||
) |
Definition at line 36 of file parachain_processor.cpp.
kagome::parachain::ParachainProcessorImpl::~ParachainProcessorImpl | ( | ) |
check that all workers are stopped.
Definition at line 56 of file parachain_processor.cpp.
|
private |
TODO(iceseer): add to awaiting_validation to be sure no doublicated validations
Definition at line 218 of file parachain_processor.cpp.
|
inlineprivate |
Definition at line 177 of file parachain_processor.hpp.
|
inlineprivate |
Definition at line 188 of file parachain_processor.hpp.
|
inlineprivate |
Definition at line 166 of file parachain_processor.hpp.
|
inlineprivate |
Definition at line 210 of file parachain_processor.hpp.
|
inlineprivate |
Definition at line 205 of file parachain_processor.hpp.
|
private |
TODO(iceseer): https://github.com/paritytech/polkadot/blob/master/primitives/src/v2/mod.rs#L1535-L1545
TODO(iceseer): https://github.com/paritytech/polkadot/blob/master/primitives/src/v2/mod.rs#L1535-L1545
Definition at line 351 of file parachain_processor.cpp.
|
private |
Definition at line 103 of file parachain_processor.cpp.
|
private |
Definition at line 262 of file parachain_processor.cpp.
|
private |
Definition at line 144 of file parachain_processor.cpp.
|
private |
Definition at line 404 of file parachain_processor.cpp.
void kagome::parachain::ParachainProcessorImpl::handleStatement | ( | libp2p::peer::PeerId const & | peer_id, |
primitives::BlockHash const & | relay_parent, | ||
std::shared_ptr< network::Statement > const & | statement | ||
) |
Definition at line 267 of file parachain_processor.cpp.
|
private |
Definition at line 339 of file parachain_processor.cpp.
|
private |
Definition at line 324 of file parachain_processor.cpp.
|
private |
TODO(iceseer): add to awaiting_validation to be sure no doublicated validations
request PoV
validate PoV
Definition at line 193 of file parachain_processor.cpp.
|
private |
Definition at line 123 of file parachain_processor.cpp.
|
private |
Definition at line 461 of file parachain_processor.cpp.
|
inlineprivate |
Definition at line 235 of file parachain_processor.hpp.
|
private |
Definition at line 514 of file parachain_processor.cpp.
|
private |
Definition at line 331 of file parachain_processor.cpp.
|
private |
Not implemented yet
Definition at line 497 of file parachain_processor.cpp.
|
private |
Definition at line 566 of file parachain_processor.cpp.
|
private |
Definition at line 583 of file parachain_processor.cpp.
|
private |
Definition at line 469 of file parachain_processor.cpp.
bool kagome::parachain::ParachainProcessorImpl::prepare | ( | ) |
Definition at line 65 of file parachain_processor.cpp.
void kagome::parachain::ParachainProcessorImpl::requestCollations | ( | network::PendingCollation const & | pending_collation | ) |
Definition at line 608 of file parachain_processor.cpp.
|
private |
Definition at line 189 of file parachain_processor.cpp.
void kagome::parachain::ParachainProcessorImpl::setAssignedParachain | ( | std::optional< network::ParachainId > | para_id | ) |
Definition at line 603 of file parachain_processor.cpp.
|
private |
Definition at line 254 of file parachain_processor.cpp.
bool kagome::parachain::ParachainProcessorImpl::start | ( | ) |
Definition at line 71 of file parachain_processor.cpp.
void kagome::parachain::ParachainProcessorImpl::stop | ( | ) |
Definition at line 87 of file parachain_processor.cpp.
|
private |
Definition at line 519 of file parachain_processor.cpp.
|
private |
Definition at line 502 of file parachain_processor.cpp.
|
private |
Definition at line 508 of file parachain_processor.cpp.
|
private |
Definition at line 291 of file parachain_processor.hpp.
|
private |
Definition at line 287 of file parachain_processor.hpp.
|
private |
Definition at line 269 of file parachain_processor.hpp.
|
private |
Definition at line 294 of file parachain_processor.hpp.
|
static |
Definition at line 50 of file parachain_processor.hpp.
|
private |
Definition at line 293 of file parachain_processor.hpp.
|
private |
Definition at line 271 of file parachain_processor.hpp.
struct { ... } kagome::parachain::ParachainProcessorImpl::our_current_state_ |
|
private |
Definition at line 268 of file parachain_processor.hpp.
|
private |
Definition at line 270 of file parachain_processor.hpp.
|
private |
Definition at line 292 of file parachain_processor.hpp.
|
private |
Definition at line 288 of file parachain_processor.hpp.
|
private |
Definition at line 289 of file parachain_processor.hpp.