Upgrade to v3.0.0 (#141)
parent
09707d5721
commit
d567c87707
|
@ -30,8 +30,10 @@ jobs:
|
|||
curl https://sh.rustup.rs -sSf | sh -s -- -y
|
||||
source ~/.cargo/env
|
||||
rustup default stable
|
||||
rustup update nightly
|
||||
rustup update stable
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
|
||||
- name: Check Build
|
||||
run: |
|
||||
make init
|
||||
make check
|
||||
SKIP_WASM_BUILD=1 cargo check --release
|
||||
|
|
File diff suppressed because it is too large
Load Diff
19
Makefile
19
Makefile
|
@ -1,19 +0,0 @@
|
|||
.PHONY: init
|
||||
init:
|
||||
./scripts/init.sh
|
||||
|
||||
.PHONY: check
|
||||
check:
|
||||
SKIP_WASM_BUILD=1 cargo check --release
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
SKIP_WASM_BUILD=1 cargo test --release --all
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
cargo run --release -- --dev --tmp
|
||||
|
||||
.PHONY: build
|
||||
build:
|
||||
cargo build --release
|
36
README.md
36
README.md
|
@ -4,34 +4,27 @@ A fresh FRAME-based [Substrate](https://www.substrate.io/) node, ready for hacki
|
|||
|
||||
## Getting Started
|
||||
|
||||
This project contains some configuration files to help get started :hammer_and_wrench:
|
||||
Follow these steps to get started with the Node Template :hammer_and_wrench:
|
||||
|
||||
### Rust Setup
|
||||
|
||||
Follow the [Rust setup instructions](./doc/rust-setup.md) before using the included Makefile to
|
||||
build the Node Template.
|
||||
First, complete the [basic Rust setup instructions](./doc/rust-setup.md).
|
||||
|
||||
### Makefile
|
||||
### Run
|
||||
|
||||
This project uses a [Makefile](Makefile) to document helpful commands and make it easier to execute
|
||||
them. Get started by running these [`make`](https://www.gnu.org/software/make/manual/make.html)
|
||||
targets:
|
||||
Use Rust's native `cargo` command to build and launch the template node:
|
||||
|
||||
1. `make init` - Run the [init script](scripts/init.sh) to configure the Rust toolchain for
|
||||
[WebAssembly compilation](https://substrate.dev/docs/en/knowledgebase/getting-started/#webassembly-compilation).
|
||||
1. `make run` - Build and launch this project in development mode.
|
||||
|
||||
The init script and Makefile both specify the version of the
|
||||
[Rust nightly compiler](https://substrate.dev/docs/en/knowledgebase/getting-started/#rust-nightly-toolchain)
|
||||
that this project depends on.
|
||||
```sh
|
||||
cargo run --release -- --dev --tmp
|
||||
```
|
||||
|
||||
### Build
|
||||
|
||||
The `make run` command will perform an initial build. Use the following command to build the node
|
||||
The `cargo run` command will perform an initial build. Use the following command to build the node
|
||||
without launching it:
|
||||
|
||||
```sh
|
||||
make build
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
### Embedded Docs
|
||||
|
@ -45,8 +38,9 @@ subcommands:
|
|||
|
||||
## Run
|
||||
|
||||
The `make run` command will launch a temporary node and its state will be discarded after you
|
||||
terminate the process. After the project has been built, there are other ways to launch the node.
|
||||
The provided `cargo run` command will launch a temporary node and its state will be discarded after
|
||||
you terminate the process. After the project has been built, there are other ways to launch the
|
||||
node.
|
||||
|
||||
### Single-Node Development Chain
|
||||
|
||||
|
@ -137,7 +131,7 @@ Review the [FRAME runtime implementation](./runtime/src/lib.rs) included in this
|
|||
the following:
|
||||
|
||||
- This file configures several pallets to include in the runtime. Each pallet configuration is
|
||||
defined by a code block that begins with `impl $PALLET_NAME::Trait for Runtime`.
|
||||
defined by a code block that begins with `impl $PALLET_NAME::Config for Runtime`.
|
||||
- The pallets are composed into a single runtime by way of the
|
||||
[`construct_runtime!`](https://crates.parity.io/frame_support/macro.construct_runtime.html)
|
||||
macro, which is part of the core
|
||||
|
@ -161,8 +155,8 @@ A FRAME pallet is compromised of a number of blockchain primitives:
|
|||
- Events: Substrate uses [events](https://substrate.dev/docs/en/knowledgebase/runtime/events) to
|
||||
notify users of important changes in the runtime.
|
||||
- Errors: When a dispatchable fails, it returns an error.
|
||||
- Trait: The `Trait` configuration interface is used to define the types and parameters upon which
|
||||
a FRAME pallet depends.
|
||||
- Config: The `Config` configuration interface is used to define the types and parameters upon
|
||||
which a FRAME pallet depends.
|
||||
|
||||
### Run in Docker
|
||||
|
||||
|
|
|
@ -71,14 +71,11 @@ curl https://sh.rustup.rs -sSf | sh
|
|||
source ~/.cargo/env
|
||||
```
|
||||
|
||||
Finally, configure the Rust toolchain to default to the latest stable version:
|
||||
Finally, configure the Rust toolchain:
|
||||
|
||||
```bash
|
||||
rustup default stable
|
||||
rustup update nightly
|
||||
rustup update stable
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
||||
```
|
||||
|
||||
## Build the Project
|
||||
|
||||
Now that the standard Rust environment is configured, use the
|
||||
[included Makefile](../README.md#makefile) to install the project-specific toolchains and build the
|
||||
project.
|
||||
|
|
|
@ -7,7 +7,7 @@ homepage = 'https://substrate.dev'
|
|||
license = 'Unlicense'
|
||||
name = 'node-template'
|
||||
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
|
||||
version = '2.0.1'
|
||||
version = '3.0.0'
|
||||
|
||||
[[bin]]
|
||||
name = 'node-template'
|
||||
|
@ -16,41 +16,42 @@ name = 'node-template'
|
|||
targets = ['x86_64-unknown-linux-gnu']
|
||||
|
||||
[build-dependencies]
|
||||
substrate-build-script-utils = '2.0.1'
|
||||
substrate-build-script-utils = '3.0.0'
|
||||
|
||||
[dependencies]
|
||||
jsonrpc-core = '15.0.0'
|
||||
jsonrpc-core = '15.1.0'
|
||||
structopt = '0.3.8'
|
||||
|
||||
# local dependencies
|
||||
node-template-runtime = { path = '../runtime', version = '2.0.1' }
|
||||
node-template-runtime = { path = '../runtime', version = '3.0.0' }
|
||||
|
||||
# Substrate dependencies
|
||||
frame-benchmarking = '2.0.1'
|
||||
frame-benchmarking-cli = '2.0.1'
|
||||
pallet-transaction-payment-rpc = '2.0.1'
|
||||
sc-basic-authorship = '0.8.1'
|
||||
sc-cli = { features = ['wasmtime'], version = '0.8.1' }
|
||||
sc-client-api = '2.0.1'
|
||||
sc-consensus = '0.8.1'
|
||||
sc-consensus-aura = '0.8.1'
|
||||
sc-executor = { features = ['wasmtime'], version = '0.8.1' }
|
||||
sc-finality-grandpa = '0.8.1'
|
||||
sc-rpc = '2.0.1'
|
||||
sc-rpc-api = '0.8.1'
|
||||
sc-service = { features = ['wasmtime'], version = '0.8.1' }
|
||||
sc-transaction-pool = '2.0.1'
|
||||
sp-api = '2.0.1'
|
||||
sp-block-builder = '2.0.1'
|
||||
sp-blockchain = '2.0.1'
|
||||
sp-consensus = '0.8.1'
|
||||
sp-consensus-aura = '0.8.1'
|
||||
sp-core = '2.0.1'
|
||||
sp-finality-grandpa = '2.0.1'
|
||||
sp-inherents = '2.0.1'
|
||||
sp-runtime = '2.0.1'
|
||||
sp-transaction-pool = '2.0.1'
|
||||
substrate-frame-rpc-system = '2.0.1'
|
||||
frame-benchmarking = '3.0.0'
|
||||
frame-benchmarking-cli = '3.0.0'
|
||||
pallet-transaction-payment-rpc = '3.0.0'
|
||||
sc-basic-authorship = '0.9.0'
|
||||
sc-cli = { features = ['wasmtime'], version = '0.9.0' }
|
||||
sc-client-api = '3.0.0'
|
||||
sc-consensus = '0.9.0'
|
||||
sc-consensus-aura = '0.9.0'
|
||||
sc-executor = { features = ['wasmtime'], version = '0.9.0' }
|
||||
sc-finality-grandpa = '0.9.0'
|
||||
sc-keystore = '3.0.0'
|
||||
sc-rpc = '3.0.0'
|
||||
sc-rpc-api = '0.9.0'
|
||||
sc-service = { features = ['wasmtime'], version = '0.9.0' }
|
||||
sc-transaction-pool = '3.0.0'
|
||||
sp-api = '3.0.0'
|
||||
sp-block-builder = '3.0.0'
|
||||
sp-blockchain = '3.0.0'
|
||||
sp-consensus = '0.9.0'
|
||||
sp-consensus-aura = '0.9.0'
|
||||
sp-core = '3.0.0'
|
||||
sp-finality-grandpa = '3.0.0'
|
||||
sp-inherents = '3.0.0'
|
||||
sp-runtime = '3.0.0'
|
||||
sp-transaction-pool = '3.0.0'
|
||||
substrate-frame-rpc-system = '3.0.0'
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -39,7 +39,7 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
|
|||
}
|
||||
|
||||
pub fn development_config() -> Result<ChainSpec, String> {
|
||||
let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?;
|
||||
|
||||
Ok(ChainSpec::from_genesis(
|
||||
// Name
|
||||
|
@ -78,7 +78,7 @@ pub fn development_config() -> Result<ChainSpec, String> {
|
|||
}
|
||||
|
||||
pub fn local_testnet_config() -> Result<ChainSpec, String> {
|
||||
let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm binary not available".to_string())?;
|
||||
|
||||
Ok(ChainSpec::from_genesis(
|
||||
// Name
|
||||
|
|
|
@ -12,6 +12,8 @@ pub struct Cli {
|
|||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub enum Subcommand {
|
||||
/// Key management cli utilities
|
||||
Key(sc_cli::KeySubcommand),
|
||||
/// Build a chain specification.
|
||||
BuildSpec(sc_cli::BuildSpecCmd),
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
|
||||
// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -66,6 +66,7 @@ pub fn run() -> sc_cli::Result<()> {
|
|||
let cli = Cli::from_args();
|
||||
|
||||
match &cli.subcommand {
|
||||
Some(Subcommand::Key(cmd)) => cmd.run(&cli),
|
||||
Some(Subcommand::BuildSpec(cmd)) => {
|
||||
let runner = cli.create_runner(cmd)?;
|
||||
runner.sync_run(|config| cmd.run(config.chain_spec, config.network))
|
||||
|
@ -126,9 +127,11 @@ pub fn run() -> sc_cli::Result<()> {
|
|||
},
|
||||
None => {
|
||||
let runner = cli.create_runner(&cli.run)?;
|
||||
runner.run_node_until_exit(|config| match config.role {
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
match config.role {
|
||||
Role::Light => service::new_light(config),
|
||||
_ => service::new_full(config),
|
||||
}.map_err(sc_cli::Error::Service)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ use sp_inherents::InherentDataProviders;
|
|||
use sc_executor::native_executor_instance;
|
||||
pub use sc_executor::NativeExecutor;
|
||||
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
|
||||
use sc_finality_grandpa::{FinalityProofProvider as GrandpaFinalityProofProvider, SharedVoterState};
|
||||
use sc_finality_grandpa::SharedVoterState;
|
||||
use sc_keystore::LocalKeystore;
|
||||
|
||||
// Our native executor instance.
|
||||
native_executor_instance!(
|
||||
|
@ -34,12 +35,16 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
sc_finality_grandpa::GrandpaBlockImport<FullBackend, Block, FullClient, FullSelectChain>,
|
||||
AuraPair
|
||||
>,
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>
|
||||
sc_finality_grandpa::LinkHalf<Block, FullClient, FullSelectChain>,
|
||||
)
|
||||
>, ServiceError> {
|
||||
if config.keystore_remote.is_some() {
|
||||
return Err(ServiceError::Other(
|
||||
format!("Remote Keystores are not supported.")))
|
||||
}
|
||||
let inherent_data_providers = sp_inherents::InherentDataProviders::new();
|
||||
|
||||
let (client, backend, keystore, task_manager) =
|
||||
let (client, backend, keystore_container, task_manager) =
|
||||
sc_service::new_full_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
let client = Arc::new(client);
|
||||
|
||||
|
@ -47,6 +52,7 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
|
||||
let transaction_pool = sc_transaction_pool::BasicPool::new_full(
|
||||
config.transaction_pool.clone(),
|
||||
config.role.is_authority().into(),
|
||||
config.prometheus_registry(),
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
|
@ -64,7 +70,6 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
aura_block_import.clone(),
|
||||
Some(Box::new(grandpa_block_import.clone())),
|
||||
None,
|
||||
client.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
&task_manager.spawn_handle(),
|
||||
|
@ -73,22 +78,38 @@ pub fn new_partial(config: &Configuration) -> Result<sc_service::PartialComponen
|
|||
)?;
|
||||
|
||||
Ok(sc_service::PartialComponents {
|
||||
client, backend, task_manager, import_queue, keystore, select_chain, transaction_pool,
|
||||
client, backend, task_manager, import_queue, keystore_container, select_chain, transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (aura_block_import, grandpa_link),
|
||||
})
|
||||
}
|
||||
|
||||
fn remote_keystore(_url: &String) -> Result<Arc<LocalKeystore>, &'static str> {
|
||||
// FIXME: here would the concrete keystore be built,
|
||||
// must return a concrete type (NOT `LocalKeystore`) that
|
||||
// implements `CryptoStore` and `SyncCryptoStore`
|
||||
Err("Remote Keystore not supported.")
|
||||
}
|
||||
|
||||
/// Builds a new service for a full client.
|
||||
pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
pub fn new_full(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let sc_service::PartialComponents {
|
||||
client, backend, mut task_manager, import_queue, keystore, select_chain, transaction_pool,
|
||||
client, backend, mut task_manager, import_queue, mut keystore_container, select_chain, transaction_pool,
|
||||
inherent_data_providers,
|
||||
other: (block_import, grandpa_link),
|
||||
} = new_partial(&config)?;
|
||||
|
||||
let finality_proof_provider =
|
||||
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
|
||||
if let Some(url) = &config.keystore_remote {
|
||||
match remote_keystore(url) {
|
||||
Ok(k) => keystore_container.set_remote_keystore(k),
|
||||
Err(e) => {
|
||||
return Err(ServiceError::Other(
|
||||
format!("Error hooking up remote keystore for {}: {}", url, e)))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
|
@ -99,8 +120,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
import_queue,
|
||||
on_demand: None,
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: None,
|
||||
finality_proof_provider: Some(finality_proof_provider.clone()),
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
|
@ -111,10 +130,10 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
|
||||
let role = config.role.clone();
|
||||
let force_authoring = config.force_authoring;
|
||||
let backoff_authoring_blocks: Option<()> = None;
|
||||
let name = config.network.node_name.clone();
|
||||
let enable_grandpa = !config.disable_grandpa;
|
||||
let prometheus_registry = config.prometheus_registry().cloned();
|
||||
let telemetry_connection_sinks = sc_service::TelemetryConnectionSinks::default();
|
||||
|
||||
let rpc_extensions_builder = {
|
||||
let client = client.clone();
|
||||
|
@ -131,21 +150,26 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
})
|
||||
};
|
||||
|
||||
sc_service::spawn_tasks(sc_service::SpawnTasksParams {
|
||||
let (_rpc_handlers, telemetry_connection_notifier) = sc_service::spawn_tasks(
|
||||
sc_service::SpawnTasksParams {
|
||||
network: network.clone(),
|
||||
client: client.clone(),
|
||||
keystore: keystore.clone(),
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
task_manager: &mut task_manager,
|
||||
transaction_pool: transaction_pool.clone(),
|
||||
telemetry_connection_sinks: telemetry_connection_sinks.clone(),
|
||||
rpc_extensions_builder: rpc_extensions_builder,
|
||||
rpc_extensions_builder,
|
||||
on_demand: None,
|
||||
remote_blockchain: None,
|
||||
backend, network_status_sinks, system_rpc_tx, config,
|
||||
})?;
|
||||
backend,
|
||||
network_status_sinks,
|
||||
system_rpc_tx,
|
||||
config,
|
||||
},
|
||||
)?;
|
||||
|
||||
if role.is_authority() {
|
||||
let proposer = sc_basic_authorship::ProposerFactory::new(
|
||||
task_manager.spawn_handle(),
|
||||
client.clone(),
|
||||
transaction_pool,
|
||||
prometheus_registry.as_ref(),
|
||||
|
@ -154,7 +178,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
let can_author_with =
|
||||
sp_consensus::CanAuthorWithNativeVersion::new(client.executor().clone());
|
||||
|
||||
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _>(
|
||||
let aura = sc_consensus_aura::start_aura::<_, _, _, _, _, AuraPair, _, _, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
client.clone(),
|
||||
select_chain,
|
||||
|
@ -163,7 +187,8 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
network.clone(),
|
||||
inherent_data_providers.clone(),
|
||||
force_authoring,
|
||||
keystore.clone(),
|
||||
backoff_authoring_blocks,
|
||||
keystore_container.sync_keystore(),
|
||||
can_author_with,
|
||||
)?;
|
||||
|
||||
|
@ -175,7 +200,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
// if the node isn't actively participating in consensus then it doesn't
|
||||
// need a keystore, regardless of which protocol we use below.
|
||||
let keystore = if role.is_authority() {
|
||||
Some(keystore as sp_core::traits::BareCryptoStorePtr)
|
||||
Some(keystore_container.sync_keystore())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
@ -201,8 +226,7 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
config: grandpa_config,
|
||||
link: grandpa_link,
|
||||
network,
|
||||
inherent_data_providers,
|
||||
telemetry_on_connect: Some(telemetry_connection_sinks.on_connect_stream()),
|
||||
telemetry_on_connect: telemetry_connection_notifier.map(|x| x.on_connect_stream()),
|
||||
voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
|
||||
prometheus_registry,
|
||||
shared_voter_state: SharedVoterState::empty(),
|
||||
|
@ -214,12 +238,6 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
"grandpa-voter",
|
||||
sc_finality_grandpa::run_grandpa_voter(grandpa_config)?
|
||||
);
|
||||
} else {
|
||||
sc_finality_grandpa::setup_disabled_grandpa(
|
||||
client,
|
||||
&inherent_data_providers,
|
||||
network,
|
||||
)?;
|
||||
}
|
||||
|
||||
network_starter.start_network();
|
||||
|
@ -227,10 +245,14 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
}
|
||||
|
||||
/// Builds a new service for a light client.
|
||||
pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let (client, backend, keystore, mut task_manager, on_demand) =
|
||||
pub fn new_light(mut config: Configuration) -> Result<TaskManager, ServiceError> {
|
||||
let (client, backend, keystore_container, mut task_manager, on_demand) =
|
||||
sc_service::new_light_parts::<Block, RuntimeApi, Executor>(&config)?;
|
||||
|
||||
config.network.extra_sets.push(sc_finality_grandpa::grandpa_peers_set_config());
|
||||
|
||||
let select_chain = sc_consensus::LongestChain::new(backend.clone());
|
||||
|
||||
let transaction_pool = Arc::new(sc_transaction_pool::BasicPool::new_light(
|
||||
config.transaction_pool.clone(),
|
||||
config.prometheus_registry(),
|
||||
|
@ -239,19 +261,21 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
on_demand.clone(),
|
||||
));
|
||||
|
||||
let grandpa_block_import = sc_finality_grandpa::light_block_import(
|
||||
client.clone(), backend.clone(), &(client.clone() as Arc<_>),
|
||||
Arc::new(on_demand.checker().clone()) as Arc<_>,
|
||||
let (grandpa_block_import, _) = sc_finality_grandpa::block_import(
|
||||
client.clone(),
|
||||
&(client.clone() as Arc<_>),
|
||||
select_chain.clone(),
|
||||
)?;
|
||||
let finality_proof_import = grandpa_block_import.clone();
|
||||
let finality_proof_request_builder =
|
||||
finality_proof_import.create_finality_proof_request_builder();
|
||||
|
||||
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
|
||||
grandpa_block_import.clone(),
|
||||
client.clone(),
|
||||
);
|
||||
|
||||
let import_queue = sc_consensus_aura::import_queue::<_, _, _, AuraPair, _, _>(
|
||||
sc_consensus_aura::slot_duration(&*client)?,
|
||||
grandpa_block_import,
|
||||
None,
|
||||
Some(Box::new(finality_proof_import)),
|
||||
aura_block_import,
|
||||
Some(Box::new(grandpa_block_import)),
|
||||
client.clone(),
|
||||
InherentDataProviders::new(),
|
||||
&task_manager.spawn_handle(),
|
||||
|
@ -259,9 +283,6 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
sp_consensus::NeverCanAuthor,
|
||||
)?;
|
||||
|
||||
let finality_proof_provider =
|
||||
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
sc_service::build_network(sc_service::BuildNetworkParams {
|
||||
config: &config,
|
||||
|
@ -271,8 +292,6 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
import_queue,
|
||||
on_demand: Some(on_demand.clone()),
|
||||
block_announce_validator_builder: None,
|
||||
finality_proof_request_builder: Some(finality_proof_request_builder),
|
||||
finality_proof_provider: Some(finality_proof_provider),
|
||||
})?;
|
||||
|
||||
if config.offchain_worker.enabled {
|
||||
|
@ -287,10 +306,9 @@ pub fn new_light(config: Configuration) -> Result<TaskManager, ServiceError> {
|
|||
task_manager: &mut task_manager,
|
||||
on_demand: Some(on_demand),
|
||||
rpc_extensions_builder: Box::new(|_, _| ()),
|
||||
telemetry_connection_sinks: sc_service::TelemetryConnectionSinks::default(),
|
||||
config,
|
||||
client,
|
||||
keystore,
|
||||
keystore: keystore_container.sync_keystore(),
|
||||
backend,
|
||||
network,
|
||||
network_status_sinks,
|
||||
|
|
|
@ -6,7 +6,7 @@ homepage = 'https://substrate.dev'
|
|||
license = 'Unlicense'
|
||||
name = 'pallet-template'
|
||||
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
|
||||
version = '2.0.1'
|
||||
version = '3.0.0'
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ['x86_64-unknown-linux-gnu']
|
||||
|
@ -16,16 +16,17 @@ targets = ['x86_64-unknown-linux-gnu']
|
|||
default-features = false
|
||||
features = ['derive']
|
||||
package = 'parity-scale-codec'
|
||||
version = '1.3.4'
|
||||
version = '2.0.0'
|
||||
|
||||
[dependencies]
|
||||
frame-support = { default-features = false, version = '2.0.1' }
|
||||
frame-system = { default-features = false, version = '2.0.1' }
|
||||
frame-support = { default-features = false, version = '3.0.0' }
|
||||
frame-system = { default-features = false, version = '3.0.0' }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-core = { default-features = false, version = '2.0.1' }
|
||||
sp-io = { default-features = false, version = '2.0.1' }
|
||||
sp-runtime = { default-features = false, version = '2.0.1' }
|
||||
serde = { version = "1.0.119" }
|
||||
sp-core = { default-features = false, version = '3.0.0' }
|
||||
sp-io = { default-features = false, version = '3.0.0' }
|
||||
sp-runtime = { default-features = false, version = '3.0.0' }
|
||||
|
||||
[features]
|
||||
default = ['std']
|
||||
|
|
|
@ -14,9 +14,9 @@ mod mock;
|
|||
mod tests;
|
||||
|
||||
/// Configure the pallet by specifying the parameters and types on which it depends.
|
||||
pub trait Trait: frame_system::Trait {
|
||||
pub trait Config: frame_system::Config {
|
||||
/// Because this pallet emits events, it depends on the runtime's definition of an event.
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Config>::Event>;
|
||||
}
|
||||
|
||||
// The pallet's runtime storage items.
|
||||
|
@ -25,7 +25,7 @@ decl_storage! {
|
|||
// A unique name is used to ensure that the pallet's storage items are isolated.
|
||||
// This name may be updated, but each pallet in the runtime must use a unique name.
|
||||
// ---------------------------------vvvvvvvvvvvvvv
|
||||
trait Store for Module<T: Trait> as TemplateModule {
|
||||
trait Store for Module<T: Config> as TemplateModule {
|
||||
// Learn more about declaring storage items:
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/storage#declaring-storage-items
|
||||
Something get(fn something): Option<u32>;
|
||||
|
@ -35,7 +35,7 @@ decl_storage! {
|
|||
// Pallets use events to inform users when important changes are made.
|
||||
// https://substrate.dev/docs/en/knowledgebase/runtime/events
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Config>::AccountId {
|
||||
/// Event documentation should end with an array that provides descriptive names for event
|
||||
/// parameters. [something, who]
|
||||
SomethingStored(u32, AccountId),
|
||||
|
@ -44,7 +44,7 @@ decl_event!(
|
|||
|
||||
// Errors inform users that something went wrong.
|
||||
decl_error! {
|
||||
pub enum Error for Module<T: Trait> {
|
||||
pub enum Error for Module<T: Config> {
|
||||
/// Error names should be descriptive.
|
||||
NoneValue,
|
||||
/// Errors should have helpful documentation associated with them.
|
||||
|
@ -56,7 +56,7 @@ decl_error! {
|
|||
// These functions materialize as "extrinsics", which are often compared to transactions.
|
||||
// Dispatchable functions must be annotated with a weight and must return a DispatchResult.
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Config> for enum Call where origin: T::Origin {
|
||||
// Errors must be initialized if they are used by the pallet.
|
||||
type Error = Error<T>;
|
||||
|
||||
|
|
|
@ -1,30 +1,38 @@
|
|||
use crate::{Module, Trait};
|
||||
use crate as pallet_template;
|
||||
use sp_core::H256;
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_support::parameter_types;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header,
|
||||
};
|
||||
use frame_system as system;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
}
|
||||
type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic<Test>;
|
||||
type Block = frame_system::mocking::MockBlock<Test>;
|
||||
|
||||
// Configure a mock runtime to test the pallet.
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic,
|
||||
{
|
||||
System: frame_system::{Module, Call, Config, Storage, Event<T>},
|
||||
TemplateModule: pallet_template::{Module, Call, Storage, Event<T>},
|
||||
}
|
||||
);
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Test;
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
pub const MaximumBlockWeight: Weight = 1024;
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
|
||||
pub const SS58Prefix: u8 = 42;
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
impl system::Config for Test {
|
||||
type BaseCallFilter = ();
|
||||
type BlockWeights = ();
|
||||
type BlockLength = ();
|
||||
type DbWeight = ();
|
||||
type Origin = Origin;
|
||||
type Call = ();
|
||||
type Call = Call;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
type Hash = H256;
|
||||
|
@ -32,29 +40,21 @@ impl system::Trait for Test {
|
|||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<Self::AccountId>;
|
||||
type Header = Header;
|
||||
type Event = ();
|
||||
type Event = Event;
|
||||
type BlockHashCount = BlockHashCount;
|
||||
type MaximumBlockWeight = MaximumBlockWeight;
|
||||
type DbWeight = ();
|
||||
type BlockExecutionWeight = ();
|
||||
type ExtrinsicBaseWeight = ();
|
||||
type MaximumExtrinsicWeight = MaximumBlockWeight;
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type AvailableBlockRatio = AvailableBlockRatio;
|
||||
type Version = ();
|
||||
type PalletInfo = ();
|
||||
type PalletInfo = PalletInfo;
|
||||
type AccountData = ();
|
||||
type OnNewAccount = ();
|
||||
type OnKilledAccount = ();
|
||||
type SystemWeightInfo = ();
|
||||
type SS58Prefix = SS58Prefix;
|
||||
}
|
||||
|
||||
impl Trait for Test {
|
||||
type Event = ();
|
||||
impl pallet_template::Config for Test {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
pub type TemplateModule = Module<Test>;
|
||||
|
||||
// Build genesis storage according to the mock runtime.
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
||||
|
|
|
@ -5,54 +5,54 @@ homepage = 'https://substrate.dev'
|
|||
license = 'Unlicense'
|
||||
name = 'node-template-runtime'
|
||||
repository = 'https://github.com/substrate-developer-hub/substrate-node-template/'
|
||||
version = '2.0.1'
|
||||
version = '3.0.0'
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
targets = ['x86_64-unknown-linux-gnu']
|
||||
|
||||
[build-dependencies]
|
||||
substrate-wasm-builder = '3.0.0'
|
||||
substrate-wasm-builder = '4.0.0'
|
||||
|
||||
# alias "parity-scale-code" to "codec"
|
||||
[dependencies.codec]
|
||||
default-features = false
|
||||
features = ['derive']
|
||||
package = 'parity-scale-codec'
|
||||
version = '1.3.4'
|
||||
version = '2.0.0'
|
||||
|
||||
[dependencies]
|
||||
hex-literal = { optional = true, version = '0.3.1' }
|
||||
serde = { features = ['derive'], optional = true, version = '1.0.119' }
|
||||
|
||||
# local dependencies
|
||||
pallet-template = { path = '../pallets/template', default-features = false, version = '2.0.1' }
|
||||
pallet-template = { path = '../pallets/template', default-features = false, version = '3.0.0' }
|
||||
|
||||
# Substrate dependencies
|
||||
frame-benchmarking = { default-features = false, optional = true, version = '2.0.1' }
|
||||
frame-executive = { default-features = false, version = '2.0.1' }
|
||||
frame-support = { default-features = false, version = '2.0.1' }
|
||||
frame-system = { default-features = false, version = '2.0.1' }
|
||||
frame-system-benchmarking = { default-features = false, optional = true, version = '2.0.1' }
|
||||
frame-system-rpc-runtime-api = { default-features = false, version = '2.0.1' }
|
||||
pallet-aura = { default-features = false, version = '2.0.1' }
|
||||
pallet-balances = { default-features = false, version = '2.0.1' }
|
||||
pallet-grandpa = { default-features = false, version = '2.0.1' }
|
||||
pallet-randomness-collective-flip = { default-features = false, version = '2.0.1' }
|
||||
pallet-sudo = { default-features = false, version = '2.0.1' }
|
||||
pallet-timestamp = { default-features = false, version = '2.0.1' }
|
||||
pallet-transaction-payment = { default-features = false, version = '2.0.1' }
|
||||
pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '2.0.1' }
|
||||
sp-api = { default-features = false, version = '2.0.1' }
|
||||
sp-block-builder = { default-features = false, version = '2.0.1' }
|
||||
sp-consensus-aura = { default-features = false, version = '0.8.1' }
|
||||
sp-core = { default-features = false, version = '2.0.1' }
|
||||
sp-inherents = { default-features = false, version = '2.0.1' }
|
||||
sp-offchain = { default-features = false, version = '2.0.1' }
|
||||
sp-runtime = { default-features = false, version = '2.0.1' }
|
||||
sp-session = { default-features = false, version = '2.0.1' }
|
||||
sp-std = { default-features = false, version = '2.0.1' }
|
||||
sp-transaction-pool = { default-features = false, version = '2.0.1' }
|
||||
sp-version = { default-features = false, version = '2.0.1' }
|
||||
frame-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
|
||||
frame-executive = { default-features = false, version = '3.0.0' }
|
||||
frame-support = { default-features = false, version = '3.0.0' }
|
||||
frame-system = { default-features = false, version = '3.0.0' }
|
||||
frame-system-benchmarking = { default-features = false, optional = true, version = '3.0.0' }
|
||||
frame-system-rpc-runtime-api = { default-features = false, version = '3.0.0' }
|
||||
pallet-aura = { default-features = false, version = '3.0.0' }
|
||||
pallet-balances = { default-features = false, version = '3.0.0' }
|
||||
pallet-grandpa = { default-features = false, version = '3.0.0' }
|
||||
pallet-randomness-collective-flip = { default-features = false, version = '3.0.0' }
|
||||
pallet-sudo = { default-features = false, version = '3.0.0' }
|
||||
pallet-timestamp = { default-features = false, version = '3.0.0' }
|
||||
pallet-transaction-payment = { default-features = false, version = '3.0.0' }
|
||||
pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '3.0.0' }
|
||||
sp-api = { default-features = false, version = '3.0.0' }
|
||||
sp-block-builder = { default-features = false, version = '3.0.0' }
|
||||
sp-consensus-aura = { default-features = false, version = '0.9.0' }
|
||||
sp-core = { default-features = false, version = '3.0.0' }
|
||||
sp-inherents = { default-features = false, version = '3.0.0' }
|
||||
sp-offchain = { default-features = false, version = '3.0.0' }
|
||||
sp-runtime = { default-features = false, version = '3.0.0' }
|
||||
sp-session = { default-features = false, version = '3.0.0' }
|
||||
sp-std = { default-features = false, version = '3.0.0' }
|
||||
sp-transaction-pool = { default-features = false, version = '3.0.0' }
|
||||
sp-version = { default-features = false, version = '3.0.0' }
|
||||
|
||||
[features]
|
||||
default = ['std']
|
||||
|
|
|
@ -13,7 +13,7 @@ use sp_runtime::{
|
|||
transaction_validity::{TransactionValidity, TransactionSource},
|
||||
};
|
||||
use sp_runtime::traits::{
|
||||
BlakeTwo256, Block as BlockT, Verify, IdentifyAccount, NumberFor, Saturating,
|
||||
AccountIdLookup, BlakeTwo256, Block as BlockT, Verify, IdentifyAccount, NumberFor,
|
||||
};
|
||||
use sp_api::impl_runtime_apis;
|
||||
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
|
||||
|
@ -37,6 +37,7 @@ pub use frame_support::{
|
|||
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
|
||||
},
|
||||
};
|
||||
use pallet_transaction_payment::CurrencyAdapter;
|
||||
|
||||
/// Import the template pallet.
|
||||
pub use pallet_template;
|
||||
|
@ -101,6 +102,13 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||
transaction_version: 1,
|
||||
};
|
||||
|
||||
|
||||
/// This determines the average expected block time that we are targeting.
|
||||
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`.
|
||||
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked
|
||||
/// up by `pallet_aura` to implement `fn slot_duration()`.
|
||||
///
|
||||
/// Change this to adjust the block time.
|
||||
pub const MILLISECS_PER_BLOCK: u64 = 6000;
|
||||
|
||||
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;
|
||||
|
@ -119,29 +127,34 @@ pub fn native_version() -> NativeVersion {
|
|||
}
|
||||
}
|
||||
|
||||
const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);
|
||||
|
||||
parameter_types! {
|
||||
pub const Version: RuntimeVersion = VERSION;
|
||||
pub const BlockHashCount: BlockNumber = 2400;
|
||||
/// We allow for 2 seconds of compute with a 6 second average block time.
|
||||
pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;
|
||||
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 BlockWeights: frame_system::limits::BlockWeights = frame_system::limits::BlockWeights
|
||||
::with_sensible_defaults(2 * WEIGHT_PER_SECOND, NORMAL_DISPATCH_RATIO);
|
||||
pub BlockLength: frame_system::limits::BlockLength = frame_system::limits::BlockLength
|
||||
::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);
|
||||
pub const SS58Prefix: u8 = 42;
|
||||
}
|
||||
|
||||
// Configure FRAME pallets to include in runtime.
|
||||
|
||||
impl frame_system::Trait for Runtime {
|
||||
impl frame_system::Config for Runtime {
|
||||
/// The basic call filter to use in dispatchable.
|
||||
type BaseCallFilter = ();
|
||||
/// Block & extrinsics weights: base values and limits.
|
||||
type BlockWeights = BlockWeights;
|
||||
/// The maximum length of a block (in bytes).
|
||||
type BlockLength = BlockLength;
|
||||
/// 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 = multiaddress::AccountIdLookup<AccountId, ()>;
|
||||
type Lookup = AccountIdLookup<AccountId, ()>;
|
||||
/// The index type for storing how many extrinsics an account has signed.
|
||||
type Index = Index;
|
||||
/// The index type for blocks.
|
||||
|
@ -158,24 +171,8 @@ impl frame_system::Trait for Runtime {
|
|||
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 = RocksDbWeight;
|
||||
/// The weight of the overhead invoked on the block import process, independent of the
|
||||
/// extrinsics included in that block.
|
||||
type BlockExecutionWeight = 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!`.
|
||||
|
@ -190,13 +187,15 @@ impl frame_system::Trait for Runtime {
|
|||
type AccountData = pallet_balances::AccountData<Balance>;
|
||||
/// Weight information for the extrinsics of this pallet.
|
||||
type SystemWeightInfo = ();
|
||||
/// This is used as an identifier of the chain. 42 is the generic substrate prefix.
|
||||
type SS58Prefix = SS58Prefix;
|
||||
}
|
||||
|
||||
impl pallet_aura::Trait for Runtime {
|
||||
impl pallet_aura::Config for Runtime {
|
||||
type AuthorityId = AuraId;
|
||||
}
|
||||
|
||||
impl pallet_grandpa::Trait for Runtime {
|
||||
impl pallet_grandpa::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
|
||||
|
@ -219,7 +218,7 @@ parameter_types! {
|
|||
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
|
||||
}
|
||||
|
||||
impl pallet_timestamp::Trait for Runtime {
|
||||
impl pallet_timestamp::Config for Runtime {
|
||||
/// A timestamp: milliseconds since the unix epoch.
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Aura;
|
||||
|
@ -232,7 +231,7 @@ parameter_types! {
|
|||
pub const MaxLocks: u32 = 50;
|
||||
}
|
||||
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
impl pallet_balances::Config for Runtime {
|
||||
type MaxLocks = MaxLocks;
|
||||
/// The type for recording an account's balance.
|
||||
type Balance = Balance;
|
||||
|
@ -241,28 +240,27 @@ impl pallet_balances::Trait for Runtime {
|
|||
type DustRemoval = ();
|
||||
type ExistentialDeposit = ExistentialDeposit;
|
||||
type AccountStore = System;
|
||||
type WeightInfo = ();
|
||||
type WeightInfo = pallet_balances::weights::SubstrateWeight<Runtime>;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const TransactionByteFee: Balance = 1;
|
||||
}
|
||||
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type OnTransactionPayment = ();
|
||||
impl pallet_transaction_payment::Config for Runtime {
|
||||
type OnChargeTransaction = CurrencyAdapter<Balances, ()>;
|
||||
type TransactionByteFee = TransactionByteFee;
|
||||
type WeightToFee = IdentityFee<Balance>;
|
||||
type FeeMultiplierUpdate = ();
|
||||
}
|
||||
|
||||
impl pallet_sudo::Trait for Runtime {
|
||||
impl pallet_sudo::Config for Runtime {
|
||||
type Event = Event;
|
||||
type Call = Call;
|
||||
}
|
||||
|
||||
/// Configure the template pallet in pallets/template.
|
||||
impl pallet_template::Trait for Runtime {
|
||||
impl pallet_template::Config for Runtime {
|
||||
type Event = Event;
|
||||
}
|
||||
|
||||
|
@ -276,7 +274,7 @@ construct_runtime!(
|
|||
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},
|
||||
Aura: pallet_aura::{Module, Config<T>},
|
||||
Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event},
|
||||
Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>},
|
||||
TransactionPayment: pallet_transaction_payment::{Module, Storage},
|
||||
|
@ -287,8 +285,7 @@ construct_runtime!(
|
|||
);
|
||||
|
||||
/// The address format for describing accounts.
|
||||
mod multiaddress;
|
||||
pub type Address = multiaddress::MultiAddress<AccountId, ()>;
|
||||
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
|
||||
/// Block header type as expected by this runtime.
|
||||
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
|
||||
/// Block type as expected by this runtime.
|
||||
|
@ -444,6 +441,12 @@ impl_runtime_apis! {
|
|||
) -> pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo<Balance> {
|
||||
TransactionPayment::query_info(uxt, len)
|
||||
}
|
||||
fn query_fee_details(
|
||||
uxt: <Block as BlockT>::Extrinsic,
|
||||
len: u32,
|
||||
) -> pallet_transaction_payment::FeeDetails<Balance> {
|
||||
TransactionPayment::query_fee_details(uxt, len)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
|
@ -454,7 +457,7 @@ impl_runtime_apis! {
|
|||
use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
|
||||
|
||||
use frame_system_benchmarking::Module as SystemBench;
|
||||
impl frame_system_benchmarking::Trait for Runtime {}
|
||||
impl frame_system_benchmarking::Config for Runtime {}
|
||||
|
||||
let whitelist: Vec<TrackedStorageKey> = vec![
|
||||
// Block Number
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) 2017-2021 Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! MultiAddress type is a wrapper for multiple downstream account formats.
|
||||
//! Copied from `sp_runtime::multiaddress`, and can be removed and replaced when
|
||||
//! updating to a newer version of Substrate.
|
||||
|
||||
use codec::{Encode, Decode, Codec};
|
||||
use sp_std::{vec::Vec, marker::PhantomData, fmt::Debug};
|
||||
use sp_runtime::{RuntimeDebug, traits::{LookupError, StaticLookup}};
|
||||
|
||||
/// A multi-format address wrapper for on-chain accounts.
|
||||
#[derive(Encode, Decode, PartialEq, Eq, Clone, RuntimeDebug)]
|
||||
#[cfg_attr(feature = "std", derive(Hash))]
|
||||
pub enum MultiAddress<AccountId, AccountIndex> {
|
||||
/// It's an account ID (pubkey).
|
||||
Id(AccountId),
|
||||
/// It's an account index.
|
||||
Index(#[codec(compact)] AccountIndex),
|
||||
/// It's some arbitrary raw bytes.
|
||||
Raw(Vec<u8>),
|
||||
/// It's a 32 byte representation.
|
||||
Address32([u8; 32]),
|
||||
/// Its a 20 byte representation.
|
||||
Address20([u8; 20]),
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
impl<AccountId, AccountIndex> std::fmt::Display for MultiAddress<AccountId, AccountIndex>
|
||||
where
|
||||
AccountId: std::fmt::Debug,
|
||||
AccountIndex: std::fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
use sp_core::hexdisplay::HexDisplay;
|
||||
match self {
|
||||
MultiAddress::Raw(inner) => write!(f, "MultiAddress::Raw({})", HexDisplay::from(inner)),
|
||||
MultiAddress::Address32(inner) => write!(f, "MultiAddress::Address32({})", HexDisplay::from(inner)),
|
||||
MultiAddress::Address20(inner) => write!(f, "MultiAddress::Address20({})", HexDisplay::from(inner)),
|
||||
_ => write!(f, "{:?}", self),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<AccountId, AccountIndex> From<AccountId> for MultiAddress<AccountId, AccountIndex> {
|
||||
fn from(a: AccountId) -> Self {
|
||||
MultiAddress::Id(a)
|
||||
}
|
||||
}
|
||||
|
||||
impl<AccountId: Default, AccountIndex> Default for MultiAddress<AccountId, AccountIndex> {
|
||||
fn default() -> Self {
|
||||
MultiAddress::Id(Default::default())
|
||||
}
|
||||
}
|
||||
|
||||
/// A lookup implementation returning the `AccountId` from a `MultiAddress`.
|
||||
pub struct AccountIdLookup<AccountId, AccountIndex>(PhantomData<(AccountId, AccountIndex)>);
|
||||
impl<AccountId, AccountIndex> StaticLookup for AccountIdLookup<AccountId, AccountIndex>
|
||||
where
|
||||
AccountId: Codec + Clone + PartialEq + Debug,
|
||||
AccountIndex: Codec + Clone + PartialEq + Debug,
|
||||
MultiAddress<AccountId, AccountIndex>: Codec,
|
||||
{
|
||||
type Source = MultiAddress<AccountId, AccountIndex>;
|
||||
type Target = AccountId;
|
||||
fn lookup(x: Self::Source) -> Result<Self::Target, LookupError> {
|
||||
match x {
|
||||
MultiAddress::Id(i) => Ok(i),
|
||||
_ => Err(LookupError),
|
||||
}
|
||||
}
|
||||
fn unlookup(x: Self::Target) -> Self::Source {
|
||||
MultiAddress::Id(x)
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "*** Initializing WASM build environment ***"
|
||||
|
||||
if [ -z $CI_PROJECT_NAME ] ; then
|
||||
rustup update nightly
|
||||
rustup update stable
|
||||
fi
|
||||
|
||||
rustup target add wasm32-unknown-unknown --toolchain nightly
|
Loading…
Reference in New Issue