From 05a84adfeee4cee2727caae0da49e16ebb0e2981 Mon Sep 17 00:00:00 2001 From: hammeWang Date: Wed, 30 Oct 2019 17:13:41 +0800 Subject: [PATCH 1/3] add srml/bridge --- Cargo.toml | 1 + srml/bridge/Cargo.toml | 9 +++++++++ srml/bridge/src/lib.rs | 7 +++++++ 3 files changed, 17 insertions(+) create mode 100644 srml/bridge/Cargo.toml create mode 100644 srml/bridge/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index adc22a05b..aa53054b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,6 +70,7 @@ members = [ "srml/kton", "srml/support", "srml/try", + "srml/bridge", ] exclude = ["node/runtime/wasm"] diff --git a/srml/bridge/Cargo.toml b/srml/bridge/Cargo.toml new file mode 100644 index 000000000..200836784 --- /dev/null +++ b/srml/bridge/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "bridge" +version = "0.1.0" +authors = ["hammeWang "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/srml/bridge/src/lib.rs b/srml/bridge/src/lib.rs new file mode 100644 index 000000000..31e1bb209 --- /dev/null +++ b/srml/bridge/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} From 677e63efcbf2fe0b6ff92e0b9dcd251712a94ed5 Mon Sep 17 00:00:00 2001 From: hammeWang Date: Thu, 31 Oct 2019 18:38:44 +0800 Subject: [PATCH 2/3] start on chainrelay --- Cargo.lock | 14 ++++++++++++++ Cargo.toml | 3 ++- node/cli/src/lib.rs | 12 ++++++++++-- srml/bridge/src/lib.rs | 7 ------- srml/chainrelay/Cargo.toml | 22 ++++++++++++++++++++++ srml/{bridge => chainrelay/poa}/Cargo.toml | 7 ++++++- srml/chainrelay/poa/src/lib.rs | 4 ++++ srml/chainrelay/src/lib.rs | 21 +++++++++++++++++++++ 8 files changed, 79 insertions(+), 11 deletions(-) delete mode 100644 srml/bridge/src/lib.rs create mode 100644 srml/chainrelay/Cargo.toml rename srml/{bridge => chainrelay/poa}/Cargo.toml (74%) create mode 100644 srml/chainrelay/poa/src/lib.rs create mode 100644 srml/chainrelay/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 03ecc657d..eea698b36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -660,6 +660,20 @@ dependencies = [ "vergen 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "darwinia-chainrelay" +version = "0.1.0" +dependencies = [ + "darwinia-chainrelay-poa 0.1.0", + "sr-std 2.0.0 (git+https://github.com/paritytech/substrate.git)", + "srml-support 2.0.0 (git+https://github.com/paritytech/substrate.git)", + "srml-system 2.0.0 (git+https://github.com/paritytech/substrate.git)", +] + +[[package]] +name = "darwinia-chainrelay-poa" +version = "0.1.0" + [[package]] name = "darwinia-staking" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index aa53054b5..340f4c43d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -70,7 +70,8 @@ members = [ "srml/kton", "srml/support", "srml/try", - "srml/bridge", + "srml/chainrelay", + "srml/chainrelay/poa" ] exclude = ["node/runtime/wasm"] diff --git a/node/cli/src/lib.rs b/node/cli/src/lib.rs index 468333a5f..e6ea54ced 100644 --- a/node/cli/src/lib.rs +++ b/node/cli/src/lib.rs @@ -47,6 +47,7 @@ pub enum ChainSpec { FlamingFir, /// Whatever the current runtime is with the "global testnet" defaults. StagingTestnet, + CrayfishTestnet, } /// Custom subcommands. @@ -129,6 +130,7 @@ impl ChainSpec { ChainSpec::Development => chain_spec::development_config(), ChainSpec::LocalTestnet => chain_spec::local_testnet_config(), ChainSpec::StagingTestnet => chain_spec::staging_testnet_config(), + ChainSpec::CrayfishTestnet => chain_spec::crayfish_testnet_config(), }) } @@ -136,8 +138,9 @@ impl ChainSpec { match s { "dev" => Some(ChainSpec::Development), "local" => Some(ChainSpec::LocalTestnet), - "" | "fir" | "flaming-fir" => Some(ChainSpec::FlamingFir), + "fir" | "flaming-fir" => Some(ChainSpec::FlamingFir), "staging" => Some(ChainSpec::StagingTestnet), + "" => Some(ChainSpec::CrayfishTestnet), _ => None, } } @@ -166,7 +169,12 @@ where |exit, _cli_args, _custom_args, config: Config<_, _>| { info!("{}", version.name); info!(" version {}", config.full_version()); - info!(" by Parity Technologies, 2017-2019"); + info!(" _____ _ _ "); + info!(" | __ \\ (_) (_) "); + info!(" | | | | __ _ _ ____ ___ _ __ _ __ _ "); + info!(" | | | |/ _` | '__\\ \\ /\\ / / | '_ \\| |/ _` |"); + info!(" | |__| | (_| | | \\ V V /| | | | | | (_| |"); + info!(" |_____/ \\__,_|_| \\_/\\_/ |_|_| |_|_|\\__,_|"); info!("Chain specification: {}", config.chain_spec.name()); info!("Node name: {}", config.name); info!("Roles: {:?}", config.roles); diff --git a/srml/bridge/src/lib.rs b/srml/bridge/src/lib.rs deleted file mode 100644 index 31e1bb209..000000000 --- a/srml/bridge/src/lib.rs +++ /dev/null @@ -1,7 +0,0 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} diff --git a/srml/chainrelay/Cargo.toml b/srml/chainrelay/Cargo.toml new file mode 100644 index 000000000..c42d9bb81 --- /dev/null +++ b/srml/chainrelay/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "darwinia-chainrelay" +version = "0.1.0" +authors = ["hammeWang "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rstd = { package = "sr-std", git = 'https://github.com/paritytech/substrate.git', default-features = false } +support = { package = "srml-support", git = 'https://github.com/paritytech/substrate.git', default-features = false } +system = { package = "srml-system", git = 'https://github.com/paritytech/substrate.git', default-features = false } +poa = { package = "darwinia-chainrelay-poa", path = "../chainrelay/poa", default-features = false } + +[features] +default = ["std"] +std = [ + "rstd/std", + "support/std", + "system/std", + "poa/std", +] \ No newline at end of file diff --git a/srml/bridge/Cargo.toml b/srml/chainrelay/poa/Cargo.toml similarity index 74% rename from srml/bridge/Cargo.toml rename to srml/chainrelay/poa/Cargo.toml index 200836784..252e715c9 100644 --- a/srml/bridge/Cargo.toml +++ b/srml/chainrelay/poa/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bridge" +name = "darwinia-chainrelay-poa" version = "0.1.0" authors = ["hammeWang "] edition = "2018" @@ -7,3 +7,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + + +[features] +default = ["std"] +std = [] \ No newline at end of file diff --git a/srml/chainrelay/poa/src/lib.rs b/srml/chainrelay/poa/src/lib.rs new file mode 100644 index 000000000..69529b312 --- /dev/null +++ b/srml/chainrelay/poa/src/lib.rs @@ -0,0 +1,4 @@ +pub struct BestHeader { + height: u64, // enough for ethereum poa network (kovan) + hash: Hash, +} diff --git a/srml/chainrelay/src/lib.rs b/srml/chainrelay/src/lib.rs new file mode 100644 index 000000000..acc6c9867 --- /dev/null +++ b/srml/chainrelay/src/lib.rs @@ -0,0 +1,21 @@ +//! prototype module for bridging in ethereum poa blockcahin + +#![recursion_limit = "128"] +#![cfg_attr(not(feature = "std"), no_std)] + +use rstd::prelude::*; +use support::{decl_event, decl_module, decl_storage, ensure}; + +use poa::BestHeader; + +pub trait Trait: system::Trait {} + +decl_storage! { + trait Store for Module as Bridge { + // we don't need to start from genesis block + pub InitialBlock get(initial_block) config(): T::BlockNumber; + // BestHeader + pub BestHeader get(best_header): BestHeader; + + } +} From b48b129653a8d36ced5f074696eb91adac68d5c3 Mon Sep 17 00:00:00 2001 From: hammeWang Date: Fri, 1 Nov 2019 15:41:10 +0800 Subject: [PATCH 3/3] fix https://github.com/darwinia-network/darwinia/issues/84 --- node/cli/src/lib.rs | 2 +- node/runtime/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/node/cli/src/lib.rs b/node/cli/src/lib.rs index e6ea54ced..217b880b2 100644 --- a/node/cli/src/lib.rs +++ b/node/cli/src/lib.rs @@ -169,7 +169,7 @@ where |exit, _cli_args, _custom_args, config: Config<_, _>| { info!("{}", version.name); info!(" version {}", config.full_version()); - info!(" _____ _ _ "); + info!(" _____ _ _ "); info!(" | __ \\ (_) (_) "); info!(" | | | | __ _ _ ____ ___ _ __ _ __ _ "); info!(" | | | |/ _` | '__\\ \\ /\\ / / | '_ \\| |/ _` |"); diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index f837c9a1a..27f8e1e81 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -264,7 +264,7 @@ parameter_types! { impl session::Trait for Runtime { type OnSessionEnding = Staking; type SessionHandler = SessionHandlers; - type ShouldEndSession = session::PeriodicSessions; + type ShouldEndSession = Babe; type Event = Event; type Keys = SessionKeys; type ValidatorId = ::AccountId;