mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 23:21:06 +00:00
Track and accumulate ingress roots in runtime (#287)
* track unrouted ingress in runtime * test ingress routing * fix compilation * add space Co-Authored-By: Gavin Wood <github@gavwood.com>
This commit is contained in:
committed by
GitHub
parent
bc59254f41
commit
58ab4f6b9f
@@ -30,7 +30,7 @@ use futures::sync::oneshot;
|
||||
use polkadot_primitives::{Block, SessionKey, Hash, Header};
|
||||
use polkadot_primitives::parachain::{
|
||||
Id as ParaId, BlockData, CollatorId, CandidateReceipt, Collation, PoVBlock,
|
||||
ConsolidatedIngressRoots,
|
||||
StructuredUnroutedIngress,
|
||||
};
|
||||
use substrate_network::{PeerId, RequestId, Context};
|
||||
use substrate_network::{message, generic_message};
|
||||
@@ -83,7 +83,7 @@ struct PoVBlockRequest {
|
||||
candidate_hash: Hash,
|
||||
block_data_hash: Hash,
|
||||
sender: oneshot::Sender<PoVBlock>,
|
||||
canon_roots: ConsolidatedIngressRoots,
|
||||
canon_roots: StructuredUnroutedIngress,
|
||||
}
|
||||
|
||||
impl PoVBlockRequest {
|
||||
@@ -218,7 +218,7 @@ impl PolkadotProtocol {
|
||||
ctx: &mut Context<Block>,
|
||||
candidate: &CandidateReceipt,
|
||||
relay_parent: Hash,
|
||||
canon_roots: ConsolidatedIngressRoots,
|
||||
canon_roots: StructuredUnroutedIngress,
|
||||
) -> oneshot::Receiver<PoVBlock> {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
@@ -547,7 +547,7 @@ impl Specialization<Block> for PolkadotProtocol {
|
||||
validation_session_parent: Default::default(),
|
||||
candidate_hash: Default::default(),
|
||||
block_data_hash: Default::default(),
|
||||
canon_roots: ConsolidatedIngressRoots(Vec::new()),
|
||||
canon_roots: StructuredUnroutedIngress(Vec::new()),
|
||||
sender,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use polkadot_validation::GenericStatement;
|
||||
use polkadot_primitives::{Block, Hash, SessionKey};
|
||||
use polkadot_primitives::parachain::{
|
||||
CandidateReceipt, HeadData, PoVBlock, BlockData, CollatorId, ValidatorId,
|
||||
ConsolidatedIngressRoots,
|
||||
StructuredUnroutedIngress,
|
||||
};
|
||||
use substrate_primitives::crypto::UncheckedInto;
|
||||
use parity_codec::Encode;
|
||||
@@ -175,7 +175,7 @@ fn fetches_from_those_with_knowledge() {
|
||||
let knowledge = session.knowledge();
|
||||
|
||||
knowledge.lock().note_statement(a_key.clone(), &GenericStatement::Valid(candidate_hash));
|
||||
let canon_roots = ConsolidatedIngressRoots(Vec::new());
|
||||
let canon_roots = StructuredUnroutedIngress(Vec::new());
|
||||
let recv = protocol.fetch_pov_block(
|
||||
&mut TestContext::default(),
|
||||
&candidate_receipt,
|
||||
|
||||
@@ -29,7 +29,7 @@ use polkadot_validation::{SharedTable, MessagesFrom, Network};
|
||||
use polkadot_primitives::{SessionKey, Block, Hash, Header, BlockId};
|
||||
use polkadot_primitives::parachain::{
|
||||
Id as ParaId, Chain, DutyRoster, ParachainHost, OutgoingMessage,
|
||||
ValidatorId, ConsolidatedIngressRoots,
|
||||
ValidatorId, StructuredUnroutedIngress, BlockIngressRoots,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use substrate_client::error::Result as ClientResult;
|
||||
@@ -175,7 +175,7 @@ struct ApiData {
|
||||
validators: Vec<ValidatorId>,
|
||||
duties: Vec<Chain>,
|
||||
active_parachains: Vec<ParaId>,
|
||||
ingress: HashMap<ParaId, ConsolidatedIngressRoots>,
|
||||
ingress: HashMap<ParaId, StructuredUnroutedIngress>,
|
||||
}
|
||||
|
||||
#[derive(Default, Clone)]
|
||||
@@ -306,7 +306,7 @@ impl ParachainHost<Block> for RuntimeApi {
|
||||
_: ExecutionContext,
|
||||
id: Option<ParaId>,
|
||||
_: Vec<u8>,
|
||||
) -> ClientResult<NativeOrEncoded<Option<ConsolidatedIngressRoots>>> {
|
||||
) -> ClientResult<NativeOrEncoded<Option<StructuredUnroutedIngress>>> {
|
||||
let id = id.unwrap();
|
||||
Ok(NativeOrEncoded::Native(self.data.lock().ingress.get(&id).cloned()))
|
||||
}
|
||||
@@ -372,7 +372,7 @@ impl IngressBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
fn build(self) -> HashMap<ParaId, ConsolidatedIngressRoots> {
|
||||
fn build(self) -> HashMap<ParaId, BlockIngressRoots> {
|
||||
let mut map = HashMap::new();
|
||||
for ((source, target), messages) in self.egress {
|
||||
map.entry(target).or_insert_with(Vec::new)
|
||||
@@ -383,7 +383,7 @@ impl IngressBuilder {
|
||||
roots.sort_by_key(|&(para_id, _)| para_id);
|
||||
}
|
||||
|
||||
map.into_iter().map(|(k, v)| (k, ConsolidatedIngressRoots(v))).collect()
|
||||
map.into_iter().map(|(k, v)| (k, BlockIngressRoots(v))).collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user