Unverified Commit c69ba7e2 authored by Gavin Wood's avatar Gavin Wood Committed by GitHub
Browse files

Substrate.from() (#426)

* Substrate.from()

* Fix some transaction validation code

* must be more specific for matching now.

* Update `wasm-builder` and add `build-only-wasm` script

* Update to latest service builder interfaces

* ANother substrate update

* Another update
parent d2dac086
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -10,7 +10,7 @@ polkadot-primitives = { path = "../primitives" }
parking_lot = "0.9.0"
log = "0.4.6"
codec = { package = "parity-scale-codec", version = "~1.0.0", default-features = false, features = ["derive"] }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
kvdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="616b40150ded71f57f650067fcbc5c99d7c343e6" }
......@@ -11,5 +11,5 @@ tokio = "0.1.7"
futures = "0.1.17"
exit-future = "0.1"
structopt = "0.2"
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
cli = { package = "substrate-cli", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
service = { package = "polkadot-service", path = "../service" }
......@@ -8,10 +8,10 @@ edition = "2018"
[dependencies]
futures = "0.1.17"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17", features = ["compat"] }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
polkadot-runtime = { path = "../runtime" }
polkadot-primitives = { path = "../primitives" }
polkadot-cli = { path = "../cli" }
......@@ -22,4 +22,4 @@ log = "0.4"
tokio = "0.1.7"
[dev-dependencies]
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
......@@ -8,5 +8,5 @@ edition = "2018"
primitives = { package = "polkadot-primitives", path = "../primitives" }
reed_solomon = { package = "reed-solomon-erasure", git = "https://github.com/paritytech/reed-solomon-erasure" }
codec = { package = "parity-scale-codec", version = "~1.0.0", default-features = false, features = ["derive"] }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
trie = { package = "substrate-trie", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
......@@ -6,5 +6,5 @@ description = "Polkadot node implementation in Rust."
edition = "2018"
[dependencies]
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
polkadot-runtime = { path = "../runtime" }
......@@ -12,13 +12,13 @@ av_store = { package = "polkadot-availability-store", path = "../availability-st
polkadot-validation = { path = "../validation" }
polkadot-primitives = { path = "../primitives" }
codec = { package = "parity-scale-codec", version = "~1.0.0", default-features = false, features = ["derive"] }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
futures = "0.1"
log = "0.4"
exit-future = "0.1.4"
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-client = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
[dev-dependencies]
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
......@@ -10,7 +10,7 @@ codec = { package = "parity-scale-codec", version = "1.0.5", default-features =
wasmi = { version = "0.4.3", optional = true }
derive_more = { version = "0.14", optional = true }
serde = { version = "1.0", default-features = false, features = [ "derive" ] }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-master", default-features = false }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing", default-features = false }
lazy_static = { version = "1.3.0", optional = true }
parking_lot = { version = "0.7.1", optional = true }
log = { version = "0.4.6", optional = true }
......
......@@ -7,18 +7,18 @@ edition = "2018"
[dependencies]
serde = { version = "1.0", optional = true, features = ["derive"] }
parity-scale-codec = { version = "1.0.5", default-features = false, features = ["bit-vec", "derive"] }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
application-crypto = { package = "substrate-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
application-crypto = { package = "substrate-application-crypto", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
substrate-client = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
sr-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
runtime_primitives = { package = "sr-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
polkadot-parachain = { path = "../parachain", default-features = false }
bitvec = { version = "0.14.0", default-features = false, features = ["alloc"] }
babe = { package = "srml-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "srml-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
[dev-dependencies]
substrate-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-serializer = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
pretty_assertions = "0.5.1"
[features]
......
......@@ -72,3 +72,20 @@ pub type BlockId = generic::BlockId<Block>;
/// Opaque, encoded, unchecked extrinsic.
pub use runtime_primitives::OpaqueExtrinsic as UncheckedExtrinsic;
/// Custom validity errors used in Polkadot while validating transactions.
#[repr(u8)]
pub enum ValidityError {
/// The ethereum signature is invalid.
InvalidEthereumSignature = 0,
/// The signer has no claim.
SignerHasNoClaim = 1,
/// No permission to execute the call.
NoPermission = 2,
}
impl From<ValidityError> for u8 {
fn from(err: ValidityError) -> Self {
err as u8
}
}
......@@ -7,57 +7,60 @@ build = "build.rs"
[dependencies]
bitvec = { version = "0.14.0", default-features = false, features = ["alloc"] }
rustc-hex = { version = "2.0.1", default-features = false }
codec = { package = "parity-scale-codec", version = "~1.0.0", default-features = false, features = ["derive"] }
log = { version = "0.3", optional = true }
rustc-hex = { version = "2.0.1", default-features = false }
safe-mix = { version = "1.0", default-features = false}
serde = { version = "1.0", default-features = false }
serde_derive = { version = "1.0", optional = true }
safe-mix = { version = "1.0", default-features = false}
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
offchain-primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
sr-staking-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
substrate-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
authorship = { package = "srml-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
babe = { package = "srml-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
collective = { package = "srml-collective", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
democracy = { package = "srml-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
elections = { package = "srml-elections", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
finality-tracker = { package = "srml-finality-tracker", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
grandpa = { package = "srml-grandpa", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
membership = { package = "srml-membership", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
offences = { package = "srml-offences", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
session = { package = "srml-session", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
staking = { package = "srml-staking", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
sudo = { package = "srml-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
system = { package = "srml-system", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
timestamp = { package = "srml-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
treasury = { package = "srml-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
primitives = { package = "polkadot-primitives", path = "../primitives", default-features = false }
codec = { package = "parity-scale-codec", version = "~1.0.0", default-features = false, features = ["derive"] }
substrate-serializer = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
rstd = { package = "sr-std", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
srml-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
substrate-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offchain-primitives = { package = "substrate-offchain-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
authorship = { package = "srml-authorship", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
balances = { package = "srml-balances", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
collective = { package = "srml-collective", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
elections = { package = "srml-elections", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
democracy = { package = "srml-democracy", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
executive = { package = "srml-executive", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
finality-tracker = { package = "srml-finality-tracker", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
grandpa = { package = "srml-grandpa", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
indices = { package = "srml-indices", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
membership = { package = "srml-membership", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
offences = { package = "srml-offences", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-staking-primitives = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
session = { package = "srml-session", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
staking = { package = "srml-staking", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sudo = { package = "srml-sudo", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
system = { package = "srml-system", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
timestamp = { package = "srml-timestamp", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
treasury = { package = "srml-treasury", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
version = { package = "sr-version", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "srml-babe", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
substrate-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
[dev-dependencies]
hex-literal = "0.2.0"
libsecp256k1 = "0.2.1"
tiny-keccak = "1.4.2"
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
keyring = { package = "substrate-keyring", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
substrate-trie = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
trie-db = "0.15"
serde_json = "1.0"
[build-dependencies]
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.1" }
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.2" }
[features]
default = ["std"]
......
......@@ -17,5 +17,5 @@
use wasm_builder_runner::{build_current_project, WasmBuilderSource};
fn main() {
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.3"));
}
\ No newline at end of file
build_current_project("wasm_binary.rs", WasmBuilderSource::Crates("1.0.5"));
}
......@@ -29,8 +29,11 @@ use sr_primitives::traits::Zero;
use sr_primitives::{
weights::SimpleDispatchInfo,
traits::ValidateUnsigned,
transaction_validity::{TransactionLongevity, TransactionValidity, ValidTransaction},
transaction_validity::{
TransactionLongevity, TransactionValidity, ValidTransaction, InvalidTransaction
},
};
use primitives::ValidityError;
use system;
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
......@@ -194,11 +197,6 @@ impl<T: Trait> ValidateUnsigned for Module<T> {
type Call = Call<T>;
fn validate_unsigned(call: &Self::Call) -> TransactionValidity {
// Note errors > 0 are from ApplyError
const INVALID_ETHEREUM_SIGNATURE: i8 = -10;
const SIGNER_HAS_NO_CLAIM: i8 = -20;
const INVALID_CALL: i8 = -30;
const PRIORITY: u64 = 100;
match call {
......@@ -208,14 +206,18 @@ impl<T: Trait> ValidateUnsigned for Module<T> {
let signer = if let Some(s) = maybe_signer {
s
} else {
return TransactionValidity::Invalid(INVALID_ETHEREUM_SIGNATURE);
return InvalidTransaction::Custom(
ValidityError::InvalidEthereumSignature.into(),
).into();
};
if !<Claims<T>>::exists(&signer) {
return TransactionValidity::Invalid(SIGNER_HAS_NO_CLAIM);
return Err(InvalidTransaction::Custom(
ValidityError::SignerHasNoClaim.into(),
).into());
}
TransactionValidity::Valid(ValidTransaction {
Ok(ValidTransaction {
priority: PRIORITY,
requires: vec![],
provides: vec![("claims", signer).encode()],
......@@ -223,7 +225,7 @@ impl<T: Trait> ValidateUnsigned for Module<T> {
propagate: true,
})
}
_ => TransactionValidity::Invalid(INVALID_CALL)
_ => Err(InvalidTransaction::Call.into()),
}
}
}
......@@ -387,8 +389,10 @@ mod tests {
fn origin_signed_claiming_fail() {
with_externalities(&mut new_test_ext(), || {
assert_eq!(Balances::free_balance(&42), 0);
assert_err!(Claims::claim(Origin::signed(42), 42, alice_sig(&42u64.encode())),
"bad origin: expected to be no origin");
assert_err!(
Claims::claim(Origin::signed(42), 42, alice_sig(&42u64.encode())),
"RequireNoOrigin",
);
});
}
......@@ -434,7 +438,7 @@ mod tests {
with_externalities(&mut new_test_ext(), || {
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(1, alice_sig(&1u64.encode()))),
TransactionValidity::Valid(ValidTransaction {
Ok(ValidTransaction {
priority: 100,
requires: vec![],
provides: vec![("claims", alice_eth()).encode()],
......@@ -444,15 +448,15 @@ mod tests {
);
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(0, EcdsaSignature([0; 65]))),
TransactionValidity::Invalid(-10)
InvalidTransaction::Custom(ValidityError::InvalidEthereumSignature.into()).into(),
);
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(1, bob_sig(&1u64.encode()))),
TransactionValidity::Invalid(-20)
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
assert_eq!(
<Module<Test>>::validate_unsigned(&Call::claim(0, bob_sig(&1u64.encode()))),
TransactionValidity::Invalid(-20)
InvalidTransaction::Custom(ValidityError::SignerHasNoClaim.into()).into(),
);
});
}
......
......@@ -31,16 +31,17 @@ use codec::{Encode, Decode};
use substrate_primitives::u32_trait::{_1, _2, _3, _4};
use primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain,
parachain, ValidityError,
};
use client::{
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
runtime_api as client_api, impl_runtime_apis,
};
use sr_primitives::{
ApplyResult, generic, transaction_validity::{ValidTransaction, TransactionValidity},
ApplyResult, generic,
transaction_validity::{TransactionValidity, InvalidTransaction, TransactionValidityError},
impl_opaque_keys, weights::{Weight, DispatchInfo}, create_runtime_str, key_types, traits::{
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, DispatchError, SignedExtension,
BlakeTwo256, Block as BlockT, DigestFor, StaticLookup, SignedExtension,
},
};
use version::RuntimeVersion;
......@@ -55,6 +56,7 @@ use srml_support::{
parameter_types, construct_runtime, traits::{SplitTwoWays, Currency}
};
use im_online::sr25519::{AuthorityId as ImOnlineId};
use system::offchain::TransactionSubmitter;
#[cfg(feature = "std")]
pub use staking::StakerStatus;
......@@ -98,7 +100,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("kusama"),
impl_name: create_runtime_str!("parity-kusama"),
authoring_version: 1,
spec_version: 1002,
spec_version: 1003,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
};
......@@ -124,14 +126,14 @@ impl SignedExtension for OnlyStakingAndClaims {
type Call = Call;
type AdditionalSigned = ();
type Pre = ();
fn additional_signed(&self) -> rstd::result::Result<(), &'static str> { Ok(()) }
fn additional_signed(&self) -> rstd::result::Result<(), TransactionValidityError> { Ok(()) }
fn validate(&self, _: &Self::AccountId, call: &Self::Call, _: DispatchInfo, _: usize)
-> Result<ValidTransaction, DispatchError>
-> TransactionValidity
{
match call {
Call::Staking(_) | Call::Claims(_) | Call::Sudo(_) | Call::Session(_) =>
Ok(Default::default()),
_ => Err(DispatchError::NoPermission),
_ => Err(InvalidTransaction::Custom(ValidityError::NoPermission.into()).into()),
}
}
}
......@@ -413,11 +415,13 @@ impl offences::Trait for Runtime {
type OnOffenceHandler = Staking;
}
type SubmitTransaction = TransactionSubmitter<ImOnlineId, Runtime, UncheckedExtrinsic>;
impl im_online::Trait for Runtime {
type AuthorityId = ImOnlineId;
type Call = Call;
type Event = Event;
type UncheckedExtrinsic = UncheckedExtrinsic;
type Call = Call;
type SubmitTransaction = SubmitTransaction;
type ReportUnresponsiveness = ();
type CurrentElectedSet = staking::CurrentElectedStashAccounts<Runtime>;
}
......
......@@ -22,7 +22,7 @@ use codec::{Encode, Decode, HasCompact};
use srml_support::{decl_storage, decl_module, fail, ensure};
use sr_primitives::traits::{
Hash as HashT, BlakeTwo256, Member, CheckedConversion, Saturating, One, Zero,
Hash as HashT, BlakeTwo256, Member, CheckedConversion, Saturating, One, Zero, Dispatchable,
};
use sr_primitives::weights::SimpleDispatchInfo;
use primitives::{Hash, Balance, parachain::{
......@@ -31,7 +31,7 @@ use primitives::{Hash, Balance, parachain::{
}};
use {system, session};
use srml_support::{
StorageValue, StorageMap, Parameter, Dispatchable, dispatch::Result,
StorageValue, StorageMap, Parameter, dispatch::Result,
traits::{Currency, Get, WithdrawReason, ExistenceRequirement}
};
......
#!/usr/bin/env sh
# Script for building only the WASM binary of the given project.
set -e
PROJECT_ROOT=`git rev-parse --show-toplevel`
if [ "$#" -lt 1 ]; then
echo "You need to pass the name of the crate you want to compile!"
exit 1
fi
WASM_BUILDER_RUNNER="$PROJECT_ROOT/target/release/wbuild-runner/$1"
if [ -z "$2" ]; then
export WASM_TARGET_DIRECTORY=$(pwd)
else
export WASM_TARGET_DIRECTORY=$2
fi
if [ -d $WASM_BUILDER_RUNNER ]; then
export DEBUG=false
export OUT_DIR="$PROJECT_ROOT/target/release/build"
cargo run --release --manifest-path="$WASM_BUILDER_RUNNER/Cargo.toml" \
| grep -vE "cargo:rerun-if-|Executing build command"
else
cargo build --release -p $1
fi
......@@ -18,23 +18,23 @@ polkadot-primitives = { path = "../primitives" }
polkadot-runtime = { path = "../runtime" }
polkadot-executor = { path = "../executor" }
polkadot-network = { path = "../network" }
sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
client-db = { package = "substrate-client-db", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
srml-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-master" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-master" }
sr-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
sr-primitives = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
primitives = { package = "substrate-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
client = { package = "substrate-client", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
client-db = { package = "substrate-client-db", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
substrate-executor = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
substrate-network = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
consensus_common = { package = "substrate-consensus-common", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
grandpa = { package = "substrate-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
grandpa_primitives = { package = "substrate-finality-grandpa-primitives", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
inherents = { package = "substrate-inherents", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
service = { package = "substrate-service", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
telemetry = { package = "substrate-telemetry", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
transaction_pool = { package = "substrate-transaction-pool", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
substrate-keystore = { git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
srml-babe = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
srml-staking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
im-online = { package = "srml-im-online", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
babe = { package = "substrate-consensus-babe", git = "https://github.com/paritytech/substrate", branch = "polkadot-testing" }
babe-primitives = { package = "substrate-consensus-babe-primitives", git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-testing" }
......@@ -84,9 +84,8 @@ macro_rules! new_full_start {
let builder = service::ServiceBuilder::new_full::<
Block, RuntimeApi, polkadot_executor::Executor
>($config)?
.with_select_chain(|_config, client| {
#[allow(deprecated)]
Ok(client::LongestChain::new(client.backend().clone()))
.with_select_chain(|_, backend| {
Ok(client::LongestChain::new(backend.clone()))
})?
.with_transaction_pool(|config, client|
Ok(transaction_pool::txpool::Pool::new(config, transaction_pool::ChainApi::new(client)))
......@@ -137,12 +136,20 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
CallExecutor = impl CallExecutor<Block, Blake2Hasher> + Clone + Send + Sync + 'static,
>, ServiceError>
{
let is_authority = config.roles.is_authority();
let is_collator = config.custom.collating_for.is_some();
let force_authoring = config.force_authoring;
let max_block_data_size = config.custom.max_block_data_size;
let db_path = config.database_path.clone();
let disable_grandpa = config.disable_grandpa;
let name = config.name.clone();
let (builder, mut import_setup, inherent_data_providers, mut tasks_to_spawn) = new_full_start!(config);
let service = builder
.with_network_protocol(|config| Ok(PolkadotProtocol::new(config.custom.collating_for.clone())))?
.with_finality_proof_provider(|client|
Ok(Arc::new(GrandpaFinalityProofProvider::new(client.clone(), client)) as _)
.with_finality_proof_provider(|client, backend|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
)?
.build()?;
......@@ -160,7 +167,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
}
}
if service.config().custom.collating_for.is_some() {
if is_collator {
info!(
"The node cannot start as an authority because it is also configured to run as a collator."
);
......@@ -201,11 +208,11 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
(is_known, client.clone()),
);
if service.config().roles.is_authority() {
if is_authority {
let availability_store = {
use std::path::PathBuf;
let mut path = PathBuf::from(service.config().database_path.clone());
let mut path = PathBuf::from(db_path);
path.push("availability");
av_store::Store::new(::av_store::Config {
......@@ -239,7 +246,7 @@ pub fn new_full(config: Configuration<CustomConfiguration, GenesisConfig>)
service.keystore(),
availability_store,
polkadot_runtime::constants::time::SLOT_DURATION,
service.config().custom.max_block_data_size,
max_block_data_size,
);