diff --git a/core/test-runtime/wasm/Cargo.lock b/core/test-runtime/wasm/Cargo.lock index fdba699543195..ae0aa19bc5e9e 100644 --- a/core/test-runtime/wasm/Cargo.lock +++ b/core/test-runtime/wasm/Cargo.lock @@ -1159,7 +1159,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "schnorrkel" version = "0.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/w3f/schnorrkel#0a0de4294b475ef6abdeebb50067f213ca79b3c7" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1168,6 +1168,7 @@ dependencies = [ "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1441,11 +1442,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substrate-bip39" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1568,12 +1569,12 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", - "substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2206,7 +2207,7 @@ dependencies = [ "checksum rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "403bb3a286107a04825a5f82e1270acc1e14028d3d554d7a1e08914549575ab8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" -"checksum schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe554f318830b48e5da8ab1ccb1ffd02b79228364dac7766b7cd1ec461ca5116" +"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" @@ -2226,7 +2227,7 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6183ce9e04bec5f113ff19c8ef5355dad20a4196134b5402732bf5d3c1a351" +"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" diff --git a/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 416fd30a5c971..6ac732ef728d4 100644 Binary files a/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/node/runtime/src/lib.rs b/node/runtime/src/lib.rs index 45b252b04cb67..9f53f2cd33855 100644 --- a/node/runtime/src/lib.rs +++ b/node/runtime/src/lib.rs @@ -61,7 +61,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { impl_name: create_runtime_str!("substrate-node"), authoring_version: 10, spec_version: 34, - impl_version: 35, + impl_version: 36, apis: RUNTIME_API_VERSIONS, }; diff --git a/node/runtime/wasm/Cargo.lock b/node/runtime/wasm/Cargo.lock index f6cfef7c80957..81008e6e100d3 100644 --- a/node/runtime/wasm/Cargo.lock +++ b/node/runtime/wasm/Cargo.lock @@ -1236,7 +1236,7 @@ dependencies = [ [[package]] name = "schnorrkel" version = "0.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/w3f/schnorrkel#0a0de4294b475ef6abdeebb50067f213ca79b3c7" dependencies = [ "clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "curve25519-dalek 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1245,6 +1245,7 @@ dependencies = [ "merlin 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "rand_chacha 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sha3 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1818,11 +1819,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "substrate-bip39" version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/paritytech/substrate-bip39#a28806512c977992af8d6740d45352f5a1c832a0" dependencies = [ "hmac 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1956,12 +1957,12 @@ dependencies = [ "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", "ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)", "serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)", "sha2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", - "substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)", "tiny-bip39 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", "twox-hash 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2567,7 +2568,7 @@ dependencies = [ "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "eb9e9b8cde282a9fe6a42dd4681319bfb63f121b8a8ee9439c6f4107e58a46f7" "checksum safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" -"checksum schnorrkel 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe554f318830b48e5da8ab1ccb1ffd02b79228364dac7766b7cd1ec461ca5116" +"checksum schnorrkel 0.0.0 (git+https://github.com/w3f/schnorrkel)" = "" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" @@ -2587,7 +2588,7 @@ dependencies = [ "checksum spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44363f6f51401c34e7be73db0db371c04705d35efbe9f7d6082e03a921a32c55" "checksum stable_deref_trait 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" "checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" -"checksum substrate-bip39 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ec6183ce9e04bec5f113ff19c8ef5355dad20a4196134b5402732bf5d3c1a351" +"checksum substrate-bip39 0.2.0 (git+https://github.com/paritytech/substrate-bip39)" = "" "checksum subtle 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d67a5a62ba6e01cb2192ff309324cb4875d0c451d55fe2319433abe7a05a8ee" "checksum subtle 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "702662512f3ddeb74a64ce2fbbf3707ee1b6bb663d28bb054e0779bbc720d926" "checksum syn 0.15.27 (registry+https://github.com/rust-lang/crates.io-index)" = "525bd55255f03c816e5d7f615587bd13030c7103354fadb104993dcee6a788ec" diff --git a/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index 2192c80bc519e..443f890501638 100644 Binary files a/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ diff --git a/srml/balances/src/lib.rs b/srml/balances/src/lib.rs index c9b62998fc070..42c998f7ca8b6 100644 --- a/srml/balances/src/lib.rs +++ b/srml/balances/src/lib.rs @@ -302,7 +302,11 @@ impl Module { if would_create && value < Self::existential_deposit() { return Err("value too low to create account"); } - Self::ensure_account_can_withdraw(transactor, value, WithdrawReason::Transfer, new_from_balance)?; + Self::ensure_account_can_withdraw( + transactor, + WithdrawReason::Transfer | WithdrawReason::TransactionPayment, + new_from_balance, + )?; // NOTE: total stake being stored in the same type means that this could never overflow // but better to be safe than sorry. @@ -370,18 +374,18 @@ impl Module { /// Returns `Ok` iff the account is able to make a withdrawal of the given amount /// for the given reason. - /// + /// /// `Err(...)` with the reason why not otherwise. pub fn ensure_account_can_withdraw( who: &T::AccountId, - _amount: T::Balance, - reason: WithdrawReason, + reasons: impl Into, new_balance: T::Balance, ) -> Result { - match reason { - WithdrawReason::Reserve | WithdrawReason::Transfer if Self::vesting_balance(who) > new_balance => - return Err("vesting balance too high to send value"), - _ => {} + let reasons = reasons.into(); + if reasons.intersects(WithdrawReason::Reserve | WithdrawReason::Transfer) + && Self::vesting_balance(who) > new_balance + { + return Err("vesting balance too high to send value"); } let locks = Self::locks(who); if locks.is_empty() { @@ -389,7 +393,7 @@ impl Module { } let now = >::block_number(); if Self::locks(who).into_iter() - .all(|l| now >= l.until || new_balance >= l.amount || !l.reasons.contains(reason)) + .all(|l| now >= l.until || new_balance >= l.amount || !l.reasons.intersects(reasons)) { Ok(()) } else { @@ -416,7 +420,7 @@ where Self::free_balance(who) .checked_sub(&value) .map_or(false, |new_balance| - Self::ensure_account_can_withdraw(who, value, WithdrawReason::Reserve, new_balance).is_ok() + Self::ensure_account_can_withdraw(who, WithdrawReason::Reserve, new_balance).is_ok() ) } @@ -467,7 +471,7 @@ where return Err("not enough free funds") } let new_balance = b - value; - Self::ensure_account_can_withdraw(who, value, WithdrawReason::Reserve, new_balance)?; + Self::ensure_account_can_withdraw(who, WithdrawReason::Reserve, new_balance)?; Self::set_reserved_balance(who, Self::reserved_balance(who) + value); Self::set_free_balance(who, new_balance); Ok(()) @@ -602,7 +606,7 @@ impl TransferAsset for Module { let b = Self::free_balance(who); ensure!(b >= value, "account has too few funds"); let new_balance = b - value; - Self::ensure_account_can_withdraw(who, value, reason, new_balance)?; + Self::ensure_account_can_withdraw(who, reason, new_balance)?; Self::set_free_balance(who, new_balance); Self::decrease_total_stake_by(value); Ok(()) diff --git a/srml/contract/src/exec.rs b/srml/contract/src/exec.rs index 0dbe8b3260410..dc9fb1c218915 100644 --- a/srml/contract/src/exec.rs +++ b/srml/contract/src/exec.rs @@ -520,7 +520,7 @@ fn transfer<'a, T: Trait, V: Vm, L: Loader>( if would_create && value < ctx.config.existential_deposit { return Err("value too low to create account"); } - >::ensure_account_can_withdraw(transactor, value, WithdrawReason::Transfer, new_from_balance)?; + >::ensure_account_can_withdraw(transactor, WithdrawReason::Transfer, new_from_balance)?; let new_to_balance = match to_balance.checked_add(&value) { Some(b) => b,