mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 03:18:01 +00:00
Prepare separate runtime for testing sub2sub bridge (#341)
* renamed bin/node/runtime to bin/node/rialto-runtime * replaced bridge-node-runtime references with rialto-runtime references * separate folders for millau/rialto nodes+runtimes * extracted pallet-shift-session-manager * bridge-node -> bridge-node-runtime * uninstall previous rust (temp solution???) * fix dockerfile * cargo fmt * fix benchmarks check * fix benchmarks again * update LAST_RUST_UPDATE to clear the cache * changed runtime comments * move bin/node/* to bin/ * REVERT ME * Revert "REVERT ME" This reverts commit 7c335f946308ed11d9ed6ffec7c1c13dbe2743ed. * specify container name * REVERT ME * container_name -> hostname * fix typo * aliases * Revert "REVERT ME" This reverts commit 0e74af5f8430f1975a3fc924d8b52079f266bda1. * removed prefixes
This commit is contained in:
committed by
Bastian Köcher
parent
bed44dec13
commit
d8ae786792
+10
-10
@@ -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:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "millau-bridge-node"
|
||||
description = "Substrate node compatible with Millau runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
bridge-node = { path = "../node", default-features = false, features = ["millau"] }
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Millau bridge node.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
/// Run node.
|
||||
fn main() -> bridge_node::Result {
|
||||
bridge_node::run()
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
[package]
|
||||
name = "millau-runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
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",
|
||||
]
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! 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 = <<Signature as Verify>::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<Hash>;
|
||||
|
||||
/// 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<BlockNumber, BlakeTwo256>;
|
||||
/// Opaque block type.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// Opaque block identifier type.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
}
|
||||
|
||||
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<AccountId>;
|
||||
/// 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<BlockNumber, BlakeTwo256>;
|
||||
/// 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<Balance>;
|
||||
/// 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 = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;
|
||||
|
||||
type KeyOwnerIdentification =
|
||||
<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::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<Runtime>;
|
||||
type OnTransactionPayment = ();
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
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 = <Self as frame_system::Trait>::AccountId;
|
||||
type ValidatorIdOf = ();
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type NextSessionRotation = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type SessionManager = pallet_shift_session_manager::Module<Runtime>;
|
||||
type SessionHandler = <SessionKeys as OpaqueKeys>::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<T>},
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage},
|
||||
Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent},
|
||||
Aura: pallet_aura::{Module, Config<T>, Inherent},
|
||||
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
|
||||
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Module, Storage},
|
||||
Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},
|
||||
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
|
||||
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<BlockNumber, BlakeTwo256>;
|
||||
/// Block type as expected by this runtime.
|
||||
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
/// A Block signed with a Justification
|
||||
pub type SignedBlock = generic::SignedBlock<Block>;
|
||||
/// BlockId type as expected by this runtime.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
/// The SignedExtension to the basic transaction logic.
|
||||
pub type SignedExtra = (
|
||||
frame_system::CheckSpecVersion<Runtime>,
|
||||
frame_system::CheckTxVersion<Runtime>,
|
||||
frame_system::CheckGenesis<Runtime>,
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
);
|
||||
/// The payload being signed in transactions.
|
||||
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
/// Extrinsic type that has already been checked.
|
||||
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;
|
||||
/// Executive: handles dispatch to the various modules.
|
||||
pub type Executive =
|
||||
frame_executive::Executive<Runtime, Block, frame_system::ChainContext<Runtime>, Runtime, AllModules>;
|
||||
|
||||
impl_runtime_apis! {
|
||||
impl sp_api::Core<Block> for Runtime {
|
||||
fn version() -> RuntimeVersion {
|
||||
VERSION
|
||||
}
|
||||
|
||||
fn execute_block(block: Block) {
|
||||
Executive::execute_block(block)
|
||||
}
|
||||
|
||||
fn initialize_block(header: &<Block as BlockT>::Header) {
|
||||
Executive::initialize_block(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_api::Metadata<Block> for Runtime {
|
||||
fn metadata() -> OpaqueMetadata {
|
||||
Runtime::metadata().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_block_builder::BlockBuilder<Block> for Runtime {
|
||||
fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
|
||||
Executive::apply_extrinsic(extrinsic)
|
||||
}
|
||||
|
||||
fn finalize_block() -> <Block as BlockT>::Header {
|
||||
Executive::finalize_block()
|
||||
}
|
||||
|
||||
fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
|
||||
data.create_extrinsics()
|
||||
}
|
||||
|
||||
fn check_inherents(
|
||||
block: Block,
|
||||
data: sp_inherents::InherentData,
|
||||
) -> sp_inherents::CheckInherentsResult {
|
||||
data.check_extrinsics(&block)
|
||||
}
|
||||
|
||||
fn random_seed() -> <Block as BlockT>::Hash {
|
||||
RandomnessCollectiveFlip::random_seed()
|
||||
}
|
||||
}
|
||||
|
||||
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {
|
||||
fn account_nonce(account: AccountId) -> Index {
|
||||
System::account_nonce(account)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
|
||||
fn validate_transaction(
|
||||
source: TransactionSource,
|
||||
tx: <Block as BlockT>::Extrinsic,
|
||||
) -> TransactionValidity {
|
||||
Executive::validate_transaction(source, tx)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_offchain::OffchainWorkerApi<Block> for Runtime {
|
||||
fn offchain_worker(header: &<Block as BlockT>::Header) {
|
||||
Executive::offchain_worker(header)
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> u64 {
|
||||
Aura::slot_duration()
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities()
|
||||
}
|
||||
}
|
||||
|
||||
impl sp_session::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
|
||||
fn decode_session_keys(
|
||||
encoded: Vec<u8>,
|
||||
) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
|
||||
SessionKeys::decode_into_raw_public_keys(&encoded)
|
||||
}
|
||||
}
|
||||
|
||||
impl fg_primitives::GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_authorities() -> GrandpaAuthorityList {
|
||||
Grandpa::grandpa_authorities()
|
||||
}
|
||||
|
||||
fn submit_report_equivocation_unsigned_extrinsic(
|
||||
equivocation_proof: fg_primitives::EquivocationProof<
|
||||
<Block as BlockT>::Hash,
|
||||
NumberFor<Block>,
|
||||
>,
|
||||
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<fg_primitives::OpaqueKeyOwnershipProof> {
|
||||
// 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 = "../runtime"
|
||||
path = "../millau-runtime"
|
||||
default-features = false
|
||||
features = ["std"]
|
||||
|
||||
[dependencies.rialto-runtime]
|
||||
optional = true
|
||||
version = "0.1.0"
|
||||
path = "../rialto-runtime"
|
||||
default-features = false
|
||||
features = ["std"]
|
||||
|
||||
@@ -148,6 +152,12 @@ git = "https://github.com/paritytech/substrate.git"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
runtime-benchmarks = [
|
||||
"bridge-node-runtime/runtime-benchmarks",
|
||||
millau = [
|
||||
"millau-runtime",
|
||||
]
|
||||
rialto = [
|
||||
"rialto-runtime",
|
||||
]
|
||||
runtime-benchmarks = [
|
||||
"rialto-runtime/runtime-benchmarks",
|
||||
]
|
||||
@@ -14,11 +14,11 @@
|
||||
// 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/>.
|
||||
|
||||
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<BridgeRialtoConfig> {
|
||||
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<BridgeKovanConfig> {
|
||||
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(),
|
||||
})
|
||||
}
|
||||
@@ -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<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
&bridge_node_runtime::VERSION
|
||||
&rialto_runtime::VERSION
|
||||
}
|
||||
|
||||
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
||||
@@ -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()
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[package]
|
||||
name = "rialto-bridge-node"
|
||||
description = "Substrate node compatible with Rialto runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
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",
|
||||
]
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! Rialto bridge node.
|
||||
|
||||
#![warn(missing_docs)]
|
||||
|
||||
/// Run node.
|
||||
fn main() -> bridge_node::Result {
|
||||
bridge_node::run()
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "bridge-node-runtime"
|
||||
name = "rialto-runtime"
|
||||
version = "0.1.0"
|
||||
authors = ["Parity Technologies <admin@parity.io>"]
|
||||
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"
|
||||
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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()
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
// 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/>.
|
||||
|
||||
//! 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,
|
||||
@@ -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"
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
// 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/>.
|
||||
|
||||
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;
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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<EthereumToSubstrateExchange> for SubstrateTransactionsTarget {
|
||||
async fn filter_transaction_proof(&self, proof: &EthereumTransactionInclusionProof) -> Result<bool, Self::Error> {
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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<QueuedEthereumHeader>) -> 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<QueuedEthereumHeader>) -> 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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<bool>;
|
||||
/// 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<bool> {
|
||||
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::<bridge_node_runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<bridge_node_runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<bridge_node_runtime::Runtime>::new(),
|
||||
frame_system::CheckEra::<bridge_node_runtime::Runtime>::from(sp_runtime::generic::Era::Immortal),
|
||||
frame_system::CheckNonce::<bridge_node_runtime::Runtime>::from(i),
|
||||
frame_system::CheckWeight::<bridge_node_runtime::Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<bridge_node_runtime::Runtime>::from(f),
|
||||
frame_system::CheckSpecVersion::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckTxVersion::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckGenesis::<rialto_runtime::Runtime>::new(),
|
||||
frame_system::CheckEra::<rialto_runtime::Runtime>::from(sp_runtime::generic::Era::Immortal),
|
||||
frame_system::CheckNonce::<rialto_runtime::Runtime>::from(i),
|
||||
frame_system::CheckWeight::<rialto_runtime::Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<rialto_runtime::Runtime>::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)
|
||||
}
|
||||
|
||||
@@ -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<u8>;
|
||||
|
||||
/// Substrate header ID.
|
||||
pub type SubstrateHeaderId = HeaderId<bridge_node_runtime::Hash, bridge_node_runtime::BlockNumber>;
|
||||
pub type SubstrateHeaderId = HeaderId<rialto_runtime::Hash, rialto_runtime::BlockNumber>;
|
||||
|
||||
/// Queued substrate header ID.
|
||||
pub type QueuedSubstrateHeader = QueuedHeader<SubstrateHeadersSyncPipeline>;
|
||||
@@ -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<bridge_node_runtime::Hash, bridge_node_runtime::BlockNumber> for Header {
|
||||
impl SourceHeader<rialto_runtime::Hash, rialto_runtime::BlockNumber> for Header {
|
||||
fn id(&self) -> SubstrateHeaderId {
|
||||
HeaderId(self.number, self.hash())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user