Add GenesisConfig for Millau and Rialto Runtimes (#401)

* Add Rialto as a target for the Millau node

* Rename Rialto module to Rialto-PoA

This will reduce confusion as the Millau runtime has a
Rialto module as well which refers to the Substrate chain.

* Add Millau as a target for the Rialto node

* Be more explicit about Rialto PoA related code

* Missed some name changes in the Ethereum PoA relay

* Re-export Substrate pallet structs used by node

* Remove `first_scheduled_change` of Millau in Rialto node

* Make Millau's genesis config for Rialto bridge more accurate

* Set initial header for Millau config

* Update initial Millau authorities

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>

* RustFmt Millau authorities

Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
This commit is contained in:
Hernando Castano
2020-10-09 02:09:06 -04:00
committed by Bastian Köcher
parent 9e9ac8df3c
commit f52c839d6e
13 changed files with 210 additions and 35 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ jsonrpc-core = "15.0.0"
structopt = "0.3.17"
# Bridge dependencies
bp-rialto = { path = "../../../primitives/rialto" }
millau-runtime = { path = "../runtime" }
# Substrate Dependencies
+12 -2
View File
@@ -15,8 +15,8 @@
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
use millau_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature,
SudoConfig, SystemConfig, WASM_BINARY,
AccountId, AuraConfig, BalancesConfig, BridgeRialtoConfig, GenesisConfig, GrandpaConfig, SessionConfig,
SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY,
};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{sr25519, Pair, Public};
@@ -155,6 +155,7 @@ fn testnet_genesis(
pallet_grandpa: Some(GrandpaConfig {
authorities: Vec::new(),
}),
pallet_substrate_bridge: load_rialto_bridge_config(),
pallet_sudo: Some(SudoConfig { key: root_key }),
pallet_session: Some(SessionConfig {
keys: initial_authorities
@@ -164,3 +165,12 @@ fn testnet_genesis(
}),
}
}
fn load_rialto_bridge_config() -> Option<BridgeRialtoConfig> {
Some(BridgeRialtoConfig {
initial_header: Some(millau_runtime::rialto::initial_header()),
initial_authority_list: millau_runtime::rialto::initial_authority_set().authorities,
initial_set_id: millau_runtime::rialto::initial_authority_set().set_id,
first_scheduled_change: None,
})
}
+3
View File
@@ -9,6 +9,7 @@ license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
[dependencies]
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
hex-literal = "0.3"
serde = { version = "1.0.115", optional = true, features = ["derive"] }
# Bridge dependencies
@@ -40,6 +41,7 @@ sp-block-builder = { version = "2.0", default-features = false }
sp-consensus-aura = { version = "0.8", default-features = false }
sp-core = { version = "2.0", default-features = false }
sp-inherents = { version = "2.0", default-features = false }
sp-finality-grandpa = { version = "2.0", default-features = false }
sp-offchain = { version = "2.0", default-features = false }
sp-runtime = { version = "2.0", default-features = false }
sp-session = { version = "2.0", default-features = false }
@@ -79,6 +81,7 @@ std = [
"sp-consensus-aura/std",
"sp-core/std",
"sp-inherents/std",
"sp-finality-grandpa/std",
"sp-offchain/std",
"sp-runtime/std",
"sp-session/std",
+3 -1
View File
@@ -28,6 +28,8 @@
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
pub mod rialto;
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
use sp_api::impl_runtime_apis;
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
@@ -321,7 +323,7 @@ construct_runtime!(
NodeBlock = opaque::Block,
UncheckedExtrinsic = UncheckedExtrinsic
{
BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage},
BridgeRialto: pallet_substrate_bridge::{Module, Call, Storage, Config<T>},
BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event<T>},
System: frame_system::{Module, Call, Config, Storage, Event<T>},
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
+56
View File
@@ -0,0 +1,56 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Parity Bridges Common.
// Parity Bridges Common is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Parity Bridges Common is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
//! Configuration parameters for the Rialto Substrate chain.
use bp_rialto::Header;
use pallet_substrate_bridge::AuthoritySet;
use sp_core::crypto::Public;
use sp_finality_grandpa::AuthorityId;
use sp_std::vec;
/// The first header known to the pallet.
///
/// Note that this does not need to be the genesis header of the Rialto
/// chain since the pallet may start at any arbitrary header.
// To get this we first need to call the `chain_getBlockHash` RPC method, and then
// we can use the result from that and call the `chain_getBlock` RPC method to get
// the rest of the info.
//
// In this case we've grabbed the genesis block of the Rialto Substrate chain.
pub fn initial_header() -> Header {
Header {
parent_hash: Default::default(),
number: Default::default(),
state_root: Default::default(),
extrinsics_root: Default::default(),
digest: Default::default(),
}
}
/// The first set of Grandpa authorities known to the pallet.
///
/// Note that this doesn't have to be the "genesis" authority set, as the
/// pallet can be configured to start from any height.
pub fn initial_authority_set() -> AuthoritySet {
let set_id = 0;
let authorities = vec![
(AuthorityId::from_slice(&[1; 32]), 1),
(AuthorityId::from_slice(&[2; 32]), 1),
(AuthorityId::from_slice(&[3; 32]), 1),
];
AuthoritySet::new(authorities, set_id)
}