-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: hrmp #278
base: main
Are you sure you want to change the base?
fix: hrmp #278
Changes from all commits
88acd30
ca445cd
25813fb
e39a8cf
22fd37c
e9976e7
deffdbd
f7b937f
cf3cfcc
35709ca
e50e3ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
use crate::Error; | ||
use sp_core::twox_128; | ||
use subxt::{ | ||
config::BlockHash, | ||
dynamic::{self, Value}, | ||
ext::sp_core, | ||
OnlineClient, PolkadotConfig, | ||
}; | ||
|
||
/// Clears the DMPQ state for the given parachain IDs. | ||
/// | ||
/// # Arguments | ||
/// * `relay_chain` - The relay chain. | ||
/// * `client` - Client for the network which state is to be modified. | ||
/// * `para_ids` - List of ids to build the keys that will be mutated. | ||
pub async fn clear_dmpq( | ||
client: OnlineClient<PolkadotConfig>, | ||
para_ids: &[u32], | ||
) -> Result<impl BlockHash, Error> { | ||
// Wait for blocks to be produced. | ||
let mut sub = client.blocks().subscribe_finalized().await?; | ||
for _ in 0..2 { | ||
sub.next().await; | ||
} | ||
|
||
// Generate storage keys to be removed | ||
let dmp = twox_128("Dmp".as_bytes()); | ||
let dmp_queues = twox_128("DownwardMessageQueues".as_bytes()); | ||
let dmp_queue_heads = twox_128("DownwardMessageQueueHeads".as_bytes()); | ||
let mut clear_dmq_keys = Vec::<Vec<u8>>::new(); | ||
for id in para_ids { | ||
let id = id.to_le_bytes(); | ||
// DMP Queue Head | ||
let mut key = dmp.to_vec(); | ||
key.extend(&dmp_queue_heads); | ||
key.extend(sp_core::twox_64(&id)); | ||
key.extend(id); | ||
clear_dmq_keys.push(key); | ||
// DMP Queue | ||
let mut key = dmp.to_vec(); | ||
key.extend(&dmp_queues); | ||
key.extend(sp_core::twox_64(&id)); | ||
key.extend(id); | ||
clear_dmq_keys.push(key); | ||
} | ||
|
||
// Submit calls to remove specified keys | ||
let sudo = subxt_signer::sr25519::dev::alice(); | ||
let kill_storage = dynamic::tx( | ||
"System", | ||
"kill_storage", | ||
vec![Value::unnamed_composite(clear_dmq_keys.into_iter().map(Value::from_bytes))], | ||
); | ||
let sudo_call = dynamic::tx("Sudo", "sudo", vec![kill_storage.into_value()]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is merged before |
||
Ok(client.tx().sign_and_submit_default(&sudo_call, &sudo).await?) | ||
} | ||
|
||
/// A supported relay chain. | ||
pub enum RelayChain { | ||
/// Paseo. | ||
PaseoLocal, | ||
/// Rococo. | ||
RococoLocal, | ||
} | ||
|
||
impl RelayChain { | ||
/// Attempts to convert a chain identifier into a supported `RelayChain` variant. | ||
/// | ||
/// # Arguments | ||
/// * `id` - The relay chain identifier. | ||
pub fn from(id: &str) -> Option<RelayChain> { | ||
match id { | ||
"paseo-local" => Some(RelayChain::PaseoLocal), | ||
"rococo-local" => Some(RelayChain::RococoLocal), | ||
_ => None, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# pop up parachain -f ./tests/networks/kusama+asset-hub.toml | ||
|
||
[relaychain] | ||
chain = "kusama-local" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
validator = true | ||
|
||
[[parachains]] | ||
id = 1000 | ||
chain = "asset-hub-kusama-local" | ||
|
||
[[parachains.collators]] | ||
name = "asset-hub" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# pop up parachain -f ./tests/networks/paseo+asset-hub.toml | ||
|
||
[relaychain] | ||
chain = "paseo-local" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
validator = true | ||
|
||
[[parachains]] | ||
id = 1000 | ||
chain = "asset-hub-paseo-local" | ||
|
||
[[parachains.collators]] | ||
name = "asset-hub" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# pop up parachain -f ./tests/networks/polkadot+asset-hub.toml | ||
|
||
[relaychain] | ||
chain = "polkadot-local" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
validator = true | ||
|
||
[[parachains]] | ||
id = 1000 | ||
chain = "asset-hub-polkadot-local" | ||
|
||
[[parachains.collators]] | ||
name = "asset-hub" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# pop up parachain -f ./tests/networks/rococo+asset-hub.toml | ||
|
||
[relaychain] | ||
chain = "rococo-local" | ||
|
||
[[relaychain.nodes]] | ||
name = "alice" | ||
validator = true | ||
|
||
[[relaychain.nodes]] | ||
name = "bob" | ||
validator = true | ||
|
||
[[parachains]] | ||
id = 1000 | ||
chain = "asset-hub-rococo-local" | ||
|
||
[[parachains.collators]] | ||
name = "asset-hub" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time I tried with an old chain-spec-generator the message was
Channels successfully prepared for initialization.
. but no channels were actually opened. This is likely nothing to worry about, as it should not occur to any user once we start using the releases from https://github.com/r0gue-io/paseo-network-runtimes.