ci: add quick-check with rustfmt (#615)

* ci: add quick-check with clippy and rustfmt

* chore: rustfmt round

* chore: set the same rustfmt config than substrate

* chore: fix formatting

* cI: remove clippy

* ci: switch to nightly for the checks

* ci: fix toolchains and naming

* ci: Limit the check to formatting

* chore: fix formatting

* Update .rustfmt.toml

* Update .rustfmt.toml

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Chevdor
2021-09-16 16:57:52 +02:00
committed by GitHub
parent e3eb3a0a12
commit 6b20f7a2c5
98 changed files with 1244 additions and 1872 deletions
+40
View File
@@ -0,0 +1,40 @@
name: Quick check Formatting
on:
push:
branches:
- "*"
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
jobs:
quick_check:
strategy:
matrix:
os: ["ubuntu-latest"]
runs-on: ${{ matrix.os }}
steps:
- name: Install Rust nightly toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: clippy, rustfmt
- name: Cache Dependencies & Build Outputs
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-${{ matrix.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/checkout@v2
- name: Cargo fmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
+23 -2
View File
@@ -1,2 +1,23 @@
hard_tabs=true # Basic
merge_imports=true hard_tabs = true
max_width = 100
use_small_heuristics = "Max"
# Imports
imports_granularity = "Crate"
reorder_imports = true
# Consistency
newline_style = "Unix"
# Misc
binop_separator = "Back"
chain_width = 80
match_arm_blocks = false
match_arm_leading_pipes = "Preserve"
match_block_trailing_comma = true
reorder_impl_items = false
spaces_around_ranges = false
trailing_comma = "Vertical"
trailing_semicolon = false
use_field_init_shorthand = true
+8 -13
View File
@@ -54,10 +54,8 @@ impl PurgeChainCmd {
relay_config: sc_service::Configuration, relay_config: sc_service::Configuration,
) -> sc_cli::Result<()> { ) -> sc_cli::Result<()> {
let databases = match (self.parachain, self.relaychain) { let databases = match (self.parachain, self.relaychain) {
(true, true) | (false, false) => vec![ (true, true) | (false, false) =>
("parachain", para_config.database), vec![("parachain", para_config.database), ("relaychain", relay_config.database)],
("relaychain", relay_config.database),
],
(true, false) => vec![("parachain", para_config.database)], (true, false) => vec![("parachain", para_config.database)],
(false, true) => vec![("relaychain", relay_config.database)], (false, true) => vec![("relaychain", relay_config.database)],
}; };
@@ -86,11 +84,11 @@ impl PurgeChainCmd {
let input = input.trim(); let input = input.trim();
match input.chars().nth(0) { match input.chars().nth(0) {
Some('y') | Some('Y') => {} Some('y') | Some('Y') => {},
_ => { _ => {
println!("Aborted"); println!("Aborted");
return Ok(()); return Ok(())
} },
} }
} }
@@ -98,10 +96,10 @@ impl PurgeChainCmd {
match fs::remove_dir_all(&db_path) { match fs::remove_dir_all(&db_path) {
Ok(_) => { Ok(_) => {
println!("{:?} removed.", &db_path); println!("{:?} removed.", &db_path);
} },
Err(ref err) if err.kind() == io::ErrorKind::NotFound => { Err(ref err) if err.kind() == io::ErrorKind::NotFound => {
eprintln!("{:?} did not exist.", &db_path); eprintln!("{:?} did not exist.", &db_path);
} },
Err(err) => return Err(err.into()), Err(err) => return Err(err.into()),
} }
} }
@@ -155,10 +153,7 @@ impl RunCmd {
new_base.validator = self.base.validator || self.collator; new_base.validator = self.base.validator || self.collator;
NormalizedRunCmd { NormalizedRunCmd { base: new_base, parachain_id: self.parachain_id }
base: new_base,
parachain_id: self.parachain_id,
}
} }
} }
+19 -41
View File
@@ -81,12 +81,7 @@ where
) -> Self { ) -> Self {
let wait_to_announce = Arc::new(Mutex::new(WaitToAnnounce::new(spawner, announce_block))); let wait_to_announce = Arc::new(Mutex::new(WaitToAnnounce::new(spawner, announce_block)));
Self { Self { block_status, wait_to_announce, runtime_api, parachain_consensus }
block_status,
wait_to_announce,
runtime_api,
parachain_consensus,
}
} }
/// Checks the status of the given block hash in the Parachain. /// Checks the status of the given block hash in the Parachain.
@@ -101,7 +96,7 @@ where
"Skipping candidate production, because block is still queued for import.", "Skipping candidate production, because block is still queued for import.",
); );
false false
} },
Ok(BlockStatus::InChainWithState) => true, Ok(BlockStatus::InChainWithState) => true,
Ok(BlockStatus::InChainPruned) => { Ok(BlockStatus::InChainPruned) => {
tracing::error!( tracing::error!(
@@ -110,7 +105,7 @@ where
hash, hash,
); );
false false
} },
Ok(BlockStatus::KnownBad) => { Ok(BlockStatus::KnownBad) => {
tracing::error!( tracing::error!(
target: LOG_TARGET, target: LOG_TARGET,
@@ -118,7 +113,7 @@ where
"Block is tagged as known bad and is included in the relay chain! Skipping candidate production!", "Block is tagged as known bad and is included in the relay chain! Skipping candidate production!",
); );
false false
} },
Ok(BlockStatus::Unknown) => { Ok(BlockStatus::Unknown) => {
if header.number().is_zero() { if header.number().is_zero() {
tracing::error!( tracing::error!(
@@ -134,7 +129,7 @@ where
); );
} }
false false
} },
Err(e) => { Err(e) => {
tracing::error!( tracing::error!(
target: LOG_TARGET, target: LOG_TARGET,
@@ -143,7 +138,7 @@ where
"Failed to get block status.", "Failed to get block status.",
); );
false false
} },
} }
} }
@@ -168,8 +163,8 @@ where
error = ?e, error = ?e,
"Failed to collect collation info.", "Failed to collect collation info.",
); );
return None; return None
} },
}; };
Some(Collation { Some(Collation {
@@ -202,13 +197,13 @@ where
error = ?e, error = ?e,
"Could not decode the head data." "Could not decode the head data."
); );
return None; return None
} },
}; };
let last_head_hash = last_head.hash(); let last_head_hash = last_head.hash();
if !self.check_block_status(last_head_hash, &last_head) { if !self.check_block_status(last_head_hash, &last_head) {
return None; return None
} }
tracing::info!( tracing::info!(
@@ -232,8 +227,8 @@ where
Ok(proof) => proof, Ok(proof) => proof,
Err(e) => { Err(e) => {
tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e); tracing::error!(target: "cumulus-collator", "Failed to compact proof: {:?}", e);
return None; return None
} },
}; };
// Create the parachain block data for the validators. // Create the parachain block data for the validators.
@@ -252,20 +247,11 @@ where
let (result_sender, signed_stmt_recv) = oneshot::channel(); let (result_sender, signed_stmt_recv) = oneshot::channel();
self.wait_to_announce self.wait_to_announce.lock().wait_to_announce(block_hash, signed_stmt_recv);
.lock()
.wait_to_announce(block_hash, signed_stmt_recv);
tracing::info!( tracing::info!(target: LOG_TARGET, ?block_hash, "Produced proof-of-validity candidate.",);
target: LOG_TARGET,
?block_hash,
"Produced proof-of-validity candidate.",
);
Some(CollationResult { Some(CollationResult { collation, result_sender: Some(result_sender) })
collation,
result_sender: Some(result_sender),
})
} }
} }
@@ -322,10 +308,7 @@ pub async fn start_collator<Block, RA, BS, Spawner>(
}; };
overseer_handle overseer_handle
.send_msg( .send_msg(CollationGenerationMessage::Initialize(config), "StartCollator")
CollationGenerationMessage::Initialize(config),
"StartCollator",
)
.await; .await;
overseer_handle overseer_handle
@@ -384,10 +367,7 @@ mod tests {
.await .await
.expect("Imports the block"); .expect("Imports the block");
Some(ParachainCandidate { Some(ParachainCandidate { block, proof: proof.expect("Proof is returned") })
block,
proof: proof.expect("Proof is returned"),
})
} }
} }
@@ -424,9 +404,7 @@ mod tests {
spawner, spawner,
para_id, para_id,
key: CollatorPair::generate().0, key: CollatorPair::generate().0,
parachain_consensus: Box::new(DummyParachainConsensus { parachain_consensus: Box::new(DummyParachainConsensus { client: client.clone() }),
client: client.clone(),
}),
}); });
block_on(collator_start); block_on(collator_start);
+3 -7
View File
@@ -215,9 +215,8 @@ where
relay_parent: PHash, relay_parent: PHash,
validation_data: &PersistedValidationData, validation_data: &PersistedValidationData,
) -> Option<ParachainCandidate<B>> { ) -> Option<ParachainCandidate<B>> {
let (inherent_data, inherent_data_providers) = self let (inherent_data, inherent_data_providers) =
.inherent_data(parent.hash(), validation_data, relay_parent) self.inherent_data(parent.hash(), validation_data, relay_parent).await?;
.await?;
let info = SlotInfo::new( let info = SlotInfo::new(
inherent_data_providers.slot(), inherent_data_providers.slot(),
@@ -234,10 +233,7 @@ where
let res = self.aura_worker.lock().await.on_slot(info).await?; let res = self.aura_worker.lock().await.on_slot(info).await?;
Some(ParachainCandidate { Some(ParachainCandidate { block: res.block, proof: res.storage_proof })
block: res.block,
proof: res.storage_proof,
})
} }
} }
+1 -3
View File
@@ -65,9 +65,7 @@ impl<B: BlockT> ParachainConsensus<B> for Box<dyn ParachainConsensus<B> + Send +
relay_parent: PHash, relay_parent: PHash,
validation_data: &PersistedValidationData, validation_data: &PersistedValidationData,
) -> Option<ParachainCandidate<B>> { ) -> Option<ParachainCandidate<B>> {
(*self) (*self).produce_candidate(parent, relay_parent, validation_data).await
.produce_candidate(parent, relay_parent, validation_data)
.await
} }
} }
@@ -75,7 +75,7 @@ where
h h
} else { } else {
tracing::debug!(target: "cumulus-consensus", "Stopping following finalized head."); tracing::debug!(target: "cumulus-consensus", "Stopping following finalized head.");
return; return
}; };
let header = match Block::Header::decode(&mut &finalized_head[..]) { let header = match Block::Header::decode(&mut &finalized_head[..]) {
@@ -86,8 +86,8 @@ where
error = ?err, error = ?err,
"Could not decode parachain header while following finalized heads.", "Could not decode parachain header while following finalized heads.",
); );
continue; continue
} },
}; };
let hash = header.hash(); let hash = header.hash();
@@ -140,12 +140,8 @@ pub async fn run_parachain_consensus<P, R, Block, B>(
R: RelaychainClient, R: RelaychainClient,
B: Backend<Block>, B: Backend<Block>,
{ {
let follow_new_best = follow_new_best( let follow_new_best =
para_id, follow_new_best(para_id, parachain.clone(), relay_chain.clone(), announce_block);
parachain.clone(),
relay_chain.clone(),
announce_block,
);
let follow_finalized_head = follow_finalized_head(para_id, parachain, relay_chain); let follow_finalized_head = follow_finalized_head(para_id, parachain, relay_chain);
select! { select! {
_ = follow_new_best.fuse() => {}, _ = follow_new_best.fuse() => {},
@@ -242,12 +238,12 @@ async fn handle_new_block_imported<Block, P>(
}; };
let unset_hash = if notification.header.number() < unset_best_header.number() { let unset_hash = if notification.header.number() < unset_best_header.number() {
return; return
} else if notification.header.number() == unset_best_header.number() { } else if notification.header.number() == unset_best_header.number() {
let unset_hash = unset_best_header.hash(); let unset_hash = unset_best_header.hash();
if unset_hash != notification.hash { if unset_hash != notification.hash {
return; return
} else { } else {
unset_hash unset_hash
} }
@@ -263,7 +259,7 @@ async fn handle_new_block_imported<Block, P>(
.expect("We checked above that the value is set; qed"); .expect("We checked above that the value is set; qed");
import_block_as_new_best(unset_hash, unset_best_header, parachain).await; import_block_as_new_best(unset_hash, unset_best_header, parachain).await;
} },
state => tracing::debug!( state => tracing::debug!(
target: "cumulus-consensus", target: "cumulus-consensus",
?unset_best_header, ?unset_best_header,
@@ -292,8 +288,8 @@ async fn handle_new_best_parachain_head<Block, P>(
error = ?err, error = ?err,
"Could not decode Parachain header while following best heads.", "Could not decode Parachain header while following best heads.",
); );
return; return
} },
}; };
let hash = parachain_head.hash(); let hash = parachain_head.hash();
@@ -311,14 +307,14 @@ async fn handle_new_best_parachain_head<Block, P>(
unset_best_header.take(); unset_best_header.take();
import_block_as_new_best(hash, parachain_head, parachain).await; import_block_as_new_best(hash, parachain_head, parachain).await;
} },
Ok(BlockStatus::InChainPruned) => { Ok(BlockStatus::InChainPruned) => {
tracing::error!( tracing::error!(
target: "cumulus-collator", target: "cumulus-collator",
block_hash = ?hash, block_hash = ?hash,
"Trying to set pruned block as new best!", "Trying to set pruned block as new best!",
); );
} },
Ok(BlockStatus::Unknown) => { Ok(BlockStatus::Unknown) => {
*unset_best_header = Some(parachain_head); *unset_best_header = Some(parachain_head);
@@ -327,7 +323,7 @@ async fn handle_new_best_parachain_head<Block, P>(
block_hash = ?hash, block_hash = ?hash,
"Parachain block not yet imported, waiting for import to enact as best block.", "Parachain block not yet imported, waiting for import to enact as best block.",
); );
} },
Err(e) => { Err(e) => {
tracing::error!( tracing::error!(
target: "cumulus-collator", target: "cumulus-collator",
@@ -335,8 +331,8 @@ async fn handle_new_best_parachain_head<Block, P>(
error = ?e, error = ?e,
"Failed to get block status of block.", "Failed to get block status of block.",
); );
} },
_ => {} _ => {},
} }
} }
} }
@@ -356,7 +352,7 @@ where
"Skipping importing block as new best block, because there already exists a \ "Skipping importing block as new best block, because there already exists a \
best block with an higher number", best block with an higher number",
); );
return; return
} }
// Make it the new best block // Make it the new best block
@@ -364,10 +360,7 @@ where
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true)); block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(true));
block_import_params.import_existing = true; block_import_params.import_existing = true;
if let Err(err) = (&*parachain) if let Err(err) = (&*parachain).import_block(block_import_params, Default::default()).await {
.import_block(block_import_params, Default::default())
.await
{
tracing::warn!( tracing::warn!(
target: "cumulus-consensus", target: "cumulus-consensus",
block_hash = ?hash, block_hash = ?hash,
@@ -392,10 +385,7 @@ where
self.import_notification_stream() self.import_notification_stream()
.filter_map(move |n| { .filter_map(move |n| {
future::ready(if n.is_new_best { future::ready(if n.is_new_best {
relay_chain relay_chain.parachain_head_at(&BlockId::hash(n.hash), para_id).ok().flatten()
.parachain_head_at(&BlockId::hash(n.hash), para_id)
.ok()
.flatten()
} else { } else {
None None
}) })
@@ -409,10 +399,7 @@ where
self.finality_notification_stream() self.finality_notification_stream()
.filter_map(move |n| { .filter_map(move |n| {
future::ready( future::ready(
relay_chain relay_chain.parachain_head_at(&BlockId::hash(n.hash), para_id).ok().flatten(),
.parachain_head_at(&BlockId::hash(n.hash), para_id)
.ok()
.flatten(),
) )
}) })
.boxed() .boxed()
+18 -60
View File
@@ -62,9 +62,7 @@ struct Relaychain {
impl Relaychain { impl Relaychain {
fn new() -> Self { fn new() -> Self {
Self { Self { inner: Arc::new(Mutex::new(RelaychainInner::new())) }
inner: Arc::new(Mutex::new(RelaychainInner::new())),
}
} }
} }
@@ -125,24 +123,17 @@ fn follow_new_best_works() {
let block = build_and_import_block(client.clone(), false); let block = build_and_import_block(client.clone(), false);
let relay_chain = Relaychain::new(); let relay_chain = Relaychain::new();
let new_best_heads_sender = relay_chain let new_best_heads_sender = relay_chain.inner.lock().unwrap().new_best_heads_sender.clone();
.inner
.lock()
.unwrap()
.new_best_heads_sender
.clone();
let consensus = let consensus =
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {})); run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}));
let work = async move { let work = async move {
new_best_heads_sender new_best_heads_sender.unbounded_send(block.header().clone()).unwrap();
.unbounded_send(block.header().clone())
.unwrap();
loop { loop {
Delay::new(Duration::from_millis(100)).await; Delay::new(Duration::from_millis(100)).await;
if block.hash() == client.usage_info().chain.best_hash { if block.hash() == client.usage_info().chain.best_hash {
break; break
} }
} }
}; };
@@ -166,24 +157,17 @@ fn follow_finalized_works() {
let block = build_and_import_block(client.clone(), false); let block = build_and_import_block(client.clone(), false);
let relay_chain = Relaychain::new(); let relay_chain = Relaychain::new();
let finalized_sender = relay_chain let finalized_sender = relay_chain.inner.lock().unwrap().finalized_heads_sender.clone();
.inner
.lock()
.unwrap()
.finalized_heads_sender
.clone();
let consensus = let consensus =
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {})); run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}));
let work = async move { let work = async move {
finalized_sender finalized_sender.unbounded_send(block.header().clone()).unwrap();
.unbounded_send(block.header().clone())
.unwrap();
loop { loop {
Delay::new(Duration::from_millis(100)).await; Delay::new(Duration::from_millis(100)).await;
if block.hash() == client.usage_info().chain.finalized_hash { if block.hash() == client.usage_info().chain.finalized_hash {
break; break
} }
} }
}; };
@@ -214,32 +198,23 @@ fn follow_finalized_does_not_stop_on_unknown_block() {
}; };
let relay_chain = Relaychain::new(); let relay_chain = Relaychain::new();
let finalized_sender = relay_chain let finalized_sender = relay_chain.inner.lock().unwrap().finalized_heads_sender.clone();
.inner
.lock()
.unwrap()
.finalized_heads_sender
.clone();
let consensus = let consensus =
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {})); run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}));
let work = async move { let work = async move {
for _ in 0..3usize { for _ in 0..3usize {
finalized_sender finalized_sender.unbounded_send(unknown_block.header().clone()).unwrap();
.unbounded_send(unknown_block.header().clone())
.unwrap();
Delay::new(Duration::from_millis(100)).await; Delay::new(Duration::from_millis(100)).await;
} }
finalized_sender finalized_sender.unbounded_send(block.header().clone()).unwrap();
.unbounded_send(block.header().clone())
.unwrap();
loop { loop {
Delay::new(Duration::from_millis(100)).await; Delay::new(Duration::from_millis(100)).await;
if block.hash() == client.usage_info().chain.finalized_hash { if block.hash() == client.usage_info().chain.finalized_hash {
break; break
} }
} }
}; };
@@ -273,32 +248,23 @@ fn follow_new_best_sets_best_after_it_is_imported() {
}; };
let relay_chain = Relaychain::new(); let relay_chain = Relaychain::new();
let new_best_heads_sender = relay_chain let new_best_heads_sender = relay_chain.inner.lock().unwrap().new_best_heads_sender.clone();
.inner
.lock()
.unwrap()
.new_best_heads_sender
.clone();
let consensus = let consensus =
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {})); run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}));
let work = async move { let work = async move {
new_best_heads_sender new_best_heads_sender.unbounded_send(block.header().clone()).unwrap();
.unbounded_send(block.header().clone())
.unwrap();
loop { loop {
Delay::new(Duration::from_millis(100)).await; Delay::new(Duration::from_millis(100)).await;
if block.hash() == client.usage_info().chain.best_hash { if block.hash() == client.usage_info().chain.best_hash {
break; break
} }
} }
// Announce the unknown block // Announce the unknown block
new_best_heads_sender new_best_heads_sender.unbounded_send(unknown_block.header().clone()).unwrap();
.unbounded_send(unknown_block.header().clone())
.unwrap();
// Do some iterations. As this is a local task executor, only one task can run at a time. // Do some iterations. As this is a local task executor, only one task can run at a time.
// Meaning that it should already have processed the unknown block. // Meaning that it should already have processed the unknown block.
@@ -313,15 +279,12 @@ fn follow_new_best_sets_best_after_it_is_imported() {
block_import_params.body = Some(body); block_import_params.body = Some(body);
// Now import the unkown block to make it "known" // Now import the unkown block to make it "known"
client client.import_block(block_import_params, Default::default()).await.unwrap();
.import_block(block_import_params, Default::default())
.await
.unwrap();
loop { loop {
Delay::new(Duration::from_millis(100)).await; Delay::new(Duration::from_millis(100)).await;
if unknown_block.hash() == client.usage_info().chain.best_hash { if unknown_block.hash() == client.usage_info().chain.best_hash {
break; break
} }
} }
}; };
@@ -362,12 +325,7 @@ fn do_not_set_best_block_to_older_block() {
assert_eq!(NUM_BLOCKS as u32, client.usage_info().chain.best_number); assert_eq!(NUM_BLOCKS as u32, client.usage_info().chain.best_number);
let relay_chain = Relaychain::new(); let relay_chain = Relaychain::new();
let new_best_heads_sender = relay_chain let new_best_heads_sender = relay_chain.inner.lock().unwrap().new_best_heads_sender.clone();
.inner
.lock()
.unwrap()
.new_best_heads_sender
.clone();
let consensus = let consensus =
run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {})); run_parachain_consensus(100.into(), client.clone(), relay_chain, Arc::new(|_, _| {}));
@@ -40,11 +40,7 @@ pub struct Verifier<Client, Block, CIDP> {
impl<Client, Block, CIDP> Verifier<Client, Block, CIDP> { impl<Client, Block, CIDP> Verifier<Client, Block, CIDP> {
/// Create a new instance. /// Create a new instance.
pub fn new(client: Arc<Client>, create_inherent_data_providers: CIDP) -> Self { pub fn new(client: Arc<Client>, create_inherent_data_providers: CIDP) -> Self {
Self { Self { client, create_inherent_data_providers, _marker: PhantomData }
client,
create_inherent_data_providers,
_marker: PhantomData,
}
} }
} }
@@ -59,13 +55,7 @@ where
async fn verify( async fn verify(
&mut self, &mut self,
mut block_params: BlockImportParams<Block, ()>, mut block_params: BlockImportParams<Block, ()>,
) -> Result< ) -> Result<(BlockImportParams<Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
(
BlockImportParams<Block, ()>,
Option<Vec<(CacheKeyId, Vec<u8>)>>,
),
String,
> {
if let Some(inner_body) = block_params.body.take() { if let Some(inner_body) = block_params.body.take() {
let inherent_data_providers = self let inherent_data_providers = self
.create_inherent_data_providers .create_inherent_data_providers
@@ -73,9 +63,8 @@ where
.await .await
.map_err(|e| e.to_string())?; .map_err(|e| e.to_string())?;
let inherent_data = inherent_data_providers let inherent_data =
.create_inherent_data() inherent_data_providers.create_inherent_data().map_err(|e| format!("{:?}", e))?;
.map_err(|e| format!("{:?}", e))?;
let block = Block::new(block_params.header.clone(), inner_body); let block = Block::new(block_params.header.clone(), inner_body);
@@ -130,9 +119,7 @@ where
Ok(BasicQueue::new( Ok(BasicQueue::new(
verifier, verifier,
Box::new(cumulus_client_consensus_common::ParachainBlockImport::new( Box::new(cumulus_client_consensus_common::ParachainBlockImport::new(block_import)),
block_import,
)),
None, None,
spawner, spawner,
registry, registry,
@@ -180,15 +180,10 @@ where
) )
.ok()?; .ok()?;
let inherent_data = self let inherent_data =
.inherent_data(parent.hash(), &validation_data, relay_parent) self.inherent_data(parent.hash(), &validation_data, relay_parent).await?;
.await?;
let Proposal { let Proposal { block, storage_changes, proof } = proposer
block,
storage_changes,
proof,
} = proposer
.propose( .propose(
inherent_data, inherent_data,
Default::default(), Default::default(),
@@ -226,7 +221,7 @@ where
"Error importing build block.", "Error importing build block.",
); );
return None; return None
} }
Some(ParachainCandidate { block, proof }) Some(ParachainCandidate { block, proof })
+37 -66
View File
@@ -33,13 +33,13 @@ use sp_runtime::{
traits::{Block as BlockT, HashFor, Header as HeaderT}, traits::{Block as BlockT, HashFor, Header as HeaderT},
}; };
use polkadot_node_primitives::{SignedFullStatement, Statement, CollationSecondedSignal}; use polkadot_client::ClientHandle;
use polkadot_node_primitives::{CollationSecondedSignal, SignedFullStatement, Statement};
use polkadot_parachain::primitives::HeadData; use polkadot_parachain::primitives::HeadData;
use polkadot_primitives::v1::{ use polkadot_primitives::v1::{
Block as PBlock, Hash as PHash, CandidateReceipt, CompactStatement, Id as ParaId, Block as PBlock, CandidateReceipt, CompactStatement, Hash as PHash, Id as ParaId,
OccupiedCoreAssumption, ParachainHost, UncheckedSigned, SigningContext, OccupiedCoreAssumption, ParachainHost, SigningContext, UncheckedSigned,
}; };
use polkadot_client::ClientHandle;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use futures::{ use futures::{
@@ -85,14 +85,13 @@ impl BlockAnnounceData {
/// ///
/// This will not check the signature, for this you should use [`BlockAnnounceData::check_signature`]. /// This will not check the signature, for this you should use [`BlockAnnounceData::check_signature`].
fn validate(&self, encoded_header: Vec<u8>) -> Result<(), Validation> { fn validate(&self, encoded_header: Vec<u8>) -> Result<(), Validation> {
let candidate_hash = if let CompactStatement::Seconded(h) = self.statement.unchecked_payload() { let candidate_hash = if let CompactStatement::Seconded(h) =
self.statement.unchecked_payload()
{
h h
} else { } else {
tracing::debug!( tracing::debug!(target: LOG_TARGET, "`CompactStatement` isn't the candidate variant!",);
target: LOG_TARGET, return Err(Validation::Failure { disconnect: true })
"`CompactStatement` isn't the candidate variant!",
);
return Err(Validation::Failure { disconnect: true });
}; };
if *candidate_hash != self.receipt.hash() { if *candidate_hash != self.receipt.hash() {
@@ -100,7 +99,7 @@ impl BlockAnnounceData {
target: LOG_TARGET, target: LOG_TARGET,
"Receipt candidate hash doesn't match candidate hash in statement", "Receipt candidate hash doesn't match candidate hash in statement",
); );
return Err(Validation::Failure { disconnect: true }); return Err(Validation::Failure { disconnect: true })
} }
if HeadData(encoded_header).hash() != self.receipt.descriptor.para_head { if HeadData(encoded_header).hash() != self.receipt.descriptor.para_head {
@@ -108,7 +107,7 @@ impl BlockAnnounceData {
target: LOG_TARGET, target: LOG_TARGET,
"Receipt para head hash doesn't match the hash of the header in the block announcement", "Receipt para head hash doesn't match the hash of the header in the block announcement",
); );
return Err(Validation::Failure { disconnect: true }); return Err(Validation::Failure { disconnect: true })
} }
Ok(()) Ok(())
@@ -131,22 +130,16 @@ impl BlockAnnounceData {
let runtime_api_block_id = BlockId::Hash(self.receipt.descriptor.relay_parent); let runtime_api_block_id = BlockId::Hash(self.receipt.descriptor.relay_parent);
let session_index = match runtime_api.session_index_for_child(&runtime_api_block_id) { let session_index = match runtime_api.session_index_for_child(&runtime_api_block_id) {
Ok(r) => r, Ok(r) => r,
Err(e) => { Err(e) => return Err(BlockAnnounceError(format!("{:?}", e))),
return Err(BlockAnnounceError(format!("{:?}", e)));
}
}; };
let signing_context = SigningContext { let signing_context =
parent_hash: self.receipt.descriptor.relay_parent, SigningContext { parent_hash: self.receipt.descriptor.relay_parent, session_index };
session_index,
};
// Check that the signer is a legit validator. // Check that the signer is a legit validator.
let authorities = match runtime_api.validators(&runtime_api_block_id) { let authorities = match runtime_api.validators(&runtime_api_block_id) {
Ok(r) => r, Ok(r) => r,
Err(e) => { Err(e) => return Err(BlockAnnounceError(format!("{:?}", e))),
return Err(BlockAnnounceError(format!("{:?}", e)));
}
}; };
let signer = match authorities.get(validator_index.0 as usize) { let signer = match authorities.get(validator_index.0 as usize) {
Some(r) => r, Some(r) => r,
@@ -156,22 +149,18 @@ impl BlockAnnounceData {
"Block announcement justification signer is a validator index out of bound", "Block announcement justification signer is a validator index out of bound",
); );
return Ok(Validation::Failure { disconnect: true }); return Ok(Validation::Failure { disconnect: true })
} },
}; };
// Check statement is correctly signed. // Check statement is correctly signed.
if self if self.statement.try_into_checked(&signing_context, &signer).is_err() {
.statement
.try_into_checked(&signing_context, &signer)
.is_err()
{
tracing::debug!( tracing::debug!(
target: LOG_TARGET, target: LOG_TARGET,
"Block announcement justification signature is invalid.", "Block announcement justification signature is invalid.",
); );
return Ok(Validation::Failure { disconnect: true }); return Ok(Validation::Failure { disconnect: true })
} }
Ok(Validation::Success { is_new_best: true }) Ok(Validation::Success { is_new_best: true })
@@ -185,13 +174,10 @@ impl TryFrom<&'_ SignedFullStatement> for BlockAnnounceData {
let receipt = if let Statement::Seconded(receipt) = stmt.payload() { let receipt = if let Statement::Seconded(receipt) = stmt.payload() {
receipt.to_plain() receipt.to_plain()
} else { } else {
return Err(()); return Err(())
}; };
Ok(BlockAnnounceData { Ok(BlockAnnounceData { receipt, statement: stmt.convert_payload().into() })
receipt,
statement: stmt.convert_payload().into(),
})
} }
} }
@@ -273,16 +259,13 @@ where
.persisted_validation_data(block_id, para_id, OccupiedCoreAssumption::TimedOut) .persisted_validation_data(block_id, para_id, OccupiedCoreAssumption::TimedOut)
.map_err(|e| Box::new(BlockAnnounceError(format!("{:?}", e))) as Box<_>)? .map_err(|e| Box::new(BlockAnnounceError(format!("{:?}", e))) as Box<_>)?
.ok_or_else(|| { .ok_or_else(|| {
Box::new(BlockAnnounceError( Box::new(BlockAnnounceError("Could not find parachain head in relay chain".into()))
"Could not find parachain head in relay chain".into(), as Box<_>
)) as Box<_>
})?; })?;
let para_head = let para_head =
Block::Header::decode(&mut &validation_data.parent_head.0[..]).map_err(|e| { Block::Header::decode(&mut &validation_data.parent_head.0[..]).map_err(|e| {
Box::new(BlockAnnounceError(format!( Box::new(BlockAnnounceError(format!("Failed to decode parachain head: {:?}", e)))
"Failed to decode parachain head: {:?}", as Box<_>
e
))) as Box<_>
})?; })?;
Ok(para_head) Ok(para_head)
@@ -320,21 +303,15 @@ where
let best_head = let best_head =
Self::included_block(&*relay_chain_client, &runtime_api_block_id, para_id)?; Self::included_block(&*relay_chain_client, &runtime_api_block_id, para_id)?;
let known_best_number = best_head.number(); let known_best_number = best_head.number();
let backed_block = || let backed_block =
Self::backed_block_hash(&*relay_chain_client, &runtime_api_block_id, para_id); || Self::backed_block_hash(&*relay_chain_client, &runtime_api_block_id, para_id);
if best_head == header { if best_head == header {
tracing::debug!( tracing::debug!(target: LOG_TARGET, "Announced block matches best block.",);
target: LOG_TARGET,
"Announced block matches best block.",
);
Ok(Validation::Success { is_new_best: true }) Ok(Validation::Success { is_new_best: true })
} else if Some(HeadData(header.encode()).hash()) == backed_block()? { } else if Some(HeadData(header.encode()).hash()) == backed_block()? {
tracing::debug!( tracing::debug!(target: LOG_TARGET, "Announced block matches latest backed block.",);
target: LOG_TARGET,
"Announced block matches latest backed block.",
);
Ok(Validation::Success { is_new_best: true }) Ok(Validation::Success { is_new_best: true })
} else if block_number >= known_best_number { } else if block_number >= known_best_number {
@@ -367,23 +344,20 @@ where
mut data: &[u8], mut data: &[u8],
) -> Pin<Box<dyn Future<Output = Result<Validation, BoxedError>> + Send>> { ) -> Pin<Box<dyn Future<Output = Result<Validation, BoxedError>> + Send>> {
if self.relay_chain_sync_oracle.is_major_syncing() { if self.relay_chain_sync_oracle.is_major_syncing() {
return ready(Ok(Validation::Success { is_new_best: false })).boxed(); return ready(Ok(Validation::Success { is_new_best: false })).boxed()
} }
if data.is_empty() { if data.is_empty() {
return self return self.handle_empty_block_announce_data(header.clone()).boxed()
.handle_empty_block_announce_data(header.clone())
.boxed();
} }
let block_announce_data = match BlockAnnounceData::decode(&mut data) { let block_announce_data = match BlockAnnounceData::decode(&mut data) {
Ok(r) => r, Ok(r) => r,
Err(_) => { Err(_) =>
return ready(Err(Box::new(BlockAnnounceError( return ready(Err(Box::new(BlockAnnounceError(
"Can not decode the `BlockAnnounceData`".into(), "Can not decode the `BlockAnnounceData`".into(),
)) as Box<_>)) )) as Box<_>))
.boxed() .boxed(),
}
}; };
let relay_chain_client = self.relay_chain_client.clone(); let relay_chain_client = self.relay_chain_client.clone();
@@ -392,7 +366,7 @@ where
async move { async move {
if let Err(e) = block_announce_data.validate(header_encoded) { if let Err(e) = block_announce_data.validate(header_encoded) {
return Ok(e); return Ok(e)
} }
let relay_parent = block_announce_data.receipt.descriptor.relay_parent; let relay_parent = block_announce_data.receipt.descriptor.relay_parent;
@@ -519,10 +493,7 @@ impl<Block: BlockT> WaitToAnnounce<Block> {
spawner: Arc<dyn SpawnNamed + Send + Sync>, spawner: Arc<dyn SpawnNamed + Send + Sync>,
announce_block: Arc<dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync>, announce_block: Arc<dyn Fn(Block::Hash, Option<Vec<u8>>) + Send + Sync>,
) -> WaitToAnnounce<Block> { ) -> WaitToAnnounce<Block> {
WaitToAnnounce { WaitToAnnounce { spawner, announce_block }
spawner,
announce_block,
}
} }
/// Wait for a candidate message for the block, then announce the block. The candidate /// Wait for a candidate message for the block, then announce the block. The candidate
@@ -567,8 +538,8 @@ async fn wait_to_announce<Block: BlockT>(
block = ?block_hash, block = ?block_hash,
"Wait to announce stopped, because sender was dropped.", "Wait to announce stopped, because sender was dropped.",
); );
return; return
} },
}; };
if let Ok(data) = BlockAnnounceData::try_from(&statement) { if let Ok(data) = BlockAnnounceData::try_from(&statement) {
+23 -68
View File
@@ -15,15 +15,16 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. // along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
use super::*; use super::*;
use cumulus_test_service::runtime::{Block, Header, Hash}; use cumulus_test_service::runtime::{Block, Hash, Header};
use futures::{executor::block_on, poll, task::Poll}; use futures::{executor::block_on, poll, task::Poll};
use parking_lot::Mutex;
use polkadot_node_primitives::{SignedFullStatement, Statement}; use polkadot_node_primitives::{SignedFullStatement, Statement};
use polkadot_primitives::v1::{ use polkadot_primitives::v1::{
Block as PBlock, BlockNumber, CandidateCommitments, CandidateDescriptor, CandidateEvent, Block as PBlock, BlockNumber, CandidateCommitments, CandidateDescriptor, CandidateEvent,
CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash as PHash, HeadData, Id as ParaId, CommittedCandidateReceipt, CoreState, GroupRotationInfo, Hash as PHash, HeadData, Id as ParaId,
InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, ParachainHost, InboundDownwardMessage, InboundHrmpMessage, OccupiedCoreAssumption, ParachainHost,
PersistedValidationData, SessionIndex, SessionInfo, SigningContext, ValidationCode, ValidationCodeHash, PersistedValidationData, SessionIndex, SessionInfo, SigningContext, ValidationCode,
ValidatorId, ValidatorIndex, ValidationCodeHash, ValidatorId, ValidatorIndex,
}; };
use polkadot_test_client::{ use polkadot_test_client::{
Client as PClient, ClientBlockImportExt, DefaultTestClientBuilderExt, FullBackend as PBackend, Client as PClient, ClientBlockImportExt, DefaultTestClientBuilderExt, FullBackend as PBackend,
@@ -37,7 +38,6 @@ use sp_keyring::Sr25519Keyring;
use sp_keystore::{testing::KeyStore, SyncCryptoStore, SyncCryptoStorePtr}; use sp_keystore::{testing::KeyStore, SyncCryptoStore, SyncCryptoStorePtr};
use sp_runtime::RuntimeAppPublic; use sp_runtime::RuntimeAppPublic;
use std::collections::BTreeMap; use std::collections::BTreeMap;
use parking_lot::Mutex;
fn check_error(error: crate::BoxedError, check_error: impl Fn(&BlockAnnounceError) -> bool) { fn check_error(error: crate::BoxedError, check_error: impl Fn(&BlockAnnounceError) -> bool) {
let error = *error let error = *error
@@ -61,10 +61,8 @@ impl SyncOracle for DummyCollatorNetwork {
} }
} }
fn make_validator_and_api() -> ( fn make_validator_and_api(
BlockAnnounceValidator<Block, TestApi, PBackend, PClient>, ) -> (BlockAnnounceValidator<Block, TestApi, PBackend, PClient>, Arc<TestApi>) {
Arc<TestApi>,
) {
let api = Arc::new(TestApi::new()); let api = Arc::new(TestApi::new());
( (
@@ -94,12 +92,7 @@ async fn make_gossip_message_and_header_using_genesis(
api: Arc<TestApi>, api: Arc<TestApi>,
validator_index: u32, validator_index: u32,
) -> (SignedFullStatement, Header) { ) -> (SignedFullStatement, Header) {
let relay_parent = api let relay_parent = api.relay_client.hash(0).ok().flatten().expect("Genesis hash exists");
.relay_client
.hash(0)
.ok()
.flatten()
.expect("Genesis hash exists");
make_gossip_message_and_header(api, relay_parent, validator_index).await make_gossip_message_and_header(api, relay_parent, validator_index).await
} }
@@ -116,14 +109,9 @@ async fn make_gossip_message_and_header(
Some(&Sr25519Keyring::Alice.to_seed()), Some(&Sr25519Keyring::Alice.to_seed()),
) )
.unwrap(); .unwrap();
let session_index = api let session_index =
.runtime_api() api.runtime_api().session_index_for_child(&BlockId::Hash(relay_parent)).unwrap();
.session_index_for_child(&BlockId::Hash(relay_parent)) let signing_context = SigningContext { parent_hash: relay_parent, session_index };
.unwrap();
let signing_context = SigningContext {
parent_hash: relay_parent,
session_index,
};
let header = default_header(); let header = default_header();
let candidate_receipt = CommittedCandidateReceipt { let candidate_receipt = CommittedCandidateReceipt {
@@ -156,10 +144,7 @@ async fn make_gossip_message_and_header(
#[test] #[test]
fn valid_if_no_data_and_less_than_best_known_number() { fn valid_if_no_data_and_less_than_best_known_number() {
let mut validator = make_validator_and_api().0; let mut validator = make_validator_and_api().0;
let header = Header { let header = Header { number: 0, ..default_header() };
number: 0,
..default_header()
};
let res = block_on(validator.validate(&header, &[])); let res = block_on(validator.validate(&header, &[]));
assert_eq!( assert_eq!(
@@ -172,11 +157,7 @@ fn valid_if_no_data_and_less_than_best_known_number() {
#[test] #[test]
fn invalid_if_no_data_exceeds_best_known_number() { fn invalid_if_no_data_exceeds_best_known_number() {
let mut validator = make_validator_and_api().0; let mut validator = make_validator_and_api().0;
let header = Header { let header = Header { number: 1, state_root: Hash::random(), ..default_header() };
number: 1,
state_root: Hash::random(),
..default_header()
};
let res = block_on(validator.validate(&header, &[])); let res = block_on(validator.validate(&header, &[]));
assert_eq!( assert_eq!(
@@ -219,9 +200,7 @@ fn check_signer_is_legit_validator() {
let (mut validator, api) = make_validator_and_api(); let (mut validator, api) = make_validator_and_api();
let (signed_statement, header) = block_on(make_gossip_message_and_header_using_genesis(api, 1)); let (signed_statement, header) = block_on(make_gossip_message_and_header_using_genesis(api, 1));
let data = BlockAnnounceData::try_from(&signed_statement) let data = BlockAnnounceData::try_from(&signed_statement).unwrap().encode();
.unwrap()
.encode();
let res = block_on(validator.validate(&header, &data)); let res = block_on(validator.validate(&header, &data));
assert_eq!(Validation::Failure { disconnect: true }, res.unwrap()); assert_eq!(Validation::Failure { disconnect: true }, res.unwrap());
@@ -233,9 +212,7 @@ fn check_statement_is_correctly_signed() {
let (signed_statement, header) = block_on(make_gossip_message_and_header_using_genesis(api, 0)); let (signed_statement, header) = block_on(make_gossip_message_and_header_using_genesis(api, 0));
let mut data = BlockAnnounceData::try_from(&signed_statement) let mut data = BlockAnnounceData::try_from(&signed_statement).unwrap().encode();
.unwrap()
.encode();
// The signature comes at the end of the type, so change a bit to make the signature invalid. // The signature comes at the end of the type, so change a bit to make the signature invalid.
let last = data.len() - 1; let last = data.len() - 1;
@@ -258,14 +235,9 @@ fn check_statement_seconded() {
Some(&Sr25519Keyring::Alice.to_seed()), Some(&Sr25519Keyring::Alice.to_seed()),
) )
.unwrap(); .unwrap();
let session_index = api let session_index =
.runtime_api() api.runtime_api().session_index_for_child(&BlockId::Hash(relay_parent)).unwrap();
.session_index_for_child(&BlockId::Hash(relay_parent)) let signing_context = SigningContext { parent_hash: relay_parent, session_index };
.unwrap();
let signing_context = SigningContext {
parent_hash: relay_parent,
session_index,
};
let statement = Statement::Valid(Default::default()); let statement = Statement::Valid(Default::default());
@@ -296,9 +268,7 @@ fn check_header_match_candidate_receipt_header() {
let (signed_statement, mut header) = let (signed_statement, mut header) =
block_on(make_gossip_message_and_header_using_genesis(api, 0)); block_on(make_gossip_message_and_header_using_genesis(api, 0));
let data = BlockAnnounceData::try_from(&signed_statement) let data = BlockAnnounceData::try_from(&signed_statement).unwrap().encode();
.unwrap()
.encode();
header.number = 300; header.number = 300;
let res = block_on(validator.validate(&header, &data)); let res = block_on(validator.validate(&header, &data));
@@ -315,17 +285,11 @@ fn relay_parent_not_imported_when_block_announce_is_processed() {
let (mut validator, api) = make_validator_and_api(); let (mut validator, api) = make_validator_and_api();
let mut client = api.relay_client.clone(); let mut client = api.relay_client.clone();
let block = client let block = client.init_polkadot_block_builder().build().expect("Build new block").block;
.init_polkadot_block_builder()
.build()
.expect("Build new block")
.block;
let (signed_statement, header) = make_gossip_message_and_header(api, block.hash(), 0).await; let (signed_statement, header) = make_gossip_message_and_header(api, block.hash(), 0).await;
let data = BlockAnnounceData::try_from(&signed_statement) let data = BlockAnnounceData::try_from(&signed_statement).unwrap().encode();
.unwrap()
.encode();
let mut validation = validator.validate(&header, &data); let mut validation = validator.validate(&header, &data);
@@ -333,10 +297,7 @@ fn relay_parent_not_imported_when_block_announce_is_processed() {
// that the future is still pending. // that the future is still pending.
assert!(poll!(&mut validation).is_pending()); assert!(poll!(&mut validation).is_pending());
client client.import(BlockOrigin::Own, block).await.expect("Imports the block");
.import(BlockOrigin::Own, block)
.await
.expect("Imports the block");
assert!(matches!( assert!(matches!(
poll!(validation), poll!(validation),
@@ -357,10 +318,7 @@ fn block_announced_without_statement_and_block_only_backed() {
let validation = validator.validate(&header, &[]); let validation = validator.validate(&header, &[]);
assert!(matches!( assert!(matches!(validation.await, Ok(Validation::Success { is_new_best: true })));
validation.await,
Ok(Validation::Success { is_new_best: true })
));
}); });
} }
@@ -401,10 +359,7 @@ impl ProvideRuntimeApi<PBlock> for TestApi {
type Api = RuntimeApi; type Api = RuntimeApi;
fn runtime_api<'a>(&'a self) -> ApiRef<'a, Self::Api> { fn runtime_api<'a>(&'a self) -> ApiRef<'a, Self::Api> {
RuntimeApi { RuntimeApi { data: self.data.clone() }.into()
data: self.data.clone(),
}
.into()
} }
} }
@@ -31,10 +31,7 @@ const TIMEOUT_IN_SECONDS: u64 = 6;
/// Custom error type used by [`WaitOnRelayChainBlock`]. /// Custom error type used by [`WaitOnRelayChainBlock`].
#[derive(Debug, derive_more::Display)] #[derive(Debug, derive_more::Display)]
pub enum Error { pub enum Error {
#[display( #[display(fmt = "Timeout while waiting for relay-chain block `{}` to be imported.", _0)]
fmt = "Timeout while waiting for relay-chain block `{}` to be imported.",
_0
)]
Timeout(PHash), Timeout(PHash),
#[display( #[display(
fmt = "Import listener closed while waiting for relay-chain block `{}` to be imported.", fmt = "Import listener closed while waiting for relay-chain block `{}` to be imported.",
@@ -73,20 +70,14 @@ pub struct WaitOnRelayChainBlock<B, BCE> {
impl<B, BCE> Clone for WaitOnRelayChainBlock<B, BCE> { impl<B, BCE> Clone for WaitOnRelayChainBlock<B, BCE> {
fn clone(&self) -> Self { fn clone(&self) -> Self {
Self { Self { backend: self.backend.clone(), block_chain_events: self.block_chain_events.clone() }
backend: self.backend.clone(),
block_chain_events: self.block_chain_events.clone(),
}
} }
} }
impl<B, BCE> WaitOnRelayChainBlock<B, BCE> { impl<B, BCE> WaitOnRelayChainBlock<B, BCE> {
/// Creates a new instance of `Self`. /// Creates a new instance of `Self`.
pub fn new(backend: Arc<B>, block_chain_events: Arc<BCE>) -> Self { pub fn new(backend: Arc<B>, block_chain_events: Arc<BCE>) -> Self {
Self { Self { backend, block_chain_events }
backend,
block_chain_events,
}
} }
} }
@@ -103,11 +94,9 @@ where
) -> impl Future<Output = Result<(), Error>> { ) -> impl Future<Output = Result<(), Error>> {
let _lock = self.backend.get_import_lock().read(); let _lock = self.backend.get_import_lock().read();
match self.backend.blockchain().status(BlockId::Hash(hash)) { match self.backend.blockchain().status(BlockId::Hash(hash)) {
Ok(BlockStatus::InChain) => { Ok(BlockStatus::InChain) => return ready(Ok(())).boxed(),
return ready(Ok(())).boxed();
}
Err(err) => return ready(Err(Error::BlockchainError(hash, err))).boxed(), Err(err) => return ready(Err(Error::BlockchainError(hash, err))).boxed(),
_ => {} _ => {},
} }
let mut listener = self.block_chain_events.import_notification_stream(); let mut listener = self.block_chain_events.import_notification_stream();
@@ -171,10 +160,7 @@ mod tests {
block_on(async move { block_on(async move {
// Should be ready on the first poll // Should be ready on the first poll
assert!(matches!( assert!(matches!(poll!(wait.wait_on_relay_chain_block(hash)), Poll::Ready(Ok(()))));
poll!(wait.wait_on_relay_chain_block(hash)),
Poll::Ready(Ok(()))
));
}); });
} }
@@ -191,10 +177,7 @@ mod tests {
assert!(poll!(&mut future).is_pending()); assert!(poll!(&mut future).is_pending());
// Import the block that should fire the notification // Import the block that should fire the notification
client client.import(BlockOrigin::Own, block).await.expect("Imports the block");
.import(BlockOrigin::Own, block)
.await
.expect("Imports the block");
// Now it should have received the notification and report that the block was imported // Now it should have received the notification and report that the block was imported
assert!(matches!(poll!(future), Poll::Ready(Ok(())))); assert!(matches!(poll!(future), Poll::Ready(Ok(()))));
@@ -208,10 +191,7 @@ mod tests {
let wait = WaitOnRelayChainBlock::new(backend, client.clone()); let wait = WaitOnRelayChainBlock::new(backend, client.clone());
assert!(matches!( assert!(matches!(block_on(wait.wait_on_relay_chain_block(hash)), Err(Error::Timeout(_))));
block_on(wait.wait_on_relay_chain_block(hash)),
Err(Error::Timeout(_))
));
} }
#[test] #[test]
@@ -227,9 +207,7 @@ mod tests {
); );
let mut block_builder = client.init_polkadot_block_builder(); let mut block_builder = client.init_polkadot_block_builder();
// Push an extrinsic to get a different block hash. // Push an extrinsic to get a different block hash.
block_builder block_builder.push_polkadot_extrinsic(ext).expect("Push extrinsic");
.push_polkadot_extrinsic(ext)
.expect("Push extrinsic");
let block2 = block_builder.build().expect("Build second block").block; let block2 = block_builder.build().expect("Build second block").block;
let hash2 = block2.hash(); let hash2 = block2.hash();
@@ -243,20 +221,14 @@ mod tests {
assert!(poll!(&mut future2).is_pending()); assert!(poll!(&mut future2).is_pending());
// Import the block that should fire the notification // Import the block that should fire the notification
client client.import(BlockOrigin::Own, block2).await.expect("Imports the second block");
.import(BlockOrigin::Own, block2)
.await
.expect("Imports the second block");
// The import notification of the second block should not make this one finish // The import notification of the second block should not make this one finish
assert!(poll!(&mut future).is_pending()); assert!(poll!(&mut future).is_pending());
// Now it should have received the notification and report that the block was imported // Now it should have received the notification and report that the block was imported
assert!(matches!(poll!(future2), Poll::Ready(Ok(())))); assert!(matches!(poll!(future2), Poll::Ready(Ok(()))));
client client.import(BlockOrigin::Own, block).await.expect("Imports the first block");
.import(BlockOrigin::Own, block)
.await
.expect("Imports the first block");
// Now it should be ready // Now it should be ready
assert!(matches!(poll!(future), Poll::Ready(Ok(())))); assert!(matches!(poll!(future), Poll::Ready(Ok(()))));
@@ -39,11 +39,7 @@ pub(crate) struct ActiveCandidateRecovery<Block: BlockT> {
impl<Block: BlockT> ActiveCandidateRecovery<Block> { impl<Block: BlockT> ActiveCandidateRecovery<Block> {
pub fn new(overseer_handle: OverseerHandle) -> Self { pub fn new(overseer_handle: OverseerHandle) -> Self {
Self { Self { recoveries: Default::default(), candidates: Default::default(), overseer_handle }
recoveries: Default::default(),
candidates: Default::default(),
overseer_handle,
}
} }
/// Recover the given `pending_candidate`. /// Recover the given `pending_candidate`.
@@ -80,14 +76,14 @@ impl<Block: BlockT> ActiveCandidateRecovery<Block> {
"Availability recovery failed", "Availability recovery failed",
); );
(block_hash, None) (block_hash, None)
} },
Err(_) => { Err(_) => {
tracing::debug!( tracing::debug!(
target: crate::LOG_TARGET, target: crate::LOG_TARGET,
"Availability recovery oneshot channel closed", "Availability recovery oneshot channel closed",
); );
(block_hash, None) (block_hash, None)
} },
} }
} }
.boxed(), .boxed(),
@@ -106,7 +102,7 @@ impl<Block: BlockT> ActiveCandidateRecovery<Block> {
loop { loop {
if let Some(res) = self.recoveries.next().await { if let Some(res) = self.recoveries.next().await {
self.candidates.remove(&res.0); self.candidates.remove(&res.0);
return res; return res
} else { } else {
futures::pending!() futures::pending!()
} }
+39 -45
View File
@@ -149,12 +149,12 @@ where
error = ?e, error = ?e,
"Failed to decode parachain header from pending candidate", "Failed to decode parachain header from pending candidate",
); );
return; return
} },
}; };
if *header.number() <= self.parachain_client.usage_info().chain.finalized_number { if *header.number() <= self.parachain_client.usage_info().chain.finalized_number {
return; return
} }
let hash = header.hash(); let hash = header.hash();
@@ -169,8 +169,8 @@ where
block_hash = ?hash, block_hash = ?hash,
"Failed to get block status", "Failed to get block status",
); );
return; return
} },
} }
if self if self
@@ -185,7 +185,7 @@ where
) )
.is_some() .is_some()
{ {
return; return
} }
// Wait some random time, with the maximum being the slot duration of the relay chain // Wait some random time, with the maximum being the slot duration of the relay chain
@@ -207,8 +207,7 @@ where
/// Handle a finalized block with the given `block_number`. /// Handle a finalized block with the given `block_number`.
fn handle_block_finalized(&mut self, block_number: NumberFor<Block>) { fn handle_block_finalized(&mut self, block_number: NumberFor<Block>) {
self.pending_candidates self.pending_candidates.retain(|_, pc| pc.block_number > block_number);
.retain(|_, pc| pc.block_number > block_number);
} }
/// Recover the candidate for the given `block_hash`. /// Recover the candidate for the given `block_hash`.
@@ -245,8 +244,8 @@ where
Some(data) => data, Some(data) => data,
None => { None => {
self.clear_waiting_for_parent(block_hash); self.clear_waiting_for_parent(block_hash);
return; return
} },
}; };
let raw_block_data = match sp_maybe_compressed_blob::decompress( let raw_block_data = match sp_maybe_compressed_blob::decompress(
@@ -259,8 +258,8 @@ where
self.clear_waiting_for_parent(block_hash); self.clear_waiting_for_parent(block_hash);
return; return
} },
}; };
let block_data = match ParachainBlockData::<Block>::decode(&mut &raw_block_data[..]) { let block_data = match ParachainBlockData::<Block>::decode(&mut &raw_block_data[..]) {
@@ -274,8 +273,8 @@ where
self.clear_waiting_for_parent(block_hash); self.clear_waiting_for_parent(block_hash);
return; return
} },
}; };
let block = block_data.into_block(); let block = block_data.into_block();
@@ -292,11 +291,8 @@ where
"Parent is still being recovered, waiting.", "Parent is still being recovered, waiting.",
); );
self.waiting_for_parent self.waiting_for_parent.entry(parent).or_default().push(block);
.entry(parent) return
.or_default()
.push(block);
return;
} else { } else {
tracing::debug!( tracing::debug!(
target: "cumulus-consensus", target: "cumulus-consensus",
@@ -307,9 +303,9 @@ where
self.clear_waiting_for_parent(block_hash); self.clear_waiting_for_parent(block_hash);
return; return
} }
} },
Err(error) => { Err(error) => {
tracing::debug!( tracing::debug!(
target: "cumulus-consensus", target: "cumulus-consensus",
@@ -320,8 +316,8 @@ where
self.clear_waiting_for_parent(block_hash); self.clear_waiting_for_parent(block_hash);
return; return
} },
// Any other status is fine to "ignore/accept" // Any other status is fine to "ignore/accept"
_ => (), _ => (),
} }
@@ -431,27 +427,25 @@ where
RC: ProvideRuntimeApi<PBlock> + BlockchainEvents<PBlock>, RC: ProvideRuntimeApi<PBlock> + BlockchainEvents<PBlock>,
RC::Api: ParachainHost<PBlock>, RC::Api: ParachainHost<PBlock>,
{ {
relay_chain_client relay_chain_client.import_notification_stream().filter_map(move |n| {
.import_notification_stream() let runtime_api = relay_chain_client.runtime_api();
.filter_map(move |n| { let res = runtime_api
let runtime_api = relay_chain_client.runtime_api(); .candidate_pending_availability(&BlockId::hash(n.hash), para_id)
let res = runtime_api .and_then(|pa| {
.candidate_pending_availability(&BlockId::hash(n.hash), para_id) runtime_api
.and_then(|pa| { .session_index_for_child(&BlockId::hash(n.hash))
runtime_api .map(|v| pa.map(|pa| (pa, v)))
.session_index_for_child(&BlockId::hash(n.hash)) })
.map(|v| pa.map(|pa| (pa, v))) .map_err(|e| {
}) tracing::error!(
.map_err(|e| { target: LOG_TARGET,
tracing::error!( error = ?e,
target: LOG_TARGET, "Failed fetch pending candidates.",
error = ?e, )
"Failed fetch pending candidates.", })
) .ok()
}) .flatten();
.ok()
.flatten();
async move { res } async move { res }
}) })
} }
+15 -26
View File
@@ -118,19 +118,17 @@ where
_phantom: PhantomData, _phantom: PhantomData,
}); });
relay_chain_full_node relay_chain_full_node.client.execute_with(StartPoVRecovery {
.client para_id,
.execute_with(StartPoVRecovery { client: client.clone(),
para_id, import_queue,
client: client.clone(), task_manager,
import_queue, overseer_handle: relay_chain_full_node
task_manager, .overseer_handle
overseer_handle: relay_chain_full_node .clone()
.overseer_handle .ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?,
.clone() _phantom: PhantomData,
.ok_or_else(|| "Polkadot full node did not provide an `OverseerHandle`!")?, })?;
_phantom: PhantomData,
})?;
cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams { cumulus_client_collator::start_collator(cumulus_client_collator::StartCollatorParams {
runtime_api: client.clone(), runtime_api: client.clone(),
@@ -239,9 +237,7 @@ where
self.announce_block, self.announce_block,
); );
self.task_manager self.task_manager.spawn_essential_handle().spawn("cumulus-consensus", consensus);
.spawn_essential_handle()
.spawn("cumulus-consensus", consensus);
} }
} }
@@ -311,9 +307,7 @@ pub fn build_polkadot_full_node(
) -> Result<RFullNode<PClient>, polkadot_service::Error> { ) -> Result<RFullNode<PClient>, polkadot_service::Error> {
let is_light = matches!(config.role, Role::Light); let is_light = matches!(config.role, Role::Light);
if is_light { if is_light {
Err(polkadot_service::Error::Sub( Err(polkadot_service::Error::Sub("Light client not supported.".into()))
"Light client not supported.".into(),
))
} else { } else {
let collator_key = CollatorPair::generate().0; let collator_key = CollatorPair::generate().0;
@@ -327,10 +321,7 @@ pub fn build_polkadot_full_node(
polkadot_service::RealOverseerGen, polkadot_service::RealOverseerGen,
)?; )?;
Ok(RFullNode { Ok(RFullNode { relay_chain_full_node, collator_key })
relay_chain_full_node,
collator_key,
})
} }
} }
@@ -359,9 +350,7 @@ impl<Block: BlockT> ImportQueue<Block> for SharedImportQueue<Block> {
number: NumberFor<Block>, number: NumberFor<Block>,
justifications: Justifications, justifications: Justifications,
) { ) {
self.0 self.0.lock().import_justifications(who, hash, number, justifications)
.lock()
.import_justifications(who, hash, number, justifications)
} }
fn poll_actions(&mut self, cx: &mut std::task::Context, link: &mut dyn Link<Block>) { fn poll_actions(&mut self, cx: &mut std::task::Context, link: &mut dyn Link<Block>) {
+4 -8
View File
@@ -131,18 +131,14 @@ where
(Some(s), false) => { (Some(s), false) => {
seal = Some(s); seal = Some(s);
false false
} },
} }
}); });
let seal = seal.expect("Could not find an AuRa seal digest!"); let seal = seal.expect("Could not find an AuRa seal digest!");
let author = Aura::<T>::find_author( let author = Aura::<T>::find_author(
header header.digest().logs().iter().filter_map(|d| d.as_pre_runtime()),
.digest()
.logs()
.iter()
.filter_map(|d| d.as_pre_runtime()),
) )
.expect("Could not find AuRa author index!"); .expect("Could not find AuRa author index!");
@@ -150,9 +146,9 @@ where
if !authorities if !authorities
.get(author as usize) .get(author as usize)
.unwrap_or_else(|| .unwrap_or_else(|| {
panic!("Invalid AuRa author index {} for authorities: {:?}", author, authorities) panic!("Invalid AuRa author index {} for authorities: {:?}", author, authorities)
) })
.verify(&pre_hash, &seal) .verify(&pre_hash, &seal)
{ {
panic!("Invalid AuRa seal"); panic!("Invalid AuRa seal");
@@ -19,15 +19,15 @@ use super::*;
#[allow(unused)] #[allow(unused)]
use crate::Pallet as CollatorSelection; use crate::Pallet as CollatorSelection;
use sp_std::prelude::*; use frame_benchmarking::{account, benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller, account};
use frame_system::{RawOrigin, EventRecord};
use frame_support::{ use frame_support::{
assert_ok, assert_ok,
traits::{Currency, Get, EnsureOrigin}, traits::{Currency, EnsureOrigin, Get},
}; };
use frame_system::{EventRecord, RawOrigin};
use pallet_authorship::EventHandler; use pallet_authorship::EventHandler;
use pallet_session::SessionManager; use pallet_session::SessionManager;
use sp_std::prelude::*;
pub type BalanceOf<T> = pub type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance; <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
@@ -38,7 +38,7 @@ const SEED: u32 = 0;
macro_rules! whitelist { macro_rules! whitelist {
($acc:ident) => { ($acc:ident) => {
frame_benchmarking::benchmarking::add_to_whitelist( frame_benchmarking::benchmarking::add_to_whitelist(
frame_system::Account::<T>::hashed_key_for(&$acc).into() frame_system::Account::<T>::hashed_key_for(&$acc).into(),
); );
}; };
} }
+82 -60
View File
@@ -74,29 +74,27 @@ pub mod weights;
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
pub use crate::weights::WeightInfo;
use core::ops::Div;
use frame_support::{ use frame_support::{
dispatch::DispatchResultWithPostInfo, dispatch::DispatchResultWithPostInfo,
pallet_prelude::*,
inherent::Vec, inherent::Vec,
traits::{ pallet_prelude::*,
Currency, ReservableCurrency, EnsureOrigin, ExistenceRequirement::KeepAlive, ValidatorRegistration
},
PalletId,
};
use frame_system::pallet_prelude::*;
use frame_system::Config as SystemConfig;
use frame_support::{
sp_runtime::{ sp_runtime::{
traits::{AccountIdConversion, CheckedSub, Saturating, Zero},
RuntimeDebug, RuntimeDebug,
traits::{AccountIdConversion, CheckedSub, Zero, Saturating}, },
traits::{
Currency, EnsureOrigin, ExistenceRequirement::KeepAlive, ReservableCurrency,
ValidatorRegistration,
}, },
weights::DispatchClass, weights::DispatchClass,
PalletId,
}; };
use sp_runtime::traits::Convert; use frame_system::{pallet_prelude::*, Config as SystemConfig};
use core::ops::Div;
use pallet_session::SessionManager; use pallet_session::SessionManager;
use sp_runtime::traits::Convert;
use sp_staking::SessionIndex; use sp_staking::SessionIndex;
pub use crate::weights::WeightInfo;
type BalanceOf<T> = type BalanceOf<T> =
<<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance; <<T as Config>::Currency as Currency<<T as SystemConfig>::AccountId>>::Balance;
@@ -136,7 +134,6 @@ pub mod pallet {
/// This does not take into account the invulnerables. /// This does not take into account the invulnerables.
type MinCandidates: Get<u32>; type MinCandidates: Get<u32>;
/// Maximum number of invulnerables. /// Maximum number of invulnerables.
/// ///
/// Used only for benchmarking. /// Used only for benchmarking.
@@ -156,7 +153,6 @@ pub mod pallet {
/// Validate a user is registered /// Validate a user is registered
type ValidatorRegistration: ValidatorRegistration<Self::ValidatorId>; type ValidatorRegistration: ValidatorRegistration<Self::ValidatorId>;
/// The weight information of this pallet. /// The weight information of this pallet.
type WeightInfo: WeightInfo; type WeightInfo: WeightInfo;
} }
@@ -182,16 +178,14 @@ pub mod pallet {
/// The (community, limited) collation candidates. /// The (community, limited) collation candidates.
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn candidates)] #[pallet::getter(fn candidates)]
pub type Candidates<T: Config> = StorageValue< pub type Candidates<T: Config> =
_, StorageValue<_, Vec<CandidateInfo<T::AccountId, BalanceOf<T>>>, ValueQuery>;
Vec<CandidateInfo<T::AccountId, BalanceOf<T>>>,
ValueQuery,
>;
/// Last block authored by collator. /// Last block authored by collator.
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn last_authored_block)] #[pallet::getter(fn last_authored_block)]
pub type LastAuthoredBlock<T: Config> = StorageMap<_, Twox64Concat, T::AccountId, T::BlockNumber, ValueQuery>; pub type LastAuthoredBlock<T: Config> =
StorageMap<_, Twox64Concat, T::AccountId, T::BlockNumber, ValueQuery>;
/// Desired number of candidates. /// Desired number of candidates.
/// ///
@@ -205,7 +199,6 @@ pub mod pallet {
#[pallet::getter(fn candidacy_bond)] #[pallet::getter(fn candidacy_bond)]
pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>; pub type CandidacyBond<T> = StorageValue<_, BalanceOf<T>, ValueQuery>;
#[pallet::genesis_config] #[pallet::genesis_config]
pub struct GenesisConfig<T: Config> { pub struct GenesisConfig<T: Config> {
pub invulnerables: Vec<T::AccountId>, pub invulnerables: Vec<T::AccountId>,
@@ -227,9 +220,12 @@ pub mod pallet {
#[pallet::genesis_build] #[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> { impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
fn build(&self) { fn build(&self) {
let duplicate_invulnerables =
let duplicate_invulnerables = self.invulnerables.iter().collect::<std::collections::BTreeSet<_>>(); self.invulnerables.iter().collect::<std::collections::BTreeSet<_>>();
assert!(duplicate_invulnerables.len() == self.invulnerables.len(), "duplicate invulnerables in genesis."); assert!(
duplicate_invulnerables.len() == self.invulnerables.len(),
"duplicate invulnerables in genesis."
);
assert!( assert!(
T::MaxInvulnerables::get() >= (self.invulnerables.len() as u32), T::MaxInvulnerables::get() >= (self.invulnerables.len() as u32),
@@ -276,7 +272,7 @@ pub mod pallet {
/// Account has no associated validator ID /// Account has no associated validator ID
NoAssociatedValidatorId, NoAssociatedValidatorId,
/// Validator ID is not yet registered /// Validator ID is not yet registered
ValidatorNotRegistered ValidatorNotRegistered,
} }
#[pallet::hooks] #[pallet::hooks]
@@ -302,13 +298,14 @@ pub mod pallet {
} }
#[pallet::weight(T::WeightInfo::set_desired_candidates())] #[pallet::weight(T::WeightInfo::set_desired_candidates())]
pub fn set_desired_candidates(origin: OriginFor<T>, max: u32) -> DispatchResultWithPostInfo { pub fn set_desired_candidates(
origin: OriginFor<T>,
max: u32,
) -> DispatchResultWithPostInfo {
T::UpdateOrigin::ensure_origin(origin)?; T::UpdateOrigin::ensure_origin(origin)?;
// we trust origin calls, this is just a for more accurate benchmarking // we trust origin calls, this is just a for more accurate benchmarking
if max > T::MaxCandidates::get() { if max > T::MaxCandidates::get() {
log::warn!( log::warn!("max > T::MaxCandidates; you might need to run benchmarks again");
"max > T::MaxCandidates; you might need to run benchmarks again"
);
} }
<DesiredCandidates<T>>::put(&max); <DesiredCandidates<T>>::put(&max);
Self::deposit_event(Event::NewDesiredCandidates(max)); Self::deposit_event(Event::NewDesiredCandidates(max));
@@ -316,7 +313,10 @@ pub mod pallet {
} }
#[pallet::weight(T::WeightInfo::set_candidacy_bond())] #[pallet::weight(T::WeightInfo::set_candidacy_bond())]
pub fn set_candidacy_bond(origin: OriginFor<T>, bond: BalanceOf<T>) -> DispatchResultWithPostInfo { pub fn set_candidacy_bond(
origin: OriginFor<T>,
bond: BalanceOf<T>,
) -> DispatchResultWithPostInfo {
T::UpdateOrigin::ensure_origin(origin)?; T::UpdateOrigin::ensure_origin(origin)?;
<CandidacyBond<T>>::put(&bond); <CandidacyBond<T>>::put(&bond);
Self::deposit_event(Event::NewCandidacyBond(bond)); Self::deposit_event(Event::NewCandidacyBond(bond));
@@ -332,8 +332,12 @@ pub mod pallet {
ensure!((length as u32) < Self::desired_candidates(), Error::<T>::TooManyCandidates); ensure!((length as u32) < Self::desired_candidates(), Error::<T>::TooManyCandidates);
ensure!(!Self::invulnerables().contains(&who), Error::<T>::AlreadyInvulnerable); ensure!(!Self::invulnerables().contains(&who), Error::<T>::AlreadyInvulnerable);
let validator_key = T::ValidatorIdOf::convert(who.clone()).ok_or(Error::<T>::NoAssociatedValidatorId)?; let validator_key = T::ValidatorIdOf::convert(who.clone())
ensure!(T::ValidatorRegistration::is_registered(&validator_key), Error::<T>::ValidatorNotRegistered); .ok_or(Error::<T>::NoAssociatedValidatorId)?;
ensure!(
T::ValidatorRegistration::is_registered(&validator_key),
Error::<T>::ValidatorNotRegistered
);
let deposit = Self::candidacy_bond(); let deposit = Self::candidacy_bond();
// First authored block is current block plus kick threshold to handle session delay // First authored block is current block plus kick threshold to handle session delay
@@ -346,7 +350,10 @@ pub mod pallet {
} else { } else {
T::Currency::reserve(&who, deposit)?; T::Currency::reserve(&who, deposit)?;
candidates.push(incoming); candidates.push(incoming);
<LastAuthoredBlock<T>>::insert(who.clone(), frame_system::Pallet::<T>::block_number() + T::KickThreshold::get()); <LastAuthoredBlock<T>>::insert(
who.clone(),
frame_system::Pallet::<T>::block_number() + T::KickThreshold::get(),
);
Ok(candidates.len()) Ok(candidates.len())
} }
})?; })?;
@@ -358,7 +365,10 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))] #[pallet::weight(T::WeightInfo::leave_intent(T::MaxCandidates::get()))]
pub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo { pub fn leave_intent(origin: OriginFor<T>) -> DispatchResultWithPostInfo {
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
ensure!(Self::candidates().len() as u32 > T::MinCandidates::get(), Error::<T>::TooFewCandidates); ensure!(
Self::candidates().len() as u32 > T::MinCandidates::get(),
Error::<T>::TooFewCandidates
);
let current_count = Self::try_remove_candidate(&who)?; let current_count = Self::try_remove_candidate(&who)?;
Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into()) Ok(Some(T::WeightInfo::leave_intent(current_count as u32)).into())
@@ -372,13 +382,17 @@ pub mod pallet {
} }
/// Removes a candidate if they exist and sends them back their deposit /// Removes a candidate if they exist and sends them back their deposit
fn try_remove_candidate(who: &T::AccountId) -> Result<usize, DispatchError> { fn try_remove_candidate(who: &T::AccountId) -> Result<usize, DispatchError> {
let current_count = <Candidates<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> { let current_count =
let index = candidates.iter().position(|candidate| candidate.who == *who).ok_or(Error::<T>::NotCandidate)?; <Candidates<T>>::try_mutate(|candidates| -> Result<usize, DispatchError> {
T::Currency::unreserve(&who, candidates[index].deposit); let index = candidates
candidates.remove(index); .iter()
<LastAuthoredBlock<T>>::remove(who.clone()); .position(|candidate| candidate.who == *who)
Ok(candidates.len()) .ok_or(Error::<T>::NotCandidate)?;
})?; T::Currency::unreserve(&who, candidates[index].deposit);
candidates.remove(index);
<LastAuthoredBlock<T>>::remove(who.clone());
Ok(candidates.len())
})?;
Self::deposit_event(Event::CandidateRemoved(who.clone())); Self::deposit_event(Event::CandidateRemoved(who.clone()));
Ok(current_count) Ok(current_count)
} }
@@ -388,29 +402,34 @@ pub mod pallet {
/// This is done on the fly, as frequent as we are told to do so, as the session manager. /// This is done on the fly, as frequent as we are told to do so, as the session manager.
pub fn assemble_collators(candidates: Vec<T::AccountId>) -> Vec<T::AccountId> { pub fn assemble_collators(candidates: Vec<T::AccountId>) -> Vec<T::AccountId> {
let mut collators = Self::invulnerables(); let mut collators = Self::invulnerables();
collators.extend( collators.extend(candidates.into_iter().collect::<Vec<_>>());
candidates.into_iter().collect::<Vec<_>>(),
);
collators collators
} }
/// Kicks out and candidates that did not produce a block in the kick threshold. /// Kicks out and candidates that did not produce a block in the kick threshold.
pub fn kick_stale_candidates(candidates: Vec<CandidateInfo<T::AccountId, BalanceOf<T>>>) -> Vec<T::AccountId> { pub fn kick_stale_candidates(
candidates: Vec<CandidateInfo<T::AccountId, BalanceOf<T>>>,
) -> Vec<T::AccountId> {
let now = frame_system::Pallet::<T>::block_number(); let now = frame_system::Pallet::<T>::block_number();
let kick_threshold = T::KickThreshold::get(); let kick_threshold = T::KickThreshold::get();
let new_candidates = candidates.into_iter().filter_map(|c| { let new_candidates = candidates
let last_block = <LastAuthoredBlock<T>>::get(c.who.clone()); .into_iter()
let since_last = now.saturating_sub(last_block); .filter_map(|c| {
if since_last < kick_threshold || Self::candidates().len() as u32 <= T::MinCandidates::get() { let last_block = <LastAuthoredBlock<T>>::get(c.who.clone());
Some(c.who) let since_last = now.saturating_sub(last_block);
} else { if since_last < kick_threshold ||
let outcome = Self::try_remove_candidate(&c.who); Self::candidates().len() as u32 <= T::MinCandidates::get()
if let Err(why) = outcome { {
log::warn!("Failed to remove candidate {:?}", why); Some(c.who)
debug_assert!(false, "failed to remove candidate {:?}", why); } else {
let outcome = Self::try_remove_candidate(&c.who);
if let Err(why) = outcome {
log::warn!("Failed to remove candidate {:?}", why);
debug_assert!(false, "failed to remove candidate {:?}", why);
}
None
} }
None })
} .collect::<Vec<_>>();
}).collect::<Vec<_>>();
new_candidates new_candidates
} }
} }
@@ -423,7 +442,10 @@ pub mod pallet {
fn note_author(author: T::AccountId) { fn note_author(author: T::AccountId) {
let pot = Self::account_id(); let pot = Self::account_id();
// assumes an ED will be sent to pot. // assumes an ED will be sent to pot.
let reward = T::Currency::free_balance(&pot).checked_sub(&T::Currency::minimum_balance()).unwrap_or_else(Zero::zero).div(2u32.into()); let reward = T::Currency::free_balance(&pot)
.checked_sub(&T::Currency::minimum_balance())
.unwrap_or_else(Zero::zero)
.div(2u32.into());
// `reward` is half of pot account minus ED, this should never fail. // `reward` is half of pot account minus ED, this should never fail.
let _success = T::Currency::transfer(&pot, &author, reward, KeepAlive); let _success = T::Currency::transfer(&pot, &author, reward, KeepAlive);
debug_assert!(_success.is_ok()); debug_assert!(_success.is_ok());
+17 -25
View File
@@ -15,19 +15,19 @@
use super::*; use super::*;
use crate as collator_selection; use crate as collator_selection;
use sp_core::H256;
use frame_support::{ use frame_support::{
parameter_types, ord_parameter_types, ord_parameter_types, parameter_types,
traits::{FindAuthor, GenesisBuild, ValidatorRegistration}, traits::{FindAuthor, GenesisBuild, ValidatorRegistration},
PalletId PalletId,
}; };
use sp_runtime::{
RuntimeAppPublic,
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
testing::{Header, UintAuthorityId},
};
use frame_system::{EnsureSignedBy};
use frame_system as system; use frame_system as system;
use frame_system::EnsureSignedBy;
use sp_core::H256;
use sp_runtime::{
testing::{Header, UintAuthorityId},
traits::{BlakeTwo256, IdentityLookup, OpaqueKeys},
RuntimeAppPublic,
};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
type Block = frame_system::mocking::MockBlock<Test>; type Block = frame_system::mocking::MockBlock<Test>;
@@ -100,7 +100,8 @@ impl pallet_balances::Config for Test {
pub struct Author4; pub struct Author4;
impl FindAuthor<u64> for Author4 { impl FindAuthor<u64> for Author4 {
fn find_author<'a, I>(_digests: I) -> Option<u64> fn find_author<'a, I>(_digests: I) -> Option<u64>
where I: 'a + IntoIterator<Item = (frame_support::ConsensusEngineId, &'a [u8])>, where
I: 'a + IntoIterator<Item = (frame_support::ConsensusEngineId, &'a [u8])>,
{ {
Some(4) Some(4)
} }
@@ -224,22 +225,13 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap(); let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
let invulnerables = vec![1, 2]; let invulnerables = vec![1, 2];
let keys = invulnerables.iter().map(|i| let keys = invulnerables
( .iter()
*i, .map(|i| (*i, *i, MockSessionKeys { aura: UintAuthorityId(*i) }))
*i, .collect::<Vec<_>>();
MockSessionKeys { aura: UintAuthorityId(*i) },
)
).collect::<Vec<_>>();
let balances = pallet_balances::GenesisConfig::<Test> { let balances = pallet_balances::GenesisConfig::<Test> {
balances: vec![ balances: vec![(1, 100), (2, 100), (3, 100), (4, 100), (5, 100)],
(1, 100),
(2, 100),
(3, 100),
(4, 100),
(5, 100),
],
}; };
let collator_selection = collator_selection::GenesisConfig::<Test> { let collator_selection = collator_selection::GenesisConfig::<Test> {
desired_candidates: 2, desired_candidates: 2,
@@ -256,7 +248,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
} }
pub fn initialize_to_block(n: u64) { pub fn initialize_to_block(n: u64) {
for i in System::block_number()+1..=n { for i in System::block_number() + 1..=n {
System::set_block_number(i); System::set_block_number(i);
<AllPallets as frame_support::traits::OnInitialize<u64>>::on_initialize(i); <AllPallets as frame_support::traits::OnInitialize<u64>>::on_initialize(i);
} }
+11 -25
View File
@@ -13,15 +13,14 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
use crate as collator_selection; use crate as collator_selection;
use crate::{mock::*, Error, CandidateInfo}; use crate::{mock::*, CandidateInfo, Error};
use frame_support::{ use frame_support::{
assert_noop, assert_ok, assert_noop, assert_ok,
traits::{OnInitialize, Currency, GenesisBuild}, traits::{Currency, GenesisBuild, OnInitialize},
}; };
use sp_runtime::traits::BadOrigin;
use pallet_balances::Error as BalancesError; use pallet_balances::Error as BalancesError;
use sp_runtime::traits::BadOrigin;
#[test] #[test]
fn basic_setup_works() { fn basic_setup_works() {
@@ -59,7 +58,10 @@ fn set_desired_candidates_works() {
assert_eq!(CollatorSelection::desired_candidates(), 2); assert_eq!(CollatorSelection::desired_candidates(), 2);
// can set // can set
assert_ok!(CollatorSelection::set_desired_candidates(Origin::signed(RootAccount::get()), 7)); assert_ok!(CollatorSelection::set_desired_candidates(
Origin::signed(RootAccount::get()),
7
));
assert_eq!(CollatorSelection::desired_candidates(), 7); assert_eq!(CollatorSelection::desired_candidates(), 7);
// rejects bad origin // rejects bad origin
@@ -239,11 +241,7 @@ fn authorship_event_handler() {
// triggers `note_author` // triggers `note_author`
Authorship::on_initialize(1); Authorship::on_initialize(1);
let collator = CandidateInfo { who: 4, deposit: 10 };
let collator = CandidateInfo {
who: 4,
deposit: 10,
};
assert_eq!(CollatorSelection::candidates(), vec![collator]); assert_eq!(CollatorSelection::candidates(), vec![collator]);
assert_eq!(CollatorSelection::last_authored_block(4), 0); assert_eq!(CollatorSelection::last_authored_block(4), 0);
@@ -268,11 +266,7 @@ fn fees_edgecases() {
// triggers `note_author` // triggers `note_author`
Authorship::on_initialize(1); Authorship::on_initialize(1);
let collator = CandidateInfo { who: 4, deposit: 10 };
let collator = CandidateInfo {
who: 4,
deposit: 10,
};
assert_eq!(CollatorSelection::candidates(), vec![collator]); assert_eq!(CollatorSelection::candidates(), vec![collator]);
assert_eq!(CollatorSelection::last_authored_block(4), 0); assert_eq!(CollatorSelection::last_authored_block(4), 0);
@@ -334,10 +328,7 @@ fn kick_mechanism() {
assert_eq!(CollatorSelection::candidates().len(), 1); assert_eq!(CollatorSelection::candidates().len(), 1);
// 3 will be kicked after 1 session delay // 3 will be kicked after 1 session delay
assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]); assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 4]);
let collator = CandidateInfo { let collator = CandidateInfo { who: 4, deposit: 10 };
who: 4,
deposit: 10,
};
assert_eq!(CollatorSelection::candidates(), vec![collator]); assert_eq!(CollatorSelection::candidates(), vec![collator]);
assert_eq!(CollatorSelection::last_authored_block(4), 20); assert_eq!(CollatorSelection::last_authored_block(4), 20);
initialize_to_block(30); initialize_to_block(30);
@@ -362,10 +353,7 @@ fn should_not_kick_mechanism_too_few() {
assert_eq!(CollatorSelection::candidates().len(), 1); assert_eq!(CollatorSelection::candidates().len(), 1);
// 3 will be kicked after 1 session delay // 3 will be kicked after 1 session delay
assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 5]); assert_eq!(SessionHandlerCollators::get(), vec![1, 2, 3, 5]);
let collator = CandidateInfo { let collator = CandidateInfo { who: 5, deposit: 10 };
who: 5,
deposit: 10,
};
assert_eq!(CollatorSelection::candidates(), vec![collator]); assert_eq!(CollatorSelection::candidates(), vec![collator]);
assert_eq!(CollatorSelection::last_authored_block(4), 20); assert_eq!(CollatorSelection::last_authored_block(4), 20);
initialize_to_block(30); initialize_to_block(30);
@@ -376,7 +364,6 @@ fn should_not_kick_mechanism_too_few() {
}); });
} }
#[test] #[test]
#[should_panic = "duplicate invulnerables in genesis."] #[should_panic = "duplicate invulnerables in genesis."]
fn cannot_set_genesis_value_twice() { fn cannot_set_genesis_value_twice() {
@@ -391,5 +378,4 @@ fn cannot_set_genesis_value_twice() {
}; };
// collator selection must be initialized before session. // collator selection must be initialized before session.
collator_selection.assimilate_storage(&mut t).unwrap(); collator_selection.assimilate_storage(&mut t).unwrap();
} }
@@ -18,7 +18,10 @@
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; use frame_support::{
traits::Get,
weights::{constants::RocksDbWeight, Weight},
};
use sp_std::marker::PhantomData; use sp_std::marker::PhantomData;
// The weight info trait for `pallet_collator_selection`. // The weight info trait for `pallet_collator_selection`.
@@ -35,28 +38,26 @@ pub trait WeightInfo {
/// Weights for pallet_collator_selection using the Substrate node and recommended hardware. /// Weights for pallet_collator_selection using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>); pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
fn set_invulnerables(b: u32, ) -> Weight { fn set_invulnerables(b: u32) -> Weight {
(18_563_000 as Weight) (18_563_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((68_000 as Weight).saturating_mul(b as Weight)) .saturating_add((68_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_desired_candidates() -> Weight { fn set_desired_candidates() -> Weight {
(16_363_000 as Weight) (16_363_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_candidacy_bond() -> Weight { fn set_candidacy_bond() -> Weight {
(16_840_000 as Weight) (16_840_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn register_as_candidate(c: u32, ) -> Weight { fn register_as_candidate(c: u32) -> Weight {
(71_196_000 as Weight) (71_196_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((198_000 as Weight).saturating_mul(c as Weight)) .saturating_add((198_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn leave_intent(c: u32, ) -> Weight { fn leave_intent(c: u32) -> Weight {
(55_336_000 as Weight) (55_336_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((151_000 as Weight).saturating_mul(c as Weight)) .saturating_add((151_000 as Weight).saturating_mul(c as Weight))
@@ -68,7 +69,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight))
} }
fn new_session(r: u32, c: u32, ) -> Weight { fn new_session(r: u32, c: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_010_000 // Standard Error: 1_010_000
.saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight))
@@ -81,31 +82,28 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
} }
} }
// For backwards compatibility and tests // For backwards compatibility and tests
impl WeightInfo for () { impl WeightInfo for () {
fn set_invulnerables(b: u32, ) -> Weight { fn set_invulnerables(b: u32) -> Weight {
(18_563_000 as Weight) (18_563_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((68_000 as Weight).saturating_mul(b as Weight)) .saturating_add((68_000 as Weight).saturating_mul(b as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight)) .saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
fn set_desired_candidates() -> Weight { fn set_desired_candidates() -> Weight {
(16_363_000 as Weight) (16_363_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
fn set_candidacy_bond() -> Weight { fn set_candidacy_bond() -> Weight {
(16_840_000 as Weight) (16_840_000 as Weight).saturating_add(RocksDbWeight::get().writes(1 as Weight))
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
} }
fn register_as_candidate(c: u32, ) -> Weight { fn register_as_candidate(c: u32) -> Weight {
(71_196_000 as Weight) (71_196_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((198_000 as Weight).saturating_mul(c as Weight)) .saturating_add((198_000 as Weight).saturating_mul(c as Weight))
.saturating_add(RocksDbWeight::get().reads(4 as Weight)) .saturating_add(RocksDbWeight::get().reads(4 as Weight))
.saturating_add(RocksDbWeight::get().writes(2 as Weight)) .saturating_add(RocksDbWeight::get().writes(2 as Weight))
} }
fn leave_intent(c: u32, ) -> Weight { fn leave_intent(c: u32) -> Weight {
(55_336_000 as Weight) (55_336_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((151_000 as Weight).saturating_mul(c as Weight)) .saturating_add((151_000 as Weight).saturating_mul(c as Weight))
@@ -117,7 +115,7 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(3 as Weight)) .saturating_add(RocksDbWeight::get().reads(3 as Weight))
.saturating_add(RocksDbWeight::get().writes(4 as Weight)) .saturating_add(RocksDbWeight::get().writes(4 as Weight))
} }
fn new_session(r: u32, c: u32, ) -> Weight { fn new_session(r: u32, c: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_010_000 // Standard Error: 1_010_000
.saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight))
+148 -157
View File
@@ -21,15 +21,16 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use scale_info::TypeInfo; use codec::{Decode, Encode};
use sp_std::{prelude::*, convert::TryFrom}; use cumulus_primitives_core::{relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler};
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber; use frame_support::{
use cumulus_primitives_core::DmpMessageHandler; dispatch::Weight, traits::EnsureOrigin, weights::constants::WEIGHT_PER_MILLIS,
use codec::{Encode, Decode}; };
use sp_runtime::RuntimeDebug;
use xcm::{VersionedXcm, latest::prelude::*};
use frame_support::{traits::EnsureOrigin, dispatch::Weight, weights::constants::WEIGHT_PER_MILLIS};
pub use pallet::*; pub use pallet::*;
use scale_info::TypeInfo;
use sp_runtime::RuntimeDebug;
use sp_std::{convert::TryFrom, prelude::*};
use xcm::{latest::prelude::*, VersionedXcm};
#[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)] #[derive(Copy, Clone, Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct ConfigData { pub struct ConfigData {
@@ -42,7 +43,7 @@ pub struct ConfigData {
impl Default for ConfigData { impl Default for ConfigData {
fn default() -> Self { fn default() -> Self {
Self { Self {
max_individual: 10 * WEIGHT_PER_MILLIS, // 10 ms of execution time maximum by default max_individual: 10 * WEIGHT_PER_MILLIS, // 10 ms of execution time maximum by default
} }
} }
} }
@@ -100,23 +101,13 @@ pub mod pallet {
/// The queue pages. /// The queue pages.
#[pallet::storage] #[pallet::storage]
pub(super) type Pages<T> = StorageMap< pub(super) type Pages<T> =
_, StorageMap<_, Blake2_128Concat, PageCounter, Vec<(RelayBlockNumber, Vec<u8>)>, ValueQuery>;
Blake2_128Concat,
PageCounter,
Vec<(RelayBlockNumber, Vec<u8>)>,
ValueQuery,
>;
/// The overweight messages. /// The overweight messages.
#[pallet::storage] #[pallet::storage]
pub(super) type Overweight<T> = StorageMap< pub(super) type Overweight<T> =
_, StorageMap<_, Blake2_128Concat, OverweightIndex, (RelayBlockNumber, Vec<u8>), OptionQuery>;
Blake2_128Concat,
OverweightIndex,
(RelayBlockNumber, Vec<u8>),
OptionQuery,
>;
#[pallet::error] #[pallet::error]
pub enum Error<T> { pub enum Error<T> {
@@ -203,13 +194,14 @@ pub mod pallet {
while page_index.begin_used < page_index.end_used { while page_index.begin_used < page_index.end_used {
let page = Pages::<T>::take(page_index.begin_used); let page = Pages::<T>::take(page_index.begin_used);
for (i, &(sent_at, ref data)) in page.iter().enumerate() { for (i, &(sent_at, ref data)) in page.iter().enumerate() {
match Self::try_service_message(limit.saturating_sub(used), sent_at, &data[..]) { match Self::try_service_message(limit.saturating_sub(used), sent_at, &data[..])
{
Ok(w) => used += w, Ok(w) => used += w,
Err(..) => { Err(..) => {
// Too much weight needed - put the remaining messages back and bail // Too much weight needed - put the remaining messages back and bail
Pages::<T>::insert(page_index.begin_used, &page[i..]); Pages::<T>::insert(page_index.begin_used, &page[i..]);
return used; return used
} },
} }
} }
page_index.begin_used += 1; page_index.begin_used += 1;
@@ -233,8 +225,8 @@ pub mod pallet {
data: &[u8], data: &[u8],
) -> Result<Weight, (MessageId, Weight)> { ) -> Result<Weight, (MessageId, Weight)> {
let id = sp_io::hashing::blake2_256(&data[..]); let id = sp_io::hashing::blake2_256(&data[..]);
let maybe_msg = VersionedXcm::<T::Call>::decode(&mut &data[..]) let maybe_msg =
.map(Xcm::<T::Call>::try_from); VersionedXcm::<T::Call>::decode(&mut &data[..]).map(Xcm::<T::Call>::try_from);
match maybe_msg { match maybe_msg {
Err(_) => { Err(_) => {
Self::deposit_event(Event::InvalidFormat(id)); Self::deposit_event(Event::InvalidFormat(id));
@@ -247,14 +239,15 @@ pub mod pallet {
Ok(Ok(x)) => { Ok(Ok(x)) => {
let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, limit); let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, limit);
match outcome { match outcome {
Outcome::Error(XcmError::WeightLimitReached(required)) => Err((id, required)), Outcome::Error(XcmError::WeightLimitReached(required)) =>
Err((id, required)),
outcome => { outcome => {
let weight_used = outcome.weight_used(); let weight_used = outcome.weight_used();
Self::deposit_event(Event::ExecutedDownward(id, outcome)); Self::deposit_event(Event::ExecutedDownward(id, outcome));
Ok(weight_used) Ok(weight_used)
} },
} }
} },
} }
} }
} }
@@ -264,7 +257,7 @@ pub mod pallet {
/// the `Parent` location. /// the `Parent` location.
impl<T: Config> DmpMessageHandler for Pallet<T> { impl<T: Config> DmpMessageHandler for Pallet<T> {
fn handle_dmp_messages( fn handle_dmp_messages(
iter: impl Iterator<Item=(RelayBlockNumber, Vec<u8>)>, iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
limit: Weight, limit: Weight,
) -> Weight { ) -> Weight {
let mut page_index = PageIndex::<T>::get(); let mut page_index = PageIndex::<T>::get();
@@ -290,7 +283,8 @@ pub mod pallet {
match Self::try_service_message(remaining, sent_at, &data[..]) { match Self::try_service_message(remaining, sent_at, &data[..]) {
Ok(consumed) => used += consumed, Ok(consumed) => used += consumed,
Err((id, required)) => Err((id, required)) =>
// Too much weight required right now. // Too much weight required right now.
{
if required > config.max_individual { if required > config.max_individual {
// overweight - add to overweight queue and continue with // overweight - add to overweight queue and continue with
// message execution. // message execution.
@@ -300,14 +294,17 @@ pub mod pallet {
page_index.overweight_count += 1; page_index.overweight_count += 1;
// Not needed for control flow, but only to ensure that the compiler // Not needed for control flow, but only to ensure that the compiler
// understands that we won't attempt to re-use `data` later. // understands that we won't attempt to re-use `data` later.
continue; continue
} else { } else {
// not overweight. stop executing inline and enqueue normally // not overweight. stop executing inline and enqueue normally
// from here on. // from here on.
let item_count_left = item_count.saturating_sub(i); let item_count_left = item_count.saturating_sub(i);
maybe_enqueue_page = Some(Vec::with_capacity(item_count_left)); maybe_enqueue_page = Some(Vec::with_capacity(item_count_left));
Self::deposit_event(Event::WeightExhausted(id, remaining, required)); Self::deposit_event(Event::WeightExhausted(
id, remaining, required,
));
} }
}
} }
} }
// Cannot be an `else` here since the `maybe_enqueue_page` may have changed. // Cannot be an `else` here since the `maybe_enqueue_page` may have changed.
@@ -333,14 +330,17 @@ mod tests {
use super::*; use super::*;
use crate as dmp_queue; use crate as dmp_queue;
use std::cell::RefCell;
use codec::Encode; use codec::Encode;
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use frame_support::{parameter_types, assert_noop, traits::OnIdle}; use frame_support::{assert_noop, parameter_types, traits::OnIdle};
use sp_core::H256; use sp_core::H256;
use sp_runtime::{testing::Header, traits::{IdentityLookup, BlakeTwo256}}; use sp_runtime::{
use sp_runtime::DispatchError::BadOrigin; testing::Header,
traits::{BlakeTwo256, IdentityLookup},
DispatchError::BadOrigin,
};
use sp_version::RuntimeVersion; use sp_version::RuntimeVersion;
use std::cell::RefCell;
use xcm::latest::{MultiLocation, OriginKind}; use xcm::latest::{MultiLocation, OriginKind};
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
@@ -451,9 +451,12 @@ mod tests {
fn enqueue(enqueued: &[Xcm]) { fn enqueue(enqueued: &[Xcm]) {
if !enqueued.is_empty() { if !enqueued.is_empty() {
let mut index = PageIndex::<Test>::get(); let mut index = PageIndex::<Test>::get();
Pages::<Test>::insert(index.end_used, enqueued.iter() Pages::<Test>::insert(
.map(|m| (0, VersionedXcm::<Call>::from(m.clone()).encode())) index.end_used,
.collect::<Vec<_>>() enqueued
.iter()
.map(|m| (0, VersionedXcm::<Call>::from(m.clone()).encode()))
.collect::<Vec<_>>(),
); );
index.end_used += 1; index.end_used += 1;
PageIndex::<Test>::put(index); PageIndex::<Test>::put(index);
@@ -508,7 +511,7 @@ mod tests {
#[test] #[test]
fn service_inline_complete_works() { fn service_inline_complete_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let incoming = vec![ msg(1000), msg(1001) ]; let incoming = vec![msg(1000), msg(1001)];
let weight_used = handle_messages(&incoming, 2500); let weight_used = handle_messages(&incoming, 2500);
assert_eq!(weight_used, 2001); assert_eq!(weight_used, 2001);
assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1001)]); assert_eq!(take_trace(), vec![msg_complete(1000), msg_complete(1001)]);
@@ -519,41 +522,40 @@ mod tests {
#[test] #[test]
fn service_enqueued_works() { fn service_enqueued_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let enqueued = vec![ msg(1000), msg(1001), msg(1002) ]; let enqueued = vec![msg(1000), msg(1001), msg(1002)];
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&[], 2500); let weight_used = handle_messages(&[], 2500);
assert_eq!(weight_used, 2001); assert_eq!(weight_used, 2001);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_complete(1001), vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(1002),]
msg_limit_reached(1002), );
]);
}); });
} }
#[test] #[test]
fn enqueue_works() { fn enqueue_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let incoming = vec![ msg(1000), msg(1001), msg(1002) ]; let incoming = vec![msg(1000), msg(1001), msg(1002)];
let weight_used = handle_messages(&incoming, 999); let weight_used = handle_messages(&incoming, 999);
assert_eq!(weight_used, 0); assert_eq!(weight_used, 0);
assert_eq!(PageIndex::<Test>::get(), PageIndexData { begin_used: 0, end_used: 1, overweight_count: 0}); assert_eq!(
PageIndex::<Test>::get(),
PageIndexData { begin_used: 0, end_used: 1, overweight_count: 0 }
);
assert_eq!(Pages::<Test>::get(0).len(), 3); assert_eq!(Pages::<Test>::get(0).len(), 3);
assert_eq!(take_trace(), vec![ msg_limit_reached(1000) ]); assert_eq!(take_trace(), vec![msg_limit_reached(1000)]);
let weight_used = handle_messages(&[], 2500); let weight_used = handle_messages(&[], 2500);
assert_eq!(weight_used, 2001); assert_eq!(weight_used, 2001);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_complete(1001), vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(1002),]
msg_limit_reached(1002), );
]);
let weight_used = handle_messages(&[], 2500); let weight_used = handle_messages(&[], 2500);
assert_eq!(weight_used, 1002); assert_eq!(weight_used, 1002);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1002),]);
msg_complete(1002),
]);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -561,22 +563,16 @@ mod tests {
#[test] #[test]
fn service_inline_then_enqueue_works() { fn service_inline_then_enqueue_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let incoming = vec![ msg(1000), msg(1001), msg(1002) ]; let incoming = vec![msg(1000), msg(1001), msg(1002)];
let weight_used = handle_messages(&incoming, 1500); let weight_used = handle_messages(&incoming, 1500);
assert_eq!(weight_used, 1000); assert_eq!(weight_used, 1000);
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
assert_eq!(Pages::<Test>::get(0).len(), 2); assert_eq!(Pages::<Test>::get(0).len(), 2);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
msg_complete(1000),
msg_limit_reached(1001),
]);
let weight_used = handle_messages(&[], 2500); let weight_used = handle_messages(&[], 2500);
assert_eq!(weight_used, 2003); assert_eq!(weight_used, 2003);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1001), msg_complete(1002),]);
msg_complete(1001),
msg_complete(1002),
]);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -584,17 +580,20 @@ mod tests {
#[test] #[test]
fn service_enqueued_and_inline_works() { fn service_enqueued_and_inline_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let enqueued = vec![ msg(1000), msg(1001) ]; let enqueued = vec![msg(1000), msg(1001)];
let incoming = vec![ msg(1002), msg(1003) ]; let incoming = vec![msg(1002), msg(1003)];
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&incoming, 5000); let weight_used = handle_messages(&incoming, 5000);
assert_eq!(weight_used, 4006); assert_eq!(weight_used, 4006);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_complete(1001), vec![
msg_complete(1002), msg_complete(1000),
msg_complete(1003), msg_complete(1001),
]); msg_complete(1002),
msg_complete(1003),
]
);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -602,32 +601,26 @@ mod tests {
#[test] #[test]
fn service_enqueued_partially_and_then_enqueue_works() { fn service_enqueued_partially_and_then_enqueue_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let enqueued = vec![ msg(1000), msg(10001) ]; let enqueued = vec![msg(1000), msg(10001)];
let incoming = vec![ msg(1002), msg(1003) ]; let incoming = vec![msg(1002), msg(1003)];
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&incoming, 5000); let weight_used = handle_messages(&incoming, 5000);
assert_eq!(weight_used, 1000); assert_eq!(weight_used, 1000);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(10001),]);
msg_complete(1000),
msg_limit_reached(10001),
]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
// 5000 is not enough to process the 10001 blocker, so nothing happens. // 5000 is not enough to process the 10001 blocker, so nothing happens.
let weight_used = handle_messages(&[], 5000); let weight_used = handle_messages(&[], 5000);
assert_eq!(weight_used, 0); assert_eq!(weight_used, 0);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_limit_reached(10001),]);
msg_limit_reached(10001),
]);
// 20000 is now enough to process everything. // 20000 is now enough to process everything.
let weight_used = handle_messages(&[], 20000); let weight_used = handle_messages(&[], 20000);
assert_eq!(weight_used, 12006); assert_eq!(weight_used, 12006);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(10001), take_trace(),
msg_complete(1002), vec![msg_complete(10001), msg_complete(1002), msg_complete(1003),]
msg_complete(1003), );
]);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -635,25 +628,21 @@ mod tests {
#[test] #[test]
fn service_enqueued_completely_and_then_enqueue_works() { fn service_enqueued_completely_and_then_enqueue_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let enqueued = vec![ msg(1000), msg(1001) ]; let enqueued = vec![msg(1000), msg(1001)];
let incoming = vec![ msg(10002), msg(1003) ]; let incoming = vec![msg(10002), msg(1003)];
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&incoming, 5000); let weight_used = handle_messages(&incoming, 5000);
assert_eq!(weight_used, 2001); assert_eq!(weight_used, 2001);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_complete(1001), vec![msg_complete(1000), msg_complete(1001), msg_limit_reached(10002),]
msg_limit_reached(10002), );
]);
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
// 20000 is now enough to process everything. // 20000 is now enough to process everything.
let weight_used = handle_messages(&[], 20000); let weight_used = handle_messages(&[], 20000);
assert_eq!(weight_used, 11005); assert_eq!(weight_used, 11005);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(10002), msg_complete(1003),]);
msg_complete(10002),
msg_complete(1003),
]);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -661,25 +650,26 @@ mod tests {
#[test] #[test]
fn service_enqueued_then_inline_then_enqueue_works() { fn service_enqueued_then_inline_then_enqueue_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let enqueued = vec![ msg(1000), msg(1001) ]; let enqueued = vec![msg(1000), msg(1001)];
let incoming = vec![ msg(1002), msg(10003) ]; let incoming = vec![msg(1002), msg(10003)];
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&incoming, 5000); let weight_used = handle_messages(&incoming, 5000);
assert_eq!(weight_used, 3003); assert_eq!(weight_used, 3003);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_complete(1001), vec![
msg_complete(1002), msg_complete(1000),
msg_limit_reached(10003), msg_complete(1001),
]); msg_complete(1002),
msg_limit_reached(10003),
]
);
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
// 20000 is now enough to process everything. // 20000 is now enough to process everything.
let weight_used = handle_messages(&[], 20000); let weight_used = handle_messages(&[], 20000);
assert_eq!(weight_used, 10003); assert_eq!(weight_used, 10003);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(10003),]);
msg_complete(10003),
]);
assert!(queue_is_empty()); assert!(queue_is_empty());
}); });
} }
@@ -687,32 +677,23 @@ mod tests {
#[test] #[test]
fn page_crawling_works() { fn page_crawling_works() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let enqueued = vec![ msg(1000), msg(1001) ]; let enqueued = vec![msg(1000), msg(1001)];
enqueue(&enqueued); enqueue(&enqueued);
let weight_used = handle_messages(&vec![ msg(1002) ], 1500); let weight_used = handle_messages(&vec![msg(1002)], 1500);
assert_eq!(weight_used, 1000); assert_eq!(weight_used, 1000);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1000), msg_limit_reached(1001),]);
msg_complete(1000),
msg_limit_reached(1001),
]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 0); assert_eq!(PageIndex::<Test>::get().begin_used, 0);
let weight_used = handle_messages(&vec![ msg(1003) ], 1500); let weight_used = handle_messages(&vec![msg(1003)], 1500);
assert_eq!(weight_used, 1001); assert_eq!(weight_used, 1001);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1001), msg_limit_reached(1002),]);
msg_complete(1001),
msg_limit_reached(1002),
]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 1); assert_eq!(PageIndex::<Test>::get().begin_used, 1);
let weight_used = handle_messages(&vec![ msg(1004) ], 1500); let weight_used = handle_messages(&vec![msg(1004)], 1500);
assert_eq!(weight_used, 1002); assert_eq!(weight_used, 1002);
assert_eq!(take_trace(), vec![ assert_eq!(take_trace(), vec![msg_complete(1002), msg_limit_reached(1003),]);
msg_complete(1002),
msg_limit_reached(1003),
]);
assert_eq!(pages_queued(), 2); assert_eq!(pages_queued(), 2);
assert_eq!(PageIndex::<Test>::get().begin_used, 2); assert_eq!(PageIndex::<Test>::get().begin_used, 2);
}); });
@@ -724,15 +705,14 @@ mod tests {
// Set the overweight threshold to 9999. // Set the overweight threshold to 9999.
Configuration::<Test>::put(ConfigData { max_individual: 9999 }); Configuration::<Test>::put(ConfigData { max_individual: 9999 });
let incoming = vec![ msg(1000), msg(10001), msg(1002) ]; let incoming = vec![msg(1000), msg(10001), msg(1002)];
let weight_used = handle_messages(&incoming, 2500); let weight_used = handle_messages(&incoming, 2500);
assert_eq!(weight_used, 2002); assert_eq!(weight_used, 2002);
assert!(queue_is_empty()); assert!(queue_is_empty());
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_limit_reached(10001), vec![msg_complete(1000), msg_limit_reached(10001), msg_complete(1002),]
msg_complete(1002), );
]);
assert_eq!(overweights(), vec![0]); assert_eq!(overweights(), vec![0]);
}); });
@@ -744,49 +724,60 @@ mod tests {
// Set the overweight threshold to 9999. // Set the overweight threshold to 9999.
Configuration::<Test>::put(ConfigData { max_individual: 9999 }); Configuration::<Test>::put(ConfigData { max_individual: 9999 });
let incoming = vec![ msg(10000) ]; let incoming = vec![msg(10000)];
let weight_used = handle_messages(&incoming, 2500); let weight_used = handle_messages(&incoming, 2500);
assert_eq!(weight_used, 0); assert_eq!(weight_used, 0);
assert_eq!(take_trace(), vec![ msg_limit_reached(10000) ]); assert_eq!(take_trace(), vec![msg_limit_reached(10000)]);
assert_eq!(overweights(), vec![0]); assert_eq!(overweights(), vec![0]);
assert_noop!(DmpQueue::service_overweight(Origin::signed(1), 0, 20000), BadOrigin); assert_noop!(DmpQueue::service_overweight(Origin::signed(1), 0, 20000), BadOrigin);
assert_noop!(DmpQueue::service_overweight(Origin::root(), 1, 20000), Error::<Test>::Unknown); assert_noop!(
assert_noop!(DmpQueue::service_overweight(Origin::root(), 0, 9999), Error::<Test>::OverLimit); DmpQueue::service_overweight(Origin::root(), 1, 20000),
assert_eq!(take_trace(), vec![ msg_limit_reached(10000) ]); Error::<Test>::Unknown
);
assert_noop!(
DmpQueue::service_overweight(Origin::root(), 0, 9999),
Error::<Test>::OverLimit
);
assert_eq!(take_trace(), vec![msg_limit_reached(10000)]);
let base_weight = super::Call::<Test>::service_overweight { let base_weight = super::Call::<Test>::service_overweight { index: 0, weight_limit: 0 }
index: 0, .get_dispatch_info()
weight_limit: 0, .weight;
}.get_dispatch_info().weight;
use frame_support::weights::GetDispatchInfo; use frame_support::weights::GetDispatchInfo;
let info = DmpQueue::service_overweight(Origin::root(), 0, 20000).unwrap(); let info = DmpQueue::service_overweight(Origin::root(), 0, 20000).unwrap();
let actual_weight = info.actual_weight.unwrap(); let actual_weight = info.actual_weight.unwrap();
assert_eq!(actual_weight, base_weight + 10000); assert_eq!(actual_weight, base_weight + 10000);
assert_eq!(take_trace(), vec![ msg_complete(10000) ]); assert_eq!(take_trace(), vec![msg_complete(10000)]);
assert!(overweights().is_empty()); assert!(overweights().is_empty());
assert_noop!(DmpQueue::service_overweight(Origin::root(), 0, 20000), Error::<Test>::Unknown); assert_noop!(
DmpQueue::service_overweight(Origin::root(), 0, 20000),
Error::<Test>::Unknown
);
}); });
} }
#[test] #[test]
fn on_idle_should_service_queue() { fn on_idle_should_service_queue() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
enqueue(&vec![ msg(1000), msg(1001) ]); enqueue(&vec![msg(1000), msg(1001)]);
enqueue(&vec![ msg(1002), msg(1003) ]); enqueue(&vec![msg(1002), msg(1003)]);
enqueue(&vec![ msg(1004), msg(1005) ]); enqueue(&vec![msg(1004), msg(1005)]);
let weight_used = DmpQueue::on_idle(1, 6000); let weight_used = DmpQueue::on_idle(1, 6000);
assert_eq!(weight_used, 5010); assert_eq!(weight_used, 5010);
assert_eq!(take_trace(), vec![ assert_eq!(
msg_complete(1000), take_trace(),
msg_complete(1001), vec![
msg_complete(1002), msg_complete(1000),
msg_complete(1003), msg_complete(1001),
msg_complete(1004), msg_complete(1002),
msg_limit_reached(1005), msg_complete(1003),
]); msg_complete(1004),
msg_limit_reached(1005),
]
);
assert_eq!(pages_queued(), 1); assert_eq!(pages_queued(), 1);
}); });
} }
@@ -69,13 +69,13 @@ impl Parse for Input {
} else if lookahead.peek(keywords::CheckInherents) { } else if lookahead.peek(keywords::CheckInherents) {
parse_inner::<keywords::CheckInherents>(input, &mut check_inherents)?; parse_inner::<keywords::CheckInherents>(input, &mut check_inherents)?;
} else { } else {
return Err(lookahead.error()); return Err(lookahead.error())
} }
} }
let rest = input.parse::<TokenStream>()?; let rest = input.parse::<TokenStream>()?;
if !rest.is_empty() { if !rest.is_empty() {
return Err(Error::new(rest.span(), "Unexpected input data")); return Err(Error::new(rest.span(), "Unexpected input data"))
} }
Ok(Self { Ok(Self {
@@ -88,10 +88,8 @@ impl Parse for Input {
fn crate_() -> Result<Ident, Error> { fn crate_() -> Result<Ident, Error> {
match crate_name("cumulus-pallet-parachain-system") { match crate_name("cumulus-pallet-parachain-system") {
Ok(FoundCrate::Itself) => Ok(syn::Ident::new( Ok(FoundCrate::Itself) =>
"cumulus_pallet_parachain_system", Ok(syn::Ident::new("cumulus_pallet_parachain_system", Span::call_site())),
Span::call_site(),
)),
Ok(FoundCrate::Name(name)) => Ok(Ident::new(&name, Span::call_site())), Ok(FoundCrate::Name(name)) => Ok(Ident::new(&name, Span::call_site())),
Err(e) => Err(Error::new(Span::call_site(), e)), Err(e) => Err(Error::new(Span::call_site(), e)),
} }
@@ -99,11 +97,7 @@ fn crate_() -> Result<Ident, Error> {
#[proc_macro] #[proc_macro]
pub fn register_validate_block(input: proc_macro::TokenStream) -> proc_macro::TokenStream { pub fn register_validate_block(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let Input { let Input { runtime, check_inherents, block_executor } = match syn::parse(input) {
runtime,
check_inherents,
block_executor,
} = match syn::parse(input) {
Ok(t) => t, Ok(t) => t,
Err(e) => return e.into_compile_error().into(), Err(e) => return e.into_compile_error().into(),
}; };
+37 -59
View File
@@ -144,8 +144,8 @@ pub mod pallet {
false, false,
"host configuration is promised to set until `on_finalize`; qed", "host configuration is promised to set until `on_finalize`; qed",
); );
return; return
} },
}; };
let relevant_messaging_state = match Self::relevant_messaging_state() { let relevant_messaging_state = match Self::relevant_messaging_state() {
Some(ok) => ok, Some(ok) => ok,
@@ -155,8 +155,8 @@ pub mod pallet {
"relevant messaging state is promised to be set until `on_finalize`; \ "relevant messaging state is promised to be set until `on_finalize`; \
qed", qed",
); );
return; return
} },
}; };
<PendingUpwardMessages<T>>::mutate(|up| { <PendingUpwardMessages<T>>::mutate(|up| {
@@ -172,19 +172,16 @@ pub mod pallet {
// available_capacity and available_size. // available_capacity and available_size.
let num = up let num = up
.iter() .iter()
.scan( .scan((available_capacity as usize, available_size as usize), |state, msg| {
(available_capacity as usize, available_size as usize), let (cap_left, size_left) = *state;
|state, msg| { match (cap_left.checked_sub(1), size_left.checked_sub(msg.len())) {
let (cap_left, size_left) = *state; (Some(new_cap), Some(new_size)) => {
match (cap_left.checked_sub(1), size_left.checked_sub(msg.len())) { *state = (new_cap, new_size);
(Some(new_cap), Some(new_size)) => { Some(())
*state = (new_cap, new_size); },
Some(()) _ => None,
} }
_ => None, })
}
},
)
.count(); .count();
// TODO: #274 Return back messages that do not longer fit into the queue. // TODO: #274 Return back messages that do not longer fit into the queue.
@@ -366,10 +363,7 @@ pub mod pallet {
vfp.relay_parent_number, vfp.relay_parent_number,
); );
Ok(PostDispatchInfo { Ok(PostDispatchInfo { actual_weight: Some(total_weight), pays_fee: Pays::No })
actual_weight: Some(total_weight),
pays_fee: Pays::No,
})
} }
#[pallet::weight((1_000, DispatchClass::Operational))] #[pallet::weight((1_000, DispatchClass::Operational))]
@@ -572,11 +566,10 @@ pub mod pallet {
cumulus_primitives_parachain_inherent::INHERENT_IDENTIFIER; cumulus_primitives_parachain_inherent::INHERENT_IDENTIFIER;
fn create_inherent(data: &InherentData) -> Option<Self::Call> { fn create_inherent(data: &InherentData) -> Option<Self::Call> {
let data: ParachainInherentData = data let data: ParachainInherentData =
.get_data(&Self::INHERENT_IDENTIFIER) data.get_data(&Self::INHERENT_IDENTIFIER).ok().flatten().expect(
.ok() "validation function params are always injected into inherent data; qed",
.flatten() );
.expect("validation function params are always injected into inherent data; qed");
Some(Call::set_validation_data { data }) Some(Call::set_validation_data { data })
} }
@@ -611,11 +604,11 @@ pub mod pallet {
provides: vec![hash.as_ref().to_vec()], provides: vec![hash.as_ref().to_vec()],
longevity: TransactionLongevity::max_value(), longevity: TransactionLongevity::max_value(),
propagate: true, propagate: true,
}); })
} }
} }
if let Call::set_validation_data { .. } = call { if let Call::set_validation_data { .. } = call {
return Ok(Default::default()); return Ok(Default::default())
} }
Err(InvalidTransaction::Call.into()) Err(InvalidTransaction::Call.into())
} }
@@ -650,8 +643,8 @@ impl<T: Config> GetChannelInfo for Pallet<T> {
let channels = match Self::relevant_messaging_state() { let channels = match Self::relevant_messaging_state() {
None => { None => {
log::warn!("calling `get_channel_status` with no RelevantMessagingState?!"); log::warn!("calling `get_channel_status` with no RelevantMessagingState?!");
return ChannelStatus::Closed; return ChannelStatus::Closed
} },
Some(d) => d.egress_channels, Some(d) => d.egress_channels,
}; };
// ^^^ NOTE: This storage field should carry over from the previous block. So if it's // ^^^ NOTE: This storage field should carry over from the previous block. So if it's
@@ -667,7 +660,7 @@ impl<T: Config> GetChannelInfo for Pallet<T> {
let meta = &channels[index].1; let meta = &channels[index].1;
if meta.msg_count + 1 > meta.max_capacity { if meta.msg_count + 1 > meta.max_capacity {
// The channel is at its capacity. Skip it for now. // The channel is at its capacity. Skip it for now.
return ChannelStatus::Full; return ChannelStatus::Full
} }
let max_size_now = meta.max_total_size - meta.total_size; let max_size_now = meta.max_total_size - meta.total_size;
let max_size_ever = meta.max_message_size; let max_size_ever = meta.max_message_size;
@@ -771,9 +764,7 @@ impl<T: Config> Pallet<T> {
// A violation of the assertion below indicates that one of the messages submitted // A violation of the assertion below indicates that one of the messages submitted
// by the collator was sent from a sender that doesn't have a channel opened to // by the collator was sent from a sender that doesn't have a channel opened to
// this parachain, according to the relay-parent state. // this parachain, according to the relay-parent state.
assert!(ingress_channels assert!(ingress_channels.binary_search_by_key(sender, |&(s, _)| s).is_ok(),);
.binary_search_by_key(sender, |&(s, _)| s)
.is_ok(),);
} }
// Second, prepare horizontal messages for a more convenient processing: // Second, prepare horizontal messages for a more convenient processing:
@@ -787,9 +778,7 @@ impl<T: Config> Pallet<T> {
let mut horizontal_messages = horizontal_messages let mut horizontal_messages = horizontal_messages
.into_iter() .into_iter()
.flat_map(|(sender, channel_contents)| { .flat_map(|(sender, channel_contents)| {
channel_contents channel_contents.into_iter().map(move |message| (sender, message))
.into_iter()
.map(move |message| (sender, message))
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
horizontal_messages.sort_by(|a, b| { horizontal_messages.sort_by(|a, b| {
@@ -806,10 +795,7 @@ impl<T: Config> Pallet<T> {
{ {
for (sender, ref horizontal_message) in &horizontal_messages { for (sender, ref horizontal_message) in &horizontal_messages {
if hrmp_watermark if hrmp_watermark.map(|w| w < horizontal_message.sent_at).unwrap_or(true) {
.map(|w| w < horizontal_message.sent_at)
.unwrap_or(true)
{
hrmp_watermark = Some(horizontal_message.sent_at); hrmp_watermark = Some(horizontal_message.sent_at);
} }
@@ -882,16 +868,15 @@ impl<T: Config> Pallet<T> {
) -> Option<relay_chain::BlockNumber> { ) -> Option<relay_chain::BlockNumber> {
if <PendingRelayChainBlockNumber<T>>::get().is_some() { if <PendingRelayChainBlockNumber<T>>::get().is_some() {
// There is already upgrade scheduled. Upgrade is not allowed. // There is already upgrade scheduled. Upgrade is not allowed.
return None; return None
} }
let relay_blocks_since_last_upgrade = vfp let relay_blocks_since_last_upgrade =
.relay_parent_number vfp.relay_parent_number.saturating_sub(<LastUpgrade<T>>::get());
.saturating_sub(<LastUpgrade<T>>::get());
if relay_blocks_since_last_upgrade <= cfg.validation_upgrade_frequency { if relay_blocks_since_last_upgrade <= cfg.validation_upgrade_frequency {
// The cooldown after the last upgrade hasn't elapsed yet. Upgrade is not allowed. // The cooldown after the last upgrade hasn't elapsed yet. Upgrade is not allowed.
return None; return None
} }
Some(vfp.relay_parent_number + cfg.validation_upgrade_delay) Some(vfp.relay_parent_number + cfg.validation_upgrade_delay)
@@ -899,16 +884,10 @@ impl<T: Config> Pallet<T> {
/// The implementation of the runtime upgrade functionality for parachains. /// The implementation of the runtime upgrade functionality for parachains.
fn set_code_impl(validation_function: Vec<u8>) -> DispatchResult { fn set_code_impl(validation_function: Vec<u8>) -> DispatchResult {
ensure!( ensure!(!<PendingValidationCode<T>>::exists(), Error::<T>::OverlappingUpgrades);
!<PendingValidationCode<T>>::exists(),
Error::<T>::OverlappingUpgrades
);
let vfp = Self::validation_data().ok_or(Error::<T>::ValidationDataNotAvailable)?; let vfp = Self::validation_data().ok_or(Error::<T>::ValidationDataNotAvailable)?;
let cfg = Self::host_configuration().ok_or(Error::<T>::HostConfigurationNotAvailable)?; let cfg = Self::host_configuration().ok_or(Error::<T>::HostConfigurationNotAvailable)?;
ensure!( ensure!(validation_function.len() <= cfg.max_code_size as usize, Error::<T>::TooBig);
validation_function.len() <= cfg.max_code_size as usize,
Error::<T>::TooBig
);
let apply_block = let apply_block =
Self::code_upgrade_allowed(&vfp, &cfg).ok_or(Error::<T>::ProhibitedByPolkadot)?; Self::code_upgrade_allowed(&vfp, &cfg).ok_or(Error::<T>::ProhibitedByPolkadot)?;
@@ -1002,11 +981,10 @@ impl<T: Config> Pallet<T> {
// //
// However, changing this setting is expected to be rare. // However, changing this setting is expected to be rare.
match Self::host_configuration() { match Self::host_configuration() {
Some(cfg) => { Some(cfg) =>
if message.len() > cfg.max_upward_message_size as usize { if message.len() > cfg.max_upward_message_size as usize {
return Err(MessageSendError::TooBig); return Err(MessageSendError::TooBig)
} },
}
None => { None => {
// This storage field should carry over from the previous block. So if it's None // This storage field should carry over from the previous block. So if it's None
// then it must be that this is an edge-case where a message is attempted to be // then it must be that this is an edge-case where a message is attempted to be
@@ -1017,7 +995,7 @@ impl<T: Config> Pallet<T> {
// returned back to the sender. // returned back to the sender.
// //
// Thus fall through here. // Thus fall through here.
} },
}; };
<PendingUpwardMessages<T>>::append(message); <PendingUpwardMessages<T>>::append(message);
Ok(0) Ok(0)
@@ -19,11 +19,10 @@ use cumulus_primitives_core::{
relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId, relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId,
}; };
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_trie::{MemoryDB, HashDBT, EMPTY_PREFIX};
use sp_runtime::traits::HashFor; use sp_runtime::traits::HashFor;
use sp_state_machine::{Backend, TrieBackend}; use sp_state_machine::{Backend, TrieBackend};
use sp_std::vec::Vec; use sp_std::vec::Vec;
use sp_trie::StorageProof; use sp_trie::{HashDBT, MemoryDB, StorageProof, EMPTY_PREFIX};
/// A snapshot of some messaging related state of relay chain pertaining to the current parachain. /// A snapshot of some messaging related state of relay chain pertaining to the current parachain.
/// ///
@@ -130,14 +129,11 @@ impl RelayChainStateProof {
) -> Result<Self, Error> { ) -> Result<Self, Error> {
let db = proof.into_memory_db::<HashFor<relay_chain::Block>>(); let db = proof.into_memory_db::<HashFor<relay_chain::Block>>();
if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) { if !db.contains(&relay_parent_storage_root, EMPTY_PREFIX) {
return Err(Error::RootMismatch); return Err(Error::RootMismatch)
} }
let trie_backend = TrieBackend::new(db, relay_parent_storage_root); let trie_backend = TrieBackend::new(db, relay_parent_storage_root);
Ok(Self { Ok(Self { para_id, trie_backend })
para_id,
trie_backend,
})
} }
/// Read the [`MessagingStateSnapshot`] from the relay chain state proof. /// Read the [`MessagingStateSnapshot`] from the relay chain state proof.
@@ -174,10 +170,7 @@ impl RelayChainStateProof {
let mut ingress_channels = Vec::with_capacity(ingress_channel_index.len()); let mut ingress_channels = Vec::with_capacity(ingress_channel_index.len());
for sender in ingress_channel_index { for sender in ingress_channel_index {
let channel_id = relay_chain::v1::HrmpChannelId { let channel_id = relay_chain::v1::HrmpChannelId { sender, recipient: self.para_id };
sender,
recipient: self.para_id,
};
let hrmp_channel: AbridgedHrmpChannel = read_entry( let hrmp_channel: AbridgedHrmpChannel = read_entry(
&self.trie_backend, &self.trie_backend,
&relay_chain::well_known_keys::hrmp_channels(channel_id), &relay_chain::well_known_keys::hrmp_channels(channel_id),
@@ -189,10 +182,7 @@ impl RelayChainStateProof {
let mut egress_channels = Vec::with_capacity(egress_channel_index.len()); let mut egress_channels = Vec::with_capacity(egress_channel_index.len());
for recipient in egress_channel_index { for recipient in egress_channel_index {
let channel_id = relay_chain::v1::HrmpChannelId { let channel_id = relay_chain::v1::HrmpChannelId { sender: self.para_id, recipient };
sender: self.para_id,
recipient,
};
let hrmp_channel: AbridgedHrmpChannel = read_entry( let hrmp_channel: AbridgedHrmpChannel = read_entry(
&self.trie_backend, &self.trie_backend,
&relay_chain::well_known_keys::hrmp_channels(channel_id), &relay_chain::well_known_keys::hrmp_channels(channel_id),
@@ -226,6 +216,7 @@ impl RelayChainStateProof {
/// ///
/// Returns an error if anything failed at reading or decoding. /// Returns an error if anything failed at reading or decoding.
pub fn read_slot(&self) -> Result<relay_chain::v1::Slot, Error> { pub fn read_slot(&self) -> Result<relay_chain::v1::Slot, Error> {
read_entry(&self.trie_backend, relay_chain::well_known_keys::CURRENT_SLOT, None).map_err(Error::Slot) read_entry(&self.trie_backend, relay_chain::well_known_keys::CURRENT_SLOT, None)
.map_err(Error::Slot)
} }
} }
+53 -119
View File
@@ -17,17 +17,17 @@ use super::*;
use codec::Encode; use codec::Encode;
use cumulus_primitives_core::{ use cumulus_primitives_core::{
AbridgedHrmpChannel, InboundDownwardMessage, InboundHrmpMessage, PersistedValidationData, relay_chain::BlockNumber as RelayBlockNumber, AbridgedHrmpChannel, InboundDownwardMessage,
relay_chain::BlockNumber as RelayBlockNumber, InboundHrmpMessage, PersistedValidationData,
}; };
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
use frame_support::{ use frame_support::{
assert_ok, assert_ok,
dispatch::UnfilteredDispatchable, dispatch::UnfilteredDispatchable,
inherent::{InherentData, ProvideInherent},
parameter_types, parameter_types,
traits::{OnFinalize, OnInitialize}, traits::{OnFinalize, OnInitialize},
weights::Weight, weights::Weight,
inherent::{InherentData, ProvideInherent},
}; };
use frame_system::{InitKind, RawOrigin}; use frame_system::{InitKind, RawOrigin};
use hex_literal::hex; use hex_literal::hex;
@@ -113,10 +113,7 @@ std::thread_local! {
static SENT_MESSAGES: RefCell<Vec<(ParaId, Vec<u8>)>> = RefCell::new(Vec::new()); static SENT_MESSAGES: RefCell<Vec<(ParaId, Vec<u8>)>> = RefCell::new(Vec::new());
} }
fn send_message( fn send_message(dest: ParaId, message: Vec<u8>) {
dest: ParaId,
message: Vec<u8>,
) {
SENT_MESSAGES.with(|m| m.borrow_mut().push((dest, message))); SENT_MESSAGES.with(|m| m.borrow_mut().push((dest, message)));
} }
@@ -125,9 +122,9 @@ impl XcmpMessageSource for FromThreadLocal {
let mut ids = std::collections::BTreeSet::<ParaId>::new(); let mut ids = std::collections::BTreeSet::<ParaId>::new();
let mut taken = 0; let mut taken = 0;
let mut result = Vec::new(); let mut result = Vec::new();
SENT_MESSAGES.with(|ms| ms.borrow_mut() SENT_MESSAGES.with(|ms| {
.retain(|m| { ms.borrow_mut().retain(|m| {
let status = <Pallet::<Test> as GetChannelInfo>::get_channel_status(m.0); let status = <Pallet<Test> as GetChannelInfo>::get_channel_status(m.0);
let ready = matches!(status, ChannelStatus::Ready(..)); let ready = matches!(status, ChannelStatus::Ready(..));
if ready && !ids.contains(&m.0) && taken < maximum_channels { if ready && !ids.contains(&m.0) && taken < maximum_channels {
ids.insert(m.0); ids.insert(m.0);
@@ -138,14 +135,14 @@ impl XcmpMessageSource for FromThreadLocal {
true true
} }
}) })
); });
result result
} }
} }
impl DmpMessageHandler for SaveIntoThreadLocal { impl DmpMessageHandler for SaveIntoThreadLocal {
fn handle_dmp_messages( fn handle_dmp_messages(
iter: impl Iterator<Item=(RelayBlockNumber, Vec<u8>)>, iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
_max_weight: Weight, _max_weight: Weight,
) -> Weight { ) -> Weight {
HANDLED_DMP_MESSAGES.with(|m| { HANDLED_DMP_MESSAGES.with(|m| {
@@ -158,7 +155,7 @@ impl DmpMessageHandler for SaveIntoThreadLocal {
} }
impl XcmpMessageHandler for SaveIntoThreadLocal { impl XcmpMessageHandler for SaveIntoThreadLocal {
fn handle_xcmp_messages<'a, I: Iterator<Item=(ParaId, RelayBlockNumber, &'a [u8])>>( fn handle_xcmp_messages<'a, I: Iterator<Item = (ParaId, RelayBlockNumber, &'a [u8])>>(
iter: I, iter: I,
_max_weight: Weight, _max_weight: Weight,
) -> Weight { ) -> Weight {
@@ -177,10 +174,7 @@ fn new_test_ext() -> sp_io::TestExternalities {
HANDLED_DMP_MESSAGES.with(|m| m.borrow_mut().clear()); HANDLED_DMP_MESSAGES.with(|m| m.borrow_mut().clear());
HANDLED_XCMP_MESSAGES.with(|m| m.borrow_mut().clear()); HANDLED_XCMP_MESSAGES.with(|m| m.borrow_mut().clear());
frame_system::GenesisConfig::default() frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
.build_storage::<Test>()
.unwrap()
.into()
} }
struct ReadRuntimeVersion(Vec<u8>); struct ReadRuntimeVersion(Vec<u8>);
@@ -204,9 +198,9 @@ fn wasm_ext() -> sp_io::TestExternalities {
}; };
let mut ext = new_test_ext(); let mut ext = new_test_ext();
ext.register_extension(sp_core::traits::ReadRuntimeVersionExt::new( ext.register_extension(sp_core::traits::ReadRuntimeVersionExt::new(ReadRuntimeVersion(
ReadRuntimeVersion(version.encode()), version.encode(),
)); )));
ext ext
} }
@@ -247,11 +241,7 @@ impl BlockTests {
where where
F: 'static + Fn(), F: 'static + Fn(),
{ {
self.add_raw(BlockTest { self.add_raw(BlockTest { n, within_block: Box::new(within_block), after_block: None })
n,
within_block: Box::new(within_block),
after_block: None,
})
} }
fn add_with_post_test<F1, F2>( fn add_with_post_test<F1, F2>(
@@ -299,12 +289,7 @@ impl BlockTests {
fn run(&mut self) { fn run(&mut self) {
self.ran = true; self.ran = true;
wasm_ext().execute_with(|| { wasm_ext().execute_with(|| {
for BlockTest { for BlockTest { n, within_block, after_block } in self.tests.iter() {
n,
within_block,
after_block,
} in self.tests.iter()
{
// clear pending updates, as applicable // clear pending updates, as applicable
if let Some(upgrade_block) = self.pending_upgrade { if let Some(upgrade_block) = self.pending_upgrade {
if n >= &upgrade_block.into() { if n >= &upgrade_block.into() {
@@ -313,12 +298,7 @@ impl BlockTests {
} }
// begin initialization // begin initialization
System::initialize( System::initialize(&n, &Default::default(), &Default::default(), InitKind::Full);
&n,
&Default::default(),
&Default::default(),
InitKind::Full,
);
// now mess with the storage the way validate_block does // now mess with the storage the way validate_block does
let mut sproof_builder = RelayStateSproofBuilder::default(); let mut sproof_builder = RelayStateSproofBuilder::default();
@@ -398,9 +378,7 @@ impl Drop for BlockTests {
#[test] #[test]
#[should_panic] #[should_panic]
fn block_tests_run_on_drop() { fn block_tests_run_on_drop() {
BlockTests::new().add(123, || { BlockTests::new().add(123, || panic!("if this test passes, block tests run properly"));
panic!("if this test passes, block tests run properly")
});
} }
#[test] #[test]
@@ -412,10 +390,7 @@ fn events() {
.add_with_post_test( .add_with_post_test(
123, 123,
|| { || {
assert_ok!(System::set_code( assert_ok!(System::set_code(RawOrigin::Root.into(), Default::default()));
RawOrigin::Root.into(),
Default::default()
));
}, },
|| { || {
let events = System::events(); let events = System::events();
@@ -445,10 +420,7 @@ fn non_overlapping() {
builder.host_config.validation_upgrade_delay = 1000; builder.host_config.validation_upgrade_delay = 1000;
}) })
.add(123, || { .add(123, || {
assert_ok!(System::set_code( assert_ok!(System::set_code(RawOrigin::Root.into(), Default::default()));
RawOrigin::Root.into(),
Default::default()
));
}) })
.add(234, || { .add(234, || {
assert_eq!( assert_eq!(
@@ -466,14 +438,8 @@ fn manipulates_storage() {
!<PendingValidationCode<Test>>::exists(), !<PendingValidationCode<Test>>::exists(),
"validation function must not exist yet" "validation function must not exist yet"
); );
assert_ok!(System::set_code( assert_ok!(System::set_code(RawOrigin::Root.into(), Default::default()));
RawOrigin::Root.into(), assert!(<PendingValidationCode<Test>>::exists(), "validation function must now exist");
Default::default()
));
assert!(
<PendingValidationCode<Test>>::exists(),
"validation function must now exist"
);
}) })
.add_with_post_test( .add_with_post_test(
1234, 1234,
@@ -573,10 +539,7 @@ fn send_hrmp_message_buffer_channel_close() {
sproof.para_id = ParaId::from(200); sproof.para_id = ParaId::from(200);
sproof.hrmp_egress_channel_index = Some(vec![ParaId::from(300), ParaId::from(400)]); sproof.hrmp_egress_channel_index = Some(vec![ParaId::from(300), ParaId::from(400)]);
sproof.hrmp_channels.insert( sproof.hrmp_channels.insert(
HrmpChannelId { HrmpChannelId { sender: ParaId::from(200), recipient: ParaId::from(300) },
sender: ParaId::from(200),
recipient: ParaId::from(300),
},
AbridgedHrmpChannel { AbridgedHrmpChannel {
max_capacity: 1, max_capacity: 1,
msg_count: 1, // <- 1/1 means the channel is full msg_count: 1, // <- 1/1 means the channel is full
@@ -587,10 +550,7 @@ fn send_hrmp_message_buffer_channel_close() {
}, },
); );
sproof.hrmp_channels.insert( sproof.hrmp_channels.insert(
HrmpChannelId { HrmpChannelId { sender: ParaId::from(200), recipient: ParaId::from(400) },
sender: ParaId::from(200),
recipient: ParaId::from(400),
},
AbridgedHrmpChannel { AbridgedHrmpChannel {
max_capacity: 1, max_capacity: 1,
msg_count: 1, msg_count: 1,
@@ -605,8 +565,8 @@ fn send_hrmp_message_buffer_channel_close() {
// Adjustment according to block // Adjustment according to block
// //
match relay_block_num { match relay_block_num {
1 => {} 1 => {},
2 => {} 2 => {},
3 => { 3 => {
// The channel 200->400 ceases to exist at the relay chain block 3 // The channel 200->400 ceases to exist at the relay chain block 3
sproof sproof
@@ -628,21 +588,15 @@ fn send_hrmp_message_buffer_channel_close() {
}) })
.unwrap() .unwrap()
.msg_count = 0; .msg_count = 0;
} },
_ => unreachable!(), _ => unreachable!(),
} }
}) })
.add_with_post_test( .add_with_post_test(
1, 1,
|| { || {
send_message( send_message(ParaId::from(300), b"1".to_vec());
ParaId::from(300), send_message(ParaId::from(400), b"2".to_vec());
b"1".to_vec(),
);
send_message(
ParaId::from(400),
b"2".to_vec(),
);
}, },
|| {}, || {},
) )
@@ -662,10 +616,7 @@ fn send_hrmp_message_buffer_channel_close() {
let v = HrmpOutboundMessages::<Test>::get(); let v = HrmpOutboundMessages::<Test>::get();
assert_eq!( assert_eq!(
v, v,
vec![OutboundHrmpMessage { vec![OutboundHrmpMessage { recipient: ParaId::from(300), data: b"1".to_vec() }]
recipient: ParaId::from(300),
data: b"1".to_vec(),
}]
); );
}, },
); );
@@ -682,27 +633,15 @@ fn message_queue_chain() {
// These cases are taken from https://github.com/paritytech/polkadot/pull/2351 // These cases are taken from https://github.com/paritytech/polkadot/pull/2351
assert_eq!( assert_eq!(
MessageQueueChain::default() MessageQueueChain::default()
.extend_downward(&InboundDownwardMessage { .extend_downward(&InboundDownwardMessage { sent_at: 2, msg: vec![1, 2, 3] })
sent_at: 2, .extend_downward(&InboundDownwardMessage { sent_at: 3, msg: vec![4, 5, 6] })
msg: vec![1, 2, 3],
})
.extend_downward(&InboundDownwardMessage {
sent_at: 3,
msg: vec![4, 5, 6],
})
.head(), .head(),
hex!["88dc00db8cc9d22aa62b87807705831f164387dfa49f80a8600ed1cbe1704b6b"].into(), hex!["88dc00db8cc9d22aa62b87807705831f164387dfa49f80a8600ed1cbe1704b6b"].into(),
); );
assert_eq!( assert_eq!(
MessageQueueChain::default() MessageQueueChain::default()
.extend_hrmp(&InboundHrmpMessage { .extend_hrmp(&InboundHrmpMessage { sent_at: 2, data: vec![1, 2, 3] })
sent_at: 2, .extend_hrmp(&InboundHrmpMessage { sent_at: 3, data: vec![4, 5, 6] })
data: vec![1, 2, 3],
})
.extend_hrmp(&InboundHrmpMessage {
sent_at: 3,
data: vec![4, 5, 6],
})
.head(), .head(),
hex!["88dc00db8cc9d22aa62b87807705831f164387dfa49f80a8600ed1cbe1704b6b"].into(), hex!["88dc00db8cc9d22aa62b87807705831f164387dfa49f80a8600ed1cbe1704b6b"].into(),
); );
@@ -722,13 +661,13 @@ fn receive_dmp() {
1 => { 1 => {
sproof.dmq_mqc_head = sproof.dmq_mqc_head =
Some(MessageQueueChain::default().extend_downward(&MSG).head()); Some(MessageQueueChain::default().extend_downward(&MSG).head());
} },
_ => unreachable!(), _ => unreachable!(),
}) })
.with_inherent_data(|_, relay_block_num, data| match relay_block_num { .with_inherent_data(|_, relay_block_num, data| match relay_block_num {
1 => { 1 => {
data.downward_messages.push(MSG.clone()); data.downward_messages.push(MSG.clone());
} },
_ => unreachable!(), _ => unreachable!(),
}) })
.add(1, || { .add(1, || {
@@ -771,7 +710,7 @@ fn receive_hrmp() {
// 300 - one new message // 300 - one new message
sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head =
Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head());
} },
2 => { 2 => {
// 200 - two new messages // 200 - two new messages
// 300 - now present with one message. // 300 - now present with one message.
@@ -784,20 +723,19 @@ fn receive_hrmp() {
.extend_hrmp(&MSG_3) .extend_hrmp(&MSG_3)
.head(), .head(),
); );
} },
3 => { 3 => {
// 200 - no new messages // 200 - no new messages
// 300 - is gone // 300 - is gone
sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head = sproof.upsert_inbound_channel(ParaId::from(200)).mqc_head =
Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head()); Some(MessageQueueChain::default().extend_hrmp(&MSG_4).head());
} },
_ => unreachable!(), _ => unreachable!(),
}) })
.with_inherent_data(|_, relay_block_num, data| match relay_block_num { .with_inherent_data(|_, relay_block_num, data| match relay_block_num {
1 => { 1 => {
data.horizontal_messages data.horizontal_messages.insert(ParaId::from(300), vec![MSG_1.clone()]);
.insert(ParaId::from(300), vec![MSG_1.clone()]); },
}
2 => { 2 => {
data.horizontal_messages.insert( data.horizontal_messages.insert(
ParaId::from(300), ParaId::from(300),
@@ -809,10 +747,9 @@ fn receive_hrmp() {
MSG_3.clone(), MSG_3.clone(),
], ],
); );
data.horizontal_messages data.horizontal_messages.insert(ParaId::from(200), vec![MSG_4.clone()]);
.insert(ParaId::from(200), vec![MSG_4.clone()]); },
} 3 => {},
3 => {}
_ => unreachable!(), _ => unreachable!(),
}) })
.add(1, || { .add(1, || {
@@ -845,12 +782,12 @@ fn receive_hrmp_empty_channel() {
.with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num { .with_relay_sproof_builder(|_, relay_block_num, sproof| match relay_block_num {
1 => { 1 => {
// no channels // no channels
} },
2 => { 2 => {
// one new channel // one new channel
sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head = sproof.upsert_inbound_channel(ParaId::from(300)).mqc_head =
Some(MessageQueueChain::default().head()); Some(MessageQueueChain::default().head());
} },
_ => unreachable!(), _ => unreachable!(),
}) })
.add(1, || {}) .add(1, || {})
@@ -878,33 +815,30 @@ fn receive_hrmp_after_pause() {
1 => { 1 => {
sproof.upsert_inbound_channel(ALICE).mqc_head = sproof.upsert_inbound_channel(ALICE).mqc_head =
Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head());
} },
2 => { 2 => {
// 300 - no new messages, mqc stayed the same. // 300 - no new messages, mqc stayed the same.
sproof.upsert_inbound_channel(ALICE).mqc_head = sproof.upsert_inbound_channel(ALICE).mqc_head =
Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head()); Some(MessageQueueChain::default().extend_hrmp(&MSG_1).head());
} },
3 => { 3 => {
// 300 - new message. // 300 - new message.
sproof.upsert_inbound_channel(ALICE).mqc_head = Some( sproof.upsert_inbound_channel(ALICE).mqc_head = Some(
MessageQueueChain::default() MessageQueueChain::default().extend_hrmp(&MSG_1).extend_hrmp(&MSG_2).head(),
.extend_hrmp(&MSG_1)
.extend_hrmp(&MSG_2)
.head(),
); );
} },
_ => unreachable!(), _ => unreachable!(),
}) })
.with_inherent_data(|_, relay_block_num, data| match relay_block_num { .with_inherent_data(|_, relay_block_num, data| match relay_block_num {
1 => { 1 => {
data.horizontal_messages.insert(ALICE, vec![MSG_1.clone()]); data.horizontal_messages.insert(ALICE, vec![MSG_1.clone()]);
} },
2 => { 2 => {
// no new messages // no new messages
} },
3 => { 3 => {
data.horizontal_messages.insert(ALICE, vec![MSG_2.clone()]); data.horizontal_messages.insert(ALICE, vec![MSG_2.clone()]);
} },
_ => unreachable!(), _ => unreachable!(),
}) })
.add(1, || { .add(1, || {
@@ -16,7 +16,7 @@
//! The actual implementation of the validate block functionality. //! The actual implementation of the validate block functionality.
use frame_support::traits::{ExecuteBlock, ExtrinsicCall, IsSubType, Get}; use frame_support::traits::{ExecuteBlock, ExtrinsicCall, Get, IsSubType};
use sp_runtime::traits::{Block as BlockT, Extrinsic, HashFor, Header as HeaderT, NumberFor}; use sp_runtime::traits::{Block as BlockT, Extrinsic, HashFor, Header as HeaderT, NumberFor};
use sp_io::KillStorageResult; use sp_io::KillStorageResult;
@@ -64,10 +64,7 @@ where
let head_data = HeadData(header.encode()); let head_data = HeadData(header.encode());
let block = B::new(header, extrinsics); let block = B::new(header, extrinsics);
assert!( assert!(parent_head.hash() == *block.header().parent_hash(), "Invalid parent hash",);
parent_head.hash() == *block.header().parent_hash(),
"Invalid parent hash",
);
// Uncompress // Uncompress
let mut db = MemoryDB::default(); let mut db = MemoryDB::default();
@@ -128,7 +125,8 @@ where
.iter() .iter()
.filter_map(|e| e.call().is_sub_type()) .filter_map(|e| e.call().is_sub_type())
.find_map(|c| match c { .find_map(|c| match c {
crate::Call::set_validation_data { data: validation_data } => Some(validation_data.clone()), crate::Call::set_validation_data { data: validation_data } =>
Some(validation_data.clone()),
_ => None, _ => None,
}) })
.expect("Could not find `set_validation_data` inherent"); .expect("Could not find `set_validation_data` inherent");
@@ -196,7 +194,7 @@ fn host_storage_read(key: &[u8], value_out: &mut [u8], value_offset: u32) -> Opt
let written = sp_std::cmp::min(data.len(), value_out.len()); let written = sp_std::cmp::min(data.len(), value_out.len());
value_out[..written].copy_from_slice(&data[..written]); value_out[..written].copy_from_slice(&data[..written]);
Some(value.len() as u32) Some(value.len() as u32)
} },
None => None, None => None,
} }
} }
@@ -276,7 +274,7 @@ fn host_default_child_storage_read(
let written = sp_std::cmp::min(data.len(), value_out.len()); let written = sp_std::cmp::min(data.len(), value_out.len());
value_out[..written].copy_from_slice(&data[..written]); value_out[..written].copy_from_slice(&data[..written]);
Some(value.len() as u32) Some(value.len() as u32)
} },
None => None, None => None,
} }
} }
@@ -312,7 +310,11 @@ fn host_default_child_storage_exists(storage_key: &[u8], key: &[u8]) -> bool {
with_externalities(|ext| ext.exists_child_storage(&child_info, key)) with_externalities(|ext| ext.exists_child_storage(&child_info, key))
} }
fn host_default_child_storage_clear_prefix(storage_key: &[u8], prefix: &[u8], limit: Option<u32>) -> KillStorageResult { fn host_default_child_storage_clear_prefix(
storage_key: &[u8],
prefix: &[u8],
limit: Option<u32>,
) -> KillStorageResult {
let child_info = ChildInfo::new_default(storage_key); let child_info = ChildInfo::new_default(storage_key);
with_externalities(|ext| { with_externalities(|ext| {
let (all_removed, num_removed) = ext.clear_child_prefix(&child_info, prefix, limit); let (all_removed, num_removed) = ext.clear_child_prefix(&child_info, prefix, limit);
@@ -79,16 +79,11 @@ fn build_block_with_witness(
validation_data.relay_parent_storage_root = relay_parent_storage_root; validation_data.relay_parent_storage_root = relay_parent_storage_root;
extra_extrinsics extra_extrinsics.into_iter().for_each(|e| builder.push(e).unwrap());
.into_iter()
.for_each(|e| builder.push(e).unwrap());
let block = builder.build_parachain_block(*parent_head.state_root()); let block = builder.build_parachain_block(*parent_head.state_root());
TestBlockData { TestBlockData { block, validation_data }
block,
validation_data,
}
} }
#[test] #[test]
@@ -96,18 +91,13 @@ fn validate_block_no_extra_extrinsics() {
sp_tracing::try_init_simple(); sp_tracing::try_init_simple();
let (client, parent_head) = create_test_client(); let (client, parent_head) = create_test_client();
let TestBlockData { let TestBlockData { block, validation_data } =
block, build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
validation_data,
} = build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
let header = block.header().clone(); let header = block.header().clone();
let res_header = call_validate_block( let res_header =
parent_head, call_validate_block(parent_head, block, validation_data.relay_parent_storage_root)
block, .expect("Calls `validate_block`");
validation_data.relay_parent_storage_root,
)
.expect("Calls `validate_block`");
assert_eq!(header, res_header); assert_eq!(header, res_header);
} }
@@ -122,10 +112,7 @@ fn validate_block_with_extra_extrinsics() {
transfer(&client, Charlie, Alice, 500), transfer(&client, Charlie, Alice, 500),
]; ];
let TestBlockData { let TestBlockData { block, validation_data } = build_block_with_witness(
block,
validation_data,
} = build_block_with_witness(
&client, &client,
extra_extrinsics, extra_extrinsics,
parent_head.clone(), parent_head.clone(),
@@ -133,12 +120,9 @@ fn validate_block_with_extra_extrinsics() {
); );
let header = block.header().clone(); let header = block.header().clone();
let res_header = call_validate_block( let res_header =
parent_head, call_validate_block(parent_head, block, validation_data.relay_parent_storage_root)
block, .expect("Calls `validate_block`");
validation_data.relay_parent_storage_root,
)
.expect("Calls `validate_block`");
assert_eq!(header, res_header); assert_eq!(header, res_header);
} }
@@ -148,20 +132,14 @@ fn validate_block_invalid_parent_hash() {
if env::var("RUN_TEST").is_ok() { if env::var("RUN_TEST").is_ok() {
let (client, parent_head) = create_test_client(); let (client, parent_head) = create_test_client();
let TestBlockData { let TestBlockData { block, validation_data } =
block, build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
validation_data,
} = build_block_with_witness(&client, vec![], parent_head.clone(), Default::default());
let (mut header, extrinsics, witness) = block.deconstruct(); let (mut header, extrinsics, witness) = block.deconstruct();
header.set_parent_hash(Hash::from_low_u64_be(1)); header.set_parent_hash(Hash::from_low_u64_be(1));
let block_data = ParachainBlockData::new(header, extrinsics, witness); let block_data = ParachainBlockData::new(header, extrinsics, witness);
call_validate_block( call_validate_block(parent_head, block_data, validation_data.relay_parent_storage_root)
parent_head, .unwrap_err();
block_data,
validation_data.relay_parent_storage_root,
)
.unwrap_err();
} else { } else {
let output = Command::new(env::current_exe().unwrap()) let output = Command::new(env::current_exe().unwrap())
.args(&["validate_block_invalid_parent_hash", "--", "--nocapture"]) .args(&["validate_block_invalid_parent_hash", "--", "--nocapture"])
@@ -186,11 +164,7 @@ fn validate_block_fails_on_invalid_validation_data() {
call_validate_block(parent_head, block, Hash::random()).unwrap_err(); call_validate_block(parent_head, block, Hash::random()).unwrap_err();
} else { } else {
let output = Command::new(env::current_exe().unwrap()) let output = Command::new(env::current_exe().unwrap())
.args(&[ .args(&["validate_block_fails_on_invalid_validation_data", "--", "--nocapture"])
"validate_block_fails_on_invalid_validation_data",
"--",
"--nocapture",
])
.env("RUN_TEST", "1") .env("RUN_TEST", "1")
.output() .output()
.expect("Runs the test"); .expect("Runs the test");
@@ -208,32 +182,18 @@ fn check_inherent_fails_on_validate_block_as_expected() {
if env::var("RUN_TEST").is_ok() { if env::var("RUN_TEST").is_ok() {
let (client, parent_head) = create_test_client(); let (client, parent_head) = create_test_client();
let TestBlockData { let TestBlockData { block, validation_data } = build_block_with_witness(
block,
validation_data,
} = build_block_with_witness(
&client, &client,
vec![], vec![],
parent_head.clone(), parent_head.clone(),
RelayStateSproofBuilder { RelayStateSproofBuilder { current_slot: 1337.into(), ..Default::default() },
current_slot: 1337.into(),
..Default::default()
},
); );
call_validate_block( call_validate_block(parent_head, block, validation_data.relay_parent_storage_root)
parent_head, .unwrap_err();
block,
validation_data.relay_parent_storage_root,
)
.unwrap_err();
} else { } else {
let output = Command::new(env::current_exe().unwrap()) let output = Command::new(env::current_exe().unwrap())
.args(&[ .args(&["check_inherent_fails_on_validate_block_as_expected", "--", "--nocapture"])
"check_inherent_fails_on_validate_block_as_expected",
"--",
"--nocapture",
])
.env("RUN_TEST", "1") .env("RUN_TEST", "1")
.output() .output()
.expect("Runs the test"); .expect("Runs the test");
@@ -16,16 +16,14 @@
//! Benchmarking setup for pallet-session //! Benchmarking setup for pallet-session
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
#![cfg(feature = "runtime-benchmarks")] #![cfg(feature = "runtime-benchmarks")]
use sp_std::prelude::*; use sp_std::{prelude::*, vec};
use sp_std::vec;
use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller}; use frame_benchmarking::{benchmarks, impl_benchmark_test_suite, whitelisted_caller};
use frame_system::{RawOrigin}; use frame_system::RawOrigin;
use pallet_session::*; use pallet_session::*;
pub struct Pallet<T: Config>(pallet_session::Pallet<T>); pub struct Pallet<T: Config>(pallet_session::Pallet<T>);
pub trait Config: pallet_session::Config {} pub trait Config: pallet_session::Config {}
benchmarks! { benchmarks! {
set_keys { set_keys {
let caller: T::AccountId = whitelisted_caller(); let caller: T::AccountId = whitelisted_caller();
@@ -43,9 +41,4 @@ benchmarks! {
}: _(RawOrigin::Signed(caller)) }: _(RawOrigin::Signed(caller))
} }
impl_benchmark_test_suite!( impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test, extra = false,);
Pallet,
crate::mock::new_test_ext(),
crate::mock::Test,
extra = false,
);
+22 -19
View File
@@ -20,15 +20,19 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use sp_std::{prelude::*, convert::TryFrom}; use codec::{Decode, Encode};
use cumulus_primitives_core::{ParaId, DmpMessageHandler}; use cumulus_primitives_core::{
use cumulus_primitives_core::relay_chain::BlockNumber as RelayBlockNumber; relay_chain::BlockNumber as RelayBlockNumber, DmpMessageHandler, ParaId,
use codec::{Encode, Decode}; };
use scale_info::TypeInfo;
use sp_runtime::traits::BadOrigin;
use xcm::{VersionedXcm, latest::{Xcm, Outcome, Parent, ExecuteXcm}};
use frame_support::dispatch::Weight; use frame_support::dispatch::Weight;
pub use pallet::*; pub use pallet::*;
use scale_info::TypeInfo;
use sp_runtime::traits::BadOrigin;
use sp_std::{convert::TryFrom, prelude::*};
use xcm::{
latest::{ExecuteXcm, Outcome, Parent, Xcm},
VersionedXcm,
};
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
@@ -50,8 +54,7 @@ pub mod pallet {
} }
#[pallet::error] #[pallet::error]
pub enum Error<T> { pub enum Error<T> {}
}
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {} impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
@@ -106,14 +109,13 @@ pub mod pallet {
pub struct UnlimitedDmpExecution<T>(sp_std::marker::PhantomData<T>); pub struct UnlimitedDmpExecution<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> { impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
fn handle_dmp_messages( fn handle_dmp_messages(
iter: impl Iterator<Item=(RelayBlockNumber, Vec<u8>)>, iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
limit: Weight, limit: Weight,
) -> Weight { ) -> Weight {
let mut used = 0; let mut used = 0;
for (_sent_at, data) in iter { for (_sent_at, data) in iter {
let id = sp_io::hashing::twox_64(&data[..]); let id = sp_io::hashing::twox_64(&data[..]);
let msg = VersionedXcm::<T::Call>::decode(&mut &data[..]) let msg = VersionedXcm::<T::Call>::decode(&mut &data[..]).map(Xcm::<T::Call>::try_from);
.map(Xcm::<T::Call>::try_from);
match msg { match msg {
Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)), Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)),
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)), Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
@@ -121,7 +123,7 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, limit); let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, limit);
used += outcome.weight_used(); used += outcome.weight_used();
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome)); Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
} },
} }
} }
used used
@@ -136,14 +138,13 @@ impl<T: Config> DmpMessageHandler for UnlimitedDmpExecution<T> {
pub struct LimitAndDropDmpExecution<T>(sp_std::marker::PhantomData<T>); pub struct LimitAndDropDmpExecution<T>(sp_std::marker::PhantomData<T>);
impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> { impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
fn handle_dmp_messages( fn handle_dmp_messages(
iter: impl Iterator<Item=(RelayBlockNumber, Vec<u8>)>, iter: impl Iterator<Item = (RelayBlockNumber, Vec<u8>)>,
limit: Weight, limit: Weight,
) -> Weight { ) -> Weight {
let mut used = 0; let mut used = 0;
for (_sent_at, data) in iter { for (_sent_at, data) in iter {
let id = sp_io::hashing::twox_64(&data[..]); let id = sp_io::hashing::twox_64(&data[..]);
let msg = VersionedXcm::<T::Call>::decode(&mut &data[..]) let msg = VersionedXcm::<T::Call>::decode(&mut &data[..]).map(Xcm::<T::Call>::try_from);
.map(Xcm::<T::Call>::try_from);
match msg { match msg {
Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)), Err(_) => Pallet::<T>::deposit_event(Event::InvalidFormat(id)),
Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)), Ok(Err(())) => Pallet::<T>::deposit_event(Event::UnsupportedVersion(id)),
@@ -152,7 +153,7 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, weight_limit); let outcome = T::XcmExecutor::execute_xcm(Parent.into(), x, weight_limit);
used += outcome.weight_used(); used += outcome.weight_used();
Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome)); Pallet::<T>::deposit_event(Event::ExecutedDownward(id, outcome));
} },
} }
} }
used used
@@ -162,7 +163,8 @@ impl<T: Config> DmpMessageHandler for LimitAndDropDmpExecution<T> {
/// Ensure that the origin `o` represents a sibling parachain. /// Ensure that the origin `o` represents a sibling parachain.
/// Returns `Ok` with the parachain ID of the sibling or an `Err` otherwise. /// Returns `Ok` with the parachain ID of the sibling or an `Err` otherwise.
pub fn ensure_sibling_para<OuterOrigin>(o: OuterOrigin) -> Result<ParaId, BadOrigin> pub fn ensure_sibling_para<OuterOrigin>(o: OuterOrigin) -> Result<ParaId, BadOrigin>
where OuterOrigin: Into<Result<Origin, OuterOrigin>> where
OuterOrigin: Into<Result<Origin, OuterOrigin>>,
{ {
match o.into() { match o.into() {
Ok(Origin::SiblingParachain(id)) => Ok(id), Ok(Origin::SiblingParachain(id)) => Ok(id),
@@ -173,7 +175,8 @@ pub fn ensure_sibling_para<OuterOrigin>(o: OuterOrigin) -> Result<ParaId, BadOri
/// Ensure that the origin `o` represents is the relay chain. /// Ensure that the origin `o` represents is the relay chain.
/// Returns `Ok` if it does or an `Err` otherwise. /// Returns `Ok` if it does or an `Err` otherwise.
pub fn ensure_relay<OuterOrigin>(o: OuterOrigin) -> Result<(), BadOrigin> pub fn ensure_relay<OuterOrigin>(o: OuterOrigin) -> Result<(), BadOrigin>
where OuterOrigin: Into<Result<Origin, OuterOrigin>> where
OuterOrigin: Into<Result<Origin, OuterOrigin>>,
{ {
match o.into() { match o.into() {
Ok(Origin::Relay) => Ok(()), Ok(Origin::Relay) => Ok(()),
+54 -84
View File
@@ -34,7 +34,7 @@ mod tests;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use cumulus_primitives_core::{ use cumulus_primitives_core::{
relay_chain::BlockNumber as RelayBlockNumber, ChannelStatus, GetChannelInfo, MessageSendError, relay_chain::BlockNumber as RelayBlockNumber, ChannelStatus, GetChannelInfo, MessageSendError,
ParaId, XcmpMessageHandler, XcmpMessageSource, XcmpMessageFormat, ParaId, XcmpMessageFormat, XcmpMessageHandler, XcmpMessageSource,
}; };
use frame_support::weights::Weight; use frame_support::weights::Weight;
use rand_chacha::{ use rand_chacha::{
@@ -43,8 +43,8 @@ use rand_chacha::{
}; };
use scale_info::TypeInfo; use scale_info::TypeInfo;
use sp_runtime::{traits::Hash, RuntimeDebug}; use sp_runtime::{traits::Hash, RuntimeDebug};
use sp_std::{prelude::*, convert::TryFrom}; use sp_std::{convert::TryFrom, prelude::*};
use xcm::{latest::prelude::*, WrapVersion, VersionedXcm}; use xcm::{latest::prelude::*, VersionedXcm, WrapVersion};
pub use pallet::*; pub use pallet::*;
@@ -126,11 +126,7 @@ pub mod pallet {
#[pallet::storage] #[pallet::storage]
pub(super) type InboundXcmpStatus<T: Config> = StorageValue< pub(super) type InboundXcmpStatus<T: Config> = StorageValue<
_, _,
Vec<( Vec<(ParaId, InboundStatus, Vec<(RelayBlockNumber, XcmpMessageFormat)>)>,
ParaId,
InboundStatus,
Vec<(RelayBlockNumber, XcmpMessageFormat)>,
)>,
ValueQuery, ValueQuery,
>; >;
@@ -242,28 +238,25 @@ impl<T: Config> Pallet<T> {
let max_message_size = let max_message_size =
T::ChannelInfo::get_channel_max(recipient).ok_or(MessageSendError::NoChannel)?; T::ChannelInfo::get_channel_max(recipient).ok_or(MessageSendError::NoChannel)?;
if data.len() > max_message_size { if data.len() > max_message_size {
return Err(MessageSendError::TooBig); return Err(MessageSendError::TooBig)
} }
let mut s = <OutboundXcmpStatus<T>>::get(); let mut s = <OutboundXcmpStatus<T>>::get();
let index = s let index = s.iter().position(|item| item.0 == recipient).unwrap_or_else(|| {
.iter() s.push((recipient, OutboundStatus::Ok, false, 0, 0));
.position(|item| item.0 == recipient) s.len() - 1
.unwrap_or_else(|| { });
s.push((recipient, OutboundStatus::Ok, false, 0, 0));
s.len() - 1
});
let have_active = s[index].4 > s[index].3; let have_active = s[index].4 > s[index].3;
let appended = have_active let appended = have_active &&
&& <OutboundXcmpMessages<T>>::mutate(recipient, s[index].4 - 1, |s| { <OutboundXcmpMessages<T>>::mutate(recipient, s[index].4 - 1, |s| {
if XcmpMessageFormat::decode(&mut &s[..]) != Ok(format) { if XcmpMessageFormat::decode(&mut &s[..]) != Ok(format) {
return false; return false
} }
if s.len() + data.len() > max_message_size { if s.len() + data.len() > max_message_size {
return false; return false
} }
s.extend_from_slice(&data[..]); s.extend_from_slice(&data[..]);
return true; return true
}); });
if appended { if appended {
Ok((s[index].4 - s[index].3 - 1) as u32) Ok((s[index].4 - s[index].3 - 1) as u32)
@@ -316,10 +309,9 @@ impl<T: Config> Pallet<T> {
// Create a shuffled order for use to iterate through. // Create a shuffled order for use to iterate through.
// Not a great random seed, but good enough for our purposes. // Not a great random seed, but good enough for our purposes.
let seed = frame_system::Pallet::<T>::parent_hash(); let seed = frame_system::Pallet::<T>::parent_hash();
let seed = <[u8; 32]>::decode(&mut sp_runtime::traits::TrailingZeroInput::new( let seed =
seed.as_ref(), <[u8; 32]>::decode(&mut sp_runtime::traits::TrailingZeroInput::new(seed.as_ref()))
)) .expect("input is padded with zeroes; qed");
.expect("input is padded with zeroes; qed");
let mut rng = ChaChaRng::from_seed(seed); let mut rng = ChaChaRng::from_seed(seed);
let mut shuffled = (0..len).collect::<Vec<_>>(); let mut shuffled = (0..len).collect::<Vec<_>>();
for i in 0..len { for i in 0..len {
@@ -359,11 +351,8 @@ impl<T: Config> Pallet<T> {
// we just report the weight used. // we just report the weight used.
Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)), Outcome::Incomplete(w, e) => (Ok(w), Event::Fail(Some(hash), e)),
} }
} },
Err(()) => ( Err(()) => (Err(XcmError::UnhandledXcmVersion), Event::BadVersion(Some(hash))),
Err(XcmError::UnhandledXcmVersion),
Event::BadVersion(Some(hash)),
),
}; };
Self::deposit_event(event); Self::deposit_event(event);
result result
@@ -390,18 +379,18 @@ impl<T: Config> Pallet<T> {
// That message didn't get processed this time because of being // That message didn't get processed this time because of being
// too heavy. We leave it around for next time and bail. // too heavy. We leave it around for next time and bail.
remaining_fragments = last_remaining_fragments; remaining_fragments = last_remaining_fragments;
break; break
} },
Err(_) => { Err(_) => {
// Message looks invalid; don't attempt to retry // Message looks invalid; don't attempt to retry
} },
} }
} else { } else {
debug_assert!(false, "Invalid incoming XCMP message data"); debug_assert!(false, "Invalid incoming XCMP message data");
remaining_fragments = &b""[..]; remaining_fragments = &b""[..];
} }
} }
} },
XcmpMessageFormat::ConcatenatedEncodedBlob => { XcmpMessageFormat::ConcatenatedEncodedBlob => {
while !remaining_fragments.is_empty() { while !remaining_fragments.is_empty() {
last_remaining_fragments = remaining_fragments; last_remaining_fragments = remaining_fragments;
@@ -413,22 +402,22 @@ impl<T: Config> Pallet<T> {
// That message didn't get processed this time because of being // That message didn't get processed this time because of being
// too heavy. We leave it around for next time and bail. // too heavy. We leave it around for next time and bail.
remaining_fragments = last_remaining_fragments; remaining_fragments = last_remaining_fragments;
break; break
} },
Err(false) => { Err(false) => {
// Message invalid; don't attempt to retry // Message invalid; don't attempt to retry
} },
} }
} else { } else {
debug_assert!(false, "Invalid incoming blob message data"); debug_assert!(false, "Invalid incoming blob message data");
remaining_fragments = &b""[..]; remaining_fragments = &b""[..];
} }
} }
} },
XcmpMessageFormat::Signals => { XcmpMessageFormat::Signals => {
debug_assert!(false, "All signals are handled immediately; qed"); debug_assert!(false, "All signals are handled immediately; qed");
remaining_fragments = &b""[..]; remaining_fragments = &b""[..];
} },
} }
let is_empty = remaining_fragments.is_empty(); let is_empty = remaining_fragments.is_empty();
if is_empty { if is_empty {
@@ -469,15 +458,11 @@ impl<T: Config> Pallet<T> {
fn service_xcmp_queue(max_weight: Weight) -> Weight { fn service_xcmp_queue(max_weight: Weight) -> Weight {
let mut status = <InboundXcmpStatus<T>>::get(); // <- sorted. let mut status = <InboundXcmpStatus<T>>::get(); // <- sorted.
if status.len() == 0 { if status.len() == 0 {
return 0; return 0
} }
let QueueConfigData { let QueueConfigData { resume_threshold, threshold_weight, weight_restrict_decay, .. } =
resume_threshold, <QueueConfig<T>>::get();
threshold_weight,
weight_restrict_decay,
..
} = <QueueConfig<T>>::get();
let mut shuffled = Self::create_shuffle(status.len()); let mut shuffled = Self::create_shuffle(status.len());
let mut weight_used = 0; let mut weight_used = 0;
@@ -492,8 +477,8 @@ impl<T: Config> Pallet<T> {
// send more, heavier messages. // send more, heavier messages.
let mut shuffle_index = 0; let mut shuffle_index = 0;
while shuffle_index < shuffled.len() while shuffle_index < shuffled.len() &&
&& max_weight.saturating_sub(weight_used) >= threshold_weight max_weight.saturating_sub(weight_used) >= threshold_weight
{ {
let index = shuffled[shuffle_index]; let index = shuffled[shuffle_index];
let sender = status[index].0; let sender = status[index].0;
@@ -514,10 +499,7 @@ impl<T: Config> Pallet<T> {
} }
let weight_processed = if status[index].2.is_empty() { let weight_processed = if status[index].2.is_empty() {
debug_assert!( debug_assert!(false, "channel exists in status; there must be messages; qed");
false,
"channel exists in status; there must be messages; qed"
);
0 0
} else { } else {
// Process up to one block's worth for now. // Process up to one block's worth for now.
@@ -531,26 +513,24 @@ impl<T: Config> Pallet<T> {
}; };
weight_used += weight_processed; weight_used += weight_processed;
if status[index].2.len() as u32 <= resume_threshold if status[index].2.len() as u32 <= resume_threshold &&
&& status[index].1 == InboundStatus::Suspended status[index].1 == InboundStatus::Suspended
{ {
// Resume // Resume
let r = Self::send_signal(sender, ChannelSignal::Resume); let r = Self::send_signal(sender, ChannelSignal::Resume);
debug_assert!( debug_assert!(r.is_ok(), "WARNING: Failed sending resume into suspended channel");
r.is_ok(),
"WARNING: Failed sending resume into suspended channel"
);
status[index].1 = InboundStatus::Ok; status[index].1 = InboundStatus::Ok;
} }
// If there are more and we're making progress, we process them after we've given the // If there are more and we're making progress, we process them after we've given the
// other channels a look in. If we've still not unlocked all weight, then we set them // other channels a look in. If we've still not unlocked all weight, then we set them
// up for processing a second time anyway. // up for processing a second time anyway.
if !status[index].2.is_empty() && (weight_processed > 0 || weight_available != max_weight) if !status[index].2.is_empty() &&
(weight_processed > 0 || weight_available != max_weight)
{ {
if shuffle_index + 1 == shuffled.len() { if shuffle_index + 1 == shuffled.len() {
// Only this queue left. Just run around this loop once more. // Only this queue left. Just run around this loop once more.
continue; continue
} }
shuffled.push(index); shuffled.push(index);
} }
@@ -590,10 +570,7 @@ impl<T: Config> Pallet<T> {
s[index].1 = OutboundStatus::Ok; s[index].1 = OutboundStatus::Ok;
} }
} else { } else {
debug_assert!( debug_assert!(false, "WARNING: Attempt to resume channel that was not suspended.");
false,
"WARNING: Attempt to resume channel that was not suspended."
);
} }
}); });
} }
@@ -606,11 +583,7 @@ impl<T: Config> XcmpMessageHandler for Pallet<T> {
) -> Weight { ) -> Weight {
let mut status = <InboundXcmpStatus<T>>::get(); let mut status = <InboundXcmpStatus<T>>::get();
let QueueConfigData { let QueueConfigData { suspend_threshold, drop_threshold, .. } = <QueueConfig<T>>::get();
suspend_threshold,
drop_threshold,
..
} = <QueueConfig<T>>::get();
for (sender, sent_at, data) in iter { for (sender, sent_at, data) in iter {
// Figure out the message format. // Figure out the message format.
@@ -618,12 +591,9 @@ impl<T: Config> XcmpMessageHandler for Pallet<T> {
let format = match XcmpMessageFormat::decode(&mut data_ref) { let format = match XcmpMessageFormat::decode(&mut data_ref) {
Ok(f) => f, Ok(f) => f,
Err(_) => { Err(_) => {
debug_assert!( debug_assert!(false, "Unknown XCMP message format. Silently dropping message");
false, continue
"Unknown XCMP message format. Silently dropping message" },
);
continue;
}
}; };
if format == XcmpMessageFormat::Signals { if format == XcmpMessageFormat::Signals {
while !data_ref.is_empty() { while !data_ref.is_empty() {
@@ -656,7 +626,7 @@ impl<T: Config> XcmpMessageHandler for Pallet<T> {
"XCMP channel queue full. Silently dropping message" "XCMP channel queue full. Silently dropping message"
); );
} }
} },
Err(_) => status.push((sender, InboundStatus::Ok, vec![(sent_at, format)])), Err(_) => status.push((sender, InboundStatus::Ok, vec![(sent_at, format)])),
} }
// Queue the payload for later execution. // Queue the payload for later execution.
@@ -686,10 +656,10 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
if result.len() == max_message_count { if result.len() == max_message_count {
// We check this condition in the beginning of the loop so that we don't include // We check this condition in the beginning of the loop so that we don't include
// a message where the limit is 0. // a message where the limit is 0.
break; break
} }
if outbound_status == OutboundStatus::Suspended { if outbound_status == OutboundStatus::Suspended {
continue; continue
} }
let (max_size_now, max_size_ever) = match T::ChannelInfo::get_channel_status(para_id) { let (max_size_now, max_size_ever) = match T::ChannelInfo::get_channel_status(para_id) {
ChannelStatus::Closed => { ChannelStatus::Closed => {
@@ -702,8 +672,8 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
<SignalMessages<T>>::remove(para_id); <SignalMessages<T>>::remove(para_id);
} }
*status = (para_id, OutboundStatus::Ok, false, 0, 0); *status = (para_id, OutboundStatus::Ok, false, 0, 0);
continue; continue
} },
ChannelStatus::Full => continue, ChannelStatus::Full => continue,
ChannelStatus::Ready(n, e) => (n, e), ChannelStatus::Ready(n, e) => (n, e),
}; };
@@ -715,7 +685,7 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
signalling = false; signalling = false;
page page
} else { } else {
continue; continue
} }
} else if end > begin { } else if end > begin {
let page = <OutboundXcmpMessages<T>>::get(para_id, begin); let page = <OutboundXcmpMessages<T>>::get(para_id, begin);
@@ -724,10 +694,10 @@ impl<T: Config> XcmpMessageSource for Pallet<T> {
begin += 1; begin += 1;
page page
} else { } else {
continue; continue
} }
} else { } else {
continue; continue
}; };
if begin == end { if begin == end {
begin = 0; begin = 0;
@@ -789,7 +759,7 @@ impl<T: Config> SendXcm for Pallet<T> {
.map_err(|e| SendError::Transport(<&'static str>::from(e)))?; .map_err(|e| SendError::Transport(<&'static str>::from(e)))?;
Self::deposit_event(Event::XcmpMessageSent(Some(hash))); Self::deposit_event(Event::XcmpMessageSent(Some(hash)));
Ok(()) Ok(())
} },
// Anything else is unhandled. This includes a message this is meant for us. // Anything else is unhandled. This includes a message this is meant for us.
_ => Err(SendError::CannotReachDestination(dest, msg)), _ => Err(SendError::CannotReachDestination(dest, msg)),
} }
+7 -7
View File
@@ -15,12 +15,14 @@
use super::*; use super::*;
use crate as xcmp_queue; use crate as xcmp_queue;
use sp_core::H256;
use frame_support::parameter_types; use frame_support::parameter_types;
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup}, testing::Header}; use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
};
use xcm_builder::{ use xcm_builder::{
FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, CurrencyAdapter, CurrencyAdapter, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset, ParentIsDefault,
ParentIsDefault,
}; };
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>; type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
@@ -124,9 +126,7 @@ pub type LocalAssetTransactor = CurrencyAdapter<
(), (),
>; >;
pub type LocationToAccountId = ( pub type LocationToAccountId = (ParentIsDefault<AccountId>,);
ParentIsDefault<AccountId>,
);
pub struct XcmConfig; pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig { impl xcm_executor::Config for XcmConfig {
+3 -12
View File
@@ -14,25 +14,16 @@
// limitations under the License. // limitations under the License.
use super::*; use super::*;
use mock::{new_test_ext, XcmpQueue};
use cumulus_primitives_core::XcmpMessageHandler; use cumulus_primitives_core::XcmpMessageHandler;
use mock::{new_test_ext, XcmpQueue};
#[test] #[test]
fn one_message_does_not_panic() { fn one_message_does_not_panic() {
new_test_ext().execute_with(|| { new_test_ext().execute_with(|| {
let message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode(); let message_format = XcmpMessageFormat::ConcatenatedVersionedXcm.encode();
let messages = vec![ let messages = vec![(Default::default(), 1u32.into(), message_format.as_slice())];
(
Default::default(),
1u32.into(),
message_format.as_slice(),
),
];
// This shouldn't cause a panic // This shouldn't cause a panic
XcmpQueue::handle_xcmp_messages( XcmpQueue::handle_xcmp_messages(messages.into_iter(), Weight::max_value());
messages.into_iter(),
Weight::max_value(),
);
}) })
} }
@@ -22,9 +22,9 @@ pub use pallet::*;
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
use cumulus_primitives_core::ParaId;
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*; use frame_system::pallet_prelude::*;
use cumulus_primitives_core::ParaId;
#[pallet::pallet] #[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)] #[pallet::generate_store(pub(super) trait Store)]
@@ -47,9 +47,7 @@ pub mod pallet {
#[cfg(feature = "std")] #[cfg(feature = "std")]
impl Default for GenesisConfig { impl Default for GenesisConfig {
fn default() -> Self { fn default() -> Self {
Self { Self { parachain_id: 100.into() }
parachain_id: 100.into()
}
} }
} }
@@ -61,11 +59,14 @@ pub mod pallet {
} }
#[pallet::type_value] #[pallet::type_value]
pub(super) fn DefaultForParachainId() -> ParaId { 100.into() } pub(super) fn DefaultForParachainId() -> ParaId {
100.into()
}
#[pallet::storage] #[pallet::storage]
#[pallet::getter(fn parachain_id)] #[pallet::getter(fn parachain_id)]
pub(super) type ParachainId<T: Config> = StorageValue<_, ParaId, ValueQuery, DefaultForParachainId>; pub(super) type ParachainId<T: Config> =
StorageValue<_, ParaId, ValueQuery, DefaultForParachainId>;
impl<T: Config> Get<ParaId> for Pallet<T> { impl<T: Config> Get<ParaId> for Pallet<T> {
fn get() -> ParaId { fn get() -> ParaId {
@@ -18,20 +18,20 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use cumulus_pallet_xcm::{ensure_sibling_para, Origin as CumulusOrigin};
use cumulus_primitives_core::ParaId;
use frame_system::Config as SystemConfig;
use sp_runtime::traits::Saturating;
use sp_std::prelude::*; use sp_std::prelude::*;
use xcm::latest::prelude::*; use xcm::latest::prelude::*;
use sp_runtime::traits::Saturating;
use frame_system::Config as SystemConfig;
use cumulus_primitives_core::ParaId;
use cumulus_pallet_xcm::{Origin as CumulusOrigin, ensure_sibling_para};
pub use pallet::*; pub use pallet::*;
#[frame_support::pallet] #[frame_support::pallet]
pub mod pallet { pub mod pallet {
use super::*;
use frame_support::pallet_prelude::*; use frame_support::pallet_prelude::*;
use frame_system::pallet_prelude::*; use frame_system::pallet_prelude::*;
use super::*;
#[pallet::pallet] #[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)] #[pallet::generate_store(pub(super) trait Store)]
@@ -43,7 +43,8 @@ pub mod pallet {
/// The overarching event type. /// The overarching event type.
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>; type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
type Origin: From<<Self as SystemConfig>::Origin> + Into<Result<CumulusOrigin, <Self as Config>::Origin>>; type Origin: From<<Self as SystemConfig>::Origin>
+ Into<Result<CumulusOrigin, <Self as Config>::Origin>>;
/// The overarching call type; we assume sibling chains use the same type. /// The overarching call type; we assume sibling chains use the same type.
type Call: From<Call<Self>> + Encode; type Call: From<Call<Self>> + Encode;
@@ -53,29 +54,16 @@ pub mod pallet {
/// The target parachains to ping. /// The target parachains to ping.
#[pallet::storage] #[pallet::storage]
pub(super) type Targets<T: Config> = StorageValue< pub(super) type Targets<T: Config> = StorageValue<_, Vec<(ParaId, Vec<u8>)>, ValueQuery>;
_,
Vec<(ParaId, Vec<u8>)>,
ValueQuery,
>;
/// The total number of pings sent. /// The total number of pings sent.
#[pallet::storage] #[pallet::storage]
pub(super) type PingCount<T: Config> = StorageValue< pub(super) type PingCount<T: Config> = StorageValue<_, u32, ValueQuery>;
_,
u32,
ValueQuery,
>;
/// The sent pings. /// The sent pings.
#[pallet::storage] #[pallet::storage]
pub(super) type Pings<T: Config> = StorageMap< pub(super) type Pings<T: Config> =
_, StorageMap<_, Blake2_128Concat, u32, T::BlockNumber, OptionQuery>;
Blake2_128Concat,
u32,
T::BlockNumber,
OptionQuery,
>;
#[pallet::event] #[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)] #[pallet::generate_deposit(pub(super) fn deposit_event)]
@@ -94,17 +82,23 @@ pub mod pallet {
#[pallet::hooks] #[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> { impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_finalize( fn on_finalize(n: T::BlockNumber) {
n: T::BlockNumber,
) {
for (para, payload) in Targets::<T>::get().into_iter() { for (para, payload) in Targets::<T>::get().into_iter() {
let seq = PingCount::<T>::mutate(|seq| { *seq += 1; *seq }); let seq = PingCount::<T>::mutate(|seq| {
*seq += 1;
*seq
});
match T::XcmSender::send_xcm( match T::XcmSender::send_xcm(
(1, Junction::Parachain(para.into())).into(), (1, Junction::Parachain(para.into())).into(),
Xcm(vec![Transact { Xcm(vec![Transact {
origin_type: OriginKind::Native, origin_type: OriginKind::Native,
require_weight_at_most: 1_000, require_weight_at_most: 1_000,
call: <T as Config>::Call::from(Call::<T>::ping { seq, payload: payload.clone() }).encode().into(), call: <T as Config>::Call::from(Call::<T>::ping {
seq,
payload: payload.clone(),
})
.encode()
.into(),
}]), }]),
) { ) {
Ok(()) => { Ok(()) => {
@@ -113,7 +107,7 @@ pub mod pallet {
}, },
Err(e) => { Err(e) => {
Self::deposit_event(Event::ErrorSendingPing(e, para, seq, payload)); Self::deposit_event(Event::ErrorSendingPing(e, para, seq, payload));
} },
} }
} }
} }
@@ -129,7 +123,12 @@ pub mod pallet {
} }
#[pallet::weight(0)] #[pallet::weight(0)]
pub fn start_many(origin: OriginFor<T>, para: ParaId, count: u32, payload: Vec<u8>) -> DispatchResult { pub fn start_many(
origin: OriginFor<T>,
para: ParaId,
count: u32,
payload: Vec<u8>,
) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
for _ in 0..count { for _ in 0..count {
Targets::<T>::mutate(|t| t.push((para, payload.clone()))); Targets::<T>::mutate(|t| t.push((para, payload.clone())));
@@ -140,7 +139,11 @@ pub mod pallet {
#[pallet::weight(0)] #[pallet::weight(0)]
pub fn stop(origin: OriginFor<T>, para: ParaId) -> DispatchResult { pub fn stop(origin: OriginFor<T>, para: ParaId) -> DispatchResult {
ensure_root(origin)?; ensure_root(origin)?;
Targets::<T>::mutate(|t| if let Some(p) = t.iter().position(|(p, _)| p == &para) { t.swap_remove(p); }); Targets::<T>::mutate(|t| {
if let Some(p) = t.iter().position(|(p, _)| p == &para) {
t.swap_remove(p);
}
});
Ok(()) Ok(())
} }
@@ -166,7 +169,12 @@ pub mod pallet {
Xcm(vec![Transact { Xcm(vec![Transact {
origin_type: OriginKind::Native, origin_type: OriginKind::Native,
require_weight_at_most: 1_000, require_weight_at_most: 1_000,
call: <T as Config>::Call::from(Call::<T>::pong { seq, payload: payload.clone() } ).encode().into(), call: <T as Config>::Call::from(Call::<T>::pong {
seq,
payload: payload.clone(),
})
.encode()
.into(),
}]), }]),
) { ) {
Ok(()) => Self::deposit_event(Event::PongSent(para, seq, payload)), Ok(()) => Self::deposit_event(Event::PongSent(para, seq, payload)),
@@ -181,7 +189,12 @@ pub mod pallet {
let para = ensure_sibling_para(<T as Config>::Origin::from(origin))?; let para = ensure_sibling_para(<T as Config>::Origin::from(origin))?;
if let Some(sent_at) = Pings::<T>::take(seq) { if let Some(sent_at) = Pings::<T>::take(seq) {
Self::deposit_event(Event::Ponged(para, seq, payload, frame_system::Pallet::<T>::block_number().saturating_sub(sent_at))); Self::deposit_event(Event::Ponged(
para,
seq,
payload,
frame_system::Pallet::<T>::block_number().saturating_sub(sent_at),
));
} else { } else {
// Pong received for a ping we apparently didn't send?! // Pong received for a ping we apparently didn't send?!
Self::deposit_event(Event::UnknownPong(para, seq, payload)); Self::deposit_event(Event::UnknownPong(para, seq, payload));
@@ -185,9 +185,7 @@ mod tests {
} }
pub fn new_test_ext() -> sp_io::TestExternalities { pub fn new_test_ext() -> sp_io::TestExternalities {
let mut t = frame_system::GenesisConfig::default() let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
.build_storage::<Test>()
.unwrap();
// We use default for brevity, but you can configure as desired if needed. // We use default for brevity, but you can configure as desired if needed.
pallet_balances::GenesisConfig::<Test>::default() pallet_balances::GenesisConfig::<Test>::default()
.assimilate_storage(&mut t) .assimilate_storage(&mut t)
@@ -107,10 +107,7 @@ pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
runtime_version: VERSION,
can_author_with: Default::default(),
}
} }
/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers. /// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.
+1 -4
View File
@@ -75,10 +75,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
runtime_version: VERSION,
can_author_with: Default::default(),
}
} }
/// We assume that ~10% of the block weight is consumed by `on_initialize` handlers. /// We assume that ~10% of the block weight is consumed by `on_initialize` handlers.
+18 -72
View File
@@ -72,10 +72,7 @@ pub fn get_chain_spec(id: ParaId) -> ChainSpec {
move || { move || {
testnet_genesis( testnet_genesis(
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![ vec![get_from_seed::<AuraId>("Alice"), get_from_seed::<AuraId>("Bob")],
get_from_seed::<AuraId>("Alice"),
get_from_seed::<AuraId>("Bob"),
],
vec![ vec![
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"), get_account_id_from_seed::<sr25519::Public>("Bob"),
@@ -97,10 +94,7 @@ pub fn get_chain_spec(id: ParaId) -> ChainSpec {
None, None,
None, None,
None, None,
Extensions { Extensions { relay_chain: "westend".into(), para_id: id.into() },
relay_chain: "westend".into(),
para_id: id.into(),
},
) )
} }
@@ -114,10 +108,7 @@ pub fn get_shell_chain_spec(id: ParaId) -> ShellChainSpec {
None, None,
None, None,
None, None,
Extensions { Extensions { relay_chain: "westend".into(), para_id: id.into() },
relay_chain: "westend".into(),
para_id: id.into(),
},
) )
} }
@@ -138,7 +129,7 @@ pub fn staging_test_net(id: ParaId) -> ChainSpec {
.unchecked_into(), .unchecked_into(),
], ],
vec![ vec![
hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into(), hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into()
], ],
id, id,
) )
@@ -147,10 +138,7 @@ pub fn staging_test_net(id: ParaId) -> ChainSpec {
None, None,
None, None,
None, None,
Extensions { Extensions { relay_chain: "westend".into(), para_id: id.into() },
relay_chain: "westend".into(),
para_id: id.into(),
},
) )
} }
@@ -168,17 +156,11 @@ fn testnet_genesis(
changes_trie_config: Default::default(), changes_trie_config: Default::default(),
}, },
balances: rococo_parachain_runtime::BalancesConfig { balances: rococo_parachain_runtime::BalancesConfig {
balances: endowed_accounts balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
.iter()
.cloned()
.map(|k| (k, 1 << 60))
.collect(),
}, },
sudo: rococo_parachain_runtime::SudoConfig { key: root_key }, sudo: rococo_parachain_runtime::SudoConfig { key: root_key },
parachain_info: rococo_parachain_runtime::ParachainInfoConfig { parachain_id: id }, parachain_info: rococo_parachain_runtime::ParachainInfoConfig { parachain_id: id },
aura: rococo_parachain_runtime::AuraConfig { aura: rococo_parachain_runtime::AuraConfig { authorities: initial_authorities },
authorities: initial_authorities,
},
aura_ext: Default::default(), aura_ext: Default::default(),
parachain_system: Default::default(), parachain_system: Default::default(),
} }
@@ -277,10 +259,7 @@ pub fn statemint_development_config(id: ParaId) -> StatemintChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "polkadot-dev".into(), para_id: id.into() },
relay_chain: "polkadot-dev".into(),
para_id: id.into(),
},
) )
} }
@@ -329,10 +308,7 @@ pub fn statemint_local_config(id: ParaId) -> StatemintChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "polkadot-local".into(), para_id: id.into() },
relay_chain: "polkadot-local".into(),
para_id: id.into(),
},
) )
} }
@@ -349,11 +325,7 @@ fn statemint_genesis(
changes_trie_config: Default::default(), changes_trie_config: Default::default(),
}, },
balances: statemint_runtime::BalancesConfig { balances: statemint_runtime::BalancesConfig {
balances: endowed_accounts balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINT_ED * 4096)).collect(),
.iter()
.cloned()
.map(|k| (k, STATEMINT_ED * 4096))
.collect(),
}, },
parachain_info: statemint_runtime::ParachainInfoConfig { parachain_id: id }, parachain_info: statemint_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: statemint_runtime::CollatorSelectionConfig { collator_selection: statemint_runtime::CollatorSelectionConfig {
@@ -413,10 +385,7 @@ pub fn statemine_development_config(id: ParaId) -> StatemineChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "kusama-dev".into(), para_id: id.into() },
relay_chain: "kusama-dev".into(),
para_id: id.into(),
},
) )
} }
@@ -465,10 +434,7 @@ pub fn statemine_local_config(id: ParaId) -> StatemineChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "kusama-local".into(), para_id: id.into() },
relay_chain: "kusama-local".into(),
para_id: id.into(),
},
) )
} }
@@ -520,10 +486,7 @@ pub fn statemine_config(id: ParaId) -> StatemineChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "kusama".into(), para_id: id.into() },
relay_chain: "kusama".into(),
para_id: id.into(),
},
) )
} }
@@ -540,11 +503,7 @@ fn statemine_genesis(
changes_trie_config: Default::default(), changes_trie_config: Default::default(),
}, },
balances: statemine_runtime::BalancesConfig { balances: statemine_runtime::BalancesConfig {
balances: endowed_accounts balances: endowed_accounts.iter().cloned().map(|k| (k, STATEMINE_ED * 4096)).collect(),
.iter()
.cloned()
.map(|k| (k, STATEMINE_ED * 4096))
.collect(),
}, },
parachain_info: statemine_runtime::ParachainInfoConfig { parachain_id: id }, parachain_info: statemine_runtime::ParachainInfoConfig { parachain_id: id },
collator_selection: statemine_runtime::CollatorSelectionConfig { collator_selection: statemine_runtime::CollatorSelectionConfig {
@@ -603,10 +562,7 @@ pub fn westmint_development_config(id: ParaId) -> WestmintChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "westend".into(), para_id: id.into() },
relay_chain: "westend".into(),
para_id: id.into(),
},
) )
} }
@@ -656,10 +612,7 @@ pub fn westmint_local_config(id: ParaId) -> WestmintChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "westend-local".into(), para_id: id.into() },
relay_chain: "westend-local".into(),
para_id: id.into(),
},
) )
} }
@@ -713,10 +666,7 @@ pub fn westmint_config(id: ParaId) -> WestmintChainSpec {
None, None,
None, None,
Some(properties), Some(properties),
Extensions { Extensions { relay_chain: "westend".into(), para_id: id.into() },
relay_chain: "westend".into(),
para_id: id.into(),
},
) )
} }
@@ -734,11 +684,7 @@ fn westmint_genesis(
changes_trie_config: Default::default(), changes_trie_config: Default::default(),
}, },
balances: westmint_runtime::BalancesConfig { balances: westmint_runtime::BalancesConfig {
balances: endowed_accounts balances: endowed_accounts.iter().cloned().map(|k| (k, WESTMINT_ED * 4096)).collect(),
.iter()
.cloned()
.map(|k| (k, WESTMINT_ED * 4096))
.collect(),
}, },
sudo: westmint_runtime::SudoConfig { key: root_key }, sudo: westmint_runtime::SudoConfig { key: root_key },
parachain_info: westmint_runtime::ParachainInfoConfig { parachain_id: id }, parachain_info: westmint_runtime::ParachainInfoConfig { parachain_id: id },
+2 -9
View File
@@ -132,14 +132,7 @@ impl RelayChainCli {
) -> Self { ) -> Self {
let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec); let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);
let chain_id = extension.map(|e| e.relay_chain.clone()); let chain_id = extension.map(|e| e.relay_chain.clone());
let base_path = para_config let base_path = para_config.base_path.as_ref().map(|x| x.path().join("polkadot"));
.base_path Self { base_path, chain_id, base: polkadot_cli::RunCmd::from_iter(relay_chain_args) }
.as_ref()
.map(|x| x.path().join("polkadot"));
Self {
base_path,
chain_id,
base: polkadot_cli::RunCmd::from_iter(relay_chain_args),
}
} }
} }
+14 -26
View File
@@ -124,7 +124,7 @@ fn load_spec(
} else { } else {
Box::new(chain_spec) Box::new(chain_spec)
} }
} },
}) })
} }
@@ -292,27 +292,27 @@ pub fn run() -> Result<()> {
Some(Subcommand::BuildSpec(cmd)) => { Some(Subcommand::BuildSpec(cmd)) => {
let runner = cli.create_runner(cmd)?; let runner = cli.create_runner(cmd)?;
runner.sync_run(|config| cmd.run(config.chain_spec, config.network)) runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
} },
Some(Subcommand::CheckBlock(cmd)) => { Some(Subcommand::CheckBlock(cmd)) => {
construct_async_run!(|components, cli, cmd, config| { construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue)) Ok(cmd.run(components.client, components.import_queue))
}) })
} },
Some(Subcommand::ExportBlocks(cmd)) => { Some(Subcommand::ExportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| { construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, config.database)) Ok(cmd.run(components.client, config.database))
}) })
} },
Some(Subcommand::ExportState(cmd)) => { Some(Subcommand::ExportState(cmd)) => {
construct_async_run!(|components, cli, cmd, config| { construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, config.chain_spec)) Ok(cmd.run(components.client, config.chain_spec))
}) })
} },
Some(Subcommand::ImportBlocks(cmd)) => { Some(Subcommand::ImportBlocks(cmd)) => {
construct_async_run!(|components, cli, cmd, config| { construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.import_queue)) Ok(cmd.run(components.client, components.import_queue))
}) })
} },
Some(Subcommand::PurgeChain(cmd)) => { Some(Subcommand::PurgeChain(cmd)) => {
let runner = cli.create_runner(cmd)?; let runner = cli.create_runner(cmd)?;
@@ -333,7 +333,7 @@ pub fn run() -> Result<()> {
cmd.run(config, polkadot_config) cmd.run(config, polkadot_config)
}) })
} },
Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| { Some(Subcommand::Revert(cmd)) => construct_async_run!(|components, cli, cmd, config| {
Ok(cmd.run(components.client, components.backend)) Ok(cmd.run(components.client, components.backend))
}), }),
@@ -360,7 +360,7 @@ pub fn run() -> Result<()> {
} }
Ok(()) Ok(())
} },
Some(Subcommand::ExportGenesisWasm(params)) => { Some(Subcommand::ExportGenesisWasm(params)) => {
let mut builder = sc_cli::LoggerBuilder::new(""); let mut builder = sc_cli::LoggerBuilder::new("");
builder.with_profiling(sc_tracing::TracingReceiver::Log, ""); builder.with_profiling(sc_tracing::TracingReceiver::Log, "");
@@ -381,8 +381,8 @@ pub fn run() -> Result<()> {
} }
Ok(()) Ok(())
} },
Some(Subcommand::Benchmark(cmd)) => { Some(Subcommand::Benchmark(cmd)) =>
if cfg!(feature = "runtime-benchmarks") { if cfg!(feature = "runtime-benchmarks") {
let runner = cli.create_runner(cmd)?; let runner = cli.create_runner(cmd)?;
if runner.config().chain_spec.is_statemine() { if runner.config().chain_spec.is_statemine() {
@@ -398,8 +398,7 @@ pub fn run() -> Result<()> {
Err("Benchmarking wasn't enabled when building the node. \ Err("Benchmarking wasn't enabled when building the node. \
You can enable it with `--features runtime-benchmarks`." You can enable it with `--features runtime-benchmarks`."
.into()) .into())
} },
}
None => { None => {
let runner = cli.create_runner(&cli.run.normalize())?; let runner = cli.create_runner(&cli.run.normalize())?;
@@ -431,14 +430,7 @@ pub fn run() -> Result<()> {
info!("Parachain id: {:?}", id); info!("Parachain id: {:?}", id);
info!("Parachain Account: {}", parachain_account); info!("Parachain Account: {}", parachain_account);
info!("Parachain genesis state: {}", genesis_state); info!("Parachain genesis state: {}", genesis_state);
info!( info!("Is collating: {}", if config.role.is_authority() { "yes" } else { "no" });
"Is collating: {}",
if config.role.is_authority() {
"yes"
} else {
"no"
}
);
if config.chain_spec.is_statemint() { if config.chain_spec.is_statemint() {
crate::service::start_statemint_node::< crate::service::start_statemint_node::<
@@ -476,7 +468,7 @@ pub fn run() -> Result<()> {
.map_err(Into::into) .map_err(Into::into)
} }
}) })
} },
} }
} }
@@ -545,11 +537,7 @@ impl CliConfiguration<Self> for RelayChainCli {
fn chain_id(&self, is_dev: bool) -> Result<String> { fn chain_id(&self, is_dev: bool) -> Result<String> {
let chain_id = self.base.base.chain_id(is_dev)?; let chain_id = self.base.base.chain_id(is_dev)?;
Ok(if chain_id.is_empty() { Ok(if chain_id.is_empty() { self.chain_id.clone().unwrap_or_default() } else { chain_id })
self.chain_id.clone().unwrap_or_default()
} else {
chain_id
})
} }
fn role(&self, is_dev: bool) -> Result<sc_service::Role> { fn role(&self, is_dev: bool) -> Result<sc_service::Role> {
+3 -13
View File
@@ -61,20 +61,10 @@ where
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
let mut io = jsonrpc_core::IoHandler::default(); let mut io = jsonrpc_core::IoHandler::default();
let FullDeps { let FullDeps { client, pool, deny_unsafe } = deps;
client,
pool,
deny_unsafe,
} = deps;
io.extend_with(SystemApi::to_delegate(FullSystem::new( io.extend_with(SystemApi::to_delegate(FullSystem::new(client.clone(), pool, deny_unsafe)));
client.clone(), io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client.clone())));
pool,
deny_unsafe,
)));
io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(
client.clone(),
)));
io io
} }
+26 -43
View File
@@ -308,7 +308,7 @@ where
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>, ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
{ {
if matches!(parachain_config.role, Role::Light) { if matches!(parachain_config.role, Role::Light) {
return Err("Light client not supported!".into()); return Err("Light client not supported!".into())
} }
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
@@ -486,7 +486,7 @@ where
) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>, ) -> Result<Box<dyn ParachainConsensus<Block>>, sc_service::Error>,
{ {
if matches!(parachain_config.role, Role::Light) { if matches!(parachain_config.role, Role::Light) {
return Err("Light client not supported!".into()); return Err("Light client not supported!".into())
} }
let parachain_config = prepare_node_config(parachain_config); let parachain_config = prepare_node_config(parachain_config);
@@ -800,13 +800,7 @@ pub async fn start_shell_node(
TFullClient<Block, shell_runtime::RuntimeApi, NativeElseWasmExecutor<ShellRuntimeExecutor>>, TFullClient<Block, shell_runtime::RuntimeApi, NativeElseWasmExecutor<ShellRuntimeExecutor>>,
>, >,
)> { )> {
start_shell_node_impl::< start_shell_node_impl::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _, _, _>(
shell_runtime::RuntimeApi,
ShellRuntimeExecutor,
_,
_,
_,
>(
parachain_config, parachain_config,
polkadot_config, polkadot_config,
id, id,
@@ -832,17 +826,15 @@ pub async fn start_shell_node(
let relay_chain_backend = relay_chain_node.backend.clone(); let relay_chain_backend = relay_chain_node.backend.clone();
let relay_chain_client = relay_chain_node.client.clone(); let relay_chain_client = relay_chain_node.client.clone();
Ok( Ok(cumulus_client_consensus_relay_chain::build_relay_chain_consensus(
cumulus_client_consensus_relay_chain::build_relay_chain_consensus( cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams {
cumulus_client_consensus_relay_chain::BuildRelayChainConsensusParams { para_id: id,
para_id: id, proposer_factory,
proposer_factory, block_import: client.clone(),
block_import: client.clone(), relay_chain_client: relay_chain_node.client.clone(),
relay_chain_client: relay_chain_node.client.clone(), relay_chain_backend: relay_chain_node.backend.clone(),
relay_chain_backend: relay_chain_node.backend.clone(), create_inherent_data_providers: move |_, (relay_parent, validation_data)| {
create_inherent_data_providers: let parachain_inherent =
move |_, (relay_parent, validation_data)| {
let parachain_inherent =
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client( cumulus_primitives_parachain_inherent::ParachainInherentData::create_at_with_client(
relay_parent, relay_parent,
&relay_chain_client, &relay_chain_client,
@@ -850,19 +842,17 @@ pub async fn start_shell_node(
&validation_data, &validation_data,
id, id,
); );
async move { async move {
let parachain_inherent = let parachain_inherent = parachain_inherent.ok_or_else(|| {
parachain_inherent.ok_or_else(|| { Box::<dyn std::error::Error + Send + Sync>::from(
Box::<dyn std::error::Error + Send + Sync>::from( "Failed to create parachain inherent",
"Failed to create parachain inherent", )
) })?;
})?; Ok(parachain_inherent)
Ok(parachain_inherent) }
}
},
}, },
), },
) ))
}, },
) )
.await .await
@@ -879,7 +869,7 @@ impl<R> BuildOnAccess<R> {
match self { match self {
Self::Uninitialized(f) => { Self::Uninitialized(f) => {
*self = Self::Initialized((f.take().unwrap())()); *self = Self::Initialized((f.take().unwrap())());
} },
Self::Initialized(ref mut r) => return r, Self::Initialized(ref mut r) => return r,
} }
} }
@@ -954,13 +944,7 @@ where
async fn verify( async fn verify(
&mut self, &mut self,
block_import: BlockImportParams<Block, ()>, block_import: BlockImportParams<Block, ()>,
) -> Result< ) -> Result<(BlockImportParams<Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
(
BlockImportParams<Block, ()>,
Option<Vec<(CacheKeyId, Vec<u8>)>>,
),
String,
> {
let block_id = BlockId::hash(*block_import.header.parent_hash()); let block_id = BlockId::hash(*block_import.header.parent_hash());
if self if self
@@ -1036,9 +1020,8 @@ where
})) as Box<_> })) as Box<_>
}; };
let relay_chain_verifier = Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { let relay_chain_verifier =
Ok(()) Box::new(RelayChainVerifier::new(client.clone(), |_, _| async { Ok(()) })) as Box<_>;
})) as Box<_>;
let verifier = Verifier { let verifier = Verifier {
client: client.clone(), client: client.clone(),
@@ -32,13 +32,13 @@ pub mod currency {
/// Fee-related. /// Fee-related.
pub mod fee { pub mod fee {
use node_primitives::Balance;
pub use sp_runtime::Perbill;
use frame_support::weights::{ use frame_support::weights::{
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial, WeightToFeePolynomial,
}; };
use node_primitives::Balance;
use smallvec::smallvec; use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updates based on this value. /// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
@@ -99,10 +99,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
runtime_version: VERSION,
can_author_with: Default::default(),
}
} }
parameter_types! { parameter_types! {
@@ -320,7 +317,16 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed. /// The type used to represent the kinds of proxying allowed.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo, scale_info::TypeInfo,
)] )]
pub enum ProxyType { pub enum ProxyType {
@@ -348,58 +354,56 @@ impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &Call) -> bool {
match self { match self {
ProxyType::Any => true, ProxyType::Any => true,
ProxyType::NonTransfer => { ProxyType::NonTransfer =>
!matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }),
}
ProxyType::CancelProxy => matches!( ProxyType::CancelProxy => matches!(
c, c,
Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Assets => { ProxyType::Assets => {
matches!( matches!(
c, c,
Call::Assets { .. } Call::Assets { .. } |
| Call::Utility { .. } Call::Utility { .. } | Call::Multisig { .. } |
| Call::Multisig { .. } Call::Uniques { .. }
| Call::Uniques { .. }
) )
} },
ProxyType::AssetOwner => matches!( ProxyType::AssetOwner => matches!(
c, c,
Call::Assets(pallet_assets::Call::create { .. }) Call::Assets(pallet_assets::Call::create { .. }) |
| Call::Assets(pallet_assets::Call::destroy { .. }) Call::Assets(pallet_assets::Call::destroy { .. }) |
| Call::Assets(pallet_assets::Call::transfer_ownership { .. }) Call::Assets(pallet_assets::Call::transfer_ownership { .. }) |
| Call::Assets(pallet_assets::Call::set_team { .. }) Call::Assets(pallet_assets::Call::set_team { .. }) |
| Call::Assets(pallet_assets::Call::set_metadata { .. }) Call::Assets(pallet_assets::Call::set_metadata { .. }) |
| Call::Assets(pallet_assets::Call::clear_metadata { .. }) Call::Assets(pallet_assets::Call::clear_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::create { .. }) Call::Uniques(pallet_uniques::Call::create { .. }) |
| Call::Uniques(pallet_uniques::Call::destroy { .. }) Call::Uniques(pallet_uniques::Call::destroy { .. }) |
| Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
| Call::Uniques(pallet_uniques::Call::set_team { .. }) Call::Uniques(pallet_uniques::Call::set_team { .. }) |
| Call::Uniques(pallet_uniques::Call::set_metadata { .. }) Call::Uniques(pallet_uniques::Call::set_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::set_attribute { .. }) Call::Uniques(pallet_uniques::Call::set_attribute { .. }) |
| Call::Uniques(pallet_uniques::Call::set_class_metadata { .. }) Call::Uniques(pallet_uniques::Call::set_class_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_class_metadata { .. }) Call::Uniques(pallet_uniques::Call::clear_class_metadata { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::AssetManager => matches!( ProxyType::AssetManager => matches!(
c, c,
Call::Assets(pallet_assets::Call::mint { .. }) Call::Assets(pallet_assets::Call::mint { .. }) |
| Call::Assets(pallet_assets::Call::burn { .. }) Call::Assets(pallet_assets::Call::burn { .. }) |
| Call::Assets(pallet_assets::Call::freeze { .. }) Call::Assets(pallet_assets::Call::freeze { .. }) |
| Call::Assets(pallet_assets::Call::thaw { .. }) Call::Assets(pallet_assets::Call::thaw { .. }) |
| Call::Assets(pallet_assets::Call::freeze_asset { .. }) Call::Assets(pallet_assets::Call::freeze_asset { .. }) |
| Call::Assets(pallet_assets::Call::thaw_asset { .. }) Call::Assets(pallet_assets::Call::thaw_asset { .. }) |
| Call::Uniques(pallet_uniques::Call::mint { .. }) Call::Uniques(pallet_uniques::Call::mint { .. }) |
| Call::Uniques(pallet_uniques::Call::burn { .. }) Call::Uniques(pallet_uniques::Call::burn { .. }) |
| Call::Uniques(pallet_uniques::Call::freeze { .. }) Call::Uniques(pallet_uniques::Call::freeze { .. }) |
| Call::Uniques(pallet_uniques::Call::thaw { .. }) Call::Uniques(pallet_uniques::Call::thaw { .. }) |
| Call::Uniques(pallet_uniques::Call::freeze_class { .. }) Call::Uniques(pallet_uniques::Call::freeze_class { .. }) |
| Call::Uniques(pallet_uniques::Call::thaw_class { .. }) Call::Uniques(pallet_uniques::Call::thaw_class { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Collator => matches!( ProxyType::Collator => matches!(
c, c,
@@ -1,7 +1,7 @@
pub mod pallet_assets; pub mod pallet_assets;
pub mod pallet_balances; pub mod pallet_balances;
pub mod pallet_multisig;
pub mod pallet_collator_selection; pub mod pallet_collator_selection;
pub mod pallet_multisig;
pub mod pallet_proxy; pub mod pallet_proxy;
pub mod pallet_session; pub mod pallet_session;
pub mod pallet_timestamp; pub mod pallet_timestamp;
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_assets //! Autogenerated weights for pallet_assets
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -38,7 +36,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn destroy(c: u32, s: u32, a: u32, ) -> Weight { fn destroy(c: u32, s: u32, a: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 37_000 // Standard Error: 37_000
.saturating_add((21_529_000 as Weight).saturating_mul(c as Weight)) .saturating_add((21_529_000 as Weight).saturating_mul(c as Weight))
@@ -109,7 +107,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_metadata(_n: u32, s: u32, ) -> Weight { fn set_metadata(_n: u32, s: u32) -> Weight {
(50_315_000 as Weight) (50_315_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((8_000 as Weight).saturating_mul(s as Weight)) .saturating_add((8_000 as Weight).saturating_mul(s as Weight))
@@ -121,7 +119,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn force_set_metadata(_n: u32, s: u32, ) -> Weight { fn force_set_metadata(_n: u32, s: u32) -> Weight {
(25_933_000 as Weight) (25_933_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((7_000 as Weight).saturating_mul(s as Weight)) .saturating_add((7_000 as Weight).saturating_mul(s as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_balances //! Autogenerated weights for pallet_balances
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_collator_selection //! Autogenerated weights for pallet_collator_selection
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,28 +26,26 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_collator_selection. /// Weight functions for pallet_collator_selection.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> {
fn set_invulnerables(b: u32, ) -> Weight { fn set_invulnerables(b: u32) -> Weight {
(18_481_000 as Weight) (18_481_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((67_000 as Weight).saturating_mul(b as Weight)) .saturating_add((67_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_desired_candidates() -> Weight { fn set_desired_candidates() -> Weight {
(16_376_000 as Weight) (16_376_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_candidacy_bond() -> Weight { fn set_candidacy_bond() -> Weight {
(17_031_000 as Weight) (17_031_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn register_as_candidate(c: u32, ) -> Weight { fn register_as_candidate(c: u32) -> Weight {
(72_345_000 as Weight) (72_345_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((197_000 as Weight).saturating_mul(c as Weight)) .saturating_add((197_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn leave_intent(c: u32, ) -> Weight { fn leave_intent(c: u32) -> Weight {
(55_446_000 as Weight) (55_446_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((153_000 as Weight).saturating_mul(c as Weight)) .saturating_add((153_000 as Weight).saturating_mul(c as Weight))
@@ -61,7 +57,7 @@ impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightIn
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight))
} }
fn new_session(r: u32, c: u32, ) -> Weight { fn new_session(r: u32, c: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_004_000 // Standard Error: 1_004_000
.saturating_add((110_066_000 as Weight).saturating_mul(r as Weight)) .saturating_add((110_066_000 as Weight).saturating_mul(r as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_multisig //! Autogenerated weights for pallet_multisig
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,12 +26,12 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_multisig. /// Weight functions for pallet_multisig.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32) -> Weight {
(15_911_000 as Weight) (15_911_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(z as Weight)) .saturating_add((1_000 as Weight).saturating_mul(z as Weight))
} }
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32) -> Weight {
(55_326_000 as Weight) (55_326_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((133_000 as Weight).saturating_mul(s as Weight)) .saturating_add((133_000 as Weight).saturating_mul(s as Weight))
@@ -42,7 +40,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn as_multi_create_store(s: u32, z: u32, ) -> Weight { fn as_multi_create_store(s: u32, z: u32) -> Weight {
(62_423_000 as Weight) (62_423_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((133_000 as Weight).saturating_mul(s as Weight)) .saturating_add((133_000 as Weight).saturating_mul(s as Weight))
@@ -51,7 +49,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32) -> Weight {
(32_430_000 as Weight) (32_430_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((148_000 as Weight).saturating_mul(s as Weight)) .saturating_add((148_000 as Weight).saturating_mul(s as Weight))
@@ -60,7 +58,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { fn as_multi_approve_store(s: u32, z: u32) -> Weight {
(59_789_000 as Weight) (59_789_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((165_000 as Weight).saturating_mul(s as Weight)) .saturating_add((165_000 as Weight).saturating_mul(s as Weight))
@@ -69,7 +67,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32) -> Weight {
(80_926_000 as Weight) (80_926_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((276_000 as Weight).saturating_mul(s as Weight)) .saturating_add((276_000 as Weight).saturating_mul(s as Weight))
@@ -78,28 +76,28 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32) -> Weight {
(54_860_000 as Weight) (54_860_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((134_000 as Weight).saturating_mul(s as Weight)) .saturating_add((134_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32) -> Weight {
(31_924_000 as Weight) (31_924_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((154_000 as Weight).saturating_mul(s as Weight)) .saturating_add((154_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn approve_as_multi_complete(s: u32, ) -> Weight { fn approve_as_multi_complete(s: u32) -> Weight {
(154_001_000 as Weight) (154_001_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((281_000 as Weight).saturating_mul(s as Weight)) .saturating_add((281_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32) -> Weight {
(103_770_000 as Weight) (103_770_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((130_000 as Weight).saturating_mul(s as Weight)) .saturating_add((130_000 as Weight).saturating_mul(s as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_proxy //! Autogenerated weights for pallet_proxy
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,13 +26,13 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_proxy. /// Weight functions for pallet_proxy.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
fn proxy(p: u32, ) -> Weight { fn proxy(p: u32) -> Weight {
(27_318_000 as Weight) (27_318_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((208_000 as Weight).saturating_mul(p as Weight)) .saturating_add((208_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
} }
fn proxy_announced(a: u32, p: u32, ) -> Weight { fn proxy_announced(a: u32, p: u32) -> Weight {
(60_665_000 as Weight) (60_665_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((677_000 as Weight).saturating_mul(a as Weight)) .saturating_add((677_000 as Weight).saturating_mul(a as Weight))
@@ -43,7 +41,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn remove_announcement(a: u32, p: u32, ) -> Weight { fn remove_announcement(a: u32, p: u32) -> Weight {
(39_455_000 as Weight) (39_455_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((687_000 as Weight).saturating_mul(a as Weight)) .saturating_add((687_000 as Weight).saturating_mul(a as Weight))
@@ -52,7 +50,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn reject_announcement(a: u32, p: u32, ) -> Weight { fn reject_announcement(a: u32, p: u32) -> Weight {
(39_411_000 as Weight) (39_411_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((686_000 as Weight).saturating_mul(a as Weight)) .saturating_add((686_000 as Weight).saturating_mul(a as Weight))
@@ -61,7 +59,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn announce(a: u32, p: u32, ) -> Weight { fn announce(a: u32, p: u32) -> Weight {
(54_386_000 as Weight) (54_386_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((677_000 as Weight).saturating_mul(a as Weight)) .saturating_add((677_000 as Weight).saturating_mul(a as Weight))
@@ -70,35 +68,35 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn add_proxy(p: u32, ) -> Weight { fn add_proxy(p: u32) -> Weight {
(37_411_000 as Weight) (37_411_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((298_000 as Weight).saturating_mul(p as Weight)) .saturating_add((298_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn remove_proxy(p: u32, ) -> Weight { fn remove_proxy(p: u32) -> Weight {
(36_658_000 as Weight) (36_658_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((332_000 as Weight).saturating_mul(p as Weight)) .saturating_add((332_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn remove_proxies(p: u32, ) -> Weight { fn remove_proxies(p: u32) -> Weight {
(34_893_000 as Weight) (34_893_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((209_000 as Weight).saturating_mul(p as Weight)) .saturating_add((209_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn anonymous(p: u32, ) -> Weight { fn anonymous(p: u32) -> Weight {
(51_243_000 as Weight) (51_243_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((44_000 as Weight).saturating_mul(p as Weight)) .saturating_add((44_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn kill_anonymous(p: u32, ) -> Weight { fn kill_anonymous(p: u32) -> Weight {
(37_188_000 as Weight) (37_188_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((208_000 as Weight).saturating_mul(p as Weight)) .saturating_add((208_000 as Weight).saturating_mul(p as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_session //! Autogenerated weights for pallet_session
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./polkadot-parachains/statemine-runtime/src/weights // --output=./polkadot-parachains/statemine-runtime/src/weights
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_timestamp //! Autogenerated weights for pallet_timestamp
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -34,7 +34,6 @@
// --header=./file_header.txt // --header=./file_header.txt
// --output=./polkadot-parachains/statemine-runtime/src/weights/ // --output=./polkadot-parachains/statemine-runtime/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -54,7 +53,7 @@ impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn destroy(n: u32, m: u32, a: u32, ) -> Weight { fn destroy(n: u32, m: u32, a: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 14_000 // Standard Error: 14_000
.saturating_add((16_814_000 as Weight).saturating_mul(n as Weight)) .saturating_add((16_814_000 as Weight).saturating_mul(n as Weight))
@@ -84,7 +83,7 @@ impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn redeposit(i: u32, ) -> Weight { fn redeposit(i: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 11_000 // Standard Error: 11_000
.saturating_add((26_921_000 as Weight).saturating_mul(i as Weight)) .saturating_add((26_921_000 as Weight).saturating_mul(i as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_utility //! Autogenerated weights for pallet_utility
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemine/src/weights/ // --output=./runtime/statemine/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,7 +26,7 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_utility. /// Weight functions for pallet_utility.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
fn batch(c: u32, ) -> Weight { fn batch(c: u32) -> Weight {
(16_177_000 as Weight) (16_177_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((4_582_000 as Weight).saturating_mul(c as Weight)) .saturating_add((4_582_000 as Weight).saturating_mul(c as Weight))
@@ -36,7 +34,7 @@ impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
fn as_derivative() -> Weight { fn as_derivative() -> Weight {
(7_848_000 as Weight) (7_848_000 as Weight)
} }
fn batch_all(c: u32, ) -> Weight { fn batch_all(c: u32) -> Weight {
(17_745_000 as Weight) (17_745_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((4_578_000 as Weight).saturating_mul(c as Weight)) .saturating_add((4_578_000 as Weight).saturating_mul(c as Weight))
@@ -21,7 +21,7 @@ pub mod currency {
pub const UNITS: Balance = 10_000_000_000; pub const UNITS: Balance = 10_000_000_000;
pub const DOLLARS: Balance = UNITS; pub const DOLLARS: Balance = UNITS;
pub const CENTS: Balance = UNITS / 100; // 100_000_000 pub const CENTS: Balance = UNITS / 100; // 100_000_000
pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000 pub const MILLICENTS: Balance = CENTS / 1_000; // 100_000
pub const fn deposit(items: u32, bytes: u32) -> Balance { pub const fn deposit(items: u32, bytes: u32) -> Balance {
@@ -32,13 +32,13 @@ pub mod currency {
/// Fee-related. /// Fee-related.
pub mod fee { pub mod fee {
use node_primitives::Balance;
pub use sp_runtime::Perbill;
use frame_support::weights::{ use frame_support::weights::{
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial, WeightToFeePolynomial,
}; };
use node_primitives::Balance;
use smallvec::smallvec; use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updates based on this value. /// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
@@ -99,10 +99,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
runtime_version: VERSION,
can_author_with: Default::default(),
}
} }
parameter_types! { parameter_types! {
@@ -287,7 +284,16 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed. /// The type used to represent the kinds of proxying allowed.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo, scale_info::TypeInfo,
)] )]
pub enum ProxyType { pub enum ProxyType {
@@ -315,63 +321,63 @@ impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &Call) -> bool {
match self { match self {
ProxyType::Any => true, ProxyType::Any => true,
ProxyType::NonTransfer => { ProxyType::NonTransfer =>
!matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }),
}
ProxyType::CancelProxy => matches!( ProxyType::CancelProxy => matches!(
c, c,
Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Assets => { ProxyType::Assets => {
matches!( matches!(
c, c,
Call::Assets { .. } Call::Assets { .. } |
| Call::Utility { .. } Call::Utility { .. } | Call::Multisig { .. } |
| Call::Multisig { .. } Call::Uniques { .. }
| Call::Uniques { .. }
) )
} },
ProxyType::AssetOwner => matches!( ProxyType::AssetOwner => matches!(
c, c,
Call::Assets(pallet_assets::Call::create { .. }) Call::Assets(pallet_assets::Call::create { .. }) |
| Call::Assets(pallet_assets::Call::destroy { .. }) Call::Assets(pallet_assets::Call::destroy { .. }) |
| Call::Assets(pallet_assets::Call::transfer_ownership { .. }) Call::Assets(pallet_assets::Call::transfer_ownership { .. }) |
| Call::Assets(pallet_assets::Call::set_team { .. }) Call::Assets(pallet_assets::Call::set_team { .. }) |
| Call::Assets(pallet_assets::Call::set_metadata { .. }) Call::Assets(pallet_assets::Call::set_metadata { .. }) |
| Call::Assets(pallet_assets::Call::clear_metadata { .. }) Call::Assets(pallet_assets::Call::clear_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::create { .. }) Call::Uniques(pallet_uniques::Call::create { .. }) |
| Call::Uniques(pallet_uniques::Call::destroy { .. }) Call::Uniques(pallet_uniques::Call::destroy { .. }) |
| Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
| Call::Uniques(pallet_uniques::Call::set_team { .. }) Call::Uniques(pallet_uniques::Call::set_team { .. }) |
| Call::Uniques(pallet_uniques::Call::set_metadata { .. }) Call::Uniques(pallet_uniques::Call::set_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::set_attribute { .. }) Call::Uniques(pallet_uniques::Call::set_attribute { .. }) |
| Call::Uniques(pallet_uniques::Call::set_class_metadata { .. }) Call::Uniques(pallet_uniques::Call::set_class_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_class_metadata { .. }) Call::Uniques(pallet_uniques::Call::clear_class_metadata { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::AssetManager => matches!( ProxyType::AssetManager => matches!(
c, c,
Call::Assets(pallet_assets::Call::mint { .. }) Call::Assets(pallet_assets::Call::mint { .. }) |
| Call::Assets(pallet_assets::Call::burn { .. }) Call::Assets(pallet_assets::Call::burn { .. }) |
| Call::Assets(pallet_assets::Call::freeze { .. }) Call::Assets(pallet_assets::Call::freeze { .. }) |
| Call::Assets(pallet_assets::Call::thaw { .. }) Call::Assets(pallet_assets::Call::thaw { .. }) |
| Call::Assets(pallet_assets::Call::freeze_asset { .. }) Call::Assets(pallet_assets::Call::freeze_asset { .. }) |
| Call::Assets(pallet_assets::Call::thaw_asset { .. }) Call::Assets(pallet_assets::Call::thaw_asset { .. }) |
| Call::Uniques(pallet_uniques::Call::mint { .. }) Call::Uniques(pallet_uniques::Call::mint { .. }) |
| Call::Uniques(pallet_uniques::Call::burn { .. }) Call::Uniques(pallet_uniques::Call::burn { .. }) |
| Call::Uniques(pallet_uniques::Call::freeze { .. }) Call::Uniques(pallet_uniques::Call::freeze { .. }) |
| Call::Uniques(pallet_uniques::Call::thaw { .. }) Call::Uniques(pallet_uniques::Call::thaw { .. }) |
| Call::Uniques(pallet_uniques::Call::freeze_class { .. }) Call::Uniques(pallet_uniques::Call::freeze_class { .. }) |
| Call::Uniques(pallet_uniques::Call::thaw_class { .. }) Call::Uniques(pallet_uniques::Call::thaw_class { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Collator => matches!( ProxyType::Collator => matches!(
c, c,
Call::CollatorSelection { .. } | Call::Utility { .. } | Call::Multisig { .. } Call::CollatorSelection { .. } | Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Collator =>
matches!(c, Call::CollatorSelection(..) | Call::Utility(..) | Call::Multisig(..)),
} }
} }
fn is_superset(&self, o: &Self) -> bool { fn is_superset(&self, o: &Self) -> bool {
@@ -1,7 +1,7 @@
pub mod pallet_assets; pub mod pallet_assets;
pub mod pallet_balances; pub mod pallet_balances;
pub mod pallet_multisig;
pub mod pallet_collator_selection; pub mod pallet_collator_selection;
pub mod pallet_multisig;
pub mod pallet_proxy; pub mod pallet_proxy;
pub mod pallet_session; pub mod pallet_session;
pub mod pallet_timestamp; pub mod pallet_timestamp;
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_assets //! Autogenerated weights for pallet_assets
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -38,7 +36,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn destroy(c: u32, s: u32, a: u32, ) -> Weight { fn destroy(c: u32, s: u32, a: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 37_000 // Standard Error: 37_000
.saturating_add((21_822_000 as Weight).saturating_mul(c as Weight)) .saturating_add((21_822_000 as Weight).saturating_mul(c as Weight))
@@ -109,7 +107,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_metadata(_n: u32, s: u32, ) -> Weight { fn set_metadata(_n: u32, s: u32) -> Weight {
(50_330_000 as Weight) (50_330_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((9_000 as Weight).saturating_mul(s as Weight)) .saturating_add((9_000 as Weight).saturating_mul(s as Weight))
@@ -121,7 +119,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn force_set_metadata(_n: u32, s: u32, ) -> Weight { fn force_set_metadata(_n: u32, s: u32) -> Weight {
(26_249_000 as Weight) (26_249_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((6_000 as Weight).saturating_mul(s as Weight)) .saturating_add((6_000 as Weight).saturating_mul(s as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_balances //! Autogenerated weights for pallet_balances
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_collator_selection //! Autogenerated weights for pallet_collator_selection
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,28 +26,26 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_collator_selection. /// Weight functions for pallet_collator_selection.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> {
fn set_invulnerables(b: u32, ) -> Weight { fn set_invulnerables(b: u32) -> Weight {
(18_563_000 as Weight) (18_563_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((68_000 as Weight).saturating_mul(b as Weight)) .saturating_add((68_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_desired_candidates() -> Weight { fn set_desired_candidates() -> Weight {
(16_363_000 as Weight) (16_363_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_candidacy_bond() -> Weight { fn set_candidacy_bond() -> Weight {
(16_840_000 as Weight) (16_840_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn register_as_candidate(c: u32, ) -> Weight { fn register_as_candidate(c: u32) -> Weight {
(71_196_000 as Weight) (71_196_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((198_000 as Weight).saturating_mul(c as Weight)) .saturating_add((198_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn leave_intent(c: u32, ) -> Weight { fn leave_intent(c: u32) -> Weight {
(55_336_000 as Weight) (55_336_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((151_000 as Weight).saturating_mul(c as Weight)) .saturating_add((151_000 as Weight).saturating_mul(c as Weight))
@@ -61,7 +57,7 @@ impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightIn
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight))
} }
fn new_session(r: u32, c: u32, ) -> Weight { fn new_session(r: u32, c: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_010_000 // Standard Error: 1_010_000
.saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_multisig //! Autogenerated weights for pallet_multisig
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,12 +26,12 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_multisig. /// Weight functions for pallet_multisig.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32) -> Weight {
(14_936_000 as Weight) (14_936_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(z as Weight)) .saturating_add((1_000 as Weight).saturating_mul(z as Weight))
} }
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32) -> Weight {
(56_090_000 as Weight) (56_090_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((63_000 as Weight).saturating_mul(s as Weight)) .saturating_add((63_000 as Weight).saturating_mul(s as Weight))
@@ -42,7 +40,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn as_multi_create_store(s: u32, z: u32, ) -> Weight { fn as_multi_create_store(s: u32, z: u32) -> Weight {
(62_519_000 as Weight) (62_519_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((66_000 as Weight).saturating_mul(s as Weight)) .saturating_add((66_000 as Weight).saturating_mul(s as Weight))
@@ -51,7 +49,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32) -> Weight {
(30_781_000 as Weight) (30_781_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((111_000 as Weight).saturating_mul(s as Weight)) .saturating_add((111_000 as Weight).saturating_mul(s as Weight))
@@ -60,7 +58,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { fn as_multi_approve_store(s: u32, z: u32) -> Weight {
(60_393_000 as Weight) (60_393_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((118_000 as Weight).saturating_mul(s as Weight)) .saturating_add((118_000 as Weight).saturating_mul(s as Weight))
@@ -69,7 +67,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32) -> Weight {
(81_704_000 as Weight) (81_704_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((248_000 as Weight).saturating_mul(s as Weight)) .saturating_add((248_000 as Weight).saturating_mul(s as Weight))
@@ -78,28 +76,28 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32) -> Weight {
(55_585_000 as Weight) (55_585_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((115_000 as Weight).saturating_mul(s as Weight)) .saturating_add((115_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32) -> Weight {
(33_483_000 as Weight) (33_483_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((82_000 as Weight).saturating_mul(s as Weight)) .saturating_add((82_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn approve_as_multi_complete(s: u32, ) -> Weight { fn approve_as_multi_complete(s: u32) -> Weight {
(154_732_000 as Weight) (154_732_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((253_000 as Weight).saturating_mul(s as Weight)) .saturating_add((253_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32) -> Weight {
(104_447_000 as Weight) (104_447_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((114_000 as Weight).saturating_mul(s as Weight)) .saturating_add((114_000 as Weight).saturating_mul(s as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_proxy //! Autogenerated weights for pallet_proxy
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,13 +26,13 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_proxy. /// Weight functions for pallet_proxy.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
fn proxy(p: u32, ) -> Weight { fn proxy(p: u32) -> Weight {
(27_585_000 as Weight) (27_585_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((203_000 as Weight).saturating_mul(p as Weight)) .saturating_add((203_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
} }
fn proxy_announced(a: u32, p: u32, ) -> Weight { fn proxy_announced(a: u32, p: u32) -> Weight {
(61_093_000 as Weight) (61_093_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((680_000 as Weight).saturating_mul(a as Weight)) .saturating_add((680_000 as Weight).saturating_mul(a as Weight))
@@ -43,7 +41,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn remove_announcement(a: u32, p: u32, ) -> Weight { fn remove_announcement(a: u32, p: u32) -> Weight {
(39_494_000 as Weight) (39_494_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((686_000 as Weight).saturating_mul(a as Weight)) .saturating_add((686_000 as Weight).saturating_mul(a as Weight))
@@ -52,7 +50,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn reject_announcement(a: u32, p: u32, ) -> Weight { fn reject_announcement(a: u32, p: u32) -> Weight {
(39_817_000 as Weight) (39_817_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((685_000 as Weight).saturating_mul(a as Weight)) .saturating_add((685_000 as Weight).saturating_mul(a as Weight))
@@ -61,7 +59,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn announce(a: u32, p: u32, ) -> Weight { fn announce(a: u32, p: u32) -> Weight {
(54_835_000 as Weight) (54_835_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((684_000 as Weight).saturating_mul(a as Weight)) .saturating_add((684_000 as Weight).saturating_mul(a as Weight))
@@ -70,35 +68,35 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn add_proxy(p: u32, ) -> Weight { fn add_proxy(p: u32) -> Weight {
(37_625_000 as Weight) (37_625_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((300_000 as Weight).saturating_mul(p as Weight)) .saturating_add((300_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn remove_proxy(p: u32, ) -> Weight { fn remove_proxy(p: u32) -> Weight {
(36_945_000 as Weight) (36_945_000 as Weight)
// Standard Error: 3_000 // Standard Error: 3_000
.saturating_add((325_000 as Weight).saturating_mul(p as Weight)) .saturating_add((325_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn remove_proxies(p: u32, ) -> Weight { fn remove_proxies(p: u32) -> Weight {
(35_128_000 as Weight) (35_128_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((209_000 as Weight).saturating_mul(p as Weight)) .saturating_add((209_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn anonymous(p: u32, ) -> Weight { fn anonymous(p: u32) -> Weight {
(51_624_000 as Weight) (51_624_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((41_000 as Weight).saturating_mul(p as Weight)) .saturating_add((41_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn kill_anonymous(p: u32, ) -> Weight { fn kill_anonymous(p: u32) -> Weight {
(37_469_000 as Weight) (37_469_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((204_000 as Weight).saturating_mul(p as Weight)) .saturating_add((204_000 as Weight).saturating_mul(p as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_session //! Autogenerated weights for pallet_session
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./polkadot-parachains/statemint-runtime/src/weights // --output=./polkadot-parachains/statemint-runtime/src/weights
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_timestamp //! Autogenerated weights for pallet_timestamp
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -34,7 +34,6 @@
// --header=./file_header.txt // --header=./file_header.txt
// --output=./polkadot-parachains/statemine-runtime/src/weights/ // --output=./polkadot-parachains/statemine-runtime/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -54,7 +53,7 @@ impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn destroy(n: u32, m: u32, a: u32, ) -> Weight { fn destroy(n: u32, m: u32, a: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 14_000 // Standard Error: 14_000
.saturating_add((16_814_000 as Weight).saturating_mul(n as Weight)) .saturating_add((16_814_000 as Weight).saturating_mul(n as Weight))
@@ -84,7 +83,7 @@ impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn redeposit(i: u32, ) -> Weight { fn redeposit(i: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 11_000 // Standard Error: 11_000
.saturating_add((26_921_000 as Weight).saturating_mul(i as Weight)) .saturating_add((26_921_000 as Weight).saturating_mul(i as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_utility //! Autogenerated weights for pallet_utility
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,7 +26,7 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_utility. /// Weight functions for pallet_utility.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
fn batch(c: u32, ) -> Weight { fn batch(c: u32) -> Weight {
(15_408_000 as Weight) (15_408_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight))
@@ -36,7 +34,7 @@ impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
fn as_derivative() -> Weight { fn as_derivative() -> Weight {
(7_817_000 as Weight) (7_817_000 as Weight)
} }
fn batch_all(c: u32, ) -> Weight { fn batch_all(c: u32) -> Weight {
(16_520_000 as Weight) (16_520_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight))
@@ -48,10 +48,7 @@ fn polkadot_argument_parsing() {
.unwrap(); .unwrap();
thread::sleep(Duration::from_secs(20)); thread::sleep(Duration::from_secs(20));
assert!( assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
cmd.try_wait().unwrap().is_none(),
"the process should still be running"
);
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap(); kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
assert_eq!( assert_eq!(
common::wait_for(&mut cmd, 30).map(|x| x.success()), common::wait_for(&mut cmd, 30).map(|x| x.success()),
@@ -39,10 +39,7 @@ fn interrupt_polkadot_mdns_issue_test() {
.unwrap(); .unwrap();
thread::sleep(Duration::from_secs(20)); thread::sleep(Duration::from_secs(20));
assert!( assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
cmd.try_wait().unwrap().is_none(),
"the process should still be running"
);
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap(); kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
assert_eq!( assert_eq!(
common::wait_for(&mut cmd, 30).map(|x| x.success()), common::wait_for(&mut cmd, 30).map(|x| x.success()),
@@ -40,16 +40,11 @@ fn purge_chain_works() {
// Let it produce some blocks. // Let it produce some blocks.
thread::sleep(Duration::from_secs(30)); thread::sleep(Duration::from_secs(30));
assert!( assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
cmd.try_wait().unwrap().is_none(),
"the process should still be running"
);
// Stop the process // Stop the process
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap(); kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
assert!(common::wait_for(&mut cmd, 30) assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default());
.map(|x| x.success())
.unwrap_or_default());
base_path base_path
} }
@@ -39,10 +39,7 @@ fn running_the_node_works_and_can_be_interrupted() {
.unwrap(); .unwrap();
thread::sleep(Duration::from_secs(30)); thread::sleep(Duration::from_secs(30));
assert!( assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
cmd.try_wait().unwrap().is_none(),
"the process should still be running"
);
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap(); kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
assert_eq!( assert_eq!(
common::wait_for(&mut cmd, 30).map(|x| x.success()), common::wait_for(&mut cmd, 30).map(|x| x.success()),
@@ -32,13 +32,13 @@ pub mod currency {
/// Fee-related. /// Fee-related.
pub mod fee { pub mod fee {
use node_primitives::Balance;
pub use sp_runtime::Perbill;
use frame_support::weights::{ use frame_support::weights::{
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients,
WeightToFeePolynomial, WeightToFeePolynomial,
}; };
use node_primitives::Balance;
use smallvec::smallvec; use smallvec::smallvec;
pub use sp_runtime::Perbill;
/// The block saturation level. Fees will be updates based on this value. /// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
+51 -45
View File
@@ -99,10 +99,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
runtime_version: VERSION,
can_author_with: Default::default(),
}
} }
parameter_types! { parameter_types! {
@@ -286,7 +283,16 @@ parameter_types! {
/// The type used to represent the kinds of proxying allowed. /// The type used to represent the kinds of proxying allowed.
#[derive( #[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Encode,
Decode,
RuntimeDebug,
MaxEncodedLen,
scale_info::TypeInfo, scale_info::TypeInfo,
)] )]
pub enum ProxyType { pub enum ProxyType {
@@ -314,63 +320,63 @@ impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool { fn filter(&self, c: &Call) -> bool {
match self { match self {
ProxyType::Any => true, ProxyType::Any => true,
ProxyType::NonTransfer => { ProxyType::NonTransfer =>
!matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }) !matches!(c, Call::Balances { .. } | Call::Assets { .. } | Call::Uniques { .. }),
}
ProxyType::CancelProxy => matches!( ProxyType::CancelProxy => matches!(
c, c,
Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) Call::Proxy(pallet_proxy::Call::reject_announcement { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Assets => { ProxyType::Assets => {
matches!( matches!(
c, c,
Call::Assets { .. } Call::Assets { .. } |
| Call::Utility { .. } Call::Utility { .. } | Call::Multisig { .. } |
| Call::Multisig { .. } Call::Uniques { .. }
| Call::Uniques { .. }
) )
} },
ProxyType::AssetOwner => matches!( ProxyType::AssetOwner => matches!(
c, c,
Call::Assets(pallet_assets::Call::create { .. }) Call::Assets(pallet_assets::Call::create { .. }) |
| Call::Assets(pallet_assets::Call::destroy { .. }) Call::Assets(pallet_assets::Call::destroy { .. }) |
| Call::Assets(pallet_assets::Call::transfer_ownership { .. }) Call::Assets(pallet_assets::Call::transfer_ownership { .. }) |
| Call::Assets(pallet_assets::Call::set_team { .. }) Call::Assets(pallet_assets::Call::set_team { .. }) |
| Call::Assets(pallet_assets::Call::set_metadata { .. }) Call::Assets(pallet_assets::Call::set_metadata { .. }) |
| Call::Assets(pallet_assets::Call::clear_metadata { .. }) Call::Assets(pallet_assets::Call::clear_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::create { .. }) Call::Uniques(pallet_uniques::Call::create { .. }) |
| Call::Uniques(pallet_uniques::Call::destroy { .. }) Call::Uniques(pallet_uniques::Call::destroy { .. }) |
| Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) Call::Uniques(pallet_uniques::Call::transfer_ownership { .. }) |
| Call::Uniques(pallet_uniques::Call::set_team { .. }) Call::Uniques(pallet_uniques::Call::set_team { .. }) |
| Call::Uniques(pallet_uniques::Call::set_metadata { .. }) Call::Uniques(pallet_uniques::Call::set_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::set_attribute { .. }) Call::Uniques(pallet_uniques::Call::set_attribute { .. }) |
| Call::Uniques(pallet_uniques::Call::set_class_metadata { .. }) Call::Uniques(pallet_uniques::Call::set_class_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) Call::Uniques(pallet_uniques::Call::clear_metadata { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) Call::Uniques(pallet_uniques::Call::clear_attribute { .. }) |
| Call::Uniques(pallet_uniques::Call::clear_class_metadata { .. }) Call::Uniques(pallet_uniques::Call::clear_class_metadata { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::AssetManager => matches!( ProxyType::AssetManager => matches!(
c, c,
Call::Assets(pallet_assets::Call::mint { .. }) Call::Assets(pallet_assets::Call::mint { .. }) |
| Call::Assets(pallet_assets::Call::burn { .. }) Call::Assets(pallet_assets::Call::burn { .. }) |
| Call::Assets(pallet_assets::Call::freeze { .. }) Call::Assets(pallet_assets::Call::freeze { .. }) |
| Call::Assets(pallet_assets::Call::thaw { .. }) Call::Assets(pallet_assets::Call::thaw { .. }) |
| Call::Assets(pallet_assets::Call::freeze_asset { .. }) Call::Assets(pallet_assets::Call::freeze_asset { .. }) |
| Call::Assets(pallet_assets::Call::thaw_asset { .. }) Call::Assets(pallet_assets::Call::thaw_asset { .. }) |
| Call::Uniques(pallet_uniques::Call::mint { .. }) Call::Uniques(pallet_uniques::Call::mint { .. }) |
| Call::Uniques(pallet_uniques::Call::burn { .. }) Call::Uniques(pallet_uniques::Call::burn { .. }) |
| Call::Uniques(pallet_uniques::Call::freeze { .. }) Call::Uniques(pallet_uniques::Call::freeze { .. }) |
| Call::Uniques(pallet_uniques::Call::thaw { .. }) Call::Uniques(pallet_uniques::Call::thaw { .. }) |
| Call::Uniques(pallet_uniques::Call::freeze_class { .. }) Call::Uniques(pallet_uniques::Call::freeze_class { .. }) |
| Call::Uniques(pallet_uniques::Call::thaw_class { .. }) Call::Uniques(pallet_uniques::Call::thaw_class { .. }) |
| Call::Utility { .. } | Call::Multisig { .. } Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Collator => matches!( ProxyType::Collator => matches!(
c, c,
Call::CollatorSelection { .. } | Call::Utility { .. } | Call::Multisig { .. } Call::CollatorSelection { .. } | Call::Utility { .. } | Call::Multisig { .. }
), ),
ProxyType::Collator =>
matches!(c, Call::CollatorSelection(..) | Call::Utility(..) | Call::Multisig(..)),
} }
} }
fn is_superset(&self, o: &Self) -> bool { fn is_superset(&self, o: &Self) -> bool {
@@ -1,7 +1,7 @@
pub mod pallet_assets; pub mod pallet_assets;
pub mod pallet_balances; pub mod pallet_balances;
pub mod pallet_multisig;
pub mod pallet_collator_selection; pub mod pallet_collator_selection;
pub mod pallet_multisig;
pub mod pallet_proxy; pub mod pallet_proxy;
pub mod pallet_session; pub mod pallet_session;
pub mod pallet_timestamp; pub mod pallet_timestamp;
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_assets //! Autogenerated weights for pallet_assets
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -38,7 +36,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn destroy(c: u32, s: u32, a: u32, ) -> Weight { fn destroy(c: u32, s: u32, a: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 37_000 // Standard Error: 37_000
.saturating_add((21_822_000 as Weight).saturating_mul(c as Weight)) .saturating_add((21_822_000 as Weight).saturating_mul(c as Weight))
@@ -109,7 +107,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_metadata(_n: u32, s: u32, ) -> Weight { fn set_metadata(_n: u32, s: u32) -> Weight {
(50_330_000 as Weight) (50_330_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((9_000 as Weight).saturating_mul(s as Weight)) .saturating_add((9_000 as Weight).saturating_mul(s as Weight))
@@ -121,7 +119,7 @@ impl<T: frame_system::Config> pallet_assets::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn force_set_metadata(_n: u32, s: u32, ) -> Weight { fn force_set_metadata(_n: u32, s: u32) -> Weight {
(26_249_000 as Weight) (26_249_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((6_000 as Weight).saturating_mul(s as Weight)) .saturating_add((6_000 as Weight).saturating_mul(s as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_balances //! Autogenerated weights for pallet_balances
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_collator_selection //! Autogenerated weights for pallet_collator_selection
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,28 +26,26 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_collator_selection. /// Weight functions for pallet_collator_selection.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightInfo<T> {
fn set_invulnerables(b: u32, ) -> Weight { fn set_invulnerables(b: u32) -> Weight {
(18_563_000 as Weight) (18_563_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((68_000 as Weight).saturating_mul(b as Weight)) .saturating_add((68_000 as Weight).saturating_mul(b as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_desired_candidates() -> Weight { fn set_desired_candidates() -> Weight {
(16_363_000 as Weight) (16_363_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn set_candidacy_bond() -> Weight { fn set_candidacy_bond() -> Weight {
(16_840_000 as Weight) (16_840_000 as Weight).saturating_add(T::DbWeight::get().writes(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn register_as_candidate(c: u32, ) -> Weight { fn register_as_candidate(c: u32) -> Weight {
(71_196_000 as Weight) (71_196_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((198_000 as Weight).saturating_mul(c as Weight)) .saturating_add((198_000 as Weight).saturating_mul(c as Weight))
.saturating_add(T::DbWeight::get().reads(4 as Weight)) .saturating_add(T::DbWeight::get().reads(4 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn leave_intent(c: u32, ) -> Weight { fn leave_intent(c: u32) -> Weight {
(55_336_000 as Weight) (55_336_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((151_000 as Weight).saturating_mul(c as Weight)) .saturating_add((151_000 as Weight).saturating_mul(c as Weight))
@@ -61,7 +57,7 @@ impl<T: frame_system::Config> pallet_collator_selection::WeightInfo for WeightIn
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(4 as Weight)) .saturating_add(T::DbWeight::get().writes(4 as Weight))
} }
fn new_session(r: u32, c: u32, ) -> Weight { fn new_session(r: u32, c: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 1_010_000 // Standard Error: 1_010_000
.saturating_add((109_961_000 as Weight).saturating_mul(r as Weight)) .saturating_add((109_961_000 as Weight).saturating_mul(r as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_multisig //! Autogenerated weights for pallet_multisig
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,12 +26,12 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_multisig. /// Weight functions for pallet_multisig.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
fn as_multi_threshold_1(z: u32, ) -> Weight { fn as_multi_threshold_1(z: u32) -> Weight {
(14_936_000 as Weight) (14_936_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((1_000 as Weight).saturating_mul(z as Weight)) .saturating_add((1_000 as Weight).saturating_mul(z as Weight))
} }
fn as_multi_create(s: u32, z: u32, ) -> Weight { fn as_multi_create(s: u32, z: u32) -> Weight {
(56_090_000 as Weight) (56_090_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((63_000 as Weight).saturating_mul(s as Weight)) .saturating_add((63_000 as Weight).saturating_mul(s as Weight))
@@ -42,7 +40,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn as_multi_create_store(s: u32, z: u32, ) -> Weight { fn as_multi_create_store(s: u32, z: u32) -> Weight {
(62_519_000 as Weight) (62_519_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((66_000 as Weight).saturating_mul(s as Weight)) .saturating_add((66_000 as Weight).saturating_mul(s as Weight))
@@ -51,7 +49,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn as_multi_approve(s: u32, z: u32, ) -> Weight { fn as_multi_approve(s: u32, z: u32) -> Weight {
(30_781_000 as Weight) (30_781_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((111_000 as Weight).saturating_mul(s as Weight)) .saturating_add((111_000 as Weight).saturating_mul(s as Weight))
@@ -60,7 +58,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn as_multi_approve_store(s: u32, z: u32, ) -> Weight { fn as_multi_approve_store(s: u32, z: u32) -> Weight {
(60_393_000 as Weight) (60_393_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((118_000 as Weight).saturating_mul(s as Weight)) .saturating_add((118_000 as Weight).saturating_mul(s as Weight))
@@ -69,7 +67,7 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn as_multi_complete(s: u32, z: u32, ) -> Weight { fn as_multi_complete(s: u32, z: u32) -> Weight {
(81_704_000 as Weight) (81_704_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((248_000 as Weight).saturating_mul(s as Weight)) .saturating_add((248_000 as Weight).saturating_mul(s as Weight))
@@ -78,28 +76,28 @@ impl<T: frame_system::Config> pallet_multisig::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn approve_as_multi_create(s: u32, ) -> Weight { fn approve_as_multi_create(s: u32) -> Weight {
(55_585_000 as Weight) (55_585_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((115_000 as Weight).saturating_mul(s as Weight)) .saturating_add((115_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn approve_as_multi_approve(s: u32, ) -> Weight { fn approve_as_multi_approve(s: u32) -> Weight {
(33_483_000 as Weight) (33_483_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((82_000 as Weight).saturating_mul(s as Weight)) .saturating_add((82_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn approve_as_multi_complete(s: u32, ) -> Weight { fn approve_as_multi_complete(s: u32) -> Weight {
(154_732_000 as Weight) (154_732_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((253_000 as Weight).saturating_mul(s as Weight)) .saturating_add((253_000 as Weight).saturating_mul(s as Weight))
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn cancel_as_multi(s: u32, ) -> Weight { fn cancel_as_multi(s: u32) -> Weight {
(104_447_000 as Weight) (104_447_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((114_000 as Weight).saturating_mul(s as Weight)) .saturating_add((114_000 as Weight).saturating_mul(s as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_proxy //! Autogenerated weights for pallet_proxy
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,13 +26,13 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_proxy. /// Weight functions for pallet_proxy.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
fn proxy(p: u32, ) -> Weight { fn proxy(p: u32) -> Weight {
(27_585_000 as Weight) (27_585_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((203_000 as Weight).saturating_mul(p as Weight)) .saturating_add((203_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
} }
fn proxy_announced(a: u32, p: u32, ) -> Weight { fn proxy_announced(a: u32, p: u32) -> Weight {
(61_093_000 as Weight) (61_093_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((680_000 as Weight).saturating_mul(a as Weight)) .saturating_add((680_000 as Weight).saturating_mul(a as Weight))
@@ -43,7 +41,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn remove_announcement(a: u32, p: u32, ) -> Weight { fn remove_announcement(a: u32, p: u32) -> Weight {
(39_494_000 as Weight) (39_494_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((686_000 as Weight).saturating_mul(a as Weight)) .saturating_add((686_000 as Weight).saturating_mul(a as Weight))
@@ -52,7 +50,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn reject_announcement(a: u32, p: u32, ) -> Weight { fn reject_announcement(a: u32, p: u32) -> Weight {
(39_817_000 as Weight) (39_817_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((685_000 as Weight).saturating_mul(a as Weight)) .saturating_add((685_000 as Weight).saturating_mul(a as Weight))
@@ -61,7 +59,7 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn announce(a: u32, p: u32, ) -> Weight { fn announce(a: u32, p: u32) -> Weight {
(54_835_000 as Weight) (54_835_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((684_000 as Weight).saturating_mul(a as Weight)) .saturating_add((684_000 as Weight).saturating_mul(a as Weight))
@@ -70,35 +68,35 @@ impl<T: frame_system::Config> pallet_proxy::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(3 as Weight)) .saturating_add(T::DbWeight::get().reads(3 as Weight))
.saturating_add(T::DbWeight::get().writes(2 as Weight)) .saturating_add(T::DbWeight::get().writes(2 as Weight))
} }
fn add_proxy(p: u32, ) -> Weight { fn add_proxy(p: u32) -> Weight {
(37_625_000 as Weight) (37_625_000 as Weight)
// Standard Error: 2_000 // Standard Error: 2_000
.saturating_add((300_000 as Weight).saturating_mul(p as Weight)) .saturating_add((300_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn remove_proxy(p: u32, ) -> Weight { fn remove_proxy(p: u32) -> Weight {
(36_945_000 as Weight) (36_945_000 as Weight)
// Standard Error: 3_000 // Standard Error: 3_000
.saturating_add((325_000 as Weight).saturating_mul(p as Weight)) .saturating_add((325_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn remove_proxies(p: u32, ) -> Weight { fn remove_proxies(p: u32) -> Weight {
(35_128_000 as Weight) (35_128_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((209_000 as Weight).saturating_mul(p as Weight)) .saturating_add((209_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn anonymous(p: u32, ) -> Weight { fn anonymous(p: u32) -> Weight {
(51_624_000 as Weight) (51_624_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((41_000 as Weight).saturating_mul(p as Weight)) .saturating_add((41_000 as Weight).saturating_mul(p as Weight))
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn kill_anonymous(p: u32, ) -> Weight { fn kill_anonymous(p: u32) -> Weight {
(37_469_000 as Weight) (37_469_000 as Weight)
// Standard Error: 1_000 // Standard Error: 1_000
.saturating_add((204_000 as Weight).saturating_mul(p as Weight)) .saturating_add((204_000 as Weight).saturating_mul(p as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_session //! Autogenerated weights for pallet_session
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./polkadot-parachains/statemint-runtime/src/weights // --output=./polkadot-parachains/statemint-runtime/src/weights
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_timestamp //! Autogenerated weights for pallet_timestamp
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -34,7 +34,6 @@
// --header=./file_header.txt // --header=./file_header.txt
// --output=./polkadot-parachains/statemine-runtime/src/weights/ // --output=./polkadot-parachains/statemine-runtime/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -54,7 +53,7 @@ impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(1 as Weight)) .saturating_add(T::DbWeight::get().reads(1 as Weight))
.saturating_add(T::DbWeight::get().writes(1 as Weight)) .saturating_add(T::DbWeight::get().writes(1 as Weight))
} }
fn destroy(n: u32, m: u32, a: u32, ) -> Weight { fn destroy(n: u32, m: u32, a: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 14_000 // Standard Error: 14_000
.saturating_add((16_814_000 as Weight).saturating_mul(n as Weight)) .saturating_add((16_814_000 as Weight).saturating_mul(n as Weight))
@@ -84,7 +83,7 @@ impl<T: frame_system::Config> pallet_uniques::WeightInfo for WeightInfo<T> {
.saturating_add(T::DbWeight::get().reads(2 as Weight)) .saturating_add(T::DbWeight::get().reads(2 as Weight))
.saturating_add(T::DbWeight::get().writes(3 as Weight)) .saturating_add(T::DbWeight::get().writes(3 as Weight))
} }
fn redeposit(i: u32, ) -> Weight { fn redeposit(i: u32) -> Weight {
(0 as Weight) (0 as Weight)
// Standard Error: 11_000 // Standard Error: 11_000
.saturating_add((26_921_000 as Weight).saturating_mul(i as Weight)) .saturating_add((26_921_000 as Weight).saturating_mul(i as Weight))
@@ -1,4 +1,3 @@
//! Autogenerated weights for pallet_utility //! Autogenerated weights for pallet_utility
//! //!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0 //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 3.0.0
@@ -18,7 +17,6 @@
// --raw // --raw
// --output=./runtime/statemint/src/weights/ // --output=./runtime/statemint/src/weights/
#![allow(unused_parens)] #![allow(unused_parens)]
#![allow(unused_imports)] #![allow(unused_imports)]
@@ -28,7 +26,7 @@ use sp_std::marker::PhantomData;
/// Weight functions for pallet_utility. /// Weight functions for pallet_utility.
pub struct WeightInfo<T>(PhantomData<T>); pub struct WeightInfo<T>(PhantomData<T>);
impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> { impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
fn batch(c: u32, ) -> Weight { fn batch(c: u32) -> Weight {
(15_408_000 as Weight) (15_408_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight))
@@ -36,7 +34,7 @@ impl<T: frame_system::Config> pallet_utility::WeightInfo for WeightInfo<T> {
fn as_derivative() -> Weight { fn as_derivative() -> Weight {
(7_817_000 as Weight) (7_817_000 as Weight)
} }
fn batch_all(c: u32, ) -> Weight { fn batch_all(c: u32) -> Weight {
(16_520_000 as Weight) (16_520_000 as Weight)
// Standard Error: 0 // Standard Error: 0
.saturating_add((4_571_000 as Weight).saturating_mul(c as Weight)) .saturating_add((4_571_000 as Weight).saturating_mul(c as Weight))
+2 -12
View File
@@ -165,11 +165,7 @@ impl<B: BlockT> ParachainBlockData<B> {
extrinsics: sp_std::vec::Vec<<B as BlockT>::Extrinsic>, extrinsics: sp_std::vec::Vec<<B as BlockT>::Extrinsic>,
storage_proof: sp_trie::CompactProof, storage_proof: sp_trie::CompactProof,
) -> Self { ) -> Self {
Self { Self { header, extrinsics, storage_proof }
header,
extrinsics,
storage_proof,
}
} }
/// Convert `self` into the stored block. /// Convert `self` into the stored block.
@@ -198,13 +194,7 @@ impl<B: BlockT> ParachainBlockData<B> {
} }
/// Deconstruct into the inner parts. /// Deconstruct into the inner parts.
pub fn deconstruct( pub fn deconstruct(self) -> (B::Header, sp_std::vec::Vec<B::Extrinsic>, sp_trie::CompactProof) {
self,
) -> (
B::Header,
sp_std::vec::Vec<B::Extrinsic>,
sp_trie::CompactProof,
) {
(self.header, self.extrinsics, self.storage_proof) (self.header, self.extrinsics, self.storage_proof)
} }
} }
@@ -173,16 +173,10 @@ fn collect_relay_storage_proof(
relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id)); relevant_keys.push(relay_well_known_keys::hrmp_ingress_channel_index(para_id));
relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id)); relevant_keys.push(relay_well_known_keys::hrmp_egress_channel_index(para_id));
relevant_keys.extend(ingress_channels.into_iter().map(|sender| { relevant_keys.extend(ingress_channels.into_iter().map(|sender| {
relay_well_known_keys::hrmp_channels(HrmpChannelId { relay_well_known_keys::hrmp_channels(HrmpChannelId { sender, recipient: para_id })
sender,
recipient: para_id,
})
})); }));
relevant_keys.extend(egress_channels.into_iter().map(|recipient| { relevant_keys.extend(egress_channels.into_iter().map(|recipient| {
relay_well_known_keys::hrmp_channels(HrmpChannelId { relay_well_known_keys::hrmp_channels(HrmpChannelId { sender: para_id, recipient })
sender: para_id,
recipient,
})
})); }));
sp_state_machine::prove_read(relay_parent_state_backend, relevant_keys) sp_state_machine::prove_read(relay_parent_state_backend, relevant_keys)
@@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use cumulus_primitives_core::PersistedValidationData;
use crate::{ParachainInherentData, INHERENT_IDENTIFIER}; use crate::{ParachainInherentData, INHERENT_IDENTIFIER};
use cumulus_primitives_core::PersistedValidationData;
use sp_inherents::{InherentData, InherentDataProvider}; use sp_inherents::{InherentData, InherentDataProvider};
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder; use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
+11 -26
View File
@@ -48,25 +48,21 @@ impl InherentDataProvider {
relay_chain_slot: Slot, relay_chain_slot: Slot,
relay_chain_slot_duration: Duration, relay_chain_slot_duration: Duration,
) -> Self { ) -> Self {
Self { Self { relay_chain_slot, relay_chain_slot_duration }
relay_chain_slot,
relay_chain_slot_duration,
}
} }
/// Create the inherent data. /// Create the inherent data.
pub fn create_inherent_data(&self) -> Result<InherentData, Error> { pub fn create_inherent_data(&self) -> Result<InherentData, Error> {
let mut inherent_data = InherentData::new(); let mut inherent_data = InherentData::new();
self.provide_inherent_data(&mut inherent_data) self.provide_inherent_data(&mut inherent_data).map(|_| inherent_data)
.map(|_| inherent_data)
} }
/// Provide the inherent data into the given `inherent_data`. /// Provide the inherent data into the given `inherent_data`.
pub fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> { pub fn provide_inherent_data(&self, inherent_data: &mut InherentData) -> Result<(), Error> {
// As the parachain starts building at around `relay_chain_slot + 1` we use that slot to // As the parachain starts building at around `relay_chain_slot + 1` we use that slot to
// calculate the timestamp. // calculate the timestamp.
let data: InherentType = ((*self.relay_chain_slot + 1) let data: InherentType = ((*self.relay_chain_slot + 1) *
* self.relay_chain_slot_duration.as_millis() as u64) self.relay_chain_slot_duration.as_millis() as u64)
.into(); .into();
inherent_data.put_data(INHERENT_IDENTIFIER, &data) inherent_data.put_data(INHERENT_IDENTIFIER, &data)
@@ -114,16 +110,10 @@ mod tests {
timestamp: u64, timestamp: u64,
relay_chain_slot: Slot, relay_chain_slot: Slot,
) -> (ParachainBlockData, PHash) { ) -> (ParachainBlockData, PHash) {
let sproof_builder = RelayStateSproofBuilder { let sproof_builder =
current_slot: relay_chain_slot, RelayStateSproofBuilder { current_slot: relay_chain_slot, ..Default::default() };
..Default::default()
};
let parent_header = client let parent_header = client.header(&at).ok().flatten().expect("Genesis header exists");
.header(&at)
.ok()
.flatten()
.expect("Genesis header exists");
let relay_parent_storage_root = sproof_builder.clone().into_state_root_and_proof().0; let relay_parent_storage_root = sproof_builder.clone().into_state_root_and_proof().0;
@@ -155,18 +145,13 @@ mod tests {
let timestamp = u64::from_str(&env::var("TIMESTAMP").expect("TIMESTAMP is set")) let timestamp = u64::from_str(&env::var("TIMESTAMP").expect("TIMESTAMP is set"))
.expect("TIMESTAMP is a valid `u64`"); .expect("TIMESTAMP is a valid `u64`");
let block = build_block(&client, BlockId::number(0), SLOT_DURATION, 1.into()) let block =
.0 build_block(&client, BlockId::number(0), SLOT_DURATION, 1.into()).0.into_block();
.into_block();
futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block)) futures::executor::block_on(client.import(sp_consensus::BlockOrigin::Own, block))
.unwrap(); .unwrap();
let (block, relay_chain_root) = build_block( let (block, relay_chain_root) =
&client, build_block(&client, BlockId::number(1), timestamp, relay_chain_slot.into());
BlockId::number(1),
timestamp,
relay_chain_slot.into(),
);
let header = call_validate_block( let header = call_validate_block(
client client
+5 -7
View File
@@ -19,10 +19,10 @@
#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(not(feature = "std"), no_std)]
use sp_std::marker::PhantomData;
use codec::Encode; use codec::Encode;
use cumulus_primitives_core::UpwardMessageSender; use cumulus_primitives_core::UpwardMessageSender;
use xcm::{WrapVersion, latest::prelude::*}; use sp_std::marker::PhantomData;
use xcm::{latest::prelude::*, WrapVersion};
/// Xcm router which recognises the `Parent` destination and handles it by sending the message into /// Xcm router which recognises the `Parent` destination and handles it by sending the message into
/// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an /// the given UMP `UpwardMessageSender` implementation. Thus this essentially adapts an
@@ -36,12 +36,11 @@ impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> { fn send_xcm(dest: MultiLocation, msg: Xcm<()>) -> Result<(), SendError> {
if dest.contains_parents_only(1) { if dest.contains_parents_only(1) {
// An upward message for the relay chain. // An upward message for the relay chain.
let versioned_xcm = W::wrap_version(&dest, msg) let versioned_xcm =
.map_err(|()| SendError::DestinationUnsupported)?; W::wrap_version(&dest, msg).map_err(|()| SendError::DestinationUnsupported)?;
let data = versioned_xcm.encode(); let data = versioned_xcm.encode();
T::send_upward_message(data) T::send_upward_message(data).map_err(|e| SendError::Transport(e.into()))?;
.map_err(|e| SendError::Transport(e.into()))?;
Ok(()) Ok(())
} else { } else {
@@ -50,4 +49,3 @@ impl<T: UpwardMessageSender, W: WrapVersion> SendXcm for ParentAsUmp<T, W> {
} }
} }
} }
+3 -7
View File
@@ -107,9 +107,7 @@ fn init_block_builder<'a>(
) )
.expect("Put validation function params failed"); .expect("Put validation function params failed");
let inherents = block_builder let inherents = block_builder.create_inherents(inherent_data).expect("Creates inherents");
.create_inherents(inherent_data)
.expect("Creates inherents");
inherents inherents
.into_iter() .into_iter()
@@ -138,10 +136,8 @@ impl InitBlockBuilder for Client {
validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>, validation_data: Option<PersistedValidationData<PHash, PBlockNumber>>,
relay_sproof_builder: RelayStateSproofBuilder, relay_sproof_builder: RelayStateSproofBuilder,
) -> BlockBuilder<Block, Client, Backend> { ) -> BlockBuilder<Block, Client, Backend> {
let last_timestamp = self let last_timestamp =
.runtime_api() self.runtime_api().get_last_timestamp(&at).expect("Get last timestamp");
.get_last_timestamp(&at)
.expect("Get last timestamp");
let timestamp = last_timestamp + cumulus_test_runtime::MinimumPeriod::get(); let timestamp = last_timestamp + cumulus_test_runtime::MinimumPeriod::get();
+5 -16
View File
@@ -128,10 +128,8 @@ pub fn generate_extrinsic(
let current_block = client.info().best_number.saturated_into(); let current_block = client.info().best_number.saturated_into();
let genesis_block = client.hash(0).unwrap().unwrap(); let genesis_block = client.hash(0).unwrap().unwrap();
let nonce = 0; let nonce = 0;
let period = BlockHashCount::get() let period =
.checked_next_power_of_two() BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
.map(|c| c / 2)
.unwrap_or(2) as u64;
let tip = 0; let tip = 0;
let extra: SignedExtra = ( let extra: SignedExtra = (
frame_system::CheckSpecVersion::<Runtime>::new(), frame_system::CheckSpecVersion::<Runtime>::new(),
@@ -144,14 +142,7 @@ pub fn generate_extrinsic(
let raw_payload = SignedPayload::from_raw( let raw_payload = SignedPayload::from_raw(
function.clone(), function.clone(),
extra.clone(), extra.clone(),
( (VERSION.spec_version, genesis_block, current_block_hash, (), (), ()),
VERSION.spec_version,
genesis_block,
current_block_hash,
(),
(),
(),
),
); );
let signature = raw_payload.using_encoded(|e| origin.sign(e)); let signature = raw_payload.using_encoded(|e| origin.sign(e));
@@ -170,10 +161,8 @@ pub fn transfer(
dest: sp_keyring::AccountKeyring, dest: sp_keyring::AccountKeyring,
value: Balance, value: Balance,
) -> UncheckedExtrinsic { ) -> UncheckedExtrinsic {
let function = Call::Balances(pallet_balances::Call::transfer { let function =
dest: dest.public().into(), Call::Balances(pallet_balances::Call::transfer { dest: dest.public().into(), value });
value,
});
generate_extrinsic(client, origin, function) generate_extrinsic(client, origin, function)
} }
+5 -20
View File
@@ -81,10 +81,7 @@ impl RelayStateSproofBuilder {
} }
self.hrmp_channels self.hrmp_channels
.entry(relay_chain::v1::HrmpChannelId { .entry(relay_chain::v1::HrmpChannelId { sender, recipient: self.para_id })
sender,
recipient: self.para_id,
})
.or_insert_with(|| AbridgedHrmpChannel { .or_insert_with(|| AbridgedHrmpChannel {
max_capacity: 0, max_capacity: 0,
max_total_size: 0, max_total_size: 0,
@@ -97,10 +94,7 @@ impl RelayStateSproofBuilder {
pub fn into_state_root_and_proof( pub fn into_state_root_and_proof(
self, self,
) -> ( ) -> (polkadot_primitives::v1::Hash, sp_state_machine::StorageProof) {
polkadot_primitives::v1::Hash,
sp_state_machine::StorageProof,
) {
let (db, root) = MemoryDB::<HashFor<polkadot_primitives::v1::Block>>::default_with_root(); let (db, root) = MemoryDB::<HashFor<polkadot_primitives::v1::Block>>::default_with_root();
let mut backend = sp_state_machine::TrieBackend::new(db, root); let mut backend = sp_state_machine::TrieBackend::new(db, root);
@@ -113,10 +107,7 @@ impl RelayStateSproofBuilder {
backend.insert(vec![(None, vec![(key, Some(value))])]); backend.insert(vec![(None, vec![(key, Some(value))])]);
}; };
insert( insert(relay_chain::well_known_keys::ACTIVE_CONFIG.to_vec(), self.host_config.encode());
relay_chain::well_known_keys::ACTIVE_CONFIG.to_vec(),
self.host_config.encode(),
);
if let Some(dmq_mqc_head) = self.dmq_mqc_head { if let Some(dmq_mqc_head) = self.dmq_mqc_head {
insert( insert(
relay_chain::well_known_keys::dmq_mqc_head(self.para_id), relay_chain::well_known_keys::dmq_mqc_head(self.para_id),
@@ -150,16 +141,10 @@ impl RelayStateSproofBuilder {
); );
} }
for (channel, metadata) in self.hrmp_channels { for (channel, metadata) in self.hrmp_channels {
insert( insert(relay_chain::well_known_keys::hrmp_channels(channel), metadata.encode());
relay_chain::well_known_keys::hrmp_channels(channel),
metadata.encode(),
);
} }
insert( insert(relay_chain::well_known_keys::CURRENT_SLOT.to_vec(), self.current_slot.encode());
relay_chain::well_known_keys::CURRENT_SLOT.to_vec(),
self.current_slot.encode(),
);
} }
let root = backend.root().clone(); let root = backend.root().clone();
@@ -27,7 +27,7 @@ const SKIP_ENV: &str = "SKIP_BUILD";
fn main() { fn main() {
if env::var(SKIP_ENV).is_ok() { if env::var(SKIP_ENV).is_ok() {
return; return
} }
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo")); let out_dir = PathBuf::from(env::var("OUT_DIR").expect("`OUT_DIR` is set by cargo"));
@@ -35,11 +35,8 @@ fn main() {
let project = create_project(&out_dir); let project = create_project(&out_dir);
build_project(&project.join("Cargo.toml")); build_project(&project.join("Cargo.toml"));
fs::copy( fs::copy(project.join("target/release").join(PROJECT_NAME), out_dir.join(PROJECT_NAME))
project.join("target/release").join(PROJECT_NAME), .expect("Copies validation worker");
out_dir.join(PROJECT_NAME),
)
.expect("Copies validation worker");
} }
fn find_cargo_lock() -> PathBuf { fn find_cargo_lock() -> PathBuf {
@@ -49,7 +46,7 @@ fn find_cargo_lock() -> PathBuf {
loop { loop {
if path.join("Cargo.lock").exists() { if path.join("Cargo.lock").exists() {
return path.join("Cargo.lock"); return path.join("Cargo.lock")
} }
if !path.pop() { if !path.pop() {
@@ -109,7 +106,7 @@ fn build_project(cargo_toml: &Path) {
.status(); .status();
match status.map(|s| s.success()) { match status.map(|s| s.success()) {
Ok(true) => {} Ok(true) => {},
// Use `process.exit(1)` to have a clean error output. // Use `process.exit(1)` to have a clean error output.
_ => process::exit(1), _ => process::exit(1),
} }
+3 -9
View File
@@ -113,10 +113,7 @@ pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
/// The version information used to identify this runtime when compiled natively. /// The version information used to identify this runtime when compiled natively.
#[cfg(feature = "std")] #[cfg(feature = "std")]
pub fn native_version() -> NativeVersion { pub fn native_version() -> NativeVersion {
NativeVersion { NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
runtime_version: VERSION,
can_author_with: Default::default(),
}
} }
/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers. /// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.
@@ -421,11 +418,8 @@ impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {
) -> sp_inherents::CheckInherentsResult { ) -> sp_inherents::CheckInherentsResult {
if relay_state_proof.read_slot().expect("Reads slot") == 1337u64 { if relay_state_proof.read_slot().expect("Reads slot") == 1337u64 {
let mut res = sp_inherents::CheckInherentsResult::new(); let mut res = sp_inherents::CheckInherentsResult::new();
res.put_error( res.put_error([1u8; 8], &sp_inherents::MakeFatalError::from("You are wrong"))
[1u8; 8], .expect("Puts error");
&sp_inherents::MakeFatalError::from("You are wrong"),
)
.expect("Puts error");
res res
} else { } else {
let relay_chain_slot = relay_state_proof let relay_chain_slot = relay_state_proof
+2 -8
View File
@@ -70,9 +70,7 @@ pub fn get_chain_spec(id: ParaId) -> ChainSpec {
None, None,
None, None,
None, None,
Extensions { Extensions { para_id: id.into() },
para_id: id.into(),
},
) )
} }
@@ -110,11 +108,7 @@ fn testnet_genesis(
}, },
parachain_system: Default::default(), parachain_system: Default::default(),
balances: cumulus_test_runtime::BalancesConfig { balances: cumulus_test_runtime::BalancesConfig {
balances: endowed_accounts balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
.iter()
.cloned()
.map(|k| (k, 1 << 60))
.collect(),
}, },
sudo: cumulus_test_runtime::SudoConfig { key: root_key }, sudo: cumulus_test_runtime::SudoConfig { key: root_key },
} }
+1 -1
View File
@@ -15,8 +15,8 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>. // along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use codec::Encode; use codec::Encode;
use cumulus_primitives_core::ParaId;
use cumulus_client_service::genesis::generate_genesis_block; use cumulus_client_service::genesis::generate_genesis_block;
use cumulus_primitives_core::ParaId;
use cumulus_test_runtime::Block; use cumulus_test_runtime::Block;
use polkadot_primitives::v0::HeadData; use polkadot_primitives::v0::HeadData;
use sp_runtime::traits::Block as BlockT; use sp_runtime::traits::Block as BlockT;
+38 -72
View File
@@ -181,7 +181,7 @@ where
+ 'static, + 'static,
{ {
if matches!(parachain_config.role, Role::Light) { if matches!(parachain_config.role, Role::Light) {
return Err("Light client not supported!".into()); return Err("Light client not supported!".into())
} }
let mut parachain_config = prepare_node_config(parachain_config); let mut parachain_config = prepare_node_config(parachain_config);
@@ -274,37 +274,35 @@ where
let relay_chain_client = relay_chain_full_node.client.clone(); let relay_chain_client = relay_chain_full_node.client.clone();
let relay_chain_backend = relay_chain_full_node.backend.clone(); let relay_chain_backend = relay_chain_full_node.backend.clone();
Box::new( Box::new(cumulus_client_consensus_relay_chain::RelayChainConsensus::new(
cumulus_client_consensus_relay_chain::RelayChainConsensus::new( para_id,
para_id, proposer_factory,
proposer_factory, move |_, (relay_parent, validation_data)| {
move |_, (relay_parent, validation_data)| { let parachain_inherent =
let parachain_inherent = cumulus_primitives_parachain_inherent::ParachainInherentData::create_at(
cumulus_primitives_parachain_inherent::ParachainInherentData::create_at( relay_parent,
relay_parent, &*relay_chain_client,
&*relay_chain_client, &*relay_chain_backend,
&*relay_chain_backend, &validation_data,
&validation_data, para_id,
para_id, );
);
async move { async move {
let time = sp_timestamp::InherentDataProvider::from_system_time(); let time = sp_timestamp::InherentDataProvider::from_system_time();
let parachain_inherent = parachain_inherent.ok_or_else(|| { let parachain_inherent = parachain_inherent.ok_or_else(|| {
Box::<dyn std::error::Error + Send + Sync>::from(String::from( Box::<dyn std::error::Error + Send + Sync>::from(String::from(
"error", "error",
)) ))
})?; })?;
Ok((time, parachain_inherent)) Ok((time, parachain_inherent))
} }
}, },
client.clone(), client.clone(),
relay_chain_full_node.client.clone(), relay_chain_full_node.client.clone(),
relay_chain_full_node.backend.clone(), relay_chain_full_node.backend.clone(),
), ))
) },
}
Consensus::Null => Box::new(NullConsensus), Consensus::Null => Box::new(NullConsensus),
}; };
@@ -466,8 +464,7 @@ impl TestNodeBuilder {
mut self, mut self,
nodes: impl IntoIterator<Item = &'a polkadot_test_service::PolkadotTestNode>, nodes: impl IntoIterator<Item = &'a polkadot_test_service::PolkadotTestNode>,
) -> Self { ) -> Self {
self.relay_chain_nodes self.relay_chain_nodes.extend(nodes.into_iter().map(|n| n.addr.clone()));
.extend(nodes.into_iter().map(|n| n.addr.clone()));
self self
} }
@@ -501,8 +498,7 @@ impl TestNodeBuilder {
/// Build the [`TestNode`]. /// Build the [`TestNode`].
pub async fn build(self) -> TestNode { pub async fn build(self) -> TestNode {
let parachain_config = node_config( let parachain_config = node_config(
self.storage_update_func_parachain self.storage_update_func_parachain.unwrap_or_else(|| Box::new(|| ())),
.unwrap_or_else(|| Box::new(|| ())),
self.tokio_handle.clone(), self.tokio_handle.clone(),
self.key.clone(), self.key.clone(),
self.parachain_nodes, self.parachain_nodes,
@@ -512,8 +508,7 @@ impl TestNodeBuilder {
) )
.expect("could not generate Configuration"); .expect("could not generate Configuration");
let mut relay_chain_config = polkadot_test_service::node_config( let mut relay_chain_config = polkadot_test_service::node_config(
self.storage_update_func_relay_chain self.storage_update_func_relay_chain.unwrap_or_else(|| Box::new(|| ())),
.unwrap_or_else(|| Box::new(|| ())),
self.tokio_handle, self.tokio_handle,
self.key, self.key,
self.relay_chain_nodes, self.relay_chain_nodes,
@@ -539,13 +534,7 @@ impl TestNodeBuilder {
let peer_id = network.local_peer_id().clone(); let peer_id = network.local_peer_id().clone();
let addr = MultiaddrWithPeerId { multiaddr, peer_id }; let addr = MultiaddrWithPeerId { multiaddr, peer_id };
TestNode { TestNode { task_manager, client, network, addr, rpc_handlers }
task_manager,
client,
network,
addr,
rpc_handlers,
}
} }
} }
@@ -566,18 +555,11 @@ pub fn node_config(
) -> Result<Configuration, ServiceError> { ) -> Result<Configuration, ServiceError> {
let base_path = BasePath::new_temp_dir()?; let base_path = BasePath::new_temp_dir()?;
let root = base_path.path().to_path_buf(); let root = base_path.path().to_path_buf();
let role = if is_collator { let role = if is_collator { Role::Authority } else { Role::Full };
Role::Authority
} else {
Role::Full
};
let key_seed = key.to_seed(); let key_seed = key.to_seed();
let mut spec = Box::new(chain_spec::get_chain_spec(para_id)); let mut spec = Box::new(chain_spec::get_chain_spec(para_id));
let mut storage = spec let mut storage = spec.as_storage_builder().build_storage().expect("could not build storage");
.as_storage_builder()
.build_storage()
.expect("could not build storage");
BasicExternalities::execute_with_storage(&mut storage, storage_update_func); BasicExternalities::execute_with_storage(&mut storage, storage_update_func);
spec.set_storage(storage); spec.set_storage(storage);
@@ -614,10 +596,7 @@ pub fn node_config(
network: network_config, network: network_config,
keystore: KeystoreConfig::InMemory, keystore: KeystoreConfig::InMemory,
keystore_remote: Default::default(), keystore_remote: Default::default(),
database: DatabaseSource::RocksDb { database: DatabaseSource::RocksDb { path: root.join("db"), cache_size: 128 },
path: root.join("db"),
cache_size: 128,
},
state_cache_size: 67108864, state_cache_size: 67108864,
state_cache_child_ratio: None, state_cache_child_ratio: None,
state_pruning: PruningMode::ArchiveAll, state_pruning: PruningMode::ArchiveAll,
@@ -643,10 +622,7 @@ pub fn node_config(
prometheus_config: None, prometheus_config: None,
telemetry_endpoints: None, telemetry_endpoints: None,
default_heap_pages: None, default_heap_pages: None,
offchain_worker: OffchainWorkerConfig { offchain_worker: OffchainWorkerConfig { enabled: true, indexing_enabled: false },
enabled: true,
indexing_enabled: false,
},
force_authoring: false, force_authoring: false,
disable_grandpa: false, disable_grandpa: false,
dev_key_seed: Some(key_seed), dev_key_seed: Some(key_seed),
@@ -685,10 +661,7 @@ impl TestNode {
let call = frame_system::Call::set_code { code: validation }; let call = frame_system::Call::set_code { code: validation };
self.send_extrinsic( self.send_extrinsic(
runtime::SudoCall::sudo_unchecked_weight { runtime::SudoCall::sudo_unchecked_weight { call: Box::new(call.into()), weight: 1_000 },
call: Box::new(call.into()),
weight: 1_000,
},
Sr25519Keyring::Alice, Sr25519Keyring::Alice,
) )
.await .await
@@ -726,14 +699,7 @@ pub fn construct_extrinsic(
let raw_payload = runtime::SignedPayload::from_raw( let raw_payload = runtime::SignedPayload::from_raw(
function.clone(), function.clone(),
extra.clone(), extra.clone(),
( (runtime::VERSION.spec_version, genesis_block, current_block_hash, (), (), ()),
runtime::VERSION.spec_version,
genesis_block,
current_block_hash,
(),
(),
(),
),
); );
let signature = raw_payload.using_encoded(|e| caller.sign(e)); let signature = raw_payload.using_encoded(|e| caller.sign(e));
runtime::UncheckedExtrinsic::new_signed( runtime::UncheckedExtrinsic::new_signed(
@@ -17,8 +17,8 @@
use cumulus_primitives_core::ParaId; use cumulus_primitives_core::ParaId;
use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*}; use cumulus_test_service::{initial_head_data, run_relay_chain_validator_node, Keyring::*};
use futures::{join, StreamExt}; use futures::{join, StreamExt};
use sp_runtime::generic::BlockId;
use sc_client_api::BlockchainEvents; use sc_client_api::BlockchainEvents;
use sp_runtime::generic::BlockId;
#[substrate_test_utils::test] #[substrate_test_utils::test]
#[ignore] #[ignore]
@@ -95,7 +95,7 @@ async fn test_runtime_upgrade() {
.expect("Runtime version exists"); .expect("Runtime version exists");
if expected_runtime_version == runtime_version { if expected_runtime_version == runtime_version {
break; break
} }
} }
} }