From 1981c3a88fa0a4c7e99a37988c8fcff5ecc638f1 Mon Sep 17 00:00:00 2001 From: Gav Date: Tue, 15 May 2018 16:46:57 +0200 Subject: [PATCH 1/3] Add 128-bit shim and use for balance. --- Cargo.lock | 12 +- polkadot/primitives/src/lib.rs | 2 +- polkadot/service/src/lib.rs | 24 ++-- substrate/codec/src/slicable.rs | 2 +- substrate/runtime/primitives/src/int128.rs | 147 +++++++++++++++++++++ substrate/runtime/primitives/src/lib.rs | 3 + substrate/runtime/primitives/src/traits.rs | 4 +- 7 files changed, 172 insertions(+), 22 deletions(-) create mode 100644 substrate/runtime/primitives/src/int128.rs diff --git a/Cargo.lock b/Cargo.lock index 84210a9849164..f65837eb3cd92 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -156,7 +156,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -797,7 +797,7 @@ dependencies = [ [[package]] name = "integer-sqrt" version = "0.1.0" -source = "git+https://github.com/paritytech/integer-sqrt-rs.git#f4cf61482096dc98c1273f46a10849d182b4c23c" +source = "git+https://github.com/paritytech/integer-sqrt-rs.git#886e9cb983c46498003878afe965d55caa762025" [[package]] name = "interleaved-ordered" @@ -1125,7 +1125,7 @@ name = "num-integer" version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1135,7 +1135,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-traits" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -2168,7 +2168,7 @@ name = "substrate-runtime-primitives" version = "0.1.0" dependencies = [ "integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)", - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", @@ -2848,7 +2848,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" "checksum num-integer 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)" = "f8d26da319fb45674985c78f1d1caf99aa4941f785d384a2ae36d0740bc3e2fe" "checksum num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "9936036cc70fe4a8b2d338ab665900323290efb03983c86cbe235ae800ad8017" -"checksum num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dee092fcdf725aee04dd7da1d21debff559237d49ef1cb3e69bcb8ece44c7364" +"checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum odds 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "4eae0151b9dacf24fcc170d9995e511669a082856a91f958a2fe380bfab3fb22" "checksum ole32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" diff --git a/polkadot/primitives/src/lib.rs b/polkadot/primitives/src/lib.rs index 012cf57b3d21a..ba9d34047862e 100644 --- a/polkadot/primitives/src/lib.rs +++ b/polkadot/primitives/src/lib.rs @@ -76,4 +76,4 @@ pub type Signature = runtime_primitives::Ed25519Signature; pub type Timestamp = u64; /// The balance of an account. -pub type Balance = u64; +pub type Balance = runtime_primitives::U128; diff --git a/polkadot/service/src/lib.rs b/polkadot/service/src/lib.rs index bcb454260e933..ee24cd0eb59c4 100644 --- a/polkadot/service/src/lib.rs +++ b/polkadot/service/src/lib.rs @@ -154,8 +154,8 @@ fn poc_1_testnet_config() -> ChainConfig { staking: Some(StakingConfig { current_era: 0, intentions: initial_authorities.clone(), - transaction_fee: 100, - balances: endowed_accounts.iter().map(|&k|(k, 1u64 << 60)).collect(), + transaction_fee: 100.into(), + balances: endowed_accounts.iter().map(|&k|(k, (1u128 << 60).into())).collect(), validator_count: 12, sessions_per_era: 24, // 24 hours per era. bonding_duration: 90, // 90 days per bond. @@ -163,13 +163,13 @@ fn poc_1_testnet_config() -> ChainConfig { democracy: Some(DemocracyConfig { launch_period: 120 * 24 * 14, // 2 weeks per public referendum voting_period: 120 * 24 * 28, // 4 weeks to discuss & vote on an active referendum - minimum_deposit: 1000, // 1000 as the minimum deposit for a referendum + minimum_deposit: 1000.into(), // 1000 as the minimum deposit for a referendum }), council: Some(CouncilConfig { active_council: vec![], - candidacy_bond: 1000, // 1000 to become a council candidate - voter_bond: 100, // 100 down to vote for a candidate - present_slash_per_voter: 1, // slash by 1 per voter for an invalid presentation. + candidacy_bond: 1000.into(), // 1000 to become a council candidate + voter_bond: 100.into(), // 100 down to vote for a candidate + present_slash_per_voter: 1.into(), // slash by 1 per voter for an invalid presentation. carry_count: 24, // carry over the 24 runners-up to the next council election presentation_duration: 120 * 24, // one day for presenting winners. approval_voting_period: 7 * 120 * 24, // one week period between possible council elections. @@ -212,8 +212,8 @@ fn testnet_config(initial_authorities: Vec) -> ChainConfig { staking: Some(StakingConfig { current_era: 0, intentions: initial_authorities.clone(), - transaction_fee: 1, - balances: endowed_accounts.iter().map(|&k|(k, 1u64 << 60)).collect(), + transaction_fee: 1.into(), + balances: endowed_accounts.iter().map(|&k|(k, (1u128 << 60).into())).collect(), validator_count: 2, sessions_per_era: 5, bonding_duration: 2, @@ -221,13 +221,13 @@ fn testnet_config(initial_authorities: Vec) -> ChainConfig { democracy: Some(DemocracyConfig { launch_period: 9, voting_period: 18, - minimum_deposit: 10, + minimum_deposit: 10.into(), }), council: Some(CouncilConfig { active_council: endowed_accounts.iter().filter(|a| initial_authorities.iter().find(|b| a == b).is_none()).map(|a| (a.clone(), 1000000)).collect(), - candidacy_bond: 10, - voter_bond: 2, - present_slash_per_voter: 1, + candidacy_bond: 10.into(), + voter_bond: 2.into(), + present_slash_per_voter: 1.into(), carry_count: 4, presentation_duration: 10, approval_voting_period: 20, diff --git a/substrate/codec/src/slicable.rs b/substrate/codec/src/slicable.rs index 8c3d8f4330dce..4054b5ef5eccb 100644 --- a/substrate/codec/src/slicable.rs +++ b/substrate/codec/src/slicable.rs @@ -344,7 +344,7 @@ macro_rules! impl_non_endians { )* } } -impl_endians!(u16, u32, u64, usize, i16, i32, i64, isize); +impl_endians!(u16, u32, u64, u128, usize, i16, i32, i64, i128, isize); impl_non_endians!(i8, [u8; 1], [u8; 2], [u8; 3], [u8; 4], [u8; 5], [u8; 6], [u8; 7], [u8; 8], [u8; 10], [u8; 12], [u8; 14], [u8; 16], [u8; 20], [u8; 24], [u8; 28], [u8; 32], [u8; 40], [u8; 48], [u8; 56], [u8; 64], [u8; 80], [u8; 96], [u8; 112], [u8; 128], bool); diff --git a/substrate/runtime/primitives/src/int128.rs b/substrate/runtime/primitives/src/int128.rs new file mode 100644 index 0000000000000..227dc9ec6e634 --- /dev/null +++ b/substrate/runtime/primitives/src/int128.rs @@ -0,0 +1,147 @@ +// Copyright 2017 Parity Technologies (UK) Ltd. +// This file is part of Substrate Demo. + +// Substrate Demo is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Substrate Demo is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Substrate Demo. If not, see . + +//! 128-bit shims so that we can make it `serde::Serialize`-able, since Serde is borked for +//! the new 128-bit datatypes. + +use serde::{Serialize, Serializer}; +use serde::ser::SerializeTuple; +use codec::{Slicable, Input}; +use integer_sqrt::IntegerSquareRoot; +use num_traits::{Zero, One, Bounded}; +use rstd::ops::{Add, Sub, Mul, Div, Rem, AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; +use traits::As; + +/// A 128-bit uint shim. +#[derive(Debug, Eq, PartialEq, PartialOrd, Ord, Clone, Copy, Default)] +pub struct U128(u128); + +/// A 128-bit int shim. +#[derive(Debug, Eq, PartialEq, PartialOrd, Ord, Clone, Copy, Default)] +pub struct I128(i128); + +macro_rules! impl_as { + ( $f:ident, $i:ty ) => { + impl_as!($f, $i: u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); + }; + ( $f:ident, $i:ty : $t:ty $(, $rest:ty)* ) => { + impl As<$t> for $f { + fn as_(self) -> $t { self.0 as $t } + fn sa(t: $t) -> Self { $f(t as $i) } + } + impl_as!($f, $i : $( $rest ),*); + }; + ( $f:ident, $i:ty : ) => {} +} + + +macro_rules! impl_for { + ($type:ident, $inner:ty) => { + impl IntegerSquareRoot for $type { + fn integer_sqrt(&self) -> Self { + $type(self.0.integer_sqrt()) + } + fn integer_sqrt_checked(&self) -> Option { + self.0.integer_sqrt_checked().map(|x| $type(x)) + } + } + macro_rules! impl_bin_op { + ($op:ident, $f:ident) => { + impl $op for $type { + type Output = Self; + fn $f (self, other: Self) -> Self { + $type((self.0).$f(other.0)) + } + } + } + } + macro_rules! impl_assign_op { + ($op:ident, $f:ident) => { + impl $op for $type { + fn $f (&mut self, other: Self) { + (&mut self.0).$f(other.0) + } + } + } + } + impl_bin_op!(Add, add); + impl_bin_op!(Sub, sub); + impl_bin_op!(Mul, mul); + impl_bin_op!(Div, div); + impl_bin_op!(Rem, rem); + impl_assign_op!(AddAssign, add_assign); + impl_assign_op!(SubAssign, sub_assign); + impl_assign_op!(MulAssign, mul_assign); + impl_assign_op!(DivAssign, div_assign); + impl_assign_op!(RemAssign, rem_assign); + + impl Zero for $type { + fn zero() -> Self { + $type(Zero::zero()) + } + fn is_zero(&self) -> bool { + self.0.is_zero() + } + } + impl One for $type { + fn one() -> Self { + $type(One::one()) + } + } + + impl Bounded for $type { + fn min_value() -> Self { + $type(Bounded::min_value()) + } + fn max_value() -> Self { + $type(Bounded::max_value()) + } + } + + impl Serialize for $type { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + let mut seq = serializer.serialize_tuple(2)?; + seq.serialize_element(&(self.0 as u64))?; + seq.serialize_element(&((self.0 >> 64) as u64))?; + seq.end() + } + } + + impl Slicable for $type { + fn decode(input: &mut I) -> Option { + Slicable::decode(input).map($type) + } + + fn using_encoded R>(&self, f: F) -> R { + self.0.using_encoded(f) + } + } + + impl From<$inner> for $type { + fn from(v: $inner) -> Self { + $type(v) + } + } + + impl_as!($type, $inner); + } +} + +impl_for!(U128, u128); +impl_for!(I128, i128); diff --git a/substrate/runtime/primitives/src/lib.rs b/substrate/runtime/primitives/src/lib.rs index 3d157cc2d47b7..69b6e025e9818 100644 --- a/substrate/runtime/primitives/src/lib.rs +++ b/substrate/runtime/primitives/src/lib.rs @@ -45,6 +45,9 @@ pub mod testing; pub mod traits; pub mod generic; +mod int128; +pub use int128::{I128, U128}; + #[cfg(feature = "std")] pub type BuiltExternalities = HashMap, Vec>; diff --git a/substrate/runtime/primitives/src/traits.rs b/substrate/runtime/primitives/src/traits.rs index bcd5707f1fd83..4b7530e6db70c 100644 --- a/substrate/runtime/primitives/src/traits.rs +++ b/substrate/runtime/primitives/src/traits.rs @@ -61,7 +61,7 @@ pub trait As { macro_rules! impl_numerics { ( $( $t:ty ),* ) => { $( - impl_numerics!($t: u8, u16, u32, u64, usize, i8, i16, i32, i64, isize,); + impl_numerics!($t: u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize,); )* }; ( $f:ty : $t:ty, $( $rest:ty, )* ) => { @@ -74,7 +74,7 @@ macro_rules! impl_numerics { ( $f:ty : ) => {} } -impl_numerics!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize); +impl_numerics!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); pub struct Identity; impl Convert for Identity { From 9b060f22317ba4286a49e3ed24f524d46e1509bd Mon Sep 17 00:00:00 2001 From: Gav Date: Tue, 15 May 2018 17:07:26 +0200 Subject: [PATCH 2/3] Fix tests. --- polkadot/api/src/lib.rs | 2 +- polkadot/primitives/src/lib.rs | 16 ++++++++++++---- polkadot/runtime/src/lib.rs | 6 +++--- polkadot/transaction-pool/src/lib.rs | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/polkadot/api/src/lib.rs b/polkadot/api/src/lib.rs index 731c19a49637d..d0daabcc4ac75 100644 --- a/polkadot/api/src/lib.rs +++ b/polkadot/api/src/lib.rs @@ -140,7 +140,7 @@ pub trait PolkadotApi { fn evaluate_block(&self, at: &Self::CheckedBlockId, block: Block) -> Result<()>; /// Create a block builder on top of the parent block. - fn build_block(&self, parent: &Self::CheckedBlockId, timestamp: u64) -> Result; + fn build_block(&self, parent: &Self::CheckedBlockId, timestamp: Timestamp) -> Result; } /// A checked block ID used for the substrate-client implementation of CheckedBlockId; diff --git a/polkadot/primitives/src/lib.rs b/polkadot/primitives/src/lib.rs index ba9d34047862e..1db009c73546d 100644 --- a/polkadot/primitives/src/lib.rs +++ b/polkadot/primitives/src/lib.rs @@ -50,6 +50,8 @@ pub use primitives::block::Id as BlockId; pub use primitives::block::Log as Log; /// An index to a block. +/// 32-bits will allow for 136 years of blocks assuming 1 block per second. +/// TODO: switch to u32 pub type BlockNumber = u64; /// Alias to Ed25519 pubkey that identifies an account on the relay chain. This will almost @@ -60,11 +62,11 @@ pub type AccountId = primitives::AuthorityId; /// exactly equivalent to what the substrate calls an "authority". pub type SessionKey = primitives::AuthorityId; -/// Indentifier for a chain. -pub type ChainId = u64; +/// Indentifier for a chain. 32-bit should be plenty. +pub type ChainId = u32; -/// Index of a transaction in the relay chain. -pub type Index = u64; +/// Index of a transaction in the relay chain. 32-bit should be plenty. +pub type Index = u32; /// A hash of some data used by the relay chain. pub type Hash = primitives::H256; @@ -76,4 +78,10 @@ pub type Signature = runtime_primitives::Ed25519Signature; pub type Timestamp = u64; /// The balance of an account. +/// 128-bits (or 38 significant decimal figures) will allow for 10m currency (10^7) at a resolution +/// to all for one second's worth of an annualised 50% reward be paid to a unit holder (10^11 unit +/// denomination), or 10^18 total atomic units, to grow at 50%/year for 51 years (10^9 multiplier) +/// for an eventual total of 10^27 units (27 significant decimal figures). +/// We round denomination to 10^12 (12 sdf), and leave the other redundancy at the upper end so +/// that 32 bits may be multiplied with a balance in 128 bits without worrying about overflow. pub type Balance = runtime_primitives::U128; diff --git a/polkadot/runtime/src/lib.rs b/polkadot/runtime/src/lib.rs index f933085d51052..1cfcd31497c6d 100644 --- a/polkadot/runtime/src/lib.rs +++ b/polkadot/runtime/src/lib.rs @@ -286,7 +286,7 @@ mod tests { let tx = UncheckedExtrinsic { extrinsic: Extrinsic { signed: [1; 32], - index: 999u64, + index: 999, function: Call::Timestamp(TimestampCall::set(135135)), }, signature: primitives::hash::H512([0; 64]).into(), @@ -307,7 +307,7 @@ mod tests { fn serialize_checked() { let xt = Extrinsic { signed: hex!["0d71d1a9cad6f2ab773435a7dec1bac019994d05d1dd5eb3108211dcf25c9d1e"], - index: 0u64, + index: 0, function: Call::CouncilVoting(council::voting::Call::propose(Box::new( PrivCall::Consensus(consensus::PrivCall::set_code( vec![] @@ -316,7 +316,7 @@ mod tests { }; let v = Slicable::encode(&xt); - let data = hex!["e00000000d71d1a9cad6f2ab773435a7dec1bac019994d05d1dd5eb3108211dcf25c9d1e000000000000000007000000000000006369D39D892B7B87A6769F90E14C618C2B84EBB293E2CC46640136E112C078C75619AC2E0815F2511568736623C055156C8FC427CE2AEE4AE2838F86EFE80208"]; + let data = hex!["e00000000d71d1a9cad6f2ab773435a7dec1bac019994d05d1dd5eb3108211dcf25c9d1e0000000007000000000000006369D39D892B7B87A6769F90E14C618C2B84EBB293E2CC46640136E112C078C75619AC2E0815F2511568736623C055156C8FC427CE2AEE4AE2838F86EFE80208"]; let uxt: UncheckedExtrinsic = Slicable::decode(&mut &data[..]).unwrap(); assert_eq!(uxt.extrinsic, xt); diff --git a/polkadot/transaction-pool/src/lib.rs b/polkadot/transaction-pool/src/lib.rs index 555f2a8402b23..ea4ac1498949f 100644 --- a/polkadot/transaction-pool/src/lib.rs +++ b/polkadot/transaction-pool/src/lib.rs @@ -40,7 +40,7 @@ use polkadot_api::PolkadotApi; use primitives::{AccountId, Timestamp}; use substrate_primitives::block::Extrinsic; use runtime::{Block, UncheckedExtrinsic, TimestampCall, Call}; -use substrate_runtime_primitives::traits::Checkable; +use substrate_runtime_primitives::traits::{Bounded, Checkable}; use transaction_pool::{Pool, Readiness}; use transaction_pool::scoring::{Change, Choice}; @@ -298,7 +298,7 @@ impl<'a, T: 'a + PolkadotApi> transaction_pool::Ready for R // transaction-pool trait. let (api_handle, at_block) = (&self.api_handle, &self.at_block); let next_index = self.known_indices.entry(sender) - .or_insert_with(|| api_handle.index(at_block, sender).ok().unwrap_or_else(u64::max_value)); + .or_insert_with(|| api_handle.index(at_block, sender).ok().unwrap_or_else(Bounded::max_value)); trace!(target: "transaction-pool", "Next index for sender is {}; xt index is {}", next_index, xt.inner.index); From 68c858b306d52a9270308f2cd9d0f4c55fc026e8 Mon Sep 17 00:00:00 2001 From: Gav Date: Tue, 15 May 2018 17:56:06 +0200 Subject: [PATCH 3/3] Fix wasm build. --- demo/runtime/wasm/Cargo.lock | 8 ++++---- polkadot/runtime/wasm/Cargo.lock | 8 ++++---- substrate/runtime/primitives/src/int128.rs | 5 +++-- .../substrate_test_runtime.compact.wasm | Bin 16186 -> 16187 bytes .../release/substrate_test_runtime.wasm | Bin 17932 -> 17933 bytes 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/demo/runtime/wasm/Cargo.lock b/demo/runtime/wasm/Cargo.lock index 461b9c9645875..23cf261c8cc68 100644 --- a/demo/runtime/wasm/Cargo.lock +++ b/demo/runtime/wasm/Cargo.lock @@ -258,7 +258,7 @@ dependencies = [ [[package]] name = "integer-sqrt" version = "0.1.0" -source = "git+https://github.com/paritytech/integer-sqrt-rs.git#f4cf61482096dc98c1273f46a10849d182b4c23c" +source = "git+https://github.com/paritytech/integer-sqrt-rs.git#886e9cb983c46498003878afe965d55caa762025" [[package]] name = "isatty" @@ -355,7 +355,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-traits" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -768,7 +768,7 @@ name = "substrate-runtime-primitives" version = "0.1.0" dependencies = [ "integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)", - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", @@ -1082,7 +1082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum memorydb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "013b7e4c5e10c764936ebc6bd3662d8e3c92292d267bf6a42ef3f5cad9c793ee" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dee092fcdf725aee04dd7da1d21debff559237d49ef1cb3e69bcb8ece44c7364" +"checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum odds 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "4eae0151b9dacf24fcc170d9995e511669a082856a91f958a2fe380bfab3fb22" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" diff --git a/polkadot/runtime/wasm/Cargo.lock b/polkadot/runtime/wasm/Cargo.lock index 6e14575403a4a..7da50f19b39bc 100644 --- a/polkadot/runtime/wasm/Cargo.lock +++ b/polkadot/runtime/wasm/Cargo.lock @@ -223,7 +223,7 @@ dependencies = [ [[package]] name = "integer-sqrt" version = "0.1.0" -source = "git+https://github.com/paritytech/integer-sqrt-rs.git#f4cf61482096dc98c1273f46a10849d182b4c23c" +source = "git+https://github.com/paritytech/integer-sqrt-rs.git#886e9cb983c46498003878afe965d55caa762025" [[package]] name = "isatty" @@ -320,7 +320,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "num-traits" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -768,7 +768,7 @@ name = "substrate-runtime-primitives" version = "0.1.0" dependencies = [ "integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)", - "num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", @@ -1082,7 +1082,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memory_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" "checksum memorydb 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "013b7e4c5e10c764936ebc6bd3662d8e3c92292d267bf6a42ef3f5cad9c793ee" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" -"checksum num-traits 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dee092fcdf725aee04dd7da1d21debff559237d49ef1cb3e69bcb8ece44c7364" +"checksum num-traits 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "775393e285254d2f5004596d69bb8bc1149754570dcc08cf30cabeba67955e28" "checksum num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c51a3322e4bca9d212ad9a158a02abc6934d005490c054a2778df73a70aa0a30" "checksum odds 0.2.26 (registry+https://github.com/rust-lang/crates.io-index)" = "4eae0151b9dacf24fcc170d9995e511669a082856a91f958a2fe380bfab3fb22" "checksum owning_ref 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "cdf84f41639e037b484f93433aa3897863b561ed65c6e59c7073d7c561710f37" diff --git a/substrate/runtime/primitives/src/int128.rs b/substrate/runtime/primitives/src/int128.rs index 227dc9ec6e634..7bbaf914414d6 100644 --- a/substrate/runtime/primitives/src/int128.rs +++ b/substrate/runtime/primitives/src/int128.rs @@ -17,8 +17,8 @@ //! 128-bit shims so that we can make it `serde::Serialize`-able, since Serde is borked for //! the new 128-bit datatypes. -use serde::{Serialize, Serializer}; -use serde::ser::SerializeTuple; +#[cfg(feature = "std")] +use serde::ser::{Serialize, Serializer, SerializeTuple}; use codec::{Slicable, Input}; use integer_sqrt::IntegerSquareRoot; use num_traits::{Zero, One, Bounded}; @@ -111,6 +111,7 @@ macro_rules! impl_for { } } + #[cfg(feature = "std")] impl Serialize for $type { fn serialize(&self, serializer: S) -> Result where diff --git a/substrate/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 4607caa9b3f8a09d856f5903d359ba75b10fe4bb..bb8c35cae7e0d7a2f9f65c381e2384bb5e3a6cd1 100644 GIT binary patch delta 650 zcmY*XJ8M)?5aw<~4aj-U>Ei42J3oCQxJWOymyFL&^3>IP| znBx2nLD(+-3PG#|!P?T&8(0LZ8HVpMuj9inho5&F#k=ep-F#_*@{h(^-fg^{y;UtBdPyG@AITnup0`TvdBD3K0o( z1QTU6D|hBXXY=o>*-l0{CkzkK2hCGj{pZsT=n`X6aSBRBVr%~~OX4abpi(S>78G)` zw^;_`kr|V~duufEe7ASGILiCIc-?~aCNige@Ja}{y)_!W9B%>RQVGcrg+``+!^kb%utdnNQL&~BXs^SeBD%zCz8a`S%@YtZEySqW-7fw delta 649 zcmY*XyK0nC5a!>ABp~tMO;(c>AxMZKF`hYdZu9SM5(_OXECdUy)qtd zRR2=7I61j|W3K8>POm+ktA6E2>gUYI`of_d#p?Y;==G{*gvyJE%78{ln2*d_+Y4|O zk`h5HhML;>4)xnyh7g0nh>R!TvU3)#NqYpr&}tVgC6l*l(6%~|ms|q|Kx@VPS!yRJ zLj^9F1PBmymvY@($zPh8?dSpnACRjc6?lE+;wX;%(W|Sgb~qgSra3p`@u+F`t>%UA^}Tg6C2d+EPYRJY9c~KW{GNhlA&JVt`tkvV!0+ zp~yc5w`=KzD=#340dpEtp5NTBc_Az%f-c%Q&GU!N*R#R85G-d*r*i(>-CFw##FV;l diff --git a/substrate/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.wasm b/substrate/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.wasm index b7541aeb582fda727115a070472ae93056f93d90..ba0f64a59c754c764677e4a56cdc7b6f11152413 100755 GIT binary patch delta 596 zcmY*WJ8P6t6y!?+!h+$ty9z!)S0uuU@t$+vs983!)*b>8^)%mcnOvHWe)6Be~6sVH?`Hk-)5C!;}kAR>V);EO4~J^SRZ-~?Zojt151 z7`0cqr0i6!?YV!3gN(6CX{@4bZ6Vp7|4%DO*@A%9$_h?X=6ln*$UdR;zCudDJ5+o) zz1Y0r<7v4TAS7R8bSWpRHME<%yU+GEK`LXlk%&5=Qqnsxe1CgafT=~N>Oj{3sV4rq z-HMzFN|%BG%-LzjquFIaq+&OKGhN=`mF9=Du_%O?I#!5P%K5`L@TfTZA$>m+Y{hR27urJG)OWP(siW1H}@2b?soe+6$C@GKv5*UYtan}|ubodRgc$jFa#IvY%Gl1FF~wU| z`RnAPs1lIKbvNdS6*WJfqA*FvE>Ghn$VgcE^Yld*V5-I-P}gH5#Shvy8#%