mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
Benchmark Polkadot Claims Pallet (#876)
* fix * Starting to add benchmarks * make compile * add benchmarks * Make work with Substrate master * Bench validate unsigned * back to polkadot master * starting to add cli with feature flag * more stuff * Add to kusama * Update Cargo.lock * fix dev dep * bump wasm builder * Remove encode from keccak benchmark * bump spec * Add weight documentation * Update Cargo.lock * Update check_runtime.sh * Update publish_draft_release.sh * Update Cargo.lock Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
Generated
+3873
-4044
File diff suppressed because it is too large
Load Diff
@@ -56,3 +56,6 @@ maintenance = { status = "actively-developed" }
|
|||||||
[profile.release]
|
[profile.release]
|
||||||
# Polkadot runtime requires unwinding.
|
# Polkadot runtime requires unwinding.
|
||||||
panic = "unwind"
|
panic = "unwind"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
runtime-benchmarks=["cli/runtime-benchmarks"]
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ crate-type = ["cdylib", "rlib"]
|
|||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
futures = { version = "0.3.4", features = ["compat"] }
|
futures = { version = "0.3.4", features = ["compat"] }
|
||||||
structopt = "0.3.8"
|
structopt = "0.3.8"
|
||||||
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", optional = true }
|
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
@@ -28,6 +27,8 @@ sc-executor = { git = "https://github.com/paritytech/substrate", branch = "polka
|
|||||||
service = { package = "polkadot-service", path = "../service", default-features = false }
|
service = { package = "polkadot-service", path = "../service", default-features = false }
|
||||||
|
|
||||||
tokio = { version = "0.2.10", features = ["rt-threaded"], optional = true }
|
tokio = { version = "0.2.10", features = ["rt-threaded"], optional = true }
|
||||||
|
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", optional = true }
|
||||||
|
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", optional = true }
|
||||||
|
|
||||||
wasm-bindgen = { version = "0.2.57", optional = true }
|
wasm-bindgen = { version = "0.2.57", optional = true }
|
||||||
wasm-bindgen-futures = { version = "0.4.7", optional = true }
|
wasm-bindgen-futures = { version = "0.4.7", optional = true }
|
||||||
@@ -40,6 +41,7 @@ rocksdb = [ "service/rocksdb" ]
|
|||||||
cli = [
|
cli = [
|
||||||
"tokio",
|
"tokio",
|
||||||
"sc-cli",
|
"sc-cli",
|
||||||
|
"frame-benchmarking-cli",
|
||||||
"service/full-node",
|
"service/full-node",
|
||||||
]
|
]
|
||||||
browser = [
|
browser = [
|
||||||
@@ -47,3 +49,4 @@ browser = [
|
|||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"browser-utils",
|
"browser-utils",
|
||||||
]
|
]
|
||||||
|
runtime-benchmarks = ["service/runtime-benchmarks"]
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ pub enum Subcommand {
|
|||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
#[structopt(name = "validation-worker", setting = structopt::clap::AppSettings::Hidden)]
|
#[structopt(name = "validation-worker", setting = structopt::clap::AppSettings::Hidden)]
|
||||||
ValidationWorker(ValidationWorkerCommand),
|
ValidationWorker(ValidationWorkerCommand),
|
||||||
|
|
||||||
|
/// The custom benchmark subcommmand benchmarking runtime pallets.
|
||||||
|
#[structopt(
|
||||||
|
name = "benchmark",
|
||||||
|
about = "Benchmark runtime pallets."
|
||||||
|
)]
|
||||||
|
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
|
|||||||
@@ -98,6 +98,18 @@ pub fn run(version: VersionInfo) -> sc_cli::Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Some(Subcommand::Benchmark(cmd)) => {
|
||||||
|
cmd.init(&version)?;
|
||||||
|
cmd.update_config(&mut config, load_spec, &version)?;
|
||||||
|
|
||||||
|
let is_kusama = config.chain_spec.as_ref().map_or(false, |s| s.is_kusama());
|
||||||
|
|
||||||
|
if is_kusama {
|
||||||
|
cmd.run::<_, _, service::kusama_runtime::Block, service::KusamaExecutor>(config)
|
||||||
|
} else {
|
||||||
|
cmd.run::<_, _, service::polkadot_runtime::Block, service::PolkadotExecutor>(config)
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ edition = "2018"
|
|||||||
codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = [ "derive" ] }
|
codec = { package = "parity-scale-codec", version = "1.1.0", default-features = false, features = [ "derive" ] }
|
||||||
derive_more = { version = "0.99.2", optional = true }
|
derive_more = { version = "0.99.2", optional = true }
|
||||||
serde = { version = "1.0.102", default-features = false, features = [ "derive" ], optional = true }
|
serde = { version = "1.0.102", default-features = false, features = [ "derive" ], optional = true }
|
||||||
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-runtime-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-wasm-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-wasm-interface = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
@@ -35,7 +35,7 @@ std = [
|
|||||||
"codec/std",
|
"codec/std",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"serde/std",
|
"serde/std",
|
||||||
"rstd/std",
|
"sp-std/std",
|
||||||
"shared_memory",
|
"shared_memory",
|
||||||
"sp-core/std",
|
"sp-core/std",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ pub mod wasm_executor;
|
|||||||
|
|
||||||
mod wasm_api;
|
mod wasm_api;
|
||||||
|
|
||||||
use rstd::vec::Vec;
|
use sp_std::vec::Vec;
|
||||||
|
|
||||||
use codec::{Encode, Decode, CompactAs};
|
use codec::{Encode, Decode, CompactAs};
|
||||||
use sp_core::{RuntimeDebug, TypeId};
|
use sp_core::{RuntimeDebug, TypeId};
|
||||||
@@ -117,7 +117,7 @@ impl Id {
|
|||||||
pub fn is_system(&self) -> bool { self.0 < USER_INDEX_START }
|
pub fn is_system(&self) -> bool { self.0 < USER_INDEX_START }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rstd::ops::Add<u32> for Id {
|
impl sp_std::ops::Add<u32> for Id {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
fn add(self, other: u32) -> Self {
|
fn add(self, other: u32) -> Self {
|
||||||
@@ -192,7 +192,7 @@ pub enum ParachainDispatchOrigin {
|
|||||||
Root,
|
Root,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rstd::convert::TryFrom<u8> for ParachainDispatchOrigin {
|
impl sp_std::convert::TryFrom<u8> for ParachainDispatchOrigin {
|
||||||
type Error = ();
|
type Error = ();
|
||||||
fn try_from(x: u8) -> core::result::Result<ParachainDispatchOrigin, ()> {
|
fn try_from(x: u8) -> core::result::Result<ParachainDispatchOrigin, ()> {
|
||||||
const SIGNED: u8 = ParachainDispatchOrigin::Signed as u8;
|
const SIGNED: u8 = ParachainDispatchOrigin::Signed as u8;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub trait Parachain {
|
|||||||
/// function's entry point.
|
/// function's entry point.
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
pub unsafe fn load_params(params: *const u8, len: usize) -> crate::ValidationParams {
|
pub unsafe fn load_params(params: *const u8, len: usize) -> crate::ValidationParams {
|
||||||
let mut slice = rstd::slice::from_raw_parts(params, len);
|
let mut slice = sp_std::slice::from_raw_parts(params, len);
|
||||||
|
|
||||||
codec::Decode::decode(&mut slice).expect("Invalid input data")
|
codec::Decode::decode(&mut slice).expect("Invalid input data")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ inherents = { package = "sp-inherents", git = "https://github.com/paritytech/sub
|
|||||||
application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
application-crypto = { package = "sp-application-crypto", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-version = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
runtime_primitives = { package = "sp-runtime", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
polkadot-parachain = { path = "../parachain", default-features = false }
|
polkadot-parachain = { path = "../parachain", default-features = false }
|
||||||
trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
@@ -31,7 +31,7 @@ std = [
|
|||||||
"inherents/std",
|
"inherents/std",
|
||||||
"trie/std",
|
"trie/std",
|
||||||
"sp-api/std",
|
"sp-api/std",
|
||||||
"rstd/std",
|
"sp-std/std",
|
||||||
"sp-version/std",
|
"sp-version/std",
|
||||||
"runtime_primitives/std",
|
"runtime_primitives/std",
|
||||||
"serde",
|
"serde",
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Polkadot parachain types.
|
//! Polkadot parachain types.
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use rstd::cmp::Ordering;
|
use sp_std::cmp::Ordering;
|
||||||
use parity_scale_codec::{Encode, Decode};
|
use parity_scale_codec::{Encode, Decode};
|
||||||
use bitvec::vec::BitVec;
|
use bitvec::vec::BitVec;
|
||||||
use super::{Hash, Balance};
|
use super::{Hash, Balance};
|
||||||
@@ -646,7 +646,7 @@ pub struct FeeSchedule {
|
|||||||
impl FeeSchedule {
|
impl FeeSchedule {
|
||||||
/// Compute the fee for a message of given size.
|
/// Compute the fee for a message of given size.
|
||||||
pub fn compute_fee(&self, n_bytes: usize) -> Balance {
|
pub fn compute_fee(&self, n_bytes: usize) -> Balance {
|
||||||
use rstd::mem;
|
use sp_std::mem;
|
||||||
debug_assert!(mem::size_of::<Balance>() >= mem::size_of::<usize>());
|
debug_assert!(mem::size_of::<Balance>() >= mem::size_of::<usize>());
|
||||||
|
|
||||||
let n_bytes = n_bytes as Balance;
|
let n_bytes = n_bytes as Balance;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ serde_derive = { version = "1.0.102", optional = true }
|
|||||||
|
|
||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
@@ -28,14 +28,14 @@ staking = { package = "pallet-staking", git = "https://github.com/paritytech/sub
|
|||||||
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
system = { package = "frame-system", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
|
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false, optional = true }
|
||||||
|
|
||||||
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
||||||
polkadot-parachain = { path = "../../parachain", default-features = false }
|
polkadot-parachain = { path = "../../parachain", default-features = false }
|
||||||
|
libsecp256k1 = { version = "0.3.2", default-features = false, optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hex-literal = "0.2.1"
|
hex-literal = "0.2.1"
|
||||||
libsecp256k1 = "0.3.2"
|
|
||||||
tiny-keccak = "1.5.0"
|
|
||||||
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
keyring = { package = "sp-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
babe = { package = "pallet-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
@@ -44,6 +44,7 @@ pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate",
|
|||||||
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
trie-db = "0.20.0"
|
trie-db = "0.20.0"
|
||||||
serde_json = "1.0.41"
|
serde_json = "1.0.41"
|
||||||
|
libsecp256k1 = "0.3.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
@@ -57,7 +58,7 @@ std = [
|
|||||||
"sp-core/std",
|
"sp-core/std",
|
||||||
"polkadot-parachain/std",
|
"polkadot-parachain/std",
|
||||||
"sp-api/std",
|
"sp-api/std",
|
||||||
"rstd/std",
|
"sp-std/std",
|
||||||
"sp-io/std",
|
"sp-io/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"authorship/std",
|
"authorship/std",
|
||||||
@@ -73,3 +74,4 @@ std = [
|
|||||||
"serde/std",
|
"serde/std",
|
||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
runtime-benchmarks = ["frame-benchmarking", "libsecp256k1"]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
//! In the future, it is planned that this module will handle dispute resolution
|
//! In the future, it is planned that this module will handle dispute resolution
|
||||||
//! as well.
|
//! as well.
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use frame_support::{
|
use frame_support::{
|
||||||
decl_storage, decl_module, decl_error, ensure, dispatch::DispatchResult, traits::Get
|
decl_storage, decl_module, decl_error, ensure, dispatch::DispatchResult, traits::Get
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
//! Module to process claims from Ethereum addresses.
|
//! Module to process claims from Ethereum addresses.
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_io::{hashing::keccak_256, crypto::secp256k1_ecdsa_recover};
|
use sp_io::{hashing::keccak_256, crypto::secp256k1_ecdsa_recover};
|
||||||
use frame_support::{decl_event, decl_storage, decl_module, decl_error};
|
use frame_support::{decl_event, decl_storage, decl_module, decl_error};
|
||||||
use frame_support::weights::SimpleDispatchInfo;
|
use frame_support::weights::SimpleDispatchInfo;
|
||||||
@@ -85,8 +85,8 @@ impl PartialEq for EcdsaSignature {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl rstd::fmt::Debug for EcdsaSignature {
|
impl sp_std::fmt::Debug for EcdsaSignature {
|
||||||
fn fmt(&self, f: &mut rstd::fmt::Formatter<'_>) -> rstd::fmt::Result {
|
fn fmt(&self, f: &mut sp_std::fmt::Formatter<'_>) -> sp_std::fmt::Result {
|
||||||
write!(f, "EcdsaSignature({:?})", &self.0[..])
|
write!(f, "EcdsaSignature({:?})", &self.0[..])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +149,38 @@ decl_module! {
|
|||||||
/// Deposit one of this module's events by using the default implementation.
|
/// Deposit one of this module's events by using the default implementation.
|
||||||
fn deposit_event() = default;
|
fn deposit_event() = default;
|
||||||
|
|
||||||
/// Make a claim.
|
/// Make a claim to collect your DOTs.
|
||||||
|
///
|
||||||
|
/// The dispatch origin for this call must be _None_.
|
||||||
|
///
|
||||||
|
/// Unsigned Validation:
|
||||||
|
/// A call to claim is deemed valid if the signature provided matches
|
||||||
|
/// the expected signed message of:
|
||||||
|
///
|
||||||
|
/// > Ethereum Signed Message:
|
||||||
|
/// > (configured prefix string)(address)
|
||||||
|
///
|
||||||
|
/// and `address` matches the `dest` account.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - `dest`: The destination account to payout the claim.
|
||||||
|
/// - `ethereum_signature`: The signature of an ethereum signed message
|
||||||
|
/// matching the format described above.
|
||||||
|
///
|
||||||
|
/// <weight>
|
||||||
|
/// The weight of this call is invariant over the input parameters.
|
||||||
|
/// - One `eth_recover` operation which involves a keccak hash and a
|
||||||
|
/// ecdsa recover.
|
||||||
|
/// - Three storage reads to check if a claim exists for the user, to
|
||||||
|
/// get the current pot size, to see if there exists a vesting schedule.
|
||||||
|
/// - Up to one storage write for adding a new vesting schedule.
|
||||||
|
/// - One `deposit_creating` Currency call.
|
||||||
|
/// - One storage write to update the total.
|
||||||
|
/// - Two storage removals for vesting and claims information.
|
||||||
|
/// - One deposit event.
|
||||||
|
///
|
||||||
|
/// Total Complexity: O(1)
|
||||||
|
/// </weight>
|
||||||
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
#[weight = SimpleDispatchInfo::FixedNormal(1_000_000)]
|
||||||
fn claim(origin, dest: T::AccountId, ethereum_signature: EcdsaSignature) {
|
fn claim(origin, dest: T::AccountId, ethereum_signature: EcdsaSignature) {
|
||||||
ensure_none(origin)?;
|
ensure_none(origin)?;
|
||||||
@@ -180,7 +211,23 @@ decl_module! {
|
|||||||
Self::deposit_event(RawEvent::Claimed(dest, signer, balance_due));
|
Self::deposit_event(RawEvent::Claimed(dest, signer, balance_due));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new claim, if you are root.
|
/// Mint a new claim to collect DOTs.
|
||||||
|
///
|
||||||
|
/// The dispatch origin for this call must be _Root_.
|
||||||
|
///
|
||||||
|
/// Parameters:
|
||||||
|
/// - `who`: The Ethereum address allowed to collect this claim.
|
||||||
|
/// - `value`: The number of DOTs that will be claimed.
|
||||||
|
/// - `vesting_schedule`: An optional vesting schedule for these DOTs.
|
||||||
|
///
|
||||||
|
/// <weight>
|
||||||
|
/// The weight of this call is invariant over the input parameters.
|
||||||
|
/// - One storage mutate to increase the total claims available.
|
||||||
|
/// - One storage write to add a new claim.
|
||||||
|
/// - Up to one storage write to add a new vesting schedule.
|
||||||
|
///
|
||||||
|
/// Total Complexity: O(1)
|
||||||
|
/// </weight>
|
||||||
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
#[weight = SimpleDispatchInfo::FixedNormal(30_000)]
|
||||||
fn mint_claim(origin,
|
fn mint_claim(origin,
|
||||||
who: EthereumAddress,
|
who: EthereumAddress,
|
||||||
@@ -274,12 +321,35 @@ impl<T: Trait> sp_runtime::traits::ValidateUnsigned for Module<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(any(test, feature = "runtime-benchmarks"))]
|
||||||
|
mod secp_utils {
|
||||||
|
use super::*;
|
||||||
|
use secp256k1;
|
||||||
|
|
||||||
|
pub fn public(secret: &secp256k1::SecretKey) -> secp256k1::PublicKey {
|
||||||
|
secp256k1::PublicKey::from_secret_key(secret)
|
||||||
|
}
|
||||||
|
pub fn eth(secret: &secp256k1::SecretKey) -> EthereumAddress {
|
||||||
|
let mut res = EthereumAddress::default();
|
||||||
|
res.0.copy_from_slice(&keccak_256(&public(secret).serialize()[1..65])[12..]);
|
||||||
|
res
|
||||||
|
}
|
||||||
|
pub fn sig<T: Trait>(secret: &secp256k1::SecretKey, what: &[u8]) -> EcdsaSignature {
|
||||||
|
let msg = keccak_256(&<super::Module<T>>::ethereum_signable_message(&to_ascii_hex(what)[..]));
|
||||||
|
let (sig, recovery_id) = secp256k1::sign(&secp256k1::Message::parse(&msg), secret);
|
||||||
|
let mut r = [0u8; 65];
|
||||||
|
r[0..64].copy_from_slice(&sig.serialize()[..]);
|
||||||
|
r[64] = recovery_id.serialize();
|
||||||
|
EcdsaSignature(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use tiny_keccak::keccak256;
|
|
||||||
use hex_literal::hex;
|
use hex_literal::hex;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use secp_utils::*;
|
||||||
|
|
||||||
use sp_core::H256;
|
use sp_core::H256;
|
||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
@@ -363,26 +433,10 @@ mod tests {
|
|||||||
type Claims = Module<Test>;
|
type Claims = Module<Test>;
|
||||||
|
|
||||||
fn alice() -> secp256k1::SecretKey {
|
fn alice() -> secp256k1::SecretKey {
|
||||||
secp256k1::SecretKey::parse(&keccak256(b"Alice")).unwrap()
|
secp256k1::SecretKey::parse(&keccak_256(b"Alice")).unwrap()
|
||||||
}
|
}
|
||||||
fn bob() -> secp256k1::SecretKey {
|
fn bob() -> secp256k1::SecretKey {
|
||||||
secp256k1::SecretKey::parse(&keccak256(b"Bob")).unwrap()
|
secp256k1::SecretKey::parse(&keccak_256(b"Bob")).unwrap()
|
||||||
}
|
|
||||||
fn public(secret: &secp256k1::SecretKey) -> secp256k1::PublicKey {
|
|
||||||
secp256k1::PublicKey::from_secret_key(secret)
|
|
||||||
}
|
|
||||||
fn eth(secret: &secp256k1::SecretKey) -> EthereumAddress {
|
|
||||||
let mut res = EthereumAddress::default();
|
|
||||||
res.0.copy_from_slice(&keccak256(&public(secret).serialize()[1..65])[12..]);
|
|
||||||
res
|
|
||||||
}
|
|
||||||
fn sig(secret: &secp256k1::SecretKey, what: &[u8]) -> EcdsaSignature {
|
|
||||||
let msg = keccak256(&Claims::ethereum_signable_message(&to_ascii_hex(what)[..]));
|
|
||||||
let (sig, recovery_id) = secp256k1::sign(&secp256k1::Message::parse(&msg), secret);
|
|
||||||
let mut r = [0u8; 65];
|
|
||||||
r[0..64].copy_from_slice(&sig.serialize()[..]);
|
|
||||||
r[64] = recovery_id.serialize();
|
|
||||||
EcdsaSignature(r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function basically just builds a genesis storage key/value store according to
|
// This function basically just builds a genesis storage key/value store according to
|
||||||
@@ -421,7 +475,7 @@ mod tests {
|
|||||||
fn claiming_works() {
|
fn claiming_works() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_ok!(Claims::claim(Origin::NONE, 42, sig(&alice(), &42u64.encode())));
|
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode())));
|
||||||
assert_eq!(Balances::free_balance(&42), 100);
|
assert_eq!(Balances::free_balance(&42), 100);
|
||||||
assert_eq!(Vesting::vesting_balance(&42), Some(50));
|
assert_eq!(Vesting::vesting_balance(&42), Some(50));
|
||||||
assert_eq!(Claims::total(), 0);
|
assert_eq!(Claims::total(), 0);
|
||||||
@@ -437,12 +491,12 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())),
|
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode())),
|
||||||
Error::<Test>::SignerHasNoClaim,
|
Error::<Test>::SignerHasNoClaim,
|
||||||
);
|
);
|
||||||
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None));
|
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, None));
|
||||||
assert_eq!(Claims::total(), 300);
|
assert_eq!(Claims::total(), 300);
|
||||||
assert_ok!(Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())));
|
assert_ok!(Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode())));
|
||||||
assert_eq!(Balances::free_balance(&69), 200);
|
assert_eq!(Balances::free_balance(&69), 200);
|
||||||
assert_eq!(Vesting::vesting_balance(&69), None);
|
assert_eq!(Vesting::vesting_balance(&69), None);
|
||||||
assert_eq!(Claims::total(), 100);
|
assert_eq!(Claims::total(), 100);
|
||||||
@@ -458,11 +512,11 @@ mod tests {
|
|||||||
);
|
);
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())),
|
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode())),
|
||||||
Error::<Test>::SignerHasNoClaim
|
Error::<Test>::SignerHasNoClaim
|
||||||
);
|
);
|
||||||
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1))));
|
assert_ok!(Claims::mint_claim(Origin::ROOT, eth(&bob()), 200, Some((50, 10, 1))));
|
||||||
assert_ok!(Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())));
|
assert_ok!(Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode())));
|
||||||
assert_eq!(Balances::free_balance(&69), 200);
|
assert_eq!(Balances::free_balance(&69), 200);
|
||||||
assert_eq!(Vesting::vesting_balance(&69), Some(50));
|
assert_eq!(Vesting::vesting_balance(&69), Some(50));
|
||||||
});
|
});
|
||||||
@@ -473,7 +527,7 @@ mod tests {
|
|||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_err!(
|
assert_err!(
|
||||||
Claims::claim(Origin::signed(42), 42, sig(&alice(), &42u64.encode())),
|
Claims::claim(Origin::signed(42), 42, sig::<Test>(&alice(), &42u64.encode())),
|
||||||
sp_runtime::traits::BadOrigin,
|
sp_runtime::traits::BadOrigin,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -483,9 +537,9 @@ mod tests {
|
|||||||
fn double_claiming_doesnt_work() {
|
fn double_claiming_doesnt_work() {
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_ok!(Claims::claim(Origin::NONE, 42, sig(&alice(), &42u64.encode())));
|
assert_ok!(Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode())));
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Claims::claim(Origin::NONE, 42, sig(&alice(), &42u64.encode())),
|
Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &42u64.encode())),
|
||||||
Error::<Test>::SignerHasNoClaim
|
Error::<Test>::SignerHasNoClaim
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -505,7 +559,7 @@ mod tests {
|
|||||||
|
|
||||||
// They should not be able to claim
|
// They should not be able to claim
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Claims::claim(Origin::NONE, 69, sig(&bob(), &69u64.encode())),
|
Claims::claim(Origin::NONE, 69, sig::<Test>(&bob(), &69u64.encode())),
|
||||||
Error::<Test>::DestinationVesting
|
Error::<Test>::DestinationVesting
|
||||||
);
|
);
|
||||||
// Everything should be unchanged
|
// Everything should be unchanged
|
||||||
@@ -520,7 +574,7 @@ mod tests {
|
|||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Claims::claim(Origin::NONE, 42, sig(&alice(), &69u64.encode())),
|
Claims::claim(Origin::NONE, 42, sig::<Test>(&alice(), &69u64.encode())),
|
||||||
Error::<Test>::SignerHasNoClaim
|
Error::<Test>::SignerHasNoClaim
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -531,7 +585,7 @@ mod tests {
|
|||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(Balances::free_balance(42), 0);
|
assert_eq!(Balances::free_balance(42), 0);
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Claims::claim(Origin::NONE, 42, sig(&bob(), &69u64.encode())),
|
Claims::claim(Origin::NONE, 42, sig::<Test>(&bob(), &69u64.encode())),
|
||||||
Error::<Test>::SignerHasNoClaim
|
Error::<Test>::SignerHasNoClaim
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -551,12 +605,11 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn validate_unsigned_works() {
|
fn validate_unsigned_works() {
|
||||||
#![allow(deprecated)] // Allow `ValidateUnsigned`
|
|
||||||
use sp_runtime::traits::ValidateUnsigned;
|
use sp_runtime::traits::ValidateUnsigned;
|
||||||
|
|
||||||
new_test_ext().execute_with(|| {
|
new_test_ext().execute_with(|| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<Module<Test>>::validate_unsigned(&Call::claim(1, sig(&alice(), &1u64.encode()))),
|
<Module<Test>>::validate_unsigned(&Call::claim(1, sig::<Test>(&alice(), &1u64.encode()))),
|
||||||
Ok(ValidTransaction {
|
Ok(ValidTransaction {
|
||||||
priority: 100,
|
priority: 100,
|
||||||
requires: vec![],
|
requires: vec![],
|
||||||
@@ -570,13 +623,98 @@ mod tests {
|
|||||||
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
|
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<Module<Test>>::validate_unsigned(&Call::claim(1, sig(&bob(), &1u64.encode()))),
|
<Module<Test>>::validate_unsigned(&Call::claim(1, sig::<Test>(&bob(), &1u64.encode()))),
|
||||||
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
|
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
<Module<Test>>::validate_unsigned(&Call::claim(0, sig(&bob(), &1u64.encode()))),
|
<Module<Test>>::validate_unsigned(&Call::claim(0, sig::<Test>(&bob(), &1u64.encode()))),
|
||||||
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
|
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
mod benchmarking {
|
||||||
|
use super::*;
|
||||||
|
use secp_utils::*;
|
||||||
|
use system::RawOrigin;
|
||||||
|
use frame_benchmarking::{benchmarks, account};
|
||||||
|
use sp_runtime::DispatchResult;
|
||||||
|
use sp_runtime::traits::ValidateUnsigned;
|
||||||
|
use crate::claims::Call;
|
||||||
|
|
||||||
|
const SEED: u32 = 0;
|
||||||
|
|
||||||
|
const MAX_CLAIMS: u32 = 10_000;
|
||||||
|
const VALUE: u32 = 1_000_000;
|
||||||
|
|
||||||
|
fn create_claim<T: Trait>(input: u32) -> DispatchResult {
|
||||||
|
let secret_key = secp256k1::SecretKey::parse(&keccak_256(&input.encode())).unwrap();
|
||||||
|
let eth_address = eth(&secret_key);
|
||||||
|
let vesting = Some((100_000.into(), 1_000.into(), 100.into()));
|
||||||
|
super::Module::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
benchmarks! {
|
||||||
|
_ {
|
||||||
|
// Create claims in storage.
|
||||||
|
let c in 0 .. MAX_CLAIMS => create_claim::<T>(c)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Benchmark `claim` for different users.
|
||||||
|
claim {
|
||||||
|
let u in 0 .. 1000;
|
||||||
|
let secret_key = secp256k1::SecretKey::parse(&keccak_256(&u.encode())).unwrap();
|
||||||
|
let eth_address = eth(&secret_key);
|
||||||
|
let account: T::AccountId = account("user", u, SEED);
|
||||||
|
let vesting = Some((100_000.into(), 1_000.into(), 100.into()));
|
||||||
|
let signature = sig::<T>(&secret_key, &account.encode());
|
||||||
|
super::Module::<T>::mint_claim(RawOrigin::Root.into(), eth_address, VALUE.into(), vesting)?;
|
||||||
|
}: _(RawOrigin::None, account, signature)
|
||||||
|
|
||||||
|
// Benchmark `mint_claim` when there already exists `c` claims in storage.
|
||||||
|
mint_claim {
|
||||||
|
let c in ...;
|
||||||
|
let account = account("user", c, SEED);
|
||||||
|
let vesting = Some((100_000.into(), 1_000.into(), 100.into()));
|
||||||
|
}: _(RawOrigin::Root, account, VALUE.into(), vesting)
|
||||||
|
|
||||||
|
// Benchmark the time it takes to execute `validate_unsigned`
|
||||||
|
validate_unsigned {
|
||||||
|
let c in ...;
|
||||||
|
// Crate signature
|
||||||
|
let secret_key = secp256k1::SecretKey::parse(&keccak_256(&c.encode())).unwrap();
|
||||||
|
let account: T::AccountId = account("user", c, SEED);
|
||||||
|
let signature = sig::<T>(&secret_key, &account.encode());
|
||||||
|
let call = Call::<T>::claim(account, signature);
|
||||||
|
}: {
|
||||||
|
super::Module::<T>::validate_unsigned(&call)?
|
||||||
|
}
|
||||||
|
|
||||||
|
// Benchmark the time it takes to do `repeat` number of keccak256 hashes
|
||||||
|
keccak256 {
|
||||||
|
let i in 0 .. 10_000;
|
||||||
|
let bytes = (i).encode();
|
||||||
|
}: {
|
||||||
|
for index in 0 .. i {
|
||||||
|
let _hash = keccak_256(&bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Benchmark the time it takes to do `repeat` number of `eth_recover`
|
||||||
|
eth_recover {
|
||||||
|
let i in 0 .. 1_000;
|
||||||
|
// Crate signature
|
||||||
|
let secret_key = secp256k1::SecretKey::parse(&keccak_256(&i.encode())).unwrap();
|
||||||
|
let account: T::AccountId = account("user", i, SEED);
|
||||||
|
let signature = sig::<T>(&secret_key, &account.encode());
|
||||||
|
let data = account.using_encoded(to_ascii_hex);
|
||||||
|
}: {
|
||||||
|
for _ in 0 .. i {
|
||||||
|
let _maybe_signer = super::Module::<T>::eth_recover(&signature, &data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ use sp_runtime::{ModuleId,
|
|||||||
use frame_support::weights::SimpleDispatchInfo;
|
use frame_support::weights::SimpleDispatchInfo;
|
||||||
use crate::slots;
|
use crate::slots;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use rstd::vec::Vec;
|
use sp_std::vec::Vec;
|
||||||
use sp_core::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX;
|
use sp_core::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX;
|
||||||
use primitives::parachain::Id as ParaId;
|
use primitives::parachain::Id as ParaId;
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ use frame_support::traits::{OnUnbalanced, Imbalance, Currency, Get};
|
|||||||
use crate::{MaximumBlockWeight, NegativeImbalance};
|
use crate::{MaximumBlockWeight, NegativeImbalance};
|
||||||
|
|
||||||
/// Logic for the author to get a portion of fees.
|
/// Logic for the author to get a portion of fees.
|
||||||
pub struct ToAuthor<R>(rstd::marker::PhantomData<R>);
|
pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
|
||||||
|
|
||||||
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
|
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
|
||||||
where
|
where
|
||||||
@@ -44,7 +44,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Converter for currencies to votes.
|
/// Converter for currencies to votes.
|
||||||
pub struct CurrencyToVoteHandler<R>(rstd::marker::PhantomData<R>);
|
pub struct CurrencyToVoteHandler<R>(sp_std::marker::PhantomData<R>);
|
||||||
|
|
||||||
impl<R> CurrencyToVoteHandler<R>
|
impl<R> CurrencyToVoteHandler<R>
|
||||||
where
|
where
|
||||||
@@ -81,7 +81,7 @@ where
|
|||||||
///
|
///
|
||||||
/// Where `target_weight` must be given as the `Get` implementation of the `T` generic type.
|
/// Where `target_weight` must be given as the `Get` implementation of the `T` generic type.
|
||||||
/// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#relay-chain-transaction-fees
|
/// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#relay-chain-transaction-fees
|
||||||
pub struct TargetedFeeAdjustment<T, R>(rstd::marker::PhantomData<(T, R)>);
|
pub struct TargetedFeeAdjustment<T, R>(sp_std::marker::PhantomData<(T, R)>);
|
||||||
|
|
||||||
impl<T: Get<Perbill>, R: system::Trait> Convert<Fixed64, Fixed64> for TargetedFeeAdjustment<T, R> {
|
impl<T: Get<Perbill>, R: system::Trait> Convert<Fixed64, Fixed64> for TargetedFeeAdjustment<T, R> {
|
||||||
fn convert(multiplier: Fixed64) -> Fixed64 {
|
fn convert(multiplier: Fixed64) -> Fixed64 {
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
//! Main parachains logic. For now this is just the determination of which validators do what.
|
//! Main parachains logic. For now this is just the determination of which validators do what.
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use rstd::result;
|
use sp_std::result;
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
|
|
||||||
use sp_runtime::traits::{
|
use sp_runtime::traits::{
|
||||||
@@ -98,7 +98,7 @@ impl<AccountId, T: Currency<AccountId>> ParachainCurrency<AccountId> for T where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Interface to the persistent (stash) identities of the current validators.
|
/// Interface to the persistent (stash) identities of the current validators.
|
||||||
pub struct ValidatorIdentities<T>(rstd::marker::PhantomData<T>);
|
pub struct ValidatorIdentities<T>(sp_std::marker::PhantomData<T>);
|
||||||
|
|
||||||
impl<T: session::Trait> Get<Vec<T::ValidatorId>> for ValidatorIdentities<T> {
|
impl<T: session::Trait> Get<Vec<T::ValidatorId>> for ValidatorIdentities<T> {
|
||||||
fn get() -> Vec<T::ValidatorId> {
|
fn get() -> Vec<T::ValidatorId> {
|
||||||
@@ -540,7 +540,7 @@ impl<T: Trait> Module<T> {
|
|||||||
let offset = (i * 4 % 32) as usize;
|
let offset = (i * 4 % 32) as usize;
|
||||||
|
|
||||||
// number of roles remaining to select from.
|
// number of roles remaining to select from.
|
||||||
let remaining = rstd::cmp::max(1, (validator_count - i) as usize);
|
let remaining = sp_std::cmp::max(1, (validator_count - i) as usize);
|
||||||
|
|
||||||
// 8 32-bit ints per 256-bit seed.
|
// 8 32-bit ints per 256-bit seed.
|
||||||
let val_index = u32::decode(&mut &seed[offset..offset + 4])
|
let val_index = u32::decode(&mut &seed[offset..offset + 4])
|
||||||
@@ -585,7 +585,7 @@ impl<T: Trait> Module<T> {
|
|||||||
schedule: &GlobalValidationSchedule,
|
schedule: &GlobalValidationSchedule,
|
||||||
attested_candidates: &[AttestedCandidate],
|
attested_candidates: &[AttestedCandidate],
|
||||||
active_parachains: &[(ParaId, Option<(CollatorId, Retriable)>)]
|
active_parachains: &[(ParaId, Option<(CollatorId, Retriable)>)]
|
||||||
) -> rstd::result::Result<IncludedBlocks<T>, sp_runtime::DispatchError>
|
) -> sp_std::result::Result<IncludedBlocks<T>, sp_runtime::DispatchError>
|
||||||
{
|
{
|
||||||
use primitives::parachain::ValidityAttestation;
|
use primitives::parachain::ValidityAttestation;
|
||||||
use sp_runtime::traits::AppVerify;
|
use sp_runtime::traits::AppVerify;
|
||||||
@@ -657,7 +657,7 @@ impl<T: Trait> Module<T> {
|
|||||||
|
|
||||||
// computes the omitted validation data for a particular parachain.
|
// computes the omitted validation data for a particular parachain.
|
||||||
let full_candidate = |abridged: &AbridgedCandidateReceipt|
|
let full_candidate = |abridged: &AbridgedCandidateReceipt|
|
||||||
-> rstd::result::Result<CandidateReceipt, sp_runtime::DispatchError>
|
-> sp_std::result::Result<CandidateReceipt, sp_runtime::DispatchError>
|
||||||
{
|
{
|
||||||
let para_id = abridged.parachain_index;
|
let para_id = abridged.parachain_index;
|
||||||
let parent_head = match Self::parachain_head(¶_id)
|
let parent_head = match Self::parachain_head(¶_id)
|
||||||
|
|||||||
@@ -18,9 +18,9 @@
|
|||||||
//! registered and which are scheduled. Doesn't manage any of the actual execution/validation logic
|
//! registered and which are scheduled. Doesn't manage any of the actual execution/validation logic
|
||||||
//! which is left to `parachains.rs`.
|
//! which is left to `parachains.rs`.
|
||||||
|
|
||||||
use rstd::{prelude::*, result};
|
use sp_std::{prelude::*, result};
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
use rstd::marker::PhantomData;
|
use sp_std::marker::PhantomData;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
|
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -397,13 +397,13 @@ decl_module! {
|
|||||||
Parachains::mutate(|ids| swap_ordered_existence(ids, id, other));
|
Parachains::mutate(|ids| swap_ordered_existence(ids, id, other));
|
||||||
Paras::mutate(id, |i|
|
Paras::mutate(id, |i|
|
||||||
Paras::mutate(other, |j|
|
Paras::mutate(other, |j|
|
||||||
rstd::mem::swap(i, j)
|
sp_std::mem::swap(i, j)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
<Debtors<T>>::mutate(id, |i|
|
<Debtors<T>>::mutate(id, |i|
|
||||||
<Debtors<T>>::mutate(other, |j|
|
<Debtors<T>>::mutate(other, |j|
|
||||||
rstd::mem::swap(i, j)
|
sp_std::mem::swap(i, j)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
let _ = T::SwapAux::on_swap(id, other);
|
let _ = T::SwapAux::on_swap(id, other);
|
||||||
@@ -546,13 +546,13 @@ impl<T: Trait> ActiveParas for Module<T> {
|
|||||||
|
|
||||||
/// Ensure that parathread selections happen prioritized by fees.
|
/// Ensure that parathread selections happen prioritized by fees.
|
||||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||||
pub struct LimitParathreadCommits<T: Trait + Send + Sync>(rstd::marker::PhantomData<T>) where
|
pub struct LimitParathreadCommits<T: Trait + Send + Sync>(sp_std::marker::PhantomData<T>) where
|
||||||
<T as system::Trait>::Call: IsSubType<Module<T>, T>;
|
<T as system::Trait>::Call: IsSubType<Module<T>, T>;
|
||||||
|
|
||||||
impl<T: Trait + Send + Sync> rstd::fmt::Debug for LimitParathreadCommits<T> where
|
impl<T: Trait + Send + Sync> sp_std::fmt::Debug for LimitParathreadCommits<T> where
|
||||||
<T as system::Trait>::Call: IsSubType<Module<T>, T>
|
<T as system::Trait>::Call: IsSubType<Module<T>, T>
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut rstd::fmt::Formatter) -> rstd::fmt::Result {
|
fn fmt(&self, f: &mut sp_std::fmt::Formatter) -> sp_std::fmt::Result {
|
||||||
write!(f, "LimitParathreadCommits<T>")
|
write!(f, "LimitParathreadCommits<T>")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +577,7 @@ impl<T: Trait + Send + Sync> SignedExtension for LimitParathreadCommits<T> where
|
|||||||
type DispatchInfo = DispatchInfo;
|
type DispatchInfo = DispatchInfo;
|
||||||
|
|
||||||
fn additional_signed(&self)
|
fn additional_signed(&self)
|
||||||
-> rstd::result::Result<Self::AdditionalSigned, TransactionValidityError>
|
-> sp_std::result::Result<Self::AdditionalSigned, TransactionValidityError>
|
||||||
{
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@@ -624,7 +624,7 @@ impl<T: Trait + Send + Sync> SignedExtension for LimitParathreadCommits<T> where
|
|||||||
|
|
||||||
// updated the selected threads.
|
// updated the selected threads.
|
||||||
selected_threads.insert(pos, (*id, collator.clone()));
|
selected_threads.insert(pos, (*id, collator.clone()));
|
||||||
rstd::mem::drop(selected_threads);
|
sp_std::mem::drop(selected_threads);
|
||||||
SelectedThreads::put(upcoming_selected_threads);
|
SelectedThreads::put(upcoming_selected_threads);
|
||||||
|
|
||||||
// provides the state-transition for this head-data-hash; this should cue the pool
|
// provides the state-transition for this head-data-hash; this should cue the pool
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
//! The SlotRange struct which succinctly handles the ten values that
|
//! The SlotRange struct which succinctly handles the ten values that
|
||||||
//! represent all sub ranges between 0 and 3 inclusive.
|
//! represent all sub ranges between 0 and 3 inclusive.
|
||||||
|
|
||||||
use rstd::{result, ops::Add, convert::{TryFrom, TryInto}};
|
use sp_std::{result, ops::Add, convert::{TryFrom, TryInto}};
|
||||||
use sp_runtime::traits::CheckedSub;
|
use sp_runtime::traits::CheckedSub;
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
//! auctioning mechanism, for locking balance as part of the "payment", and to provide the requisite
|
//! auctioning mechanism, for locking balance as part of the "payment", and to provide the requisite
|
||||||
//! information for commissioning and decommissioning them.
|
//! information for commissioning and decommissioning them.
|
||||||
|
|
||||||
use rstd::{prelude::*, mem::swap, convert::TryInto};
|
use sp_std::{prelude::*, mem::swap, convert::TryInto};
|
||||||
use sp_runtime::traits::{
|
use sp_runtime::traits::{
|
||||||
CheckedSub, StaticLookup, Zero, One, CheckedConversion, Hash, AccountIdConversion,
|
CheckedSub, StaticLookup, Zero, One, CheckedConversion, Hash, AccountIdConversion,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/par
|
|||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
@@ -59,6 +59,7 @@ timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech
|
|||||||
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
utility = { package = "pallet-utility", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
utility = { package = "pallet-utility", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
|
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false, optional = true }
|
||||||
|
|
||||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
||||||
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
||||||
@@ -94,7 +95,7 @@ std = [
|
|||||||
"tx-pool-api/std",
|
"tx-pool-api/std",
|
||||||
"block-builder-api/std",
|
"block-builder-api/std",
|
||||||
"offchain-primitives/std",
|
"offchain-primitives/std",
|
||||||
"rstd/std",
|
"sp-std/std",
|
||||||
"sp-io/std",
|
"sp-io/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"authorship/std",
|
"authorship/std",
|
||||||
@@ -135,3 +136,4 @@ std = [
|
|||||||
"randomness-collective-flip/std",
|
"randomness-collective-flip/std",
|
||||||
"runtime-common/std",
|
"runtime-common/std",
|
||||||
]
|
]
|
||||||
|
runtime-benchmarks = ["frame-benchmarking", "runtime-common/runtime-benchmarks"]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
|
|||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
WasmBuilder::new()
|
||||||
.with_current_project()
|
.with_current_project()
|
||||||
.with_wasm_builder_from_crates("1.0.9")
|
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "8c672e107789ed10973d937ba8cac245404377e2")
|
||||||
.import_memory()
|
.import_memory()
|
||||||
.export_heap_base()
|
.export_heap_base()
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
||||||
#![recursion_limit="256"]
|
#![recursion_limit="256"]
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
|
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use primitives::{
|
use primitives::{
|
||||||
@@ -39,6 +39,8 @@ use sp_runtime::{
|
|||||||
curve::PiecewiseLinear,
|
curve::PiecewiseLinear,
|
||||||
traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup},
|
traits::{BlakeTwo256, Block as BlockT, SignedExtension, OpaqueKeys, ConvertInto, IdentityLookup},
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
use sp_runtime::RuntimeString;
|
||||||
use version::RuntimeVersion;
|
use version::RuntimeVersion;
|
||||||
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
@@ -101,7 +103,7 @@ impl SignedExtension for RestrictFunctionality {
|
|||||||
type Pre = ();
|
type Pre = ();
|
||||||
type DispatchInfo = DispatchInfo;
|
type DispatchInfo = DispatchInfo;
|
||||||
|
|
||||||
fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) }
|
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
|
||||||
|
|
||||||
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
|
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
|
||||||
-> TransactionValidity
|
-> TransactionValidity
|
||||||
@@ -867,4 +869,31 @@ sp_api::impl_runtime_apis! {
|
|||||||
TransactionPayment::query_info(uxt, len)
|
TransactionPayment::query_info(uxt, len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||||
|
fn dispatch_benchmark(
|
||||||
|
module: Vec<u8>,
|
||||||
|
extrinsic: Vec<u8>,
|
||||||
|
lowest_range_values: Vec<u32>,
|
||||||
|
highest_range_values: Vec<u32>,
|
||||||
|
steps: Vec<u32>,
|
||||||
|
repeat: u32,
|
||||||
|
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
|
||||||
|
use frame_benchmarking::Benchmarking;
|
||||||
|
|
||||||
|
let result = match module.as_slice() {
|
||||||
|
b"claims" => Claims::run_benchmark(
|
||||||
|
extrinsic,
|
||||||
|
lowest_range_values,
|
||||||
|
highest_range_values,
|
||||||
|
steps,
|
||||||
|
repeat,
|
||||||
|
),
|
||||||
|
_ => Err("Benchmark not found for this pallet."),
|
||||||
|
};
|
||||||
|
|
||||||
|
result.map_err(|e| e.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ babe-primitives = { package = "sp-consensus-babe", git = "https://github.com/par
|
|||||||
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
inherents = { package = "sp-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
offchain-primitives = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
rstd = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-std = { package = "sp-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-staking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
@@ -56,6 +56,7 @@ timestamp = { package = "pallet-timestamp", git = "https://github.com/paritytech
|
|||||||
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
treasury = { package = "pallet-treasury", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
sudo = { package = "pallet-sudo", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
vesting = { package = "pallet-vesting", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
|
||||||
|
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false, optional = true }
|
||||||
|
|
||||||
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
runtime-common = { package = "polkadot-runtime-common", path = "../common", default-features = false }
|
||||||
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
primitives = { package = "polkadot-primitives", path = "../../primitives", default-features = false }
|
||||||
@@ -91,7 +92,7 @@ std = [
|
|||||||
"tx-pool-api/std",
|
"tx-pool-api/std",
|
||||||
"block-builder-api/std",
|
"block-builder-api/std",
|
||||||
"offchain-primitives/std",
|
"offchain-primitives/std",
|
||||||
"rstd/std",
|
"sp-std/std",
|
||||||
"frame-support/std",
|
"frame-support/std",
|
||||||
"authorship/std",
|
"authorship/std",
|
||||||
"balances/std",
|
"balances/std",
|
||||||
@@ -129,3 +130,4 @@ std = [
|
|||||||
"sudo/std",
|
"sudo/std",
|
||||||
"vesting/std",
|
"vesting/std",
|
||||||
]
|
]
|
||||||
|
runtime-benchmarks = ["frame-benchmarking", "runtime-common/runtime-benchmarks"]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
|
|||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
WasmBuilder::new()
|
||||||
.with_current_project()
|
.with_current_project()
|
||||||
.with_wasm_builder_from_crates("1.0.9")
|
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "8c672e107789ed10973d937ba8cac245404377e2")
|
||||||
.import_memory()
|
.import_memory()
|
||||||
.export_heap_base()
|
.export_heap_base()
|
||||||
.build()
|
.build()
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use runtime_common::{attestations, claims, parachains, registrar, slots,
|
|||||||
MaximumBlockLength,
|
MaximumBlockLength,
|
||||||
};
|
};
|
||||||
|
|
||||||
use rstd::prelude::*;
|
use sp_std::prelude::*;
|
||||||
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
|
use sp_core::u32_trait::{_1, _2, _3, _4, _5};
|
||||||
use codec::{Encode, Decode};
|
use codec::{Encode, Decode};
|
||||||
use primitives::{
|
use primitives::{
|
||||||
@@ -43,6 +43,8 @@ use sp_runtime::{
|
|||||||
IdentityLookup
|
IdentityLookup
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
use sp_runtime::RuntimeString;
|
||||||
use version::RuntimeVersion;
|
use version::RuntimeVersion;
|
||||||
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
use grandpa::{AuthorityId as GrandpaId, fg_primitives};
|
||||||
#[cfg(any(feature = "std", test))]
|
#[cfg(any(feature = "std", test))]
|
||||||
@@ -81,7 +83,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
|||||||
spec_name: create_runtime_str!("polkadot"),
|
spec_name: create_runtime_str!("polkadot"),
|
||||||
impl_name: create_runtime_str!("parity-polkadot"),
|
impl_name: create_runtime_str!("parity-polkadot"),
|
||||||
authoring_version: 2,
|
authoring_version: 2,
|
||||||
spec_version: 1004,
|
spec_version: 1005,
|
||||||
impl_version: 0,
|
impl_version: 0,
|
||||||
apis: RUNTIME_API_VERSIONS,
|
apis: RUNTIME_API_VERSIONS,
|
||||||
};
|
};
|
||||||
@@ -109,7 +111,7 @@ impl SignedExtension for OnlyStakingAndClaims {
|
|||||||
type Pre = ();
|
type Pre = ();
|
||||||
type DispatchInfo = DispatchInfo;
|
type DispatchInfo = DispatchInfo;
|
||||||
|
|
||||||
fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) }
|
fn additional_signed(&self) -> sp_std::result::Result<(), TransactionValidityError> { Ok(()) }
|
||||||
|
|
||||||
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
|
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
|
||||||
-> TransactionValidity
|
-> TransactionValidity
|
||||||
@@ -789,4 +791,31 @@ sp_api::impl_runtime_apis! {
|
|||||||
TransactionPayment::query_info(uxt, len)
|
TransactionPayment::query_info(uxt, len)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
impl frame_benchmarking::Benchmark<Block> for Runtime {
|
||||||
|
fn dispatch_benchmark(
|
||||||
|
module: Vec<u8>,
|
||||||
|
extrinsic: Vec<u8>,
|
||||||
|
lowest_range_values: Vec<u32>,
|
||||||
|
highest_range_values: Vec<u32>,
|
||||||
|
steps: Vec<u32>,
|
||||||
|
repeat: u32,
|
||||||
|
) -> Result<Vec<frame_benchmarking::BenchmarkResults>, RuntimeString> {
|
||||||
|
use frame_benchmarking::Benchmarking;
|
||||||
|
|
||||||
|
let result = match module.as_slice() {
|
||||||
|
b"claims" => Claims::run_benchmark(
|
||||||
|
extrinsic,
|
||||||
|
lowest_range_values,
|
||||||
|
highest_range_values,
|
||||||
|
steps,
|
||||||
|
repeat,
|
||||||
|
),
|
||||||
|
_ => Err("Benchmark not found for this pallet."),
|
||||||
|
};
|
||||||
|
|
||||||
|
result.map_err(|e| e.into())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,10 @@ codec = { package = "parity-scale-codec", version = "1.1.0" }
|
|||||||
sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-session = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
sp-offchain = { package = "sp-offchain", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
prometheus-endpoint = { package = "substrate-prometheus-endpoint", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
|
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rocksdb", "full-node"]
|
default = ["rocksdb", "full-node"]
|
||||||
rocksdb = ["service/rocksdb"]
|
rocksdb = ["service/rocksdb"]
|
||||||
|
runtime-benchmarks = ["polkadot-runtime/runtime-benchmarks", "kusama-runtime/runtime-benchmarks"]
|
||||||
full-node = ["av_store", "consensus", "polkadot-network"]
|
full-node = ["av_store", "consensus", "polkadot-network"]
|
||||||
|
|||||||
@@ -62,13 +62,15 @@ pub type Configuration = service::Configuration<
|
|||||||
native_executor_instance!(
|
native_executor_instance!(
|
||||||
pub PolkadotExecutor,
|
pub PolkadotExecutor,
|
||||||
polkadot_runtime::api::dispatch,
|
polkadot_runtime::api::dispatch,
|
||||||
polkadot_runtime::native_version
|
polkadot_runtime::native_version,
|
||||||
|
frame_benchmarking::benchmarking::HostFunctions,
|
||||||
);
|
);
|
||||||
|
|
||||||
native_executor_instance!(
|
native_executor_instance!(
|
||||||
pub KusamaExecutor,
|
pub KusamaExecutor,
|
||||||
kusama_runtime::api::dispatch,
|
kusama_runtime::api::dispatch,
|
||||||
kusama_runtime::native_version
|
kusama_runtime::native_version,
|
||||||
|
frame_benchmarking::benchmarking::HostFunctions,
|
||||||
);
|
);
|
||||||
|
|
||||||
/// A set of APIs that polkadot-like runtimes must implement.
|
/// A set of APIs that polkadot-like runtimes must implement.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
|
|||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
WasmBuilder::new()
|
||||||
.with_current_project()
|
.with_current_project()
|
||||||
.with_wasm_builder_from_crates("1.0.9")
|
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "8c672e107789ed10973d937ba8cac245404377e2")
|
||||||
.export_heap_base()
|
.export_heap_base()
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use wasm_builder_runner::WasmBuilder;
|
|||||||
fn main() {
|
fn main() {
|
||||||
WasmBuilder::new()
|
WasmBuilder::new()
|
||||||
.with_current_project()
|
.with_current_project()
|
||||||
.with_wasm_builder_from_crates("1.0.9")
|
.with_wasm_builder_from_git("https://github.com/paritytech/substrate.git", "8c672e107789ed10973d937ba8cac245404377e2")
|
||||||
.export_heap_base()
|
.export_heap_base()
|
||||||
.build()
|
.build()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user