Merge pull request #32 from substrate-developer-hub/ricardo-alpha6

Update to alpha.6
main
Joshy Orndorff 2020-04-15 13:47:23 -04:00 committed by GitHub
commit 6aa91b6e04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 994 additions and 1047 deletions

1569
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,8 @@
[profile.release]
panic = 'unwind'
[workspace] [workspace]
members = [ members = [
'node', 'node',
'pallets/template', 'pallets/template',
'runtime', 'runtime',
] ]
[profile.release]
panic = 'unwind'

View File

@ -1,81 +1,78 @@
[package] [package]
authors = ['Anonymous'] authors = ['Anonymous']
build = 'build.rs' build = 'build.rs'
description = 'Substrate Node template'
edition = '2018' edition = '2018'
homepage = 'https://substrate.dev' homepage = 'https://substrate.dev'
license = 'Unlicense' license = 'Unlicense'
name = 'node-template' name = 'node-template'
repository = 'https://github.com/paritytech/substrate/' repository = 'https://github.com/paritytech/substrate/'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[build-dependencies] [package.metadata.docs.rs]
vergen = '3.0.4' targets = ['x86_64-unknown-linux-gnu']
[build-dependencies.build-script-utils]
package = 'substrate-build-script-utils'
version = '2.0.0-alpha.5'
[dependencies] [dependencies]
futures = '0.3.1' futures = '0.3.4'
log = '0.4.8' log = '0.4.8'
structopt = '0.3.8' structopt = '0.3.8'
[dependencies.grandpa]
package = 'sc-finality-grandpa'
version = '0.8.0-alpha.5'
[dependencies.grandpa-primitives]
package = 'sp-finality-grandpa'
version = '2.0.0-alpha.5'
[dependencies.node-template-runtime] [dependencies.node-template-runtime]
path = '../runtime' path = '../runtime'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sc-basic-authorship] [dependencies.sc-basic-authorship]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-cli] [dependencies.sc-cli]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-client] [dependencies.sc-client]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-client-api] [dependencies.sc-client-api]
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sc-consensus-aura] [dependencies.sc-consensus-aura]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-executor] [dependencies.sc-executor]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-finality-grandpa]
version = '0.8.0-alpha.6'
[dependencies.sc-network] [dependencies.sc-network]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-service] [dependencies.sc-service]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sc-transaction-pool] [dependencies.sc-transaction-pool]
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-consensus] [dependencies.sp-consensus]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sp-consensus-aura] [dependencies.sp-consensus-aura]
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sp-core] [dependencies.sp-core]
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-finality-grandpa]
version = '2.0.0-alpha.6'
[dependencies.sp-inherents] [dependencies.sp-inherents]
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-runtime] [dependencies.sp-runtime]
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-transaction-pool] [dependencies.sp-transaction-pool]
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[build-dependencies.substrate-build-script-utils]
version = '2.0.0-alpha.6'
[[bin]] [[bin]]
name = 'node-template' name = 'node-template'

View File

@ -1,9 +1,7 @@
use vergen::{ConstantsFlags, generate_cargo_keys}; use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};
const ERROR_MSG: &str = "Failed to generate metadata files";
fn main() { fn main() {
generate_cargo_keys(ConstantsFlags::SHA_SHORT).expect(ERROR_MSG); generate_cargo_keys();
build_script_utils::rerun_if_git_head_changed(); rerun_if_git_head_changed();
} }

View File

