From fbe27b8fb43c984e14eea905f13359d4af83b2b3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 29 May 2018 12:48:01 +0100 Subject: [PATCH] Balance is 128-bit value (#162) * Replace 128-bit shim with real type. * Remove unneeded code. * Remove superfluous deps * Reinstate deps. --- Cargo.lock | 58 ++++---- polkadot/primitives/src/lib.rs | 2 +- polkadot/service/src/lib.rs | 24 ++-- substrate/runtime/primitives/src/int128.rs | 148 --------------------- substrate/runtime/primitives/src/lib.rs | 3 - 5 files changed, 42 insertions(+), 193 deletions(-) delete mode 100644 substrate/runtime/primitives/src/int128.rs diff --git a/Cargo.lock b/Cargo.lock index 9fafbf6f49cec..beec637c362ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -259,7 +259,7 @@ name = "demo-primitives" version = "0.1.0" dependencies = [ "pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-primitives 0.1.0", @@ -277,7 +277,7 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-keyring 0.1.0", @@ -381,7 +381,7 @@ dependencies = [ "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fixed-hash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "tiny-keccak 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -488,7 +488,7 @@ dependencies = [ "rlp 0.2.1 (git+https://github.com/paritytech/parity.git)", "rust-crypto 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "slab 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -506,7 +506,7 @@ dependencies = [ "ethereum-types-serialize 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "fixed-hash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc_version 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "uint 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -515,7 +515,7 @@ name = "ethereum-types-serialize" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -768,7 +768,7 @@ source = "git+https://github.com/paritytech/jsonrpc.git#0fd13be062625c6d4c89859c dependencies = [ "futures 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -793,7 +793,7 @@ source = "git+https://github.com/paritytech/jsonrpc.git#0fd13be062625c6d4c89859c dependencies = [ "jsonrpc-core 8.0.2 (git+https://github.com/paritytech/jsonrpc.git)", "jsonrpc-pubsub 8.0.1 (git+https://github.com/paritytech/jsonrpc.git)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1318,7 +1318,7 @@ dependencies = [ "ethcore-crypto 0.1.0 (git+https://github.com/paritytech/parity.git)", "hex 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "subtle 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1340,7 +1340,7 @@ name = "polkadot-primitives" version = "0.1.0" dependencies = [ "pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-primitives 0.1.0", @@ -1358,7 +1358,7 @@ dependencies = [ "polkadot-primitives 0.1.0", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-keyring 0.1.0", @@ -1725,7 +1725,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "serde" -version = "1.0.27" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -1755,7 +1755,7 @@ dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "num-traits 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1914,7 +1914,7 @@ dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-primitives 0.1.0", @@ -1962,7 +1962,7 @@ dependencies = [ "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-bft 0.1.0", @@ -1986,7 +1986,7 @@ dependencies = [ "fixed-hash 0.1.3 (git+https://github.com/rphmeier/primitives.git?branch=compile-for-wasm)", "pretty_assertions 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.0 (git+https://github.com/rphmeier/rustc-hex.git)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-runtime-std 0.1.0", @@ -2032,7 +2032,7 @@ name = "substrate-runtime-consensus" version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-primitives 0.1.0", "substrate-runtime-io 0.1.0", @@ -2049,7 +2049,7 @@ dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-keyring 0.1.0", "substrate-primitives 0.1.0", @@ -2070,7 +2070,7 @@ version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-primitives 0.1.0", "substrate-runtime-consensus 0.1.0", @@ -2088,7 +2088,7 @@ name = "substrate-runtime-executive" version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-primitives 0.1.0", "substrate-runtime-consensus 0.1.0", @@ -2121,7 +2121,7 @@ version = "0.1.0" dependencies = [ "integer-sqrt 0.1.0 (git+https://github.com/paritytech/integer-sqrt-rs.git)", "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 1.0.63 (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", "substrate-primitives 0.1.0", @@ -2148,7 +2148,7 @@ version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-keyring 0.1.0", "substrate-primitives 0.1.0", @@ -2169,7 +2169,7 @@ dependencies = [ "parity-wasm 0.30.0 (registry+https://github.com/rust-lang/crates.io-index)", "pwasm-utils 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-keyring 0.1.0", "substrate-primitives 0.1.0", @@ -2199,7 +2199,7 @@ version = "0.1.0" dependencies = [ "ed25519 0.1.0", "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (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", "substrate-primitives 0.1.0", @@ -2213,7 +2213,7 @@ version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "safe-mix 0.1.0", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-primitives 0.1.0", "substrate-runtime-io 0.1.0", @@ -2227,7 +2227,7 @@ name = "substrate-runtime-timestamp" version = "0.1.0" dependencies = [ "hex-literal 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "substrate-codec 0.1.0", "substrate-primitives 0.1.0", "substrate-runtime-io 0.1.0", @@ -2241,7 +2241,7 @@ dependencies = [ name = "substrate-serializer" version = "0.1.0" dependencies = [ - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2589,7 +2589,7 @@ name = "wabt" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2851,7 +2851,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum semver 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a3186ec9e65071a2095434b1f5bb24838d4e8e130f584c790f6033c79943537" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "db99f3919e20faa51bb2996057f5031d8685019b5a06139b1ce761da671b8526" +"checksum serde 1.0.63 (registry+https://github.com/rust-lang/crates.io-index)" = "6f4a07014dd9a6845448a9e62f6f27595847f09828caabf1b1d50bb6755fa4d2" "checksum serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)" = "f4ba7591cfe93755e89eeecdbcc668885624829b020050e6aec99c2a03bd3fd0" "checksum serde_derive_internals 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6e03f1c9530c3fb0a0a5c9b826bdd9246a5921ae995d75f512ac917fc4dd55b5" "checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" diff --git a/polkadot/primitives/src/lib.rs b/polkadot/primitives/src/lib.rs index b9a636162c912..a140e6ccee928 100644 --- a/polkadot/primitives/src/lib.rs +++ b/polkadot/primitives/src/lib.rs @@ -83,4 +83,4 @@ pub type Timestamp = u64; /// 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; +pub type Balance = u128; diff --git a/polkadot/service/src/lib.rs b/polkadot/service/src/lib.rs index 3dde4242bc520..5113193a36905 100644 --- a/polkadot/service/src/lib.rs +++ b/polkadot/service/src/lib.rs @@ -164,8 +164,8 @@ fn poc_1_testnet_config() -> ChainConfig { staking: Some(StakingConfig { current_era: 0, intentions: initial_authorities.clone(), - transaction_fee: 100.into(), - balances: endowed_accounts.iter().map(|&k|(k, (1u128 << 60).into())).collect(), + transaction_fee: 100, + balances: endowed_accounts.iter().map(|&k|(k, 1u128 << 60)).collect(), validator_count: 12, sessions_per_era: 24, // 24 hours per era. bonding_duration: 90, // 90 days per bond. @@ -173,13 +173,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.into(), // 1000 as the minimum deposit for a referendum + minimum_deposit: 1000, // 1000 as the minimum deposit for a referendum }), council: Some(CouncilConfig { active_council: vec![], - 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. + 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. 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. @@ -222,8 +222,8 @@ fn testnet_config(initial_authorities: Vec) -> ChainConfig { staking: Some(StakingConfig { current_era: 0, intentions: initial_authorities.clone(), - transaction_fee: 1.into(), - balances: endowed_accounts.iter().map(|&k|(k, (1u128 << 60).into())).collect(), + transaction_fee: 1, + balances: endowed_accounts.iter().map(|&k|(k, (1u128 << 60))).collect(), validator_count: 2, sessions_per_era: 5, bonding_duration: 2, @@ -231,13 +231,13 @@ fn testnet_config(initial_authorities: Vec) -> ChainConfig { democracy: Some(DemocracyConfig { launch_period: 9, voting_period: 18, - minimum_deposit: 10.into(), + minimum_deposit: 10, }), 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.into(), - voter_bond: 2.into(), - present_slash_per_voter: 1.into(), + candidacy_bond: 10, + voter_bond: 2, + present_slash_per_voter: 1, carry_count: 4, presentation_duration: 10, approval_voting_period: 20, diff --git a/substrate/runtime/primitives/src/int128.rs b/substrate/runtime/primitives/src/int128.rs deleted file mode 100644 index 7bbaf914414d6..0000000000000 --- a/substrate/runtime/primitives/src/int128.rs +++ /dev/null @@ -1,148 +0,0 @@ -// 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. - -#[cfg(feature = "std")] -use serde::ser::{Serialize, Serializer, 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()) - } - } - - #[cfg(feature = "std")] - 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 69b6e025e9818..3d157cc2d47b7 100644 --- a/substrate/runtime/primitives/src/lib.rs +++ b/substrate/runtime/primitives/src/lib.rs @@ -45,9 +45,6 @@ pub mod testing; pub mod traits; pub mod generic; -mod int128; -pub use int128::{I128, U128}; - #[cfg(feature = "std")] pub type BuiltExternalities = HashMap, Vec>;