diff --git a/bridges/README.md b/bridges/README.md index 1f426a860716a..744056faa1350 100644 --- a/bridges/README.md +++ b/bridges/README.md @@ -13,7 +13,7 @@ PoA chains to Substrate. We're working on expanding this functionality in the fu ## Contents - [Installation](#installation) - [Project Layout](#project-layout) -- [Bridge Node Runtime](#bridge-node-runtime) +- [Rialto Runtime](#rialto-runtime) - [Ethereum Node](#ethereum-node) - [Bridge Relay](#bridge-relay) - [Running the Bridge](#running-the-bridge) @@ -60,7 +60,7 @@ the `relays` which are used to pass messages between chains. │ └── substrate // 🚧 WIP 🚧 ``` -## Bridge Node Runtime +## Rialto Runtime The node runtime consists of several runtime modules, however not all of them are used at the same time. When running an Ethereum PoA to Substrate bridge the modules required are the Ethereum module and the currency exchange module. When running a Substrate to Substrate bridge the Substrate and @@ -170,7 +170,7 @@ First you'll need to build the bridge node and relay. This can be done as follow ```bash # In `parity-bridges-common` folder -cargo build -p bridge-node +cargo build -p rialto-bridge-node cargo build -p ethereum-poa-relay ``` @@ -204,7 +204,7 @@ chains it must be run last. ```bash # In `parity-bridges-common` folder ./scripts/run-openethereum-node.sh -./scripts/run-bridge-node.sh +./scripts/run-rialto-bridge-node.sh ./scripts/run-eth2sub-relay.sh ``` At this point you should see the relayer submitting blocks from the Ethereum chain @@ -221,7 +221,7 @@ docker build . -t bridge-relay-dev You can also build and run the Substrate based node as follows: ```bash -docker build . -t bridge-node-dev --build-arg PROJECT=bridge-node +docker build . -t bridge-node-dev --build-arg PROJECT=rialto-bridge-node ``` To run the Substrate node you can do the following: @@ -248,15 +248,15 @@ docker run -it poa-relay ``` By default the relayer is configured to connect to OpenEthereum `--dev` chain node and Substrate -`bridge-node` running in `--dev` mode. +`rialto-bridge-node` running in `--dev` mode. -To build the `bridge-node`: +To build the `rialto-bridge-node`: ```bash docker build \ https://raw.githubusercontent.com/paritytech/parity-bridges-common/master/deployments/rialto/Bridge.Dockerfile \ - -t bridge-node \ - --build-arg PROJECT=bridge-node -docker run -it bridge-node --dev + -t rialto-bridge-node \ + --build-arg PROJECT=rialto-bridge-node +docker run -it rialto-bridge-node --dev ``` And to build `OpenEthereum` with bridge support: diff --git a/bridges/bin/millau-node/Cargo.toml b/bridges/bin/millau-node/Cargo.toml new file mode 100644 index 0000000000000..646841abdc5de --- /dev/null +++ b/bridges/bin/millau-node/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "millau-bridge-node" +description = "Substrate node compatible with Millau runtime" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +bridge-node = { path = "../node", default-features = false, features = ["millau"] } diff --git a/bridges/bin/millau-node/src/main.rs b/bridges/bin/millau-node/src/main.rs new file mode 100644 index 0000000000000..6ce72ef75c823 --- /dev/null +++ b/bridges/bin/millau-node/src/main.rs @@ -0,0 +1,24 @@ +// Copyright 2019-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 . + +//! Millau bridge node. + +#![warn(missing_docs)] + +/// Run node. +fn main() -> bridge_node::Result { + bridge_node::run() +} diff --git a/bridges/bin/millau-runtime/Cargo.toml b/bridges/bin/millau-runtime/Cargo.toml new file mode 100644 index 0000000000000..a6b2cb3f1d326 --- /dev/null +++ b/bridges/bin/millau-runtime/Cargo.toml @@ -0,0 +1,254 @@ +[package] +name = "millau-runtime" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +homepage = "https://substrate.dev" +repository = "https://github.com/paritytech/parity-bridges-common/" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +hex-literal = "0.3" + +[dependencies.codec] +package = "parity-scale-codec" +version = "1.3.1" +default-features = false +features = ["derive"] + +[dependencies.serde] +version = "1.0.115" +optional = true +features = ["derive"] + +# Substrate Dependencies +[dependencies.pallet-aura] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-balances] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-bridge-call-dispatch] +version = "0.1.0" +default-features = false +path = "../../modules/call-dispatch" + +[dependencies.pallet-message-lane] +version = "0.1.0" +default-features = false +path = "../../modules/message-lane" + +[dependencies.frame-support] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-grandpa] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-randomness-collective-flip] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-sudo] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-shift-session-manager] +version = "0.1.0" +default-features = false +path = "../../modules/shift-session-manager" + +[dependencies.pallet-session] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.frame-system] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.frame-system-rpc-runtime-api] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-timestamp] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.pallet-transaction-payment] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.frame-executive] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +# Substrate Primitives +[dependencies.sp-api] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-block-builder] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-consensus-aura] +version = "0.8.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-core] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-inherents] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-io] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-offchain] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-runtime] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-session] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-staking] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-std] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-transaction-pool] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.sp-version] +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.frame-benchmarking] +optional = true +version = "2.0.0-rc6" +tag = 'v2.0.0-rc6' +default-features = false +git = "https://github.com/paritytech/substrate/" + +[dependencies.bp-header-chain] +version = "0.1.0" +default-features = false +path = "../../primitives/header-chain" + +[dependencies.bp-message-lane] +version = "0.1.0" +default-features = false +path = "../../primitives/message-lane" + +# Dev Dependencies + +[build-dependencies.wasm-builder-runner] +version = "1.0.5" +tag = 'v2.0.0-rc6' +package = "substrate-wasm-builder-runner" +git = "https://github.com/paritytech/substrate/" + +[features] +default = ["std"] +std = [ + "bp-message-lane/std", + "codec/std", + "frame-benchmarking/std", + "frame-executive/std", + "frame-support/std", + "frame-system-rpc-runtime-api/std", + "frame-system/std", + "pallet-aura/std", + "pallet-balances/std", + "pallet-bridge-call-dispatch/std", + "pallet-grandpa/std", + "pallet-randomness-collective-flip/std", + "pallet-shift-session-manager/std", + "pallet-sudo/std", + "pallet-timestamp/std", + "pallet-transaction-payment/std", + "serde", + "sp-api/std", + "sp-block-builder/std", + "sp-consensus-aura/std", + "sp-core/std", + "sp-inherents/std", + "sp-io/std", + "sp-offchain/std", + "sp-runtime/std", + "sp-session/std", + "sp-std/std", + "sp-transaction-pool/std", + "sp-version/std", +] +runtime-benchmarks = [ + "frame-benchmarking", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] diff --git a/bridges/bin/node/runtime/build.rs b/bridges/bin/millau-runtime/build.rs similarity index 100% rename from bridges/bin/node/runtime/build.rs rename to bridges/bin/millau-runtime/build.rs diff --git a/bridges/bin/millau-runtime/src/lib.rs b/bridges/bin/millau-runtime/src/lib.rs new file mode 100644 index 0000000000000..864fb8256c00e --- /dev/null +++ b/bridges/bin/millau-runtime/src/lib.rs @@ -0,0 +1,475 @@ +// Copyright 2019-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 . + +//! The Millau runtime. This can be compiled with `#[no_std]`, ready for Wasm. + +#![cfg_attr(not(feature = "std"), no_std)] +// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. +#![recursion_limit = "256"] +// Runtime-generated enums +#![allow(clippy::large_enum_variant)] +// Runtime-generated DecodeLimit::decode_all_With_depth_limit +#![allow(clippy::unnecessary_mut_passed)] + +// Make the WASM binary available. +#[cfg(feature = "std")] +include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs")); + +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; +use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; +use sp_runtime::traits::{ + BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, OpaqueKeys, Saturating, Verify, +}; +use sp_runtime::{ + create_runtime_str, generic, impl_opaque_keys, + transaction_validity::{TransactionSource, TransactionValidity}, + ApplyExtrinsicResult, MultiSignature, +}; +use sp_std::prelude::*; +#[cfg(feature = "std")] +use sp_version::NativeVersion; +use sp_version::RuntimeVersion; + +// A few exports that help ease life for downstream crates. +pub use frame_support::{ + construct_runtime, parameter_types, + traits::{Currency, ExistenceRequirement, Imbalance, KeyOwnerProofSystem, Randomness}, + weights::{IdentityFee, RuntimeDbWeight, Weight}, + StorageValue, +}; + +pub use pallet_balances::Call as BalancesCall; +pub use pallet_timestamp::Call as TimestampCall; + +#[cfg(any(feature = "std", test))] +pub use sp_runtime::BuildStorage; +pub use sp_runtime::{Perbill, Permill}; + +/// An index to a block. +pub type BlockNumber = u32; + +/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. +pub type Signature = MultiSignature; + +/// Some way of identifying an account on the chain. We intentionally make it equivalent +/// to the public key of our transaction signing scheme. +pub type AccountId = <::Signer as IdentifyAccount>::AccountId; + +/// The type for looking up accounts. We don't expect more than 4 billion of them, but you +/// never know... +pub type AccountIndex = u32; + +/// Balance of an account. +pub type Balance = u128; + +/// Index of a transaction in the chain. +pub type Index = u32; + +/// A hash of some data used by the chain. +pub type Hash = sp_core::H256; + +/// Digest item type. +pub type DigestItem = generic::DigestItem; + +/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know +/// the specifics of the runtime. They can then be made to be agnostic over specific formats +/// of data like extrinsics, allowing for them to continue syncing the network through upgrades +/// to even the core data structures. +pub mod opaque { + use super::*; + + pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; + + /// Opaque block header type. + pub type Header = generic::Header; + /// Opaque block type. + pub type Block = generic::Block; + /// Opaque block identifier type. + pub type BlockId = generic::BlockId; +} + +impl_opaque_keys! { + pub struct SessionKeys { + pub aura: Aura, + pub grandpa: Grandpa, + } +} + +/// This runtime version. +pub const VERSION: RuntimeVersion = RuntimeVersion { + spec_name: create_runtime_str!("millau-runtime"), + impl_name: create_runtime_str!("millau-runtime"), + authoring_version: 1, + spec_version: 1, + impl_version: 1, + apis: RUNTIME_API_VERSIONS, + transaction_version: 1, +}; + +pub const MILLISECS_PER_BLOCK: u64 = 6000; + +pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; + +// These time units are defined in number of blocks. +pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); +pub const HOURS: BlockNumber = MINUTES * 60; +pub const DAYS: BlockNumber = HOURS * 24; + +/// The version information used to identify this runtime when compiled natively. +#[cfg(feature = "std")] +pub fn native_version() -> NativeVersion { + NativeVersion { + runtime_version: VERSION, + can_author_with: Default::default(), + } +} + +parameter_types! { + pub const BlockHashCount: BlockNumber = 250; + pub const MaximumBlockWeight: Weight = 2_000_000_000_000; + pub const ExtrinsicBaseWeight: Weight = 10_000_000; + pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75); + /// Assume 10% of weight for average on_initialize calls. + pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get() + .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get(); + pub const MaximumBlockLength: u32 = 5 * 1024 * 1024; + pub const Version: RuntimeVersion = VERSION; + pub const DbWeight: RuntimeDbWeight = RuntimeDbWeight { + read: 60_000_000, // ~0.06 ms = ~60 µs + write: 200_000_000, // ~0.2 ms = 200 µs + }; +} + +impl frame_system::Trait for Runtime { + /// The basic call filter to use in dispatchable. + type BaseCallFilter = (); + /// The identifier used to distinguish between accounts. + type AccountId = AccountId; + /// The aggregated dispatch type that is available for extrinsics. + type Call = Call; + /// The lookup mechanism to get account ID from whatever is passed in dispatchers. + type Lookup = IdentityLookup; + /// The index type for storing how many extrinsics an account has signed. + type Index = Index; + /// The index type for blocks. + type BlockNumber = BlockNumber; + /// The type for hashing blocks and tries. + type Hash = Hash; + /// The hashing algorithm used. + type Hashing = BlakeTwo256; + /// The header type. + type Header = generic::Header; + /// The ubiquitous event type. + type Event = Event; + /// The ubiquitous origin type. + type Origin = Origin; + /// Maximum number of block number to block hash mappings to keep (oldest pruned first). + type BlockHashCount = BlockHashCount; + /// Maximum weight of each block. + type MaximumBlockWeight = MaximumBlockWeight; + /// The weight of database operations that the runtime can invoke. + type DbWeight = DbWeight; + /// The weight of the overhead invoked on the block import process, independent of the + /// extrinsics included in that block. + type BlockExecutionWeight = (); + /// The base weight of any extrinsic processed by the runtime, independent of the + /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...) + type ExtrinsicBaseWeight = ExtrinsicBaseWeight; + /// The maximum weight that a single extrinsic of `Normal` dispatch class can have, + /// idependent of the logic of that extrinsics. (Roughly max block weight - average on + /// initialize cost). + type MaximumExtrinsicWeight = MaximumExtrinsicWeight; + /// Maximum size of all encoded transactions (in bytes) that are allowed in one block. + type MaximumBlockLength = MaximumBlockLength; + /// Portion of the block weight that is available to all normal transactions. + type AvailableBlockRatio = AvailableBlockRatio; + /// Version of the runtime. + type Version = Version; + /// Converts a module to the index of the module in `construct_runtime!`. + /// + /// This type is being generated by `construct_runtime!`. + type ModuleToIndex = ModuleToIndex; + /// What to do if a new account is created. + type OnNewAccount = (); + /// What to do if an account is fully reaped from the system. + type OnKilledAccount = (); + /// The data to be stored in an account. + type AccountData = pallet_balances::AccountData; + /// Weight information for the extrinsics of this pallet. + type SystemWeightInfo = (); +} + +impl pallet_aura::Trait for Runtime { + type AuthorityId = AuraId; +} + +impl pallet_bridge_call_dispatch::Trait for Runtime { + type Event = Event; + type MessageId = (bp_message_lane::LaneId, bp_message_lane::MessageNonce); + type Call = Call; +} + +impl pallet_grandpa::Trait for Runtime { + type Event = Event; + type Call = Call; + + type KeyOwnerProofSystem = (); + + type KeyOwnerProof = >::Proof; + + type KeyOwnerIdentification = + >::IdentificationTuple; + + type HandleEquivocation = (); +} + +parameter_types! { + pub const MinimumPeriod: u64 = SLOT_DURATION / 2; +} + +impl pallet_timestamp::Trait for Runtime { + /// A timestamp: milliseconds since the unix epoch. + type Moment = u64; + type OnTimestampSet = Aura; + type MinimumPeriod = MinimumPeriod; + type WeightInfo = (); +} + +parameter_types! { + pub const ExistentialDeposit: u128 = 500; +} + +impl pallet_balances::Trait for Runtime { + /// The type for recording an account's balance. + type Balance = Balance; + /// The ubiquitous event type. + type Event = Event; + type DustRemoval = (); + type ExistentialDeposit = ExistentialDeposit; + type AccountStore = System; + type WeightInfo = (); +} + +parameter_types! { + pub const TransactionBaseFee: Balance = 0; + pub const TransactionByteFee: Balance = 1; +} + +impl pallet_transaction_payment::Trait for Runtime { + type Currency = pallet_balances::Module; + type OnTransactionPayment = (); + type TransactionByteFee = TransactionByteFee; + type WeightToFee = IdentityFee; + type FeeMultiplierUpdate = (); +} + +impl pallet_sudo::Trait for Runtime { + type Event = Event; + type Call = Call; +} + +parameter_types! { + pub const Period: BlockNumber = 4; + pub const Offset: BlockNumber = 0; +} + +impl pallet_session::Trait for Runtime { + type Event = Event; + type ValidatorId = ::AccountId; + type ValidatorIdOf = (); + type ShouldEndSession = pallet_session::PeriodicSessions; + type NextSessionRotation = pallet_session::PeriodicSessions; + type SessionManager = pallet_shift_session_manager::Module; + type SessionHandler = ::KeyTypeIdProviders; + type Keys = SessionKeys; + type DisabledValidatorsThreshold = (); + type WeightInfo = (); +} + +impl pallet_shift_session_manager::Trait for Runtime {} + +construct_runtime!( + pub enum Runtime where + Block = Block, + NodeBlock = opaque::Block, + UncheckedExtrinsic = UncheckedExtrinsic + { + BridgeCallDispatch: pallet_bridge_call_dispatch::{Module, Event}, + System: frame_system::{Module, Call, Config, Storage, Event}, + RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, + Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent}, + Aura: pallet_aura::{Module, Config, Inherent}, + Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event}, + Balances: pallet_balances::{Module, Call, Storage, Config, Event}, + TransactionPayment: pallet_transaction_payment::{Module, Storage}, + Sudo: pallet_sudo::{Module, Call, Config, Storage, Event}, + Session: pallet_session::{Module, Call, Storage, Event, Config}, + ShiftSessionManager: pallet_shift_session_manager::{Module}, + } +); + +/// The address format for describing accounts. +pub type Address = AccountId; +/// Block header type as expected by this runtime. +pub type Header = generic::Header; +/// Block type as expected by this runtime. +pub type Block = generic::Block; +/// A Block signed with a Justification +pub type SignedBlock = generic::SignedBlock; +/// BlockId type as expected by this runtime. +pub type BlockId = generic::BlockId; +/// The SignedExtension to the basic transaction logic. +pub type SignedExtra = ( + frame_system::CheckSpecVersion, + frame_system::CheckTxVersion, + frame_system::CheckGenesis, + frame_system::CheckEra, + frame_system::CheckNonce, + frame_system::CheckWeight, + pallet_transaction_payment::ChargeTransactionPayment, +); +/// The payload being signed in transactions. +pub type SignedPayload = generic::SignedPayload; +/// Unchecked extrinsic type as expected by this runtime. +pub type UncheckedExtrinsic = generic::UncheckedExtrinsic; +/// Extrinsic type that has already been checked. +pub type CheckedExtrinsic = generic::CheckedExtrinsic; +/// Executive: handles dispatch to the various modules. +pub type Executive = + frame_executive::Executive, Runtime, AllModules>; + +impl_runtime_apis! { + impl sp_api::Core for Runtime { + fn version() -> RuntimeVersion { + VERSION + } + + fn execute_block(block: Block) { + Executive::execute_block(block) + } + + fn initialize_block(header: &::Header) { + Executive::initialize_block(header) + } + } + + impl sp_api::Metadata for Runtime { + fn metadata() -> OpaqueMetadata { + Runtime::metadata().into() + } + } + + impl sp_block_builder::BlockBuilder for Runtime { + fn apply_extrinsic(extrinsic: ::Extrinsic) -> ApplyExtrinsicResult { + Executive::apply_extrinsic(extrinsic) + } + + fn finalize_block() -> ::Header { + Executive::finalize_block() + } + + fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<::Extrinsic> { + data.create_extrinsics() + } + + fn check_inherents( + block: Block, + data: sp_inherents::InherentData, + ) -> sp_inherents::CheckInherentsResult { + data.check_extrinsics(&block) + } + + fn random_seed() -> ::Hash { + RandomnessCollectiveFlip::random_seed() + } + } + + impl frame_system_rpc_runtime_api::AccountNonceApi for Runtime { + fn account_nonce(account: AccountId) -> Index { + System::account_nonce(account) + } + } + + impl sp_transaction_pool::runtime_api::TaggedTransactionQueue for Runtime { + fn validate_transaction( + source: TransactionSource, + tx: ::Extrinsic, + ) -> TransactionValidity { + Executive::validate_transaction(source, tx) + } + } + + impl sp_offchain::OffchainWorkerApi for Runtime { + fn offchain_worker(header: &::Header) { + Executive::offchain_worker(header) + } + } + + impl sp_consensus_aura::AuraApi for Runtime { + fn slot_duration() -> u64 { + Aura::slot_duration() + } + + fn authorities() -> Vec { + Aura::authorities() + } + } + + impl sp_session::SessionKeys for Runtime { + fn generate_session_keys(seed: Option>) -> Vec { + SessionKeys::generate(seed) + } + + fn decode_session_keys( + encoded: Vec, + ) -> Option, sp_core::crypto::KeyTypeId)>> { + SessionKeys::decode_into_raw_public_keys(&encoded) + } + } + + impl fg_primitives::GrandpaApi for Runtime { + fn grandpa_authorities() -> GrandpaAuthorityList { + Grandpa::grandpa_authorities() + } + + fn submit_report_equivocation_unsigned_extrinsic( + equivocation_proof: fg_primitives::EquivocationProof< + ::Hash, + NumberFor, + >, + key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof, + ) -> Option<()> { + let key_owner_proof = key_owner_proof.decode()?; + + Grandpa::submit_unsigned_equivocation_report( + equivocation_proof, + key_owner_proof, + ) + } + + fn generate_key_ownership_proof( + _set_id: fg_primitives::SetId, + _authority_id: GrandpaId, + ) -> Option { + // NOTE: this is the only implementation possible since we've + // defined our key owner proof type as a bottom type (i.e. a type + // with no values). + None + } + } +} diff --git a/bridges/bin/node/node/Cargo.toml b/bridges/bin/node/Cargo.toml similarity index 89% rename from bridges/bin/node/node/Cargo.toml rename to bridges/bin/node/Cargo.toml index c163f8e89b77f..7f6015d639c9e 100644 --- a/bridges/bin/node/node/Cargo.toml +++ b/bridges/bin/node/Cargo.toml @@ -8,20 +8,24 @@ homepage = "https://substrate.dev" repository = "https://github.com/paritytech/parity-bridges-common/" license = "GPL-3.0-or-later WITH Classpath-exception-2.0" -[[bin]] -name = "bridge-node" - [dependencies] -bp-eth-poa = { version = "0.1.0", path = "../../../primitives/ethereum-poa" } futures = "0.3.5" jsonrpc-core = "14.2.0" log = "0.4.11" -pallet-message-lane-rpc = { version = "0.1.0", path = "../../../modules/message-lane/rpc" } +pallet-message-lane-rpc = { version = "0.1.0", path = "../../modules/message-lane/rpc" } structopt = "0.3.17" -[dependencies.bridge-node-runtime] +[dependencies.millau-runtime] +optional = true +version = "0.1.0" +path = "../millau-runtime" +default-features = false +features = ["std"] + +[dependencies.rialto-runtime] +optional = true version = "0.1.0" -path = "../runtime" +path = "../rialto-runtime" default-features = false features = ["std"] @@ -148,6 +152,12 @@ git = "https://github.com/paritytech/substrate.git" [features] default = [] +millau = [ + "millau-runtime", +] +rialto = [ + "rialto-runtime", +] runtime-benchmarks = [ - "bridge-node-runtime/runtime-benchmarks", + "rialto-runtime/runtime-benchmarks", ] diff --git a/bridges/bin/node/node/build.rs b/bridges/bin/node/build.rs similarity index 100% rename from bridges/bin/node/node/build.rs rename to bridges/bin/node/build.rs diff --git a/bridges/bin/node/node/src/chain_spec.rs b/bridges/bin/node/src/chain_spec.rs similarity index 95% rename from bridges/bin/node/node/src/chain_spec.rs rename to bridges/bin/node/src/chain_spec.rs index 12c97f140e9d2..2aac990331903 100644 --- a/bridges/bin/node/node/src/chain_spec.rs +++ b/bridges/bin/node/src/chain_spec.rs @@ -14,11 +14,11 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use bridge_node_runtime::{ +use grandpa_primitives::AuthorityId as GrandpaId; +use rialto_runtime::{ AccountId, AuraConfig, BalancesConfig, BridgeKovanConfig, BridgeRialtoConfig, GenesisConfig, GrandpaConfig, SessionConfig, SessionKeys, Signature, SudoConfig, SystemConfig, WASM_BINARY, }; -use grandpa_primitives::AuthorityId as GrandpaId; use sp_consensus_aura::sr25519::AuthorityId as AuraId; use sp_core::{sr25519, Pair, Public}; use sp_runtime::traits::{IdentifyAccount, Verify}; @@ -169,16 +169,16 @@ fn testnet_genesis( fn load_rialto_bridge_config() -> Option { Some(BridgeRialtoConfig { - initial_header: bridge_node_runtime::rialto::genesis_header(), + initial_header: rialto_runtime::rialto::genesis_header(), initial_difficulty: 0.into(), - initial_validators: bridge_node_runtime::rialto::genesis_validators(), + initial_validators: rialto_runtime::rialto::genesis_validators(), }) } fn load_kovan_bridge_config() -> Option { Some(BridgeKovanConfig { - initial_header: bridge_node_runtime::kovan::genesis_header(), + initial_header: rialto_runtime::kovan::genesis_header(), initial_difficulty: 0.into(), - initial_validators: bridge_node_runtime::kovan::genesis_validators(), + initial_validators: rialto_runtime::kovan::genesis_validators(), }) } diff --git a/bridges/bin/node/node/src/cli.rs b/bridges/bin/node/src/cli.rs similarity index 100% rename from bridges/bin/node/node/src/cli.rs rename to bridges/bin/node/src/cli.rs diff --git a/bridges/bin/node/node/src/command.rs b/bridges/bin/node/src/command.rs similarity index 98% rename from bridges/bin/node/node/src/command.rs rename to bridges/bin/node/src/command.rs index 9951e9af47f6c..f216c3c42d1c7 100644 --- a/bridges/bin/node/node/src/command.rs +++ b/bridges/bin/node/src/command.rs @@ -33,7 +33,7 @@ use crate::cli::{Cli, Subcommand}; use crate::service; use crate::service::new_partial; -use bridge_node_runtime::Block; +use rialto_runtime::Block; use sc_cli::{ChainSpec, Role, RuntimeVersion, SubstrateCli}; use sc_service::PartialComponents; @@ -67,7 +67,7 @@ impl SubstrateCli for Cli { } fn native_runtime_version(_: &Box) -> &'static RuntimeVersion { - &bridge_node_runtime::VERSION + &rialto_runtime::VERSION } fn load_spec(&self, id: &str) -> Result, String> { diff --git a/bridges/bin/node/node/src/main.rs b/bridges/bin/node/src/lib.rs similarity index 90% rename from bridges/bin/node/node/src/main.rs rename to bridges/bin/node/src/lib.rs index 30b05d773b0ea..fdecc0b45f0ea 100644 --- a/bridges/bin/node/node/src/main.rs +++ b/bridges/bin/node/src/lib.rs @@ -23,6 +23,10 @@ mod service; mod cli; mod command; -fn main() -> sc_cli::Result<()> { +/// Node run result. +pub type Result = sc_cli::Result<()>; + +/// Run node. +pub fn run() -> Result { command::run() } diff --git a/bridges/bin/node/node/src/service.rs b/bridges/bin/node/src/service.rs similarity index 98% rename from bridges/bin/node/node/src/service.rs rename to bridges/bin/node/src/service.rs index e1a1919b97343..4b89ae4782560 100644 --- a/bridges/bin/node/node/src/service.rs +++ b/bridges/bin/node/src/service.rs @@ -28,7 +28,7 @@ // ===================================================================================== // ===================================================================================== -use bridge_node_runtime::{self, opaque::Block, RuntimeApi}; +use rialto_runtime::{self, opaque::Block, RuntimeApi}; use sc_client_api::{ExecutorProvider, RemoteBackend}; use sc_executor::native_executor_instance; pub use sc_executor::NativeExecutor; @@ -42,8 +42,8 @@ use std::time::Duration; // Our native executor instance. native_executor_instance!( pub Executor, - bridge_node_runtime::api::dispatch, - bridge_node_runtime::native_version, + rialto_runtime::api::dispatch, + rialto_runtime::native_version, frame_benchmarking::benchmarking::HostFunctions, ); diff --git a/bridges/bin/rialto-node/Cargo.toml b/bridges/bin/rialto-node/Cargo.toml new file mode 100644 index 0000000000000..215cf60faa28e --- /dev/null +++ b/bridges/bin/rialto-node/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "rialto-bridge-node" +description = "Substrate node compatible with Rialto runtime" +version = "0.1.0" +authors = ["Parity Technologies "] +edition = "2018" +license = "GPL-3.0-or-later WITH Classpath-exception-2.0" + +[dependencies] +bridge-node = { path = "../node", default-features = false, features = ["rialto"] } + +[features] +default = [] +runtime-benchmarks = [ + "bridge-node/runtime-benchmarks", +] diff --git a/bridges/bin/rialto-node/src/main.rs b/bridges/bin/rialto-node/src/main.rs new file mode 100644 index 0000000000000..7e101de175159 --- /dev/null +++ b/bridges/bin/rialto-node/src/main.rs @@ -0,0 +1,24 @@ +// Copyright 2019-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 . + +//! Rialto bridge node. + +#![warn(missing_docs)] + +/// Run node. +fn main() -> bridge_node::Result { + bridge_node::run() +} diff --git a/bridges/bin/node/runtime/Cargo.toml b/bridges/bin/rialto-runtime/Cargo.toml similarity index 93% rename from bridges/bin/node/runtime/Cargo.toml rename to bridges/bin/rialto-runtime/Cargo.toml index b613c857b4863..101477915342a 100644 --- a/bridges/bin/node/runtime/Cargo.toml +++ b/bridges/bin/rialto-runtime/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "bridge-node-runtime" +name = "rialto-runtime" version = "0.1.0" authors = ["Parity Technologies "] edition = "2018" @@ -43,22 +43,22 @@ git = "https://github.com/paritytech/substrate/" [dependencies.pallet-bridge-eth-poa] version = "0.1.0" default-features = false -path = "../../../modules/ethereum" +path = "../../modules/ethereum" [dependencies.pallet-bridge-call-dispatch] version = "0.1.0" default-features = false -path = "../../../modules/call-dispatch" +path = "../../modules/call-dispatch" [dependencies.pallet-bridge-currency-exchange] version = "0.1.0" default-features = false -path = "../../../modules/currency-exchange" +path = "../../modules/currency-exchange" [dependencies.pallet-message-lane] version = "0.1.0" default-features = false -path = "../../../modules/message-lane" +path = "../../modules/message-lane" [dependencies.frame-support] version = "2.0.0-rc6" @@ -81,7 +81,7 @@ git = "https://github.com/paritytech/substrate/" [dependencies.pallet-shift-session-manager] version = "0.1.0" default-features = false -path = "../../../modules/shift-session-manager" +path = "../../modules/shift-session-manager" [dependencies.pallet-sudo] version = "2.0.0-rc6" @@ -214,22 +214,22 @@ git = "https://github.com/paritytech/substrate/" [dependencies.bp-currency-exchange] version = "0.1.0" default-features = false -path = "../../../primitives/currency-exchange" +path = "../../primitives/currency-exchange" [dependencies.bp-eth-poa] version = "0.1.0" default-features = false -path = "../../../primitives/ethereum-poa" +path = "../../primitives/ethereum-poa" [dependencies.bp-header-chain] version = "0.1.0" default-features = false -path = "../../../primitives/header-chain" +path = "../../primitives/header-chain" [dependencies.bp-message-lane] version = "0.1.0" default-features = false -path = "../../../primitives/message-lane" +path = "../../primitives/message-lane" # Dev Dependencies @@ -242,7 +242,7 @@ features = ["hmac"] version = "0.1.0" default-features = false features = ["std"] -path = "../../../primitives/ethereum-poa" +path = "../../primitives/ethereum-poa" [build-dependencies.wasm-builder-runner] version = "1.0.5" diff --git a/bridges/bin/rialto-runtime/build.rs b/bridges/bin/rialto-runtime/build.rs new file mode 100644 index 0000000000000..4fda040c9bd14 --- /dev/null +++ b/bridges/bin/rialto-runtime/build.rs @@ -0,0 +1,26 @@ +// Copyright 2019-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 . + +use wasm_builder_runner::WasmBuilder; + +fn main() { + WasmBuilder::new() + .with_current_project() + .with_wasm_builder_from_crates("1.0.11") + .export_heap_base() + .import_memory() + .build() +} diff --git a/bridges/bin/node/runtime/src/benches.rs b/bridges/bin/rialto-runtime/src/benches.rs similarity index 100% rename from bridges/bin/node/runtime/src/benches.rs rename to bridges/bin/rialto-runtime/src/benches.rs diff --git a/bridges/bin/node/runtime/src/exchange.rs b/bridges/bin/rialto-runtime/src/exchange.rs similarity index 100% rename from bridges/bin/node/runtime/src/exchange.rs rename to bridges/bin/rialto-runtime/src/exchange.rs diff --git a/bridges/bin/node/runtime/src/kovan.rs b/bridges/bin/rialto-runtime/src/kovan.rs similarity index 100% rename from bridges/bin/node/runtime/src/kovan.rs rename to bridges/bin/rialto-runtime/src/kovan.rs diff --git a/bridges/bin/node/runtime/src/lib.rs b/bridges/bin/rialto-runtime/src/lib.rs similarity index 99% rename from bridges/bin/node/runtime/src/lib.rs rename to bridges/bin/rialto-runtime/src/lib.rs index 92ee820f7cd15..a00733ae74fa6 100644 --- a/bridges/bin/node/runtime/src/lib.rs +++ b/bridges/bin/rialto-runtime/src/lib.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm. +//! The Rialto runtime. This can be compiled with `#[no_std]`, ready for Wasm. #![cfg_attr(not(feature = "std"), no_std)] // `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256. @@ -121,8 +121,8 @@ impl_opaque_keys! { /// This runtime version. pub const VERSION: RuntimeVersion = RuntimeVersion { - spec_name: create_runtime_str!("bridge-node"), - impl_name: create_runtime_str!("bridge-node"), + spec_name: create_runtime_str!("rialto-runtime"), + impl_name: create_runtime_str!("rialto-runtime"), authoring_version: 1, spec_version: 1, impl_version: 1, diff --git a/bridges/bin/node/runtime/src/rialto.rs b/bridges/bin/rialto-runtime/src/rialto.rs similarity index 100% rename from bridges/bin/node/runtime/src/rialto.rs rename to bridges/bin/rialto-runtime/src/rialto.rs diff --git a/bridges/bin/node/scripts/init.sh b/bridges/bin/scripts/init.sh similarity index 100% rename from bridges/bin/node/scripts/init.sh rename to bridges/bin/scripts/init.sh diff --git a/bridges/modules/ethereum-contract/builtin/Cargo.toml b/bridges/modules/ethereum-contract/builtin/Cargo.toml index ac7b7b80b7856..3911c2cd10675 100644 --- a/bridges/modules/ethereum-contract/builtin/Cargo.toml +++ b/bridges/modules/ethereum-contract/builtin/Cargo.toml @@ -18,7 +18,7 @@ log = "0.4.11" # Runtime/chain specific dependencies -bridge-node-runtime = { path = "../../../bin/node/runtime" } +rialto-runtime = { path = "../../../bin/rialto-runtime" } [dependencies.sp-blockchain] version = "2.0.0-rc6" diff --git a/bridges/modules/ethereum-contract/builtin/src/lib.rs b/bridges/modules/ethereum-contract/builtin/src/lib.rs index f99704b45a11f..abb7375103dff 100644 --- a/bridges/modules/ethereum-contract/builtin/src/lib.rs +++ b/bridges/modules/ethereum-contract/builtin/src/lib.rs @@ -14,10 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . -use bridge_node_runtime::{Block, BlockNumber, Hash, Header as RuntimeHeader}; use codec::{Decode, Encode}; use ethereum_types::U256; use finality_grandpa::voter_set::VoterSet; +use rialto_runtime::{Block, BlockNumber, Hash, Header as RuntimeHeader}; use sp_blockchain::Error as ClientError; use sp_finality_grandpa::{AuthorityList, ConsensusLog, GRANDPA_ENGINE_ID}; @@ -177,7 +177,7 @@ pub fn verify_substrate_finality_proof( #[cfg(test)] mod tests { use super::*; - use bridge_node_runtime::DigestItem; + use rialto_runtime::DigestItem; use sp_core::crypto::Public; use sp_finality_grandpa::{AuthorityId, ScheduledChange}; use sp_runtime::generic::Digest; diff --git a/bridges/relays/ethereum/Cargo.toml b/bridges/relays/ethereum/Cargo.toml index 0842bb206d15f..16deabd717951 100644 --- a/bridges/relays/ethereum/Cargo.toml +++ b/bridges/relays/ethereum/Cargo.toml @@ -77,6 +77,6 @@ version = "0.8.0-rc6" tag = 'v2.0.0-rc6' git = "https://github.com/paritytech/substrate.git" -[dependencies.bridge-node-runtime] +[dependencies.rialto-runtime] version = "0.1.0" -path = "../../bin/node/runtime" +path = "../../bin/rialto-runtime" diff --git a/bridges/relays/ethereum/src/ethereum_exchange.rs b/bridges/relays/ethereum/src/ethereum_exchange.rs index b045b36356ff1..666b71fa3b4e7 100644 --- a/bridges/relays/ethereum/src/ethereum_exchange.rs +++ b/bridges/relays/ethereum/src/ethereum_exchange.rs @@ -38,7 +38,7 @@ use crate::utils::HeaderId; use async_trait::async_trait; use bp_currency_exchange::MaybeLockFundsTransaction; -use bridge_node_runtime::exchange::EthereumTransactionInclusionProof; +use rialto_runtime::exchange::EthereumTransactionInclusionProof; use std::time::Duration; /// Interval at which we ask Ethereum node for updates. @@ -234,7 +234,7 @@ impl TargetClient for SubstrateTransactionsTarget { async fn filter_transaction_proof(&self, proof: &EthereumTransactionInclusionProof) -> Result { // let's try to parse transaction locally let (raw_tx, raw_tx_receipt) = &proof.proof[proof.index as usize]; - let parse_result = bridge_node_runtime::exchange::EthTransaction::parse(raw_tx); + let parse_result = rialto_runtime::exchange::EthTransaction::parse(raw_tx); if parse_result.is_err() { return Ok(false); } diff --git a/bridges/relays/ethereum/src/ethereum_exchange_submit.rs b/bridges/relays/ethereum/src/ethereum_exchange_submit.rs index 69a4d7a39b7f2..4309b6e894d24 100644 --- a/bridges/relays/ethereum/src/ethereum_exchange_submit.rs +++ b/bridges/relays/ethereum/src/ethereum_exchange_submit.rs @@ -24,7 +24,7 @@ use bp_eth_poa::{ signatures::{SecretKey, SignTransaction}, UnsignedTransaction, }; -use bridge_node_runtime::exchange::LOCK_FUNDS_ADDRESS; +use rialto_runtime::exchange::LOCK_FUNDS_ADDRESS; /// Ethereum exchange transaction params. #[derive(Debug)] diff --git a/bridges/relays/ethereum/src/instances.rs b/bridges/relays/ethereum/src/instances.rs index fa6963430b1d6..4d17bcbec9b8d 100644 --- a/bridges/relays/ethereum/src/instances.rs +++ b/bridges/relays/ethereum/src/instances.rs @@ -26,8 +26,8 @@ use crate::ethereum_types::QueuedEthereumHeader; use crate::substrate_types::{into_substrate_ethereum_header, into_substrate_ethereum_receipts}; -use bridge_node_runtime::exchange::EthereumTransactionInclusionProof as Proof; -use bridge_node_runtime::Call; +use rialto_runtime::exchange::EthereumTransactionInclusionProof as Proof; +use rialto_runtime::Call; /// Interface for `Calls` which are needed to correctly sync the bridge. /// @@ -48,7 +48,7 @@ pub struct Rialto; impl BridgeInstance for Rialto { fn build_signed_header_call(&self, headers: Vec) -> Call { - let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_signed_headers( + let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers( headers .into_iter() .map(|header| { @@ -60,21 +60,21 @@ impl BridgeInstance for Rialto { .collect(), ); - bridge_node_runtime::Call::BridgeRialto(pallet_call) + rialto_runtime::Call::BridgeRialto(pallet_call) } fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call { - let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_unsigned_header( + let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header( into_substrate_ethereum_header(header.header()), into_substrate_ethereum_receipts(header.extra()), ); - bridge_node_runtime::Call::BridgeRialto(pallet_call) + rialto_runtime::Call::BridgeRialto(pallet_call) } fn build_currency_exchange_call(&self, proof: Proof) -> Call { - let pallet_call = bridge_node_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof); - bridge_node_runtime::Call::BridgeRialtoCurrencyExchange(pallet_call) + let pallet_call = rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof); + rialto_runtime::Call::BridgeRialtoCurrencyExchange(pallet_call) } } @@ -84,7 +84,7 @@ pub struct Kovan; impl BridgeInstance for Kovan { fn build_signed_header_call(&self, headers: Vec) -> Call { - let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_signed_headers( + let pallet_call = rialto_runtime::BridgeEthPoACall::import_signed_headers( headers .into_iter() .map(|header| { @@ -96,20 +96,20 @@ impl BridgeInstance for Kovan { .collect(), ); - bridge_node_runtime::Call::BridgeKovan(pallet_call) + rialto_runtime::Call::BridgeKovan(pallet_call) } fn build_unsigned_header_call(&self, header: QueuedEthereumHeader) -> Call { - let pallet_call = bridge_node_runtime::BridgeEthPoACall::import_unsigned_header( + let pallet_call = rialto_runtime::BridgeEthPoACall::import_unsigned_header( into_substrate_ethereum_header(header.header()), into_substrate_ethereum_receipts(header.extra()), ); - bridge_node_runtime::Call::BridgeKovan(pallet_call) + rialto_runtime::Call::BridgeKovan(pallet_call) } fn build_currency_exchange_call(&self, proof: Proof) -> Call { - let pallet_call = bridge_node_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof); - bridge_node_runtime::Call::BridgeKovanCurrencyExchange(pallet_call) + let pallet_call = rialto_runtime::BridgeCurrencyExchangeCall::import_peer_transaction(proof); + rialto_runtime::Call::BridgeKovanCurrencyExchange(pallet_call) } } diff --git a/bridges/relays/ethereum/src/substrate_client.rs b/bridges/relays/ethereum/src/substrate_client.rs index 7004dd8b14b97..1d3e5d03199fd 100644 --- a/bridges/relays/ethereum/src/substrate_client.rs +++ b/bridges/relays/ethereum/src/substrate_client.rs @@ -314,13 +314,13 @@ pub trait SubmitEthereumExchangeTransactionProof: SubstrateRpc { /// Pre-verify Ethereum exchange transaction proof. async fn verify_exchange_transaction_proof( &self, - proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof, + proof: rialto_runtime::exchange::EthereumTransactionInclusionProof, ) -> RpcResult; /// Submits Ethereum exchange transaction proof to Substrate runtime. async fn submit_exchange_transaction_proof( &self, params: SubstrateSigningParams, - proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof, + proof: rialto_runtime::exchange::EthereumTransactionInclusionProof, ) -> RpcResult<()>; } @@ -328,7 +328,7 @@ pub trait SubmitEthereumExchangeTransactionProof: SubstrateRpc { impl SubmitEthereumExchangeTransactionProof for SubstrateRpcClient { async fn verify_exchange_transaction_proof( &self, - proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof, + proof: rialto_runtime::exchange::EthereumTransactionInclusionProof, ) -> RpcResult { let call = EXCH_API_FILTER_TRANSACTION_PROOF.to_string(); let data = Bytes(proof.encode()); @@ -342,7 +342,7 @@ impl SubmitEthereumExchangeTransactionProof for SubstrateRpcClient { async fn submit_exchange_transaction_proof( &self, params: SubstrateSigningParams, - proof: bridge_node_runtime::exchange::EthereumTransactionInclusionProof, + proof: rialto_runtime::exchange::EthereumTransactionInclusionProof, ) -> RpcResult<()> { let account_id = params.signer.public().as_array_ref().clone().into(); let nonce = self.next_account_index(account_id).await?; @@ -357,43 +357,43 @@ impl SubmitEthereumExchangeTransactionProof for SubstrateRpcClient { /// Create signed Substrate transaction for submitting Ethereum headers. fn create_signed_submit_transaction( - signed_call: bridge_node_runtime::Call, + signed_call: rialto_runtime::Call, signer: &sp_core::sr25519::Pair, index: node_primitives::Index, genesis_hash: H256, -) -> bridge_node_runtime::UncheckedExtrinsic { +) -> rialto_runtime::UncheckedExtrinsic { create_signed_transaction(signed_call, signer, index, genesis_hash) } /// Create unsigned Substrate transaction for submitting Ethereum header. -fn create_unsigned_submit_transaction(call: bridge_node_runtime::Call) -> bridge_node_runtime::UncheckedExtrinsic { - bridge_node_runtime::UncheckedExtrinsic::new_unsigned(call) +fn create_unsigned_submit_transaction(call: rialto_runtime::Call) -> rialto_runtime::UncheckedExtrinsic { + rialto_runtime::UncheckedExtrinsic::new_unsigned(call) } /// Create signed Substrate transaction. fn create_signed_transaction( - function: bridge_node_runtime::Call, + function: rialto_runtime::Call, signer: &sp_core::sr25519::Pair, index: node_primitives::Index, genesis_hash: H256, -) -> bridge_node_runtime::UncheckedExtrinsic { +) -> rialto_runtime::UncheckedExtrinsic { let extra = |i: node_primitives::Index, f: node_primitives::Balance| { ( - frame_system::CheckSpecVersion::::new(), - frame_system::CheckTxVersion::::new(), - frame_system::CheckGenesis::::new(), - frame_system::CheckEra::::from(sp_runtime::generic::Era::Immortal), - frame_system::CheckNonce::::from(i), - frame_system::CheckWeight::::new(), - pallet_transaction_payment::ChargeTransactionPayment::::from(f), + frame_system::CheckSpecVersion::::new(), + frame_system::CheckTxVersion::::new(), + frame_system::CheckGenesis::::new(), + frame_system::CheckEra::::from(sp_runtime::generic::Era::Immortal), + frame_system::CheckNonce::::from(i), + frame_system::CheckWeight::::new(), + pallet_transaction_payment::ChargeTransactionPayment::::from(f), ) }; - let raw_payload = bridge_node_runtime::SignedPayload::from_raw( + let raw_payload = rialto_runtime::SignedPayload::from_raw( function, extra(index, 0), ( - bridge_node_runtime::VERSION.spec_version, - bridge_node_runtime::VERSION.transaction_version, + rialto_runtime::VERSION.spec_version, + rialto_runtime::VERSION.transaction_version, genesis_hash, genesis_hash, (), @@ -405,5 +405,5 @@ fn create_signed_transaction( let signer: sp_runtime::MultiSigner = signer.public().into(); let (function, extra, _) = raw_payload.deconstruct(); - bridge_node_runtime::UncheckedExtrinsic::new_signed(function, signer.into_account(), signature.into(), extra) + rialto_runtime::UncheckedExtrinsic::new_signed(function, signer.into_account(), signature.into(), extra) } diff --git a/bridges/relays/ethereum/src/substrate_types.rs b/bridges/relays/ethereum/src/substrate_types.rs index fdd2880230ab1..87931957ad3b2 100644 --- a/bridges/relays/ethereum/src/substrate_types.rs +++ b/bridges/relays/ethereum/src/substrate_types.rs @@ -28,22 +28,22 @@ pub use bp_eth_poa::{ }; /// Substrate header hash. -pub type Hash = bridge_node_runtime::Hash; +pub type Hash = rialto_runtime::Hash; /// Substrate header number. -pub type Number = bridge_node_runtime::BlockNumber; +pub type Number = rialto_runtime::BlockNumber; /// Substrate header type. -pub type Header = bridge_node_runtime::Header; +pub type Header = rialto_runtime::Header; /// Substrate signed block type. -pub type SignedBlock = bridge_node_runtime::SignedBlock; +pub type SignedBlock = rialto_runtime::SignedBlock; /// GRANDPA justification. pub type GrandpaJustification = Vec; /// Substrate header ID. -pub type SubstrateHeaderId = HeaderId; +pub type SubstrateHeaderId = HeaderId; /// Queued substrate header ID. pub type QueuedSubstrateHeader = QueuedHeader; @@ -57,8 +57,8 @@ impl HeadersSyncPipeline for SubstrateHeadersSyncPipeline { const SOURCE_NAME: &'static str = "Substrate"; const TARGET_NAME: &'static str = "Ethereum"; - type Hash = bridge_node_runtime::Hash; - type Number = bridge_node_runtime::BlockNumber; + type Hash = rialto_runtime::Hash; + type Number = rialto_runtime::BlockNumber; type Header = Header; type Extra = (); type Completion = GrandpaJustification; @@ -68,7 +68,7 @@ impl HeadersSyncPipeline for SubstrateHeadersSyncPipeline { } } -impl SourceHeader for Header { +impl SourceHeader for Header { fn id(&self) -> SubstrateHeaderId { HeaderId(self.number, self.hash()) }