@ -3,10 +3,10 @@ use node_template_runtime::{
AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig,
SudoConfig, SystemConfig, WASM_BINARY, Signature SudoConfig, SystemConfig, WASM_BINARY, Signature
}; };
use sp_consensus_aura::sr25519::{AuthorityId as AuraId}; use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use grandpa_primitives::{AuthorityId as GrandpaId}; use sp_finality_grandpa::AuthorityId as GrandpaId;
use sc_service;
use sp_runtime::traits::{Verify, IdentifyAccount}; use sp_runtime::traits::{Verify, IdentifyAccount};
use sc_service::ChainType;
// Note this is the URL for the telemetry server // Note this is the URL for the telemetry server
//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/"; //const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
@ -14,17 +14,6 @@ use sp_runtime::traits::{Verify, IdentifyAccount};
/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>; pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
/// The chain specification option. This is expected to come in from the CLI and
/// is little more than one of a number of alternatives which can easily be converted
/// from a string (`--chain=...`) into a `ChainSpec`.
#[derive(Clone, Debug)]
pub enum Alternative {
/// Whatever the current runtime is, with just Alice as an auth.
Development,
/// Whatever the current runtime is, with simple Alice/Bob auths.
LocalTestnet,
}
/// Helper function to generate a crypto pair from seed /// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public { pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None) TPublic::Pair::from_string(&format!("//{}", seed), None)
@ -42,80 +31,72 @@ pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId where
} }
/// Helper function to generate an authority key for Aura /// Helper function to generate an authority key for Aura
pub fn get_authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) {
( (
get_from_seed::<AuraId>(s), get_from_seed::<AuraId>(s),
get_from_seed::<GrandpaId>(s), get_from_seed::<GrandpaId>(s),
) )
} }
impl Alternative { pub fn development_config() -> ChainSpec {
/// Get an actual chain config from one of the alternatives. ChainSpec::from_genesis(
pub(crate) fn load(self) -> Result<ChainSpec, String> { "Development",
Ok(match self { "dev",
Alternative::Development => ChainSpec::from_genesis( ChainType::Development,
"Development", || testnet_genesis(
"dev", vec![
|| testnet_genesis( authority_keys_from_seed("Alice"),
vec![ ],
get_authority_keys_from_seed("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
], vec![
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![ get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Alice"), get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob"), get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"), ],
get_account_id_from_seed::<sr25519::Public>("Bob//stash"), true,
], ),
true, vec![],
), None,
vec![], None,
None, None,
None, None,
None, )
None }
),
Alternative::LocalTestnet => ChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
|| testnet_genesis(
vec![
get_authority_keys_from_seed("Alice"),
get_authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
true,
),
vec![],
None,
None,
None,
None
),
})
}
pub(crate) fn from(s: &str) -> Option<Self> { pub fn local_testnet_config() -> ChainSpec {
match s { ChainSpec::from_genesis(
"dev" => Some(Alternative::Development), "Local Testnet",
"" | "local" => Some(Alternative::LocalTestnet), "local_testnet",
_ => None, ChainType::Local,
} || testnet_genesis(
} vec![
authority_keys_from_seed("Alice"),
authority_keys_from_seed("Bob"),
],
get_account_id_from_seed::<sr25519::Public>("Alice"),
vec![
get_account_id_from_seed::<sr25519::Public>("Alice"),
get_account_id_from_seed::<sr25519::Public>("Bob"),
get_account_id_from_seed::<sr25519::Public>("Charlie"),
get_account_id_from_seed::<sr25519::Public>("Dave"),
get_account_id_from_seed::<sr25519::Public>("Eve"),
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
],
true,
),
vec![],
None,
None,
None,
None,
)
} }
fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>, fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
@ -141,10 +122,3 @@ fn testnet_genesis(initial_authorities: Vec<(AuraId, GrandpaId)>,
}), }),
} }
} }
pub fn load_spec(id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match Alternative::from(id) {
Some(spec) => Box::new(spec.load()?),
None => Box::new(ChainSpec::from_json_file(std::path::PathBuf::from(id))?),
})
}

View File

