From cb95a943e6eca88af59caea8ea32b1f383f906c9 Mon Sep 17 00:00:00 2001 From: Xavier Lau Date: Sat, 29 Aug 2020 08:52:57 +0800 Subject: [PATCH] companion: for #250 --- Cargo.lock | 1 + runtime/crab/Cargo.toml | 2 ++ runtime/crab/src/constants.rs | 8 ++++---- runtime/crab/src/lib.rs | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d45c9fa86..9c70fc15b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -798,6 +798,7 @@ dependencies = [ "darwinia-header-mmr", "darwinia-header-mmr-rpc-runtime-api", "darwinia-primitives", + "darwinia-relay-primitives", "darwinia-relayer-game", "darwinia-runtime-common", "darwinia-staking", diff --git a/runtime/crab/Cargo.toml b/runtime/crab/Cargo.toml index 4d7fe2c9b..2e658bc7e 100644 --- a/runtime/crab/Cargo.toml +++ b/runtime/crab/Cargo.toml @@ -24,6 +24,7 @@ darwinia-ethereum-backing = { default-features = false, git = "https:/ darwinia-ethereum-relay = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } darwinia-header-mmr = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } darwinia-header-mmr-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } +darwinia-relay-primitives = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } darwinia-relayer-game = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } darwinia-staking = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } darwinia-staking-rpc-runtime-api = { default-features = false, git = "https://github.com/darwinia-network/darwinia-common.git", branch = "master" } @@ -95,6 +96,7 @@ std = [ "darwinia-ethereum-relay/std", "darwinia-header-mmr/std", "darwinia-header-mmr-rpc-runtime-api/std", + "darwinia-relay-primitives/std", "darwinia-relayer-game/std", "darwinia-staking/std", "darwinia-staking-rpc-runtime-api/std", diff --git a/runtime/crab/src/constants.rs b/runtime/crab/src/constants.rs index 8403146e3..ab79ed743 100644 --- a/runtime/crab/src/constants.rs +++ b/runtime/crab/src/constants.rs @@ -96,13 +96,13 @@ pub mod relay { // --- darwinia --- use super::currency::*; use crate::*; - use darwinia_support::relay::*; + use darwinia_relay_primitives::*; pub struct EthereumRelayerGameAdjustor; impl AdjustableRelayerGame for EthereumRelayerGameAdjustor { type Moment = BlockNumber; type Balance = Balance; - type TcBlockNumber = ::TcBlockNumber; + type TcBlockNumber = ::BlockNumber; fn challenge_time(round: Round) -> Self::Moment { match round { @@ -113,11 +113,11 @@ pub mod relay { } } - fn round_from_chain_len(chain_len: u64) -> Round { + fn round_of_samples_count(chain_len: u64) -> Round { chain_len - 1 } - fn chain_len_from_round(round: Round) -> u64 { + fn samples_count_of_round(round: Round) -> u64 { round + 1 } diff --git a/runtime/crab/src/lib.rs b/runtime/crab/src/lib.rs index a3b59ff36..fdf2ad243 100644 --- a/runtime/crab/src/lib.rs +++ b/runtime/crab/src/lib.rs @@ -670,7 +670,7 @@ impl InstanceFilter for ProxyType { Call::Multisig(..) | Call::EthereumBacking(..) | Call::EthereumRelay(..) | - Call::RelayerGame(..) | + Call::EthereumRelayerGame(..) | Call::HeaderMMR(..) ), ProxyType::Staking => matches!(c, Call::Staking(..) | Call::Utility(..)), @@ -754,7 +754,7 @@ impl darwinia_ethereum_relay::Trait for Runtime { type ModuleId = EthereumRelayModuleId; type Event = Event; type Currency = Ring; - type RelayerGame = RelayerGame; + type RelayerGame = EthereumRelayerGame; type ApproveOrigin = ApproveOrigin; type RejectOrigin = EnsureRootOrHalfCouncil; type WeightInfo = (); @@ -841,7 +841,7 @@ construct_runtime!( EthereumBacking: darwinia_ethereum_backing::{Module, Call, Storage, Config, Event}, EthereumRelay: darwinia_ethereum_relay::{Module, Call, Storage, Config, Event}, - RelayerGame: darwinia_relayer_game::::{Module, Call, Storage, Event}, + EthereumRelayerGame: darwinia_relayer_game::::{Module, Call, Storage, Event}, // Consensus support. HeaderMMR: darwinia_header_mmr::{Module, Call, Storage},