Update to `d1cd01c74`
parent
676186d7d8
commit
60675465c2
File diff suppressed because it is too large
Load Diff
68
Cargo.toml
68
Cargo.toml
|
@ -1,3 +1,19 @@
|
|||
[[bin]]
|
||||
name = 'node-template'
|
||||
path = 'src/main.rs'
|
||||
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
build = 'build.rs'
|
||||
edition = '2018'
|
||||
name = 'node-template'
|
||||
version = '2.0.0'
|
||||
|
||||
[build-dependencies]
|
||||
vergen = '3.0.4'
|
||||
[profile.release]
|
||||
panic = 'unwind'
|
||||
|
||||
[dependencies]
|
||||
derive_more = '0.15.0'
|
||||
exit-future = '0.1.4'
|
||||
|
@ -7,20 +23,20 @@ parking_lot = '0.9.0'
|
|||
tokio = '0.1.22'
|
||||
trie-root = '0.15.2'
|
||||
|
||||
[dependencies.babe]
|
||||
[dependencies.aura]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-babe'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
package = 'substrate-consensus-aura'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.babe-primitives]
|
||||
[dependencies.aura-primitives]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-babe-primitives'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
package = 'substrate-consensus-aura-primitives'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.basic-authorship]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-basic-authorship'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.codec]
|
||||
package = 'parity-scale-codec'
|
||||
|
@ -33,22 +49,22 @@ version = '3.1.3'
|
|||
[dependencies.grandpa]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-finality-grandpa'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.grandpa-primitives]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-finality-grandpa-primitives'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.inherents]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-inherents'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.network]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-network'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.node-template-runtime]
|
||||
path = 'runtime'
|
||||
|
@ -56,48 +72,32 @@ path = 'runtime'
|
|||
[dependencies.primitives]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-primitives'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.sr-io]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.substrate-cli]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.substrate-client]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.substrate-executor]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.substrate-service]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.transaction-pool]
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-transaction-pool'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
[profile.release]
|
||||
panic = 'unwind'
|
||||
|
||||
[[bin]]
|
||||
name = 'node-template'
|
||||
path = 'src/main.rs'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[workspace]
|
||||
members = ['runtime']
|
||||
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
build = 'build.rs'
|
||||
edition = '2018'
|
||||
name = 'node-template'
|
||||
version = '2.0.0'
|
||||
|
||||
[build-dependencies]
|
||||
vergen = '3.0.4'
|
||||
|
|
14
README.md
14
README.md
|
@ -10,7 +10,7 @@ Install Rust:
|
|||
curl https://sh.rustup.rs -sSf | sh
|
||||
```
|
||||
|
||||
Install required tools:
|
||||
Initialize your Wasm Build environment:
|
||||
|
||||
```bash
|
||||
./scripts/init.sh
|
||||
|
@ -19,17 +19,23 @@ Install required tools:
|
|||
Build Wasm and native code:
|
||||
|
||||
```bash
|
||||
cargo build
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
## Run
|
||||
|
||||
### Single node development chain
|
||||
|
||||
You can start a development chain with:
|
||||
Purge any existing developer chain state:
|
||||
|
||||
```bash
|
||||
cargo run -- --dev
|
||||
./target/release/node-template purge-chain --dev
|
||||
```
|
||||
|
||||
Start a development chain with:
|
||||
|
||||
```bash
|
||||
./target/release/node-template --dev
|
||||
```
|
||||
|
||||
Detailed logs may be shown by running the node with the following environment variables set: `RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev`.
|
||||
|
|
|
@ -1,26 +1,62 @@
|
|||
[dependencies.babe]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-babe'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
edition = '2018'
|
||||
name = 'node-template-runtime'
|
||||
version = '2.0.0'
|
||||
[build-dependencies.wasm-builder-runner]
|
||||
package = 'substrate-wasm-builder-runner'
|
||||
version = '1.0.2'
|
||||
|
||||
[dependencies.babe-primitives]
|
||||
default-features = false
|
||||
[features]
|
||||
default = ['std']
|
||||
std = [
|
||||
'codec/std',
|
||||
'client/std',
|
||||
'rstd/std',
|
||||
'runtime-io/std',
|
||||
'support/std',
|
||||
'balances/std',
|
||||
'aura/std',
|
||||
'aura-primitives/std',
|
||||
'grandpa/std',
|
||||
'executive/std',
|
||||
'indices/std',
|
||||
'primitives/std',
|
||||
'sr-primitives/std',
|
||||
'randomness-collective-flip/std',
|
||||
'system/std',
|
||||
'timestamp/std',
|
||||
'sudo/std',
|
||||
'transaction-payment/std',
|
||||
'version/std',
|
||||
'serde',
|
||||
'safe-mix/std',
|
||||
'offchain-primitives/std',
|
||||
'substrate-session/std',
|
||||
]
|
||||
[dependencies.aura]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-babe-primitives'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
package = 'srml-aura'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.aura-primitives]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-consensus-aura-primitives'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.balances]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-balances'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.client]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-client'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.codec]
|
||||
default-features = false
|
||||
|
@ -32,43 +68,49 @@ version = '1.0.0'
|
|||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-executive'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.grandpa]
|
||||
default-features = false
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-grandpa'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.indices]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-indices'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.offchain-primitives]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-offchain-primitives'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.primitives]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'substrate-primitives'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.randomness-collective-flip]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-randomness-collective-flip'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.rstd]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'sr-std'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.runtime-io]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'sr-io'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.safe-mix]
|
||||
default-features = false
|
||||
|
@ -82,74 +124,45 @@ version = '1.0.101'
|
|||
[dependencies.sr-primitives]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.substrate-session]
|
||||
default-features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.sudo]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-sudo'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.support]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-support'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.system]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-system'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.timestamp]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-timestamp'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.transaction-payment]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'srml-transaction-payment'
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
||||
[dependencies.version]
|
||||
default_features = false
|
||||
git = 'https://github.com/paritytech/substrate.git'
|
||||
package = 'sr-version'
|
||||
rev = '3dedd246c62255ba6f9b777ecba318dfc2078d85'
|
||||
[build-dependencies.wasm-builder-runner]
|
||||
package = 'substrate-wasm-builder-runner'
|
||||
version = '1.0.2'
|
||||
|
||||
[package]
|
||||
authors = ['Anonymous']
|
||||
edition = '2018'
|
||||
name = 'node-template-runtime'
|
||||
version = '2.0.0'
|
||||
|
||||
[features]
|
||||
default = ['std']
|
||||
std = [
|
||||
'codec/std',
|
||||
'client/std',
|
||||
'rstd/std',
|
||||
'runtime-io/std',
|
||||
'support/std',
|
||||
'balances/std',
|
||||
'babe/std',
|
||||
'babe-primitives/std',
|
||||
'executive/std',
|
||||
'indices/std',
|
||||
'grandpa/std',
|
||||
'primitives/std',
|
||||
'sr-primitives/std',
|
||||
'system/std',
|
||||
'timestamp/std',
|
||||
'sudo/std',
|
||||
'version/std',
|
||||
'serde',
|
||||
'safe-mix/std',
|
||||
'offchain-primitives/std',
|
||||
'substrate-session/std',
|
||||
]
|
||||
rev = 'd1cd01c74e8d5550396cb654f9a3f1b641efdf4c'
|
||||
|
|
|
@ -19,7 +19,7 @@ use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSourc
|
|||
fn main() {
|
||||
build_current_project_with_rustflags(
|
||||
"wasm_binary.rs",
|
||||
WasmBuilderSource::Crates("1.0.7"),
|
||||
WasmBuilderSource::Crates("1.0.8"),
|
||||
// This instructs LLD to export __heap_base as a global variable, which is used by the
|
||||
// external memory allocator.
|
||||
"-Clink-arg=--export=__heap_base",
|
||||
|
|
|
@ -16,13 +16,13 @@ use sr_primitives::{
|
|||
};
|
||||
use sr_primitives::traits::{NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify, ConvertInto};
|
||||
use sr_primitives::weights::Weight;
|
||||
use babe::{AuthorityId as BabeId};
|
||||
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
|
||||
use grandpa::fg_primitives;
|
||||
use client::{
|
||||
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
|
||||
runtime_api as client_api, impl_runtime_apis
|
||||
};
|
||||
use aura_primitives::sr25519::AuthorityId as AuraId;
|
||||
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
|
||||
use grandpa::fg_primitives;
|
||||
use version::RuntimeVersion;
|
||||
#[cfg(feature = "std")]
|
||||
use version::NativeVersion;
|
||||
|
@ -33,7 +33,7 @@ pub use sr_primitives::BuildStorage;
|
|||
pub use timestamp::Call as TimestampCall;
|
||||
pub use balances::Call as BalancesCall;
|
||||
pub use sr_primitives::{Permill, Perbill};
|
||||
pub use support::{StorageValue, construct_runtime, parameter_types};
|
||||
pub use support::{StorageValue, construct_runtime, parameter_types, traits::Randomness};
|
||||
|
||||
/// An index to a block.
|
||||
pub type BlockNumber = u32;
|
||||
|
@ -80,14 +80,12 @@ pub mod opaque {
|
|||
/// Opaque block identifier type.
|
||||
pub type BlockId = generic::BlockId<Block>;
|
||||
|
||||
pub type SessionHandlers = (Grandpa, Babe);
|
||||
|
||||
impl_opaque_keys! {
|
||||
pub struct SessionKeys {
|
||||
#[id(key_types::AURA)]
|
||||
pub aura: AuraId,
|
||||
#[id(key_types::GRANDPA)]
|
||||
pub grandpa: GrandpaId,
|
||||
#[id(key_types::BABE)]
|
||||
pub babe: BabeId,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,20 +100,6 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||
apis: RUNTIME_API_VERSIONS,
|
||||
};
|
||||
|
||||
/// Constants for Babe.
|
||||
|
||||
/// Since BABE is probabilistic this is the average expected block time that
|
||||
/// we are targetting. Blocks will be produced at a minimum duration defined
|
||||
/// by `SLOT_DURATION`, but some slots will not be allocated to any
|
||||
/// authority and hence no block will be produced. We expect to have this
|
||||
/// block time on average following the defined slot duration and the value
|
||||
/// of `c` configured for BABE (where `1 - c` represents the probability of
|
||||
/// a slot being empty).
|
||||
/// This value is only used indirectly to define the unit constants below
|
||||
/// that are expressed in blocks. The rest of the code should use
|
||||
/// `SLOT_DURATION` instead (like the timestamp module for calculating the
|
||||
/// minimum period).
|
||||
/// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
||||
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
||||
|
||||
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
||||
|
@ -166,30 +150,22 @@ impl system::Trait for Runtime {
|
|||
type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
/// Update weight (to fee) multiplier per-block.
|
||||
type WeightMultiplierUpdate = ();
|
||||
/// 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. With a default weight system of 1byte == 1weight, 4mb is ok.
|
||||
/// Maximum weight of each block.
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
/// 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;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64;
|
||||
pub const ExpectedBlockTime: u64 = MILLISECS_PER_BLOCK;
|
||||
}
|
||||
|
||||
impl babe::Trait for Runtime {
|
||||
type EpochDuration = EpochDuration;
|
||||
type ExpectedBlockTime = ExpectedBlockTime;
|
||||
type EpochChangeTrigger = babe::SameAuthoritiesForever;
|
||||
impl aura::Trait for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
impl grandpa::Trait for Runtime {
|
||||
|
@ -215,7 +191,7 @@ parameter_types! {
|
|||
impl timestamp::Trait for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Babe;
|
||||
type OnTimestampSet = Aura;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
}
|
||||
|
||||
|
@ -223,8 +199,6 @@ parameter_types! {
|
|||
pub const ExistentialDeposit: u128 = 500;
|
||||
pub const TransferFee: u128 = 0;
|
||||
pub const CreationFee: u128 = 0;
|
||||
pub const TransactionBaseFee: u128 = 0;
|
||||
pub const TransactionByteFee: u128 = 1;
|
||||
}
|
||||
|
||||
impl balances::Trait for Runtime {
|
||||
|
@ -236,15 +210,25 @@ impl balances::Trait for Runtime {
|
|||
type OnNewAccount = Indices;
|
||||
/// The ubiquitous event type.
|
||||
type Event = Event;
|
||||
type TransactionPayment = ();
|
||||
type DustRemoval = ();
|
||||
type TransferPayment = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type TransferFee = TransferFee;
|
||||
type CreationFee = CreationFee;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TransactionBaseFee: Balance = 0;
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl transaction_payment::Trait for Runtime {
|
||||
type Currency = balances::Module<Runtime>;
|
||||
type OnTransactionPayment = ();
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = ConvertInto;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl sudo::Trait for Runtime {
|
||||
|
@ -265,13 +249,15 @@ construct_runtime!(
|
|||
{
|
||||
System: system::{Module, Call, Storage, Config, Event},
|
||||
Timestamp: timestamp::{Module, Call, Storage, Inherent},
|
||||
Babe: babe::{Module, Call, Storage, Config, Inherent(Timestamp)},
|
||||
Aura: aura::{Module, Config<T>, Inherent(Timestamp)},
|
||||
Grandpa: grandpa::{Module, Call, Storage, Config, Event},
|
||||
Indices: indices::{default, Config<T>},
|
||||
Balances: balances::{default, Error},
|
||||
TransactionPayment: transaction_payment::{Module, Storage},
|
||||
Sudo: sudo,
|
||||
// Used for the module template in `./template.rs`
|
||||
TemplateModule: template::{Module, Call, Storage, Event<T>},
|
||||
RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -292,7 +278,7 @@ pub type SignedExtra = (
|
|||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
balances::TakeFees<Runtime>
|
||||
transaction_payment::ChargeTransactionPayment<Runtime>
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
|
@ -340,7 +326,7 @@ impl_runtime_apis! {
|
|||
}
|
||||
|
||||
fn random_seed() -> <Block as BlockT>::Hash {
|
||||
System::random_seed()
|
||||
RandomnessCollectiveFlip::random_seed()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,27 +342,13 @@ impl_runtime_apis! {
|
|||
}
|
||||
}
|
||||
|
||||
impl fg_primitives::GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
|
||||
Grandpa::grandpa_authorities()
|
||||
impl aura_primitives::AuraApi<Block, AuraId> for Runtime {
|
||||
fn slot_duration() -> u64 {
|
||||
Aura::slot_duration()
|
||||
}
|
||||
}
|
||||
|
||||
impl babe_primitives::BabeApi<Block> for Runtime {
|
||||
fn configuration() -> babe_primitives::BabeConfiguration {
|
||||
// The choice of `c` parameter (where `1 - c` represents the
|
||||
// probability of a slot being empty), is done in accordance to the
|
||||
// slot duration and expected target block time, for safely
|
||||
// resisting network delays of maximum two seconds.
|
||||
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
|
||||
babe_primitives::BabeConfiguration {
|
||||
slot_duration: Babe::slot_duration(),
|
||||
epoch_length: EpochDuration::get(),
|
||||
c: PRIMARY_PROBABILITY,
|
||||
genesis_authorities: Babe::authorities(),
|
||||
randomness: Babe::randomness(),
|
||||
secondary_slots: true,
|
||||
}
|
||||
|
||||
fn authorities() -> Vec<AuraId> {
|
||||
Aura::authorities()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,4 +358,10 @@ impl_runtime_apis! {
|
|||
opaque::SessionKeys::generate(seed)
|
||||
}
|
||||
}
|
||||
|
||||
impl fg_primitives::GrandpaApi<Block> for Runtime {
|
||||
fn grandpa_authorities() -> Vec<(GrandpaId, GrandpaWeight)> {
|
||||
Grandpa::grandpa_authorities()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,12 +69,11 @@ decl_event!(
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use runtime_io::with_externalities;
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use primitives::H256;
|
||||
use support::{impl_outer_origin, assert_ok, parameter_types};
|
||||
use sr_primitives::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
|
||||
use sr_primitives::weights::Weight;
|
||||
use sr_primitives::Perbill;
|
||||
use sr_primitives::{
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header, weights::Weight, Perbill,
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
|
@ -101,7 +100,6 @@ mod tests {
|
|||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type WeightMultiplierUpdate = ();
|
||||
type Event = ();
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
|
@ -116,13 +114,13 @@ mod tests {
|
|||
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
|
||||
fn new_test_ext() -> runtime_io::TestExternalities {
|
||||
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_works_for_default_value() {
|
||||
with_externalities(&mut new_test_ext(), || {
|
||||
new_test_ext().execute_with(|| {
|
||||
// Just a dummy test for the dummy funtion `do_something`
|
||||
// calling the `do_something` function with a value 42
|
||||
assert_ok!(TemplateModule::do_something(Origin::signed(1), 42));
|
||||
|
|
|
@ -10,7 +10,3 @@ if [ -z $CI_PROJECT_NAME ] ; then
|
|||
fi
|
||||
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
|
||||
# Install wasm-gc. It's useful for stripping slimming down wasm binaries.
|
||||
command -v wasm-gc || \
|
||||
cargo +nightly install --git https://github.com/alexcrichton/wasm-gc --force
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use primitives::{Pair, Public};
|
||||
use node_template_runtime::{
|
||||
AccountId, BabeConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
|
||||
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
|
||||
SudoConfig, IndicesConfig, SystemConfig, WASM_BINARY,
|
||||
};
|
||||
use babe_primitives::{AuthorityId as BabeId};
|
||||
use aura_primitives::sr25519::{AuthorityId as AuraId};
|
||||
use grandpa_primitives::{AuthorityId as GrandpaId};
|
||||
use substrate_service;
|
||||
|
||||
|
@ -31,13 +31,11 @@ pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Pu
|
|||
.public()
|
||||
}
|
||||
|
||||
/// Helper function to generate stash, controller and session key from seed
|
||||
pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId, GrandpaId, BabeId) {
|
||||
/// Helper function to generate an authority key for Aura
|
||||
pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
|
||||
(
|
||||
get_from_seed::<AccountId>(&format!("{}//stash", seed)),
|
||||
get_from_seed::<AccountId>(seed),
|
||||
get_from_seed::<GrandpaId>(seed),
|
||||
get_from_seed::<BabeId>(seed),
|
||||
get_from_seed::<AuraId>(s),
|
||||
get_from_seed::<GrandpaId>(s),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -106,7 +104,7 @@ impl Alternative {
|
|||
}
|
||||
}
|
||||
|
||||
fn testnet_genesis(initial_authorities: Vec<(AccountId, AccountId, GrandpaId, BabeId)>,
|
||||
fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
|
||||
root_key: AccountId,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
_enable_println: bool) -> GenesisConfig {
|
||||
|
@ -125,11 +123,11 @@ fn testnet_genesis(initial_authorities: Vec<(AccountId, AccountId, GrandpaId, Ba
|
|||
sudo: Some(SudoConfig {
|
||||
key: root_key,
|
||||
}),
|
||||
babe: Some(BabeConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.3.clone(), 1)).collect(),
|
||||
aura: Some(AuraConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(),
|
||||
}),
|
||||
grandpa: Some(GrandpaConfig {
|
||||
authorities: initial_authorities.iter().map(|x| (x.2.clone(), 1)).collect(),
|
||||
authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ use tokio::runtime::Runtime;
|
|||
pub use substrate_cli::{VersionInfo, IntoExit, error};
|
||||
use substrate_cli::{informant, parse_and_prepare, ParseAndPrepare, NoCustom};
|
||||
use substrate_service::{AbstractService, Roles as ServiceRoles, Configuration};
|
||||
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
|
||||
use crate::chain_spec;
|
||||
use log::info;
|
||||
|
||||
|
|
|
@ -3,16 +3,16 @@
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
use substrate_client::LongestChain;
|
||||
use babe;
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
use futures::prelude::*;
|
||||
use node_template_runtime::{self, GenesisConfig, opaque::Block, RuntimeApi};
|
||||
use substrate_service::{error::{Error as ServiceError}, AbstractService, Configuration, ServiceBuilder};
|
||||
use transaction_pool::{self, txpool::{Pool as TransactionPool}};
|
||||
use inherents::InherentDataProviders;
|
||||
use network::construct_simple_protocol;
|
||||
use network::{construct_simple_protocol};
|
||||
use substrate_executor::native_executor_instance;
|
||||
pub use substrate_executor::NativeExecutor;
|
||||
use aura_primitives::sr25519::{AuthorityPair as AuraPair};
|
||||
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider};
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
|
@ -44,33 +44,26 @@ macro_rules! new_full_start {
|
|||
.with_transaction_pool(|config, client|
|
||||
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::FullChainApi::new(client)))
|
||||
)?
|
||||
.with_import_queue(|_config, client, mut select_chain, _transaction_pool| {
|
||||
.with_import_queue(|_config, client, mut select_chain, transaction_pool| {
|
||||
let select_chain = select_chain.take()
|
||||
.ok_or_else(|| substrate_service::Error::SelectChainRequired)?;
|
||||
|
||||
let (grandpa_block_import, grandpa_link) =
|
||||
grandpa::block_import::<_, _, _, node_template_runtime::RuntimeApi, _, _>(
|
||||
client.clone(), &*client, select_chain
|
||||
)?;
|
||||
let justification_import = grandpa_block_import.clone();
|
||||
|
||||
let (babe_block_import, babe_link) = babe::block_import(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = babe::import_queue(
|
||||
babe_link.clone(),
|
||||
babe_block_import.clone(),
|
||||
Some(Box::new(justification_import)),
|
||||
let import_queue = aura::import_queue::<_, _, AuraPair, _>(
|
||||
aura::SlotDuration::get_or_compute(&*client)?,
|
||||
Box::new(grandpa_block_import.clone()),
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
Some(transaction_pool),
|
||||
)?;
|
||||
|
||||
import_setup = Some((babe_block_import, grandpa_link, babe_link));
|
||||
import_setup = Some((grandpa_block_import, grandpa_link));
|
||||
|
||||
Ok(import_queue)
|
||||
})?;
|
||||
|
@ -83,24 +76,23 @@ macro_rules! new_full_start {
|
|||
pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisConfig>)
|
||||
-> Result<impl AbstractService, ServiceError>
|
||||
{
|
||||
|
||||
let is_authority = config.roles.is_authority();
|
||||
let force_authoring = config.force_authoring;
|
||||
let name = config.name.clone();
|
||||
let disable_grandpa = config.disable_grandpa;
|
||||
let force_authoring = config.force_authoring;
|
||||
|
||||
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
|
||||
|
||||
let (block_import, grandpa_link) =
|
||||
import_setup.take()
|
||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||
|
||||
let service = builder.with_network_protocol(|_| Ok(NodeProtocol::new()))?
|
||||
.with_finality_proof_provider(|client, backend|
|
||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||
)?
|
||||
.build()?;
|
||||
|
||||
let (block_import, grandpa_link, babe_link) =
|
||||
import_setup.take()
|
||||
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
|
||||
|
||||
if is_authority {
|
||||
let proposer = basic_authorship::ProposerFactory {
|
||||
client: service.client(),
|
||||
|
@ -111,22 +103,21 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
|||
let select_chain = service.select_chain()
|
||||
.ok_or(ServiceError::SelectChainRequired)?;
|
||||
|
||||
let babe_config = babe::BabeParams {
|
||||
keystore: service.keystore(),
|
||||
let aura = aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
|
||||
aura::SlotDuration::get_or_compute(&*client)?,
|
||||
client,
|
||||
select_chain,
|
||||
env: proposer,
|
||||
block_import,
|
||||
sync_oracle: service.network(),
|
||||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
proposer,
|
||||
service.network(),
|
||||
inherent_data_providers.clone(),
|
||||
force_authoring,
|
||||
babe_link,
|
||||
};
|
||||
service.keystore(),
|
||||
)?;
|
||||
|
||||
let babe = babe::start_babe(babe_config)?;
|
||||
let select = babe.select(service.on_exit()).then(|_| Ok(()));
|
||||
let select = aura.select(service.on_exit()).then(|_| Ok(()));
|
||||
|
||||
// the BABE authoring task is considered infallible, i.e. if it
|
||||
// the AURA authoring task is considered essential, i.e. if it
|
||||
// fails we take down the service with it.
|
||||
service.spawn_essential_task(select);
|
||||
}
|
||||
|
@ -158,6 +149,7 @@ pub fn new_full<C: Send + Default + 'static>(config: Configuration<C, GenesisCon
|
|||
inherent_data_providers: inherent_data_providers.clone(),
|
||||
on_exit: service.on_exit(),
|
||||
telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
|
||||
voting_rule: grandpa::VotingRulesBuilder::default().build(),
|
||||
};
|
||||
|
||||
// the GRANDPA voter task is considered infallible, i.e.
|
||||
|
@ -196,26 +188,18 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
|
|||
let grandpa_block_import = grandpa::light_block_import::<_, _, _, RuntimeApi, _>(
|
||||
client.clone(), backend, Arc::new(fetch_checker), client.clone()
|
||||
)?;
|
||||
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let (babe_block_import, babe_link) = babe::block_import(
|
||||
babe::Config::get_or_compute(&*client)?,
|
||||
grandpa_block_import,
|
||||
client.clone(),
|
||||
client.clone(),
|
||||
)?;
|
||||
|
||||
let import_queue = babe::import_queue(
|
||||
babe_link.clone(),
|
||||
babe_block_import,
|
||||
let import_queue = aura::import_queue::<_, _, AuraPair, ()>(
|
||||
aura::SlotDuration::get_or_compute(&*client)?,
|
||||
Box::new(grandpa_block_import),
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
client.clone(),
|
||||
client,
|
||||
inherent_data_providers.clone(),
|
||||
None,
|
||||
)?;
|
||||
|
||||
Ok((import_queue, finality_proof_request_builder))
|
||||
|
|
Loading…
Reference in New Issue