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:
Sergei Shulepov
2021-01-21 15:53:00 +01:00
committed by GitHub
parent b31a6b38a9
commit 615ac5fefe
20 changed files with 1438 additions and 1272 deletions
+33 -2
View File
@@ -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();