mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Strip out old XCMP primitives (#823)
* WIP * WIp * Mostly get tests to compile * Fix adder collator * Remove more stuff * Revert some changes to av store * Fix av store tests * Nitpicks * Restore some things * Small changes * Remvoe unused error variants
This commit is contained in:
@@ -28,8 +28,7 @@ use keystore::KeyStorePtr;
|
||||
use polkadot_primitives::{
|
||||
Hash, Block,
|
||||
parachain::{
|
||||
Id as ParaId, BlockData, CandidateReceipt, Message, AvailableMessages, ErasureChunk,
|
||||
ParachainHost,
|
||||
Id as ParaId, BlockData, CandidateReceipt, ErasureChunk, ParachainHost
|
||||
},
|
||||
};
|
||||
use sp_runtime::traits::{BlakeTwo256, Hash as HashT, HasherFor};
|
||||
@@ -126,10 +125,6 @@ pub struct Data {
|
||||
pub parachain_id: ParaId,
|
||||
/// Block data.
|
||||
pub block_data: BlockData,
|
||||
/// Outgoing message queues from execution of the block, if any.
|
||||
///
|
||||
/// The tuple pairs the message queue root and the queue data.
|
||||
pub outgoing_queues: Option<AvailableMessages>,
|
||||
}
|
||||
|
||||
/// Handle to the availability store.
|
||||
@@ -384,9 +379,4 @@ impl Store {
|
||||
{
|
||||
self.inner.block_data_by_candidate(relay_parent, candidate_hash)
|
||||
}
|
||||
|
||||
/// Query message queue data by message queue root hash.
|
||||
pub fn queue_by_root(&self, queue_root: &Hash) -> Option<Vec<Message>> {
|
||||
self.inner.queue_by_root(queue_root)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,7 @@ use codec::{Encode, Decode};
|
||||
use polkadot_erasure_coding::{self as erasure};
|
||||
use polkadot_primitives::{
|
||||
Hash,
|
||||
parachain::{
|
||||
BlockData, CandidateReceipt, Message, ErasureChunk
|
||||
},
|
||||
parachain::{BlockData, CandidateReceipt, ErasureChunk},
|
||||
};
|
||||
|
||||
use log::{trace, warn};
|
||||
@@ -130,18 +128,6 @@ impl Store {
|
||||
data.block_data.encode()
|
||||
);
|
||||
|
||||
if let Some(outgoing_queues) = data.outgoing_queues {
|
||||
// This is kept forever and not pruned.
|
||||
for (root, messages) in outgoing_queues.0 {
|
||||
tx.put_vec(
|
||||
columns::DATA,
|
||||
root.as_ref(),
|
||||
messages.encode(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
self.inner.write(tx)
|
||||
}
|
||||
|
||||
@@ -287,14 +273,13 @@ impl Store {
|
||||
columns::DATA,
|
||||
&block_data_key(&relay_parent, &receipt.block_data_hash)
|
||||
) {
|
||||
if let Ok((block_data, outgoing_queues)) = erasure::reconstruct(
|
||||
if let Ok(block_data) = erasure::reconstruct(
|
||||
n_validators as usize,
|
||||
v.iter().map(|chunk| (chunk.chunk.as_ref(), chunk.index as usize))) {
|
||||
self.make_available(Data {
|
||||
relay_parent: *relay_parent,
|
||||
parachain_id: receipt.parachain_index,
|
||||
block_data,
|
||||
outgoing_queues,
|
||||
})?;
|
||||
}
|
||||
}
|
||||
@@ -387,11 +372,6 @@ impl Store {
|
||||
})
|
||||
}
|
||||
|
||||
/// Query message queue data by message queue root hash.
|
||||
pub fn queue_by_root(&self, queue_root: &Hash) -> Option<Vec<Message>> {
|
||||
self.query_inner(columns::DATA, queue_root.as_ref())
|
||||
}
|
||||
|
||||
fn block_hash_to_candidate_hash(&self, block_hash: Hash) -> Option<Hash> {
|
||||
self.query_inner(columns::META, &block_to_candidate_key(&block_hash))
|
||||
}
|
||||
@@ -414,8 +394,8 @@ impl Store {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use polkadot_erasure_coding::{self as erasure};
|
||||
use polkadot_primitives::parachain::{Id as ParaId, AvailableMessages};
|
||||
use polkadot_erasure_coding as erasure;
|
||||
use polkadot_primitives::parachain::Id as ParaId;
|
||||
|
||||
#[test]
|
||||
fn finalization_removes_unneeded() {
|
||||
@@ -444,14 +424,12 @@ mod tests {
|
||||
relay_parent,
|
||||
parachain_id: para_id_1,
|
||||
block_data: block_data_1.clone(),
|
||||
outgoing_queues: None,
|
||||
}).unwrap();
|
||||
|
||||
store.make_available(Data {
|
||||
relay_parent,
|
||||
parachain_id: para_id_2,
|
||||
block_data: block_data_2.clone(),
|
||||
outgoing_queues: None,
|
||||
}).unwrap();
|
||||
|
||||
let candidate_1 = CandidateReceipt {
|
||||
@@ -460,7 +438,6 @@ mod tests {
|
||||
signature: Default::default(),
|
||||
head_data: Default::default(),
|
||||
parent_head: Default::default(),
|
||||
egress_queue_roots: Vec::new(),
|
||||
fees: 0,
|
||||
block_data_hash: block_data_1.hash(),
|
||||
upward_messages: Vec::new(),
|
||||
@@ -473,7 +450,6 @@ mod tests {
|
||||
signature: Default::default(),
|
||||
head_data: Default::default(),
|
||||
parent_head: Default::default(),
|
||||
egress_queue_roots: Vec::new(),
|
||||
fees: 0,
|
||||
block_data_hash: block_data_2.hash(),
|
||||
upward_messages: Vec::new(),
|
||||
@@ -516,34 +492,12 @@ mod tests {
|
||||
let para_id = 5.into();
|
||||
let block_data = BlockData(vec![1, 2, 3]);
|
||||
|
||||
let message_queue_root_1 = [0x42; 32].into();
|
||||
let message_queue_root_2 = [0x43; 32].into();
|
||||
|
||||
let message_a = Message(vec![1, 2, 3, 4]);
|
||||
let message_b = Message(vec![4, 5, 6, 7]);
|
||||
|
||||
let outgoing_queues = AvailableMessages(vec![
|
||||
(message_queue_root_1, vec![message_a.clone()]),
|
||||
(message_queue_root_2, vec![message_b.clone()]),
|
||||
]);
|
||||
|
||||
let store = Store::new_in_memory();
|
||||
store.make_available(Data {
|
||||
relay_parent,
|
||||
parachain_id: para_id,
|
||||
block_data: block_data.clone(),
|
||||
outgoing_queues: Some(outgoing_queues),
|
||||
block_data,
|
||||
}).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
store.queue_by_root(&message_queue_root_1),
|
||||
Some(vec![message_a]),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
store.queue_by_root(&message_queue_root_2),
|
||||
Some(vec![message_b]),
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -554,21 +508,10 @@ mod tests {
|
||||
let block_data_hash = block_data.hash();
|
||||
let n_validators = 5;
|
||||
|
||||
let message_queue_root_1 = [0x42; 32].into();
|
||||
let message_queue_root_2 = [0x43; 32].into();
|
||||
|
||||
let message_a = Message(vec![1, 2, 3, 4]);
|
||||
let message_b = Message(vec![5, 6, 7, 8]);
|
||||
|
||||
let outgoing_queues = Some(AvailableMessages(vec![
|
||||
(message_queue_root_1, vec![message_a.clone()]),
|
||||
(message_queue_root_2, vec![message_b.clone()]),
|
||||
]));
|
||||
|
||||
let erasure_chunks = erasure::obtain_chunks(
|
||||
n_validators,
|
||||
&block_data,
|
||||
outgoing_queues.as_ref()).unwrap();
|
||||
).unwrap();
|
||||
|
||||
let branches = erasure::branches(erasure_chunks.as_ref());
|
||||
|
||||
@@ -578,7 +521,6 @@ mod tests {
|
||||
signature: Default::default(),
|
||||
head_data: Default::default(),
|
||||
parent_head: Default::default(),
|
||||
egress_queue_roots: Vec::new(),
|
||||
fees: 0,
|
||||
block_data_hash: block_data.hash(),
|
||||
upward_messages: Vec::new(),
|
||||
|
||||
@@ -35,7 +35,7 @@ use consensus_common::{
|
||||
use polkadot_primitives::{Block, BlockId, Hash};
|
||||
use polkadot_primitives::parachain::{
|
||||
CandidateReceipt, ParachainHost, ValidatorId,
|
||||
ValidatorPair, AvailableMessages, BlockData, ErasureChunk,
|
||||
ValidatorPair, ErasureChunk, PoVBlock,
|
||||
};
|
||||
use futures::{prelude::*, future::select, channel::{mpsc, oneshot}, task::{Spawn, SpawnExt}};
|
||||
use keystore::KeyStorePtr;
|
||||
@@ -90,7 +90,7 @@ pub(crate) struct ParachainBlocks {
|
||||
/// The relay parent of the block these parachain blocks belong to.
|
||||
pub relay_parent: Hash,
|
||||
/// The blocks themselves.
|
||||
pub blocks: Vec<(CandidateReceipt, Option<(BlockData, AvailableMessages)>)>,
|
||||
pub blocks: Vec<(CandidateReceipt, Option<PoVBlock>)>,
|
||||
/// A sender to signal the result asynchronously.
|
||||
pub result: oneshot::Sender<Result<(), Error>>,
|
||||
}
|
||||
@@ -367,7 +367,7 @@ where
|
||||
runtime_handle: &Handle,
|
||||
sender: &mut mpsc::UnboundedSender<WorkerMsg>,
|
||||
relay_parent: Hash,
|
||||
blocks: Vec<(CandidateReceipt, Option<(BlockData, AvailableMessages)>)>,
|
||||
blocks: Vec<(CandidateReceipt, Option<PoVBlock>)>,
|
||||
) -> Result<(), Error> {
|
||||
let hashes: Vec<_> = blocks.iter().map(|(c, _)| c.hash()).collect();
|
||||
|
||||
@@ -375,7 +375,7 @@ where
|
||||
for (candidate, block) in blocks.into_iter() {
|
||||
let _ = self.availability_store.add_candidate(&candidate);
|
||||
|
||||
if let Some((_block, _msgs)) = block {
|
||||
if let Some(_block) = block {
|
||||
// Should we be breaking block into chunks here and gossiping it and so on?
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user