mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
parachain-system (#296)
* rename parachain-{upgrade -> system}
* Merge message-broker into parachain-system
* Remove message-broker and clean up
* Update docs
* Test upward messages sending
And also update the relay-sproof-builder so that it allows to set the
relay dispatch queue size for the given parachain.
* Test horizontal message sending
* Remove old inherent definitions
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{Backend, Client};
|
||||
use cumulus_primitives::{
|
||||
inherents::{ValidationDataType, VALIDATION_DATA_IDENTIFIER}, PersistedValidationData,
|
||||
inherents::{SystemInherentData, SYSTEM_INHERENT_IDENTIFIER}, PersistedValidationData,
|
||||
};
|
||||
use cumulus_test_runtime::{Block, GetLastTimestamp};
|
||||
use cumulus_test_relay_sproof_builder::RelayStateSproofBuilder;
|
||||
@@ -101,10 +101,12 @@ impl InitBlockBuilder for Client {
|
||||
|
||||
inherent_data
|
||||
.put_data(
|
||||
VALIDATION_DATA_IDENTIFIER,
|
||||
&ValidationDataType {
|
||||
SYSTEM_INHERENT_IDENTIFIER,
|
||||
&SystemInherentData {
|
||||
validation_data,
|
||||
relay_chain_state,
|
||||
downward_messages: Default::default(),
|
||||
horizontal_messages: Default::default(),
|
||||
},
|
||||
)
|
||||
.expect("Put validation function params failed");
|
||||
|
||||
@@ -11,6 +11,7 @@ codec = { package = "parity-scale-codec", version = "1.0.5", default-features =
|
||||
# Substrate dependencies
|
||||
sp-state-machine = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Polkadot dependencies
|
||||
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
|
||||
@@ -24,5 +25,6 @@ std = [
|
||||
"codec/std",
|
||||
"sp-state-machine/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"cumulus-primitives/std",
|
||||
]
|
||||
|
||||
@@ -14,19 +14,25 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use cumulus_primitives::{relay_chain, AbridgedHostConfiguration, AbridgedHrmpChannel, ParaId};
|
||||
use sp_runtime::traits::HashFor;
|
||||
use sp_state_machine::MemoryDB;
|
||||
use cumulus_primitives::relay_chain;
|
||||
use sp_std::collections::btree_map::BTreeMap;
|
||||
|
||||
/// Builds a sproof (portmanteau of 'spoof' and 'proof') of the relay chain state.
|
||||
#[derive(Clone)]
|
||||
pub struct RelayStateSproofBuilder {
|
||||
pub host_config: cumulus_primitives::AbridgedHostConfiguration,
|
||||
pub para_id: ParaId,
|
||||
pub host_config: AbridgedHostConfiguration,
|
||||
pub relay_dispatch_queue_size: Option<(u32, u32)>,
|
||||
pub hrmp_egress_channel_index: Option<Vec<ParaId>>,
|
||||
pub hrmp_channels: BTreeMap<relay_chain::v1::HrmpChannelId, AbridgedHrmpChannel>,
|
||||
}
|
||||
|
||||
impl Default for RelayStateSproofBuilder {
|
||||
fn default() -> Self {
|
||||
RelayStateSproofBuilder {
|
||||
para_id: ParaId::from(200),
|
||||
host_config: cumulus_primitives::AbridgedHostConfiguration {
|
||||
max_code_size: 2 * 1024 * 1024,
|
||||
max_head_data_size: 1024 * 1024,
|
||||
@@ -38,6 +44,9 @@ impl Default for RelayStateSproofBuilder {
|
||||
validation_upgrade_frequency: 6,
|
||||
validation_upgrade_delay: 6,
|
||||
},
|
||||
relay_dispatch_queue_size: None,
|
||||
hrmp_egress_channel_index: None,
|
||||
hrmp_channels: BTreeMap::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -65,6 +74,28 @@ impl RelayStateSproofBuilder {
|
||||
relay_chain::well_known_keys::ACTIVE_CONFIG.to_vec(),
|
||||
self.host_config.encode(),
|
||||
);
|
||||
if let Some(relay_dispatch_queue_size) = self.relay_dispatch_queue_size {
|
||||
insert(
|
||||
relay_chain::well_known_keys::relay_dispatch_queue_size(self.para_id),
|
||||
relay_dispatch_queue_size.encode(),
|
||||
);
|
||||
}
|
||||
if let Some(hrmp_egress_channel_index) = self.hrmp_egress_channel_index {
|
||||
let mut sorted = hrmp_egress_channel_index.clone();
|
||||
sorted.sort();
|
||||
assert_eq!(sorted, hrmp_egress_channel_index,);
|
||||
|
||||
insert(
|
||||
relay_chain::well_known_keys::hrmp_egress_channel_index(self.para_id),
|
||||
hrmp_egress_channel_index.encode(),
|
||||
);
|
||||
}
|
||||
for (channel, metadata) in self.hrmp_channels {
|
||||
insert(
|
||||
relay_chain::well_known_keys::hrmp_channels(channel),
|
||||
metadata.encode(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let root = backend.root().clone();
|
||||
|
||||
@@ -30,7 +30,7 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default
|
||||
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
|
||||
|
||||
# Cumulus dependencies
|
||||
cumulus-parachain-upgrade = { path = "../../parachain-upgrade", default-features = false }
|
||||
cumulus-parachain-system = { path = "../../parachain-system", default-features = false }
|
||||
cumulus-primitives = { path = "../../primitives", default-features = false }
|
||||
cumulus-runtime = { path = "../../runtime", default-features = false }
|
||||
|
||||
@@ -44,7 +44,7 @@ substrate-wasm-builder = "3.0.0"
|
||||
default = [ "std" ]
|
||||
std = [
|
||||
"codec/std",
|
||||
"cumulus-parachain-upgrade/std",
|
||||
"cumulus-parachain-system/std",
|
||||
"cumulus-primitives/std",
|
||||
"cumulus-runtime/std",
|
||||
"frame-executive/std",
|
||||
|
||||
@@ -207,10 +207,12 @@ impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
impl cumulus_parachain_upgrade::Config for Runtime {
|
||||
impl cumulus_parachain_system::Config for Runtime {
|
||||
type SelfParaId = ParachainId;
|
||||
type Event = Event;
|
||||
type OnValidationData = ();
|
||||
type DownwardMessageHandlers = ();
|
||||
type HrmpMessageHandlers = ();
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -228,7 +230,7 @@ construct_runtime! {
|
||||
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
ParachainUpgrade: cumulus_parachain_upgrade::{Module, Call, Storage, Inherent, Event},
|
||||
ParachainSystem: cumulus_parachain_system::{Module, Call, Storage, Inherent, Event},
|
||||
TransactionPayment: pallet_transaction_payment::{Module, Storage},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user