@ -14,36 +14,68 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>. // along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use sc_cli::VersionInfo;
use crate::service;
use crate::chain_spec; use crate::chain_spec;
use crate::cli::Cli; use crate::cli::Cli;
use crate::service;
use sc_cli::SubstrateCli;
use sp_consensus_aura::sr25519::AuthorityPair as AuraPair;
/// Parse and run command line arguments impl SubstrateCli for Cli {
pub fn run(version: VersionInfo) -> sc_cli::Result<()> { fn impl_name() -> &'static str {
let opt = sc_cli::from_args::<Cli>(&version); "Substrate Node"
}
let mut config = sc_service::Configuration::from_version(&version); fn impl_version() -> &'static str {
env!("SUBSTRATE_CLI_IMPL_VERSION")
}
match opt.subcommand { fn description() -> &'static str {
Some(subcommand) => { env!("CARGO_PKG_DESCRIPTION")
subcommand.init(&version)?; }
subcommand.update_config(&mut config, chain_spec::load_spec, &version)?;
subcommand.run( fn author() -> &'static str {
config, env!("CARGO_PKG_AUTHORS")
|config: _| Ok(new_full_start!(config).0), }
)
}, fn support_url() -> &'static str {
None => { "support.anonymous.an"
opt.run.init(&version)?; }
opt.run.update_config(&mut config, chain_spec::load_spec, &version)?;
opt.run.run( fn copyright_start_year() -> i32 {
config, 2017
service::new_light, }
service::new_full,
&version, fn executable_name() -> &'static str {
) env!("CARGO_PKG_NAME")
}, }
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
"dev" => Box::new(chain_spec::development_config()),
"" | "local" => Box::new(chain_spec::local_testnet_config()),
path => Box::new(chain_spec::ChainSpec::from_json_file(
std::path::PathBuf::from(path),
)?),
})
}
}
/// Parse and run command line arguments
pub fn run() -> sc_cli::Result<()> {
let cli = Cli::from_args();
match &cli.subcommand {
Some(subcommand) => {
let runner = cli.create_runner(subcommand)?;
runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
}
None => {
let runner = cli.create_runner(&cli.run)?;
runner.run_node(
service::new_light,
service::new_full,
node_template_runtime::VERSION
)
}
} }
} }

View File

@ -8,16 +8,5 @@ mod cli;
mod command; mod command;
fn main() -> sc_cli::Result<()> { fn main() -> sc_cli::Result<()> {
let version = sc_cli::VersionInfo { command::run()
name: "Substrate Node",
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
executable_name: "node-template",
author: "Anonymous",
description: "Template Node",
support_url: "support.anonymous.an",
copyright_start_year: 2017,
};
command::run(version)
} }

View File

@ -10,7 +10,7 @@ use sp_inherents::InherentDataProviders;
use sc_executor::native_executor_instance; use sc_executor::native_executor_instance;
pub use sc_executor::NativeExecutor; pub use sc_executor::NativeExecutor;
use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair}; use sp_consensus_aura::sr25519::{AuthorityPair as AuraPair};
use grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider}; use sc_finality_grandpa::{self, FinalityProofProvider as GrandpaFinalityProofProvider, StorageAndProofProvider};
// Our native executor instance. // Our native executor instance.
native_executor_instance!( native_executor_instance!(
@ -44,7 +44,7 @@ macro_rules! new_full_start {
.ok_or_else(|| sc_service::Error::SelectChainRequired)?; .ok_or_else(|| sc_service::Error::SelectChainRequired)?;
let (grandpa_block_import, grandpa_link) = let (grandpa_block_import, grandpa_link) =
grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?; sc_finality_grandpa::block_import(client.clone(), &(client.clone() as Arc<_>), select_chain)?;
let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new( let aura_block_import = sc_consensus_aura::AuraBlockImport::<_, _, _, AuraPair>::new(
grandpa_block_import.clone(), client.clone(), grandpa_block_import.clone(), client.clone(),
@ -72,16 +72,11 @@ macro_rules! new_full_start {
pub fn new_full(config: Configuration) pub fn new_full(config: Configuration)
-> Result<impl AbstractService, ServiceError> -> Result<impl AbstractService, ServiceError>
{ {
let is_authority = config.roles.is_authority(); let role = config.role.clone();
let force_authoring = config.force_authoring; let force_authoring = config.force_authoring;
let name = config.name.clone(); let name = config.network.node_name.clone();
let disable_grandpa = config.disable_grandpa; let disable_grandpa = config.disable_grandpa;
// sentry nodes announce themselves as authorities to the network
// and should run the same protocols authorities do, but it should
// never actively participate in any consensus process.
let participates_in_consensus = is_authority && !config.sentry_mode;
let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config); let (builder, mut import_setup, inherent_data_providers) = new_full_start!(config);
let (block_import, grandpa_link) = let (block_import, grandpa_link) =
@ -96,11 +91,9 @@ pub fn new_full(config: Configuration)
})? })?
.build()?; .build()?;
if participates_in_consensus { if role.is_authority() {
let proposer = sc_basic_authorship::ProposerFactory::new( let proposer =
service.client(), sc_basic_authorship::ProposerFactory::new(service.client(), service.transaction_pool());
service.transaction_pool()
);
let client = service.client(); let client = service.client();
let select_chain = service.select_chain() let select_chain = service.select_chain()
@ -129,20 +122,20 @@ pub fn new_full(config: Configuration)
// if the node isn't actively participating in consensus then it doesn't // if the node isn't actively participating in consensus then it doesn't
// need a keystore, regardless of which protocol we use below. // need a keystore, regardless of which protocol we use below.
let keystore = if participates_in_consensus { let keystore = if role.is_authority() {
Some(service.keystore()) Some(service.keystore())
} else { } else {
None None
}; };
let grandpa_config = grandpa::Config { let grandpa_config = sc_finality_grandpa::Config {
// FIXME #1578 make this available through chainspec // FIXME #1578 make this available through chainspec
gossip_duration: Duration::from_millis(333), gossip_duration: Duration::from_millis(333),
justification_period: 512, justification_period: 512,
name: Some(name), name: Some(name),
observer_enabled: false, observer_enabled: false,
keystore, keystore,
is_authority, is_authority: role.is_network_authority(),
}; };
let enable_grandpa = !disable_grandpa; let enable_grandpa = !disable_grandpa;
@ -153,13 +146,13 @@ pub fn new_full(config: Configuration)
// and vote data availability than the observer. The observer has not // and vote data availability than the observer. The observer has not
// been tested extensively yet and having most nodes in a network run it // been tested extensively yet and having most nodes in a network run it
// could lead to finality stalls. // could lead to finality stalls.
let grandpa_config = grandpa::GrandpaParams { let grandpa_config = sc_finality_grandpa::GrandpaParams {
config: grandpa_config, config: grandpa_config,
link: grandpa_link, link: grandpa_link,
network: service.network(), network: service.network(),
inherent_data_providers: inherent_data_providers.clone(), inherent_data_providers: inherent_data_providers.clone(),
telemetry_on_connect: Some(service.telemetry_on_connect_stream()), telemetry_on_connect: Some(service.telemetry_on_connect_stream()),
voting_rule: grandpa::VotingRulesBuilder::default().build(), voting_rule: sc_finality_grandpa::VotingRulesBuilder::default().build(),
prometheus_registry: service.prometheus_registry() prometheus_registry: service.prometheus_registry()
}; };
@ -167,10 +160,10 @@ pub fn new_full(config: Configuration)
// if it fails we take down the service with it. // if it fails we take down the service with it.
service.spawn_essential_task( service.spawn_essential_task(
"grandpa-voter", "grandpa-voter",
grandpa::run_grandpa_voter(grandpa_config)? sc_finality_grandpa::run_grandpa_voter(grandpa_config)?
); );
} else { } else {
grandpa::setup_disabled_grandpa( sc_finality_grandpa::setup_disabled_grandpa(
service.client(), service.client(),
&inherent_data_providers, &inherent_data_providers,
service.network(), service.network(),
@ -204,7 +197,7 @@ pub fn new_light(config: Configuration)
let fetch_checker = fetcher let fetch_checker = fetcher
.map(|fetcher| fetcher.checker().clone()) .map(|fetcher| fetcher.checker().clone())
.ok_or_else(|| "Trying to start light import queue without active fetch checker")?; .ok_or_else(|| "Trying to start light import queue without active fetch checker")?;
let grandpa_block_import = grandpa::light_block_import( let grandpa_block_import = sc_finality_grandpa::light_block_import(
client.clone(), client.clone(),
backend, backend,
&(client.clone() as Arc<_>), &(client.clone() as Arc<_>),

View File

@ -6,44 +6,40 @@ homepage = 'https://substrate.dev'
license = 'Unlicense' license = 'Unlicense'
name = 'pallet-template' name = 'pallet-template'
repository = 'https://github.com/paritytech/substrate/' repository = 'https://github.com/paritytech/substrate/'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[dependencies.codec] [dependencies.codec]
default-features = false default-features = false
features = ['derive'] features = ['derive']
package = 'parity-scale-codec' package = 'parity-scale-codec'
version = '1.2.0' version = '1.3.0'
[dependencies.frame-support] [dependencies.frame-support]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.safe-mix] [dependencies.frame-system]
default-features = false default-features = false
version = '1.0.0' version = '2.0.0-alpha.6'
[dependencies.system]
default-features = false
package = 'frame-system'
version = '2.0.0-alpha.5'
[dev-dependencies.sp-core] [dev-dependencies.sp-core]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dev-dependencies.sp-io] [dev-dependencies.sp-io]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dev-dependencies.sp-runtime] [dev-dependencies.sp-runtime]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[features] [features]
default = ['std'] default = ['std']
std = [ std = [
'codec/std', 'codec/std',
'frame-support/std', 'frame-support/std',
'safe-mix/std', 'frame-system/std',
'system/std',
] ]

View File

@ -10,7 +10,7 @@
/// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs /// https://github.com/paritytech/substrate/blob/master/frame/example/src/lib.rs
use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch}; use frame_support::{decl_module, decl_storage, decl_event, decl_error, dispatch};
use system::ensure_signed; use frame_system::{self as system, ensure_signed};
#[cfg(test)] #[cfg(test)]
mod mock; mod mock;
@ -75,6 +75,7 @@ decl_module! {
/// Just a dummy entry point. /// Just a dummy entry point.
/// function that can be called by the external world as an extrinsics call /// function that can be called by the external world as an extrinsics call
/// takes a parameter of the type `AccountId`, stores it, and emits an event /// takes a parameter of the type `AccountId`, stores it, and emits an event
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
pub fn do_something(origin, something: u32) -> dispatch::DispatchResult { pub fn do_something(origin, something: u32) -> dispatch::DispatchResult {
// Check it was signed and get the signer. See also: ensure_root and ensure_none // Check it was signed and get the signer. See also: ensure_root and ensure_none
let who = ensure_signed(origin)?; let who = ensure_signed(origin)?;
@ -90,6 +91,7 @@ decl_module! {
/// Another dummy entry point. /// Another dummy entry point.
/// takes no parameters, attempts to increment storage value, and possibly throws an error /// takes no parameters, attempts to increment storage value, and possibly throws an error
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
pub fn cause_error(origin) -> dispatch::DispatchResult { pub fn cause_error(origin) -> dispatch::DispatchResult {
// Check it was signed and get the signer. See also: ensure_root and ensure_none // Check it was signed and get the signer. See also: ensure_root and ensure_none
let _who = ensure_signed(origin)?; let _who = ensure_signed(origin)?;

View File

@ -6,6 +6,7 @@ use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use sp_runtime::{ use sp_runtime::{
traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header, Perbill,
}; };
use frame_system as system;
impl_outer_origin! { impl_outer_origin! {
pub enum Origin for Test {} pub enum Origin for Test {}

View File

@ -1,45 +1,36 @@
[package]
authors = ['Anonymous']
edition = '2018'
homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template-runtime'
repository = 'https://github.com/paritytech/substrate/'
version = '2.0.0-alpha.5'
[dependencies.aura] [dependencies.aura]
default-features = false default-features = false
package = 'pallet-aura' package = 'pallet-aura'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.balances] [dependencies.balances]
default-features = false default-features = false
package = 'pallet-balances' package = 'pallet-balances'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.codec] [dependencies.codec]
default-features = false default-features = false
features = ['derive'] features = ['derive']
package = 'parity-scale-codec' package = 'parity-scale-codec'
version = '1.2.0' version = '1.3.0'
[dependencies.frame-executive] [dependencies.frame-executive]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.frame-support] [dependencies.frame-support]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.grandpa] [dependencies.grandpa]
default-features = false default-features = false
package = 'pallet-grandpa' package = 'pallet-grandpa'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.randomness-collective-flip] [dependencies.randomness-collective-flip]
default-features = false default-features = false
package = 'pallet-randomness-collective-flip' package = 'pallet-randomness-collective-flip'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.serde] [dependencies.serde]
features = ['derive'] features = ['derive']
@ -48,81 +39,94 @@ version = '1.0.101'
[dependencies.sp-api] [dependencies.sp-api]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-block-builder] [dependencies.sp-block-builder]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-consensus-aura] [dependencies.sp-consensus-aura]
default-features = false default-features = false
version = '0.8.0-alpha.5' version = '0.8.0-alpha.6'
[dependencies.sp-core] [dependencies.sp-core]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-inherents] [dependencies.sp-inherents]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-io] [dependencies.sp-io]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-offchain] [dependencies.sp-offchain]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-runtime] [dependencies.sp-runtime]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-session] [dependencies.sp-session]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-std] [dependencies.sp-std]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-transaction-pool] [dependencies.sp-transaction-pool]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sp-version] [dependencies.sp-version]
default-features = false default-features = false
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.sudo] [dependencies.sudo]
default-features = false default-features = false
package = 'pallet-sudo' package = 'pallet-sudo'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.system] [dependencies.system]
default-features = false default-features = false
package = 'frame-system' package = 'frame-system'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.template] [dependencies.template]
default-features = false default-features = false
package = 'pallet-template' package = 'pallet-template'
path = '../pallets/template' path = '../pallets/template'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.timestamp] [dependencies.timestamp]
default-features = false default-features = false
package = 'pallet-timestamp' package = 'pallet-timestamp'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[dependencies.transaction-payment] [dependencies.transaction-payment]
default-features = false default-features = false
package = 'pallet-transaction-payment' package = 'pallet-transaction-payment'
version = '2.0.0-alpha.5' version = '2.0.0-alpha.6'
[build-dependencies.wasm-builder-runner] [build-dependencies.wasm-builder-runner]
package = 'substrate-wasm-builder-runner' package = 'substrate-wasm-builder-runner'
version = '1.0.5' version = '1.0.5'
[package]
authors = ['Anonymous']
edition = '2018'
homepage = 'https://substrate.dev'
license = 'Unlicense'
name = 'node-template-runtime'
repository = 'https://github.com/paritytech/substrate/'
version = '2.0.0-alpha.6'
[package.metadata.docs.rs]
targets = ['x86_64-unknown-linux-gnu']
[features] [features]
default = ['std'] default = ['std']
std = [ std = [

View File

@ -11,8 +11,8 @@ include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use sp_std::prelude::*; use sp_std::prelude::*;
use sp_core::OpaqueMetadata; use sp_core::OpaqueMetadata;
use sp_runtime::{ use sp_runtime::{
ApplyExtrinsicResult, transaction_validity::TransactionValidity, generic, create_runtime_str, ApplyExtrinsicResult, generic, create_runtime_str, impl_opaque_keys, MultiSignature,
impl_opaque_keys, MultiSignature, transaction_validity::{TransactionValidity, TransactionSource},
}; };
use sp_runtime::traits::{ use sp_runtime::traits::{
BlakeTwo256, Block as BlockT, IdentityLookup, Verify, ConvertInto, IdentifyAccount BlakeTwo256, Block as BlockT, IdentityLookup, Verify, ConvertInto, IdentifyAccount
@ -318,8 +318,11 @@ impl_runtime_apis! {
} }
impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime { impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity { fn validate_transaction(
Executive::validate_transaction(tx) source: TransactionSource,
tx: <Block as BlockT>::Extrinsic,
) -> TransactionValidity {
Executive::validate_transaction(source, tx)
} }
} }