diff --git a/substrate/Cargo.lock b/substrate/Cargo.lock index 27163a40d2..5ebc858b57 100644 --- a/substrate/Cargo.lock +++ b/substrate/Cargo.lock @@ -457,6 +457,11 @@ name = "crunchy" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crunchy" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "crypto-mac" version = "0.5.2" @@ -679,13 +684,15 @@ dependencies = [ [[package]] name = "fixed-hash" -version = "0.2.2" +version = "0.3.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2907,6 +2914,11 @@ name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "static_assertions" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "stdweb" version = "0.1.3" @@ -3275,8 +3287,8 @@ dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.9.0 (git+https://github.com/paritytech/trie)", "hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3291,7 +3303,7 @@ dependencies = [ "sr-std 0.1.0", "substrate-serializer 0.1.0", "twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -3969,11 +3981,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "uint" -version = "0.4.1" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -4324,6 +4336,7 @@ dependencies = [ "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" +"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" "checksum crypto-mac 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0999b4ff4d3446d4ddb19a63e9e00c1876e75cd7000d20e57a693b4b3f08d958" "checksum crypto-mac 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7afa06d05a046c7a47c3a849907ec303504608c927f4e85f7bfff22b7180d971" "checksum ctr 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4b669fcb8e20124db86dbd9b01e74ec0e9e420e65381311ce5249864fc7ff0c0" @@ -4350,7 +4363,7 @@ dependencies = [ "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa" "checksum finality-grandpa 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "20d8cf871510f0d57630e75f9e65f87cba29581ccab1f78666d8b2e422d0baa6" -"checksum fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d5ec8112f00ea8a483e04748a85522184418fd1cf02890b626d8fc28683f7de" +"checksum fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e71c99c903a9fe54baed1bc701b43daba8c6dc6d4aec89a32f667ab6b3094c4" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" @@ -4539,6 +4552,7 @@ dependencies = [ "checksum slog-scope 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "053344c94c0e2b22da6305efddb698d7c485809427cf40555dc936085f67a9df" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" "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 stdweb 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ef5430c8e36b713e13b48a9f709cc21e046723fe44ce34587b73a830203b533e" "checksum stdweb 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "22203527a18dc1c5c83bbd247fb005f5877d040783b6626571d6b7ed7a6f5e75" "checksum stdweb-derive 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0e21ebd9179de08f2300a65454268a17ea3de204627458588c84319c4def3930" @@ -4593,7 +4607,7 @@ dependencies = [ "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "612d636f949607bdf9b123b4a6f6d966dedf3ff669f7f045890d3a4a73948169" "checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" -"checksum uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646" +"checksum uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4630460173a57c0af94b8306091e018025d988473f641a4af754b6cde980e1e3" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9d3218ea14b4edcaccfa0df0a64a3792a2c32cc706f1b336e48867f9d3147f90" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" diff --git a/substrate/core/client/db/src/lib.rs b/substrate/core/client/db/src/lib.rs index ed4f64cf44..1e37b61cfd 100644 --- a/substrate/core/client/db/src/lib.rs +++ b/substrate/core/client/db/src/lib.rs @@ -357,7 +357,7 @@ struct StorageDb { impl state_machine::Storage for StorageDb { fn get(&self, key: &H256) -> Result, String> { - self.state_db.get(&key.0.into(), self).map(|r| r.map(|v| DBValue::from_slice(&v))) + self.state_db.get(key, self).map(|r| r.map(|v| DBValue::from_slice(&v))) .map_err(|e| format!("Database backend error: {:?}", e)) } } @@ -367,7 +367,7 @@ impl state_db::HashDb for StorageDb { type Hash = H256; fn get(&self, key: &H256) -> Result>, Self::Error> { - self.db.get(columns::STATE, &key[..]).map(|r| r.map(|v| v.to_vec())) + self.db.get(columns::STATE, key.as_bytes()).map(|r| r.map(|v| v.to_vec())) } } @@ -734,9 +734,9 @@ impl client::backend::Backend for Backend whe let mut changeset: state_db::ChangeSet = state_db::ChangeSet::default(); for (key, (val, rc)) in operation.updates.drain() { if rc > 0 { - changeset.inserted.push((key.0.into(), val.to_vec())); + changeset.inserted.push((key, val.to_vec())); } else if rc < 0 { - changeset.deleted.push(key.0.into()); + changeset.deleted.push(key); } } let number_u64 = number.as_(); @@ -1117,7 +1117,7 @@ mod tests { backend.commit_operation(op).unwrap(); - assert_eq!(backend.storage.db.get(::columns::STATE, &key.0[..]).unwrap().unwrap(), &b"hello"[..]); + assert_eq!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().unwrap(), &b"hello"[..]); hash }; @@ -1151,7 +1151,7 @@ mod tests { backend.commit_operation(op).unwrap(); - assert_eq!(backend.storage.db.get(::columns::STATE, &key.0[..]).unwrap().unwrap(), &b"hello"[..]); + assert_eq!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().unwrap(), &b"hello"[..]); hash }; @@ -1183,12 +1183,12 @@ mod tests { backend.commit_operation(op).unwrap(); - assert!(backend.storage.db.get(::columns::STATE, &key.0[..]).unwrap().is_none()); + assert!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().is_none()); } backend.finalize_block(BlockId::Number(1)).unwrap(); backend.finalize_block(BlockId::Number(2)).unwrap(); - assert!(backend.storage.db.get(::columns::STATE, &key.0[..]).unwrap().is_none()); + assert!(backend.storage.db.get(::columns::STATE, key.as_bytes()).unwrap().is_none()); } #[test] diff --git a/substrate/core/client/src/genesis.rs b/substrate/core/client/src/genesis.rs index 16dc8f5e05..83c4338b8b 100644 --- a/substrate/core/client/src/genesis.rs +++ b/substrate/core/client/src/genesis.rs @@ -67,7 +67,7 @@ mod tests { use trie::ordered_trie_root; let transactions = txs.into_iter().map(|tx| { - let signature = Pair::from(Keyring::from_public(Public::from_raw(tx.from.0)).unwrap()) + let signature = Pair::from(Keyring::from_public(Public::from_raw(tx.from.to_fixed_bytes())).unwrap()) .sign(&tx.encode()).into(); Extrinsic { transfer: tx, signature } diff --git a/substrate/core/client/src/light/fetcher.rs b/substrate/core/client/src/light/fetcher.rs index 38a46c7d68..95e02b91f9 100644 --- a/substrate/core/client/src/light/fetcher.rs +++ b/substrate/core/client/src/light/fetcher.rs @@ -478,7 +478,7 @@ pub mod tests { assert!(local_checker.check_changes_proof(&request, remote_max + 1, remote_proof.clone()).is_err()); // check proof on local client using broken proof - remote_proof = local_roots_range.into_iter().map(|v| v.to_vec()).collect(); + remote_proof = local_roots_range.into_iter().map(|v| v.as_bytes().to_vec()).collect(); assert!(local_checker.check_changes_proof(&request, remote_max, remote_proof).is_err()); } } diff --git a/substrate/core/executor/src/wasm_executor.rs b/substrate/core/executor/src/wasm_executor.rs index 56624060e7..90d6db6001 100644 --- a/substrate/core/executor/src/wasm_executor.rs +++ b/substrate/core/executor/src/wasm_executor.rs @@ -845,7 +845,7 @@ mod tests { let test_code = include_bytes!("../wasm/target/wasm32-unknown-unknown/release/runtime_test.compact.wasm"); assert_eq!( WasmExecutor::new().call(&mut ext, 8, &test_code[..], "test_enumerated_trie_root", &[]).unwrap(), - ordered_trie_root::(vec![b"zero".to_vec(), b"one".to_vec(), b"two".to_vec()].iter()).0.encode() + ordered_trie_root::(vec![b"zero".to_vec(), b"one".to_vec(), b"two".to_vec()].iter()).as_fixed_bytes().encode() ); } diff --git a/substrate/core/executor/wasm/Cargo.lock b/substrate/core/executor/wasm/Cargo.lock index 691a9291a2..94dd14381d 100644 --- a/substrate/core/executor/wasm/Cargo.lock +++ b/substrate/core/executor/wasm/Cargo.lock @@ -17,10 +17,18 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "fixed-hash" -version = "0.2.2" +name = "crunchy" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "fixed-hash" +version = "0.3.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hash-db" version = "0.9.0" @@ -141,13 +149,18 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "static_assertions" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "substrate-primitives" version = "0.1.0" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.9.0 (git+https://github.com/paritytech/trie)", "hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)", "parity-codec 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -155,7 +168,7 @@ dependencies = [ "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", - "uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -170,11 +183,11 @@ dependencies = [ [[package]] name = "uint" -version = "0.4.1" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -187,7 +200,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef" "checksum byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90492c5858dd7d2e78691cfb89f90d273a2800fc11d98f60786e5d87e2f83781" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" -"checksum fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d5ec8112f00ea8a483e04748a85522184418fd1cf02890b626d8fc28683f7de" +"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" +"checksum fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e71c99c903a9fe54baed1bc701b43daba8c6dc6d4aec89a32f667ab6b3094c4" "checksum hash-db 0.9.0 (git+https://github.com/paritytech/trie)" = "" "checksum hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)" = "" "checksum nodrop 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "9a2228dca57108069a5262f2ed8bd2e82496d2e074a06d1ccc7ce1687b6ae0a2" @@ -200,6 +214,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "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" "checksum serde 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "84257ccd054dc351472528c8587b4de2dbf0dc0fe2e634030c1a90bfdacebaa9" +"checksum static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c19be23126415861cb3a23e501d34a708f7f9b2183c5252d690941c2e69199d5" "checksum syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" -"checksum uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646" +"checksum uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4630460173a57c0af94b8306091e018025d988473f641a4af754b6cde980e1e3" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" diff --git a/substrate/core/network/src/on_demand.rs b/substrate/core/network/src/on_demand.rs index 399ba3f408..bc0f3aec9c 100644 --- a/substrate/core/network/src/on_demand.rs +++ b/substrate/core/network/src/on_demand.rs @@ -820,7 +820,11 @@ pub mod tests { }); let thread = ::std::thread::spawn(move || { let result = response.wait().unwrap(); - assert_eq!(result.hash(), "0x6443a0b46e0412e626363028115a9f2cf963eeed526b8b33e5316f08b50d0dc3".into()); + assert_eq!( + result.hash(), + "6443a0b46e0412e626363028115a9f2c\ + f963eeed526b8b33e5316f08b50d0dc3".parse().unwrap() + ); }); on_demand.on_remote_header_response(&mut network, 0, message::RemoteHeaderResponse { diff --git a/substrate/core/network/src/test/mod.rs b/substrate/core/network/src/test/mod.rs index 0da6523d0d..843ad836e0 100644 --- a/substrate/core/network/src/test/mod.rs +++ b/substrate/core/network/src/test/mod.rs @@ -255,7 +255,7 @@ impl> Peer { amount: 1, nonce, }; - let signature = Keyring::from_raw_public(transfer.from.0).unwrap().sign(&transfer.encode()).into(); + let signature = Keyring::from_raw_public(transfer.from.to_fixed_bytes()).unwrap().sign(&transfer.encode()).into(); builder.push(Extrinsic { transfer, signature }).unwrap(); nonce = nonce + 1; }); diff --git a/substrate/core/primitives/Cargo.toml b/substrate/core/primitives/Cargo.toml index 29914fc4ce..171841f1e2 100644 --- a/substrate/core/primitives/Cargo.toml +++ b/substrate/core/primitives/Cargo.toml @@ -4,15 +4,15 @@ version = "0.1.0" authors = ["Parity Technologies "] [dependencies] -crunchy = "0.1" +crunchy = { version = "0.2", default-features = false } sr-std = { path = "../sr-std", default-features = false } parity-codec = { version = "2.1", default-features = false } parity-codec-derive = { version = "2.1", default-features = false } -fixed-hash = { version = "0.2.2", default-features = false } +fixed-hash = { version = "0.3.0-beta", default-features = false } rustc-hex = { version = "2.0", default-features = false } serde = { version = "1.0", default-features = false } serde_derive = { version = "1.0", optional = true } -uint = { version = "0.4.1", default-features = false } +uint = { version = "0.5.0-beta", default-features = false } twox-hash = { version = "1.1.0", optional = true } byteorder = { version = "1.1", default-features = false } wasmi = { version = "0.4.1", optional = true } @@ -32,10 +32,13 @@ heapsize = "0.4" [features] default = ["std"] std = [ + "crunchy/std", "wasmi", "uint/std", "fixed-hash/std", - "fixed-hash/heapsizeof", + "fixed-hash/heapsize", + "fixed-hash/byteorder", + "fixed-hash/rustc-hex", "fixed-hash/libc", "parity-codec/std", "hash256-std-hasher/std", diff --git a/substrate/core/primitives/src/ed25519.rs b/substrate/core/primitives/src/ed25519.rs index 027298b4b1..2e30653e81 100644 --- a/substrate/core/primitives/src/ed25519.rs +++ b/substrate/core/primitives/src/ed25519.rs @@ -241,7 +241,7 @@ impl Pair { pub fn derive_child_probably_bad(&self, chain_data: &[u8]) -> Pair { let sig = self.sign(chain_data); let mut seed = [0u8; 32]; - seed.copy_from_slice(&sig.0[..32]); + seed.copy_from_slice(&sig[..32]); Pair::from_seed(&seed) } @@ -251,7 +251,7 @@ impl Pair { pub fn verify_strong>(sig: &Signature, message: &[u8], pubkey: P) -> bool { let public_key = untrusted::Input::from(&pubkey.as_ref().0[..]); let msg = untrusted::Input::from(message); - let sig = untrusted::Input::from(&sig.0[..]); + let sig = untrusted::Input::from(&sig.as_bytes()); match signature::verify(&signature::ED25519, public_key, msg, sig) { Ok(_) => true, @@ -316,7 +316,7 @@ mod test { assert_eq!(public, Public::from_raw(hex!("2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee"))); let message = hex!("2f8c6129d816cf51c374bc7f08c3e63ed156cf78aefb4a6550d97b87997977ee00000000000000000200d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a4500000000000000"); let signature = pair.sign(&message[..]); - println!("Correct signature: {}", HexDisplay::from(&signature.0)); + println!("Correct signature: {}", HexDisplay::from(&signature.as_bytes())); assert!(verify_strong(&signature, &message[..], &public)); } diff --git a/substrate/core/primitives/src/hash.rs b/substrate/core/primitives/src/hash.rs index 840be7e8a4..5733a738c9 100644 --- a/substrate/core/primitives/src/hash.rs +++ b/substrate/core/primitives/src/hash.rs @@ -35,7 +35,7 @@ macro_rules! impl_rest { impl<'de> Deserialize<'de> for $name { fn deserialize(deserializer: D) -> Result where D: Deserializer<'de> { bytes::deserialize_check_len(deserializer, bytes::ExpectedLen::Exact($len)) - .map(|x| (&*x).into()) + .map(|x| $name::from_slice(&x)) } } @@ -49,12 +49,29 @@ macro_rules! impl_rest { <[u8; $len] as ::codec::Decode>::decode(input).map($name) } } + + #[cfg(feature = "std")] + impl From for $name { + fn from(val: u64) -> Self { + Self::from_low_u64_be(val) + } + } } } -construct_hash!(H160, 20); -construct_hash!(H256, 32); -construct_hash!(H512, 64); +construct_fixed_hash!{ + /// Fixed-size uninterpreted hash type with 20 bytes (160 bits) size. + pub struct H160(20); +} +construct_fixed_hash!{ + /// Fixed-size uninterpreted hash type with 32 bytes (256 bits) size. + pub struct H256(32); +} +construct_fixed_hash!{ + /// Fixed-size uninterpreted hash type with 64 bytes (512 bits) size. + pub struct H512(64); +} + impl_rest!(H160, 20); impl_rest!(H256, 32); impl_rest!(H512, 64); @@ -113,7 +130,7 @@ mod tests { #[test] fn test_heapsizeof() { use heapsize::HeapSizeOf; - let h = H256::new(); + let h = H256::zero(); assert_eq!(h.heap_size_of_children(), 0); } } diff --git a/substrate/core/rpc/src/author/tests.rs b/substrate/core/rpc/src/author/tests.rs index 249d3187c7..7032355ef2 100644 --- a/substrate/core/rpc/src/author/tests.rs +++ b/substrate/core/rpc/src/author/tests.rs @@ -35,7 +35,7 @@ fn uxt(sender: Keyring, nonce: u64) -> Extrinsic { from: sender.to_raw_public().into(), to: Default::default(), }; - let signature = Keyring::from_raw_public(tx.from.0).unwrap().sign(&tx.encode()).into(); + let signature = Keyring::from_raw_public(tx.from.to_fixed_bytes()).unwrap().sign(&tx.encode()).into(); Extrinsic { transfer: tx, signature } } @@ -105,7 +105,7 @@ fn should_watch_extrinsic() { from: Keyring::Alice.to_raw_public().into(), to: Default::default(), }; - let signature = Keyring::from_raw_public(tx.from.0).unwrap().sign(&tx.encode()).into(); + let signature = Keyring::from_raw_public(tx.from.to_fixed_bytes()).unwrap().sign(&tx.encode()).into(); Extrinsic { transfer: tx, signature } }; AuthorApi::submit_rich_extrinsic(&p, replacement).unwrap(); diff --git a/substrate/core/rpc/src/chain/tests.rs b/substrate/core/rpc/src/chain/tests.rs index 644c7fed07..e673fe0af7 100644 --- a/substrate/core/rpc/src/chain/tests.rs +++ b/substrate/core/rpc/src/chain/tests.rs @@ -36,7 +36,7 @@ fn should_return_header() { parent_hash: 0.into(), number: 0, state_root: x.state_root.clone(), - extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".into(), + extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".parse().unwrap(), digest: Default::default(), } ); @@ -47,7 +47,7 @@ fn should_return_header() { parent_hash: 0.into(), number: 0, state_root: x.state_root.clone(), - extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".into(), + extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".parse().unwrap(), digest: Default::default(), } ); @@ -86,7 +86,7 @@ fn should_return_a_block() { parent_hash: api.client.genesis_hash(), number: 1, state_root: x.block.header.state_root.clone(), - extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".into(), + extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".parse().unwrap(), digest: Default::default(), }, extrinsics: vec![], @@ -100,7 +100,7 @@ fn should_return_a_block() { parent_hash: api.client.genesis_hash(), number: 1, state_root: x.block.header.state_root.clone(), - extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".into(), + extrinsics_root: "03170a2e7597b7b7e3d84c05391d139a62b157e78786d8c082f29dcf4c111314".parse().unwrap(), digest: Default::default(), }, extrinsics: vec![], diff --git a/substrate/core/sr-io/with_std.rs b/substrate/core/sr-io/with_std.rs index ccadb89efc..72fa107469 100644 --- a/substrate/core/sr-io/with_std.rs +++ b/substrate/core/sr-io/with_std.rs @@ -146,7 +146,7 @@ pub fn chain_id() -> u64 { pub fn storage_root() -> H256 { ext::with(|ext| ext.storage_root() - ).unwrap_or(H256::new()) + ).unwrap_or(H256::zero()) } /// "Commit" all existing operations and compute the resultant child storage root. diff --git a/substrate/core/sr-primitives/src/lib.rs b/substrate/core/sr-primitives/src/lib.rs index 42dcd37a2c..a8759a4890 100644 --- a/substrate/core/sr-primitives/src/lib.rs +++ b/substrate/core/sr-primitives/src/lib.rs @@ -198,7 +198,7 @@ pub struct Ed25519Signature(pub H512); impl Verify for Ed25519Signature { type Signer = H256; fn verify>(&self, mut msg: L, signer: &Self::Signer) -> bool { - runtime_io::ed25519_verify(&(self.0).0, msg.get(), &signer.0[..]) + runtime_io::ed25519_verify((self.0).as_fixed_bytes(), msg.get(), &signer.as_bytes()) } } diff --git a/substrate/core/sr-primitives/src/traits.rs b/substrate/core/sr-primitives/src/traits.rs index 0ee2db117a..5c568460ee 100644 --- a/substrate/core/sr-primitives/src/traits.rs +++ b/substrate/core/sr-primitives/src/traits.rs @@ -322,8 +322,8 @@ impl CheckEqual for substrate_primitives::H256 { #[cfg(feature = "std")] fn check_equal(&self, other: &Self) { use substrate_primitives::hexdisplay::HexDisplay; - if &self.0 != &other.0 { - println!("Hash: given={}, expected={}", HexDisplay::from(&self.0), HexDisplay::from(&other.0)); + if self != other { + println!("Hash: given={}, expected={}", HexDisplay::from(self.as_fixed_bytes()), HexDisplay::from(other.as_fixed_bytes())); } } @@ -331,8 +331,8 @@ impl CheckEqual for substrate_primitives::H256 { fn check_equal(&self, other: &Self) { if self != other { runtime_io::print("Hash not equal"); - runtime_io::print(&self.0[..]); - runtime_io::print(&other.0[..]); + runtime_io::print(self.as_bytes()); + runtime_io::print(other.as_bytes()); } } } diff --git a/substrate/core/state-db/src/lib.rs b/substrate/core/state-db/src/lib.rs index 598f0c4705..261d768560 100644 --- a/substrate/core/state-db/src/lib.rs +++ b/substrate/core/state-db/src/lib.rs @@ -363,14 +363,59 @@ mod tests { let mut db = make_db(&[91, 921, 922, 93, 94]); let state_db = StateDb::new(settings, &db).unwrap(); - db.commit(&state_db.insert_block::(&H256::from(1), 1, &H256::from(0), make_changeset(&[1], &[91])).unwrap()); - db.commit(&state_db.insert_block::(&H256::from(21), 2, &H256::from(1), make_changeset(&[21], &[921, 1])).unwrap()); - db.commit(&state_db.insert_block::(&H256::from(22), 2, &H256::from(1), make_changeset(&[22], &[922])).unwrap()); - db.commit(&state_db.insert_block::(&H256::from(3), 3, &H256::from(21), make_changeset(&[3], &[93])).unwrap()); - db.commit(&state_db.canonicalize_block(&H256::from(1))); - db.commit(&state_db.insert_block::(&H256::from(4), 4, &H256::from(3), make_changeset(&[4], &[94])).unwrap()); - db.commit(&state_db.canonicalize_block(&H256::from(21))); - db.commit(&state_db.canonicalize_block(&H256::from(3))); + db.commit( + &state_db + .insert_block::( + &H256::from_low_u64_be(1), + 1, + &H256::from_low_u64_be(0), + make_changeset(&[1], &[91]), + ) + .unwrap(), + ); + db.commit( + &state_db + .insert_block::( + &H256::from_low_u64_be(21), + 2, + &H256::from_low_u64_be(1), + make_changeset(&[21], &[921, 1]), + ) + .unwrap(), + ); + db.commit( + &state_db + .insert_block::( + &H256::from_low_u64_be(22), + 2, + &H256::from_low_u64_be(1), + make_changeset(&[22], &[922]), + ) + .unwrap(), + ); + db.commit( + &state_db + .insert_block::( + &H256::from_low_u64_be(3), + 3, + &H256::from_low_u64_be(21), + make_changeset(&[3], &[93]), + ) + .unwrap(), + ); + db.commit(&state_db.canonicalize_block(&H256::from_low_u64_be(1))); + db.commit( + &state_db + .insert_block::( + &H256::from_low_u64_be(4), + 4, + &H256::from_low_u64_be(3), + make_changeset(&[4], &[94]), + ) + .unwrap(), + ); + db.commit(&state_db.canonicalize_block(&H256::from_low_u64_be(21))); + db.commit(&state_db.canonicalize_block(&H256::from_low_u64_be(3))); (db, state_db) } diff --git a/substrate/core/state-db/src/noncanonical.rs b/substrate/core/state-db/src/noncanonical.rs index b6cd4862e7..b1d34c09ad 100644 --- a/substrate/core/state-db/src/noncanonical.rs +++ b/substrate/core/state-db/src/noncanonical.rs @@ -275,7 +275,7 @@ mod tests { use test::{make_db, make_changeset}; fn contains(overlay: &NonCanonicalOverlay, key: u64) -> bool { - overlay.get(&H256::from(key)) == Some(H256::from(key).to_vec()) + overlay.get(&H256::from_low_u64_be(key)) == Some(H256::from_low_u64_be(key).as_bytes().to_vec()) } #[test] diff --git a/substrate/core/state-db/src/test.rs b/substrate/core/state-db/src/test.rs index 3c83bb03cf..487a5c641d 100644 --- a/substrate/core/state-db/src/test.rs +++ b/substrate/core/state-db/src/test.rs @@ -62,8 +62,13 @@ impl TestDb { pub fn make_changeset(inserted: &[u64], deleted: &[u64]) -> ChangeSet { ChangeSet { - inserted: inserted.iter().map(|v| (H256::from(*v), H256::from(*v).to_vec())).collect(), - deleted: deleted.iter().map(|v| H256::from(*v)).collect(), + inserted: inserted + .iter() + .map(|v| { + (H256::from_low_u64_be(*v), H256::from_low_u64_be(*v).as_bytes().to_vec()) + }) + .collect(), + deleted: deleted.iter().map(|v| H256::from_low_u64_be(*v)).collect(), } } @@ -76,7 +81,12 @@ pub fn make_commit(inserted: &[u64], deleted: &[u64]) -> CommitSet { pub fn make_db(inserted: &[u64]) -> TestDb { TestDb { - data: inserted.iter().map(|v| (H256::from(*v), H256::from(*v).to_vec())).collect(), + data: inserted + .iter() + .map(|v| { + (H256::from_low_u64_be(*v), H256::from_low_u64_be(*v).as_bytes().to_vec()) + }) + .collect(), meta: Default::default(), } } diff --git a/substrate/core/state-machine/src/overlayed_changes.rs b/substrate/core/state-machine/src/overlayed_changes.rs index 15012ac66e..239dc0b438 100644 --- a/substrate/core/state-machine/src/overlayed_changes.rs +++ b/substrate/core/state-machine/src/overlayed_changes.rs @@ -371,7 +371,7 @@ mod tests { let changes_trie_storage = InMemoryChangesTrieStorage::new(); let mut ext = Ext::new(&mut overlay, &backend, Some(&changes_trie_storage)); const ROOT: [u8; 32] = hex!("0b41e488cccbd67d1f1089592c2c235f5c5399b053f7fe9152dd4b5f279914cd"); - assert_eq!(ext.storage_root(), H256(ROOT)); + assert_eq!(ext.storage_root(), H256::from(ROOT)); } #[test] diff --git a/substrate/core/state-machine/src/proving_backend.rs b/substrate/core/state-machine/src/proving_backend.rs index 6aa6eb9da3..a46fd74b5f 100644 --- a/substrate/core/state-machine/src/proving_backend.rs +++ b/substrate/core/state-machine/src/proving_backend.rs @@ -211,7 +211,8 @@ mod tests { #[test] fn proof_is_invalid_when_does_not_contains_root() { - assert!(create_proof_check_backend::(1.into(), vec![]).is_err()); + use primitives::H256; + assert!(create_proof_check_backend::(H256::from_low_u64_be(1), vec![]).is_err()); } #[test] diff --git a/substrate/core/state-machine/src/testing.rs b/substrate/core/state-machine/src/testing.rs index ea67773ed2..75ad342b6b 100644 --- a/substrate/core/state-machine/src/testing.rs +++ b/substrate/core/state-machine/src/testing.rs @@ -158,6 +158,6 @@ mod tests { ext.set_storage(b"dog".to_vec(), b"puppy".to_vec()); ext.set_storage(b"dogglesworth".to_vec(), b"cat".to_vec()); const ROOT: [u8; 32] = hex!("0b41e488cccbd67d1f1089592c2c235f5c5399b053f7fe9152dd4b5f279914cd"); - assert_eq!(ext.storage_root(), H256(ROOT)); + assert_eq!(ext.storage_root(), H256::from(ROOT)); } } diff --git a/substrate/core/state-machine/src/trie_backend.rs b/substrate/core/state-machine/src/trie_backend.rs index c40a5019f3..6dcaf3868e 100644 --- a/substrate/core/state-machine/src/trie_backend.rs +++ b/substrate/core/state-machine/src/trie_backend.rs @@ -212,7 +212,7 @@ pub mod tests { #[test] fn storage_root_is_non_default() { - assert!(test_trie().storage_root(::std::iter::empty()).0 != H256([0; 32])); + assert!(test_trie().storage_root(::std::iter::empty()).0 != H256::repeat_byte(0)); } #[test] diff --git a/substrate/core/test-client/src/block_builder_ext.rs b/substrate/core/test-client/src/block_builder_ext.rs index b2f15db739..11dd859c07 100644 --- a/substrate/core/test-client/src/block_builder_ext.rs +++ b/substrate/core/test-client/src/block_builder_ext.rs @@ -40,6 +40,6 @@ impl<'a, B, E> BlockBuilderExt for client::block_builder::BlockBuilder<'a, B, E, } fn sign_tx(transfer: runtime::Transfer) -> runtime::Extrinsic { - let signature = keyring::Keyring::from_raw_public(transfer.from.0.clone()).unwrap().sign(&codec::Encode::encode(&transfer)).into(); + let signature = keyring::Keyring::from_raw_public(transfer.from.to_fixed_bytes()).unwrap().sign(&codec::Encode::encode(&transfer)).into(); runtime::Extrinsic { transfer, signature } } diff --git a/substrate/core/test-runtime/src/genesismap.rs b/substrate/core/test-runtime/src/genesismap.rs index f212e2c86f..5e6adec86a 100644 --- a/substrate/core/test-runtime/src/genesismap.rs +++ b/substrate/core/test-runtime/src/genesismap.rs @@ -70,6 +70,6 @@ impl GenesisConfig { pub fn additional_storage_with_genesis(genesis_block: &::Block) -> HashMap, Vec> { map![ - twox_128(&b"latest"[..]).to_vec() => genesis_block.hash().0.to_vec() + twox_128(&b"latest"[..]).to_vec() => genesis_block.hash().as_fixed_bytes().to_vec() ] } diff --git a/substrate/core/test-runtime/src/system.rs b/substrate/core/test-runtime/src/system.rs index 6bc70368a1..a3041647d4 100644 --- a/substrate/core/test-runtime/src/system.rs +++ b/substrate/core/test-runtime/src/system.rs @@ -117,7 +117,7 @@ pub fn validate_transaction(utx: Extrinsic) -> TransactionValidity { } let hash = |from: &AccountId, nonce: u64| { - twox_128(&nonce.to_keyed_vec(&*from)).to_vec() + twox_128(&nonce.to_keyed_vec(from.as_bytes())).to_vec() }; let requires = if tx.nonce != expected_nonce && tx.nonce > 0 { let mut deps = Vec::new(); @@ -221,7 +221,11 @@ fn execute_transaction_backend(utx: &Extrinsic) -> ApplyResult { fn info_expect_equal_hash(given: &Hash, expected: &Hash) { use primitives::hexdisplay::HexDisplay; if given != expected { - println!("Hash: given={}, expected={}", HexDisplay::from(&given.0), HexDisplay::from(&expected.0)); + println!( + "Hash: given={}, expected={}", + HexDisplay::from(given.as_fixed_bytes()), + HexDisplay::from(expected.as_fixed_bytes()) + ); } } @@ -229,8 +233,8 @@ fn info_expect_equal_hash(given: &Hash, expected: &Hash) { fn info_expect_equal_hash(given: &Hash, expected: &Hash) { if given != expected { ::runtime_io::print("Hash not equal"); - ::runtime_io::print(&given.0[..]); - ::runtime_io::print(&expected.0[..]); + ::runtime_io::print(given.as_bytes()); + ::runtime_io::print(expected.as_bytes()); } } @@ -257,7 +261,7 @@ mod tests { } fn construct_signed_tx(tx: Transfer) -> Extrinsic { - let signature = Keyring::from_raw_public(tx.from.0).unwrap().sign(&tx.encode()).into(); + let signature = Keyring::from_raw_public(tx.from.to_fixed_bytes()).unwrap().sign(&tx.encode()).into(); Extrinsic { transfer: tx, signature } } diff --git a/substrate/core/test-runtime/wasm/Cargo.lock b/substrate/core/test-runtime/wasm/Cargo.lock index 990164654c..9e33aaa02e 100644 --- a/substrate/core/test-runtime/wasm/Cargo.lock +++ b/substrate/core/test-runtime/wasm/Cargo.lock @@ -84,6 +84,11 @@ name = "crunchy" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crunchy" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "elastic-array" version = "0.10.0" @@ -99,13 +104,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.2.2" +version = "0.3.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -406,11 +413,6 @@ dependencies = [ "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustc-hex" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "rustc-hex" version = "2.0.1" @@ -544,6 +546,11 @@ name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "static_assertions" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "substrate-metadata" version = "0.1.0" @@ -561,8 +568,8 @@ dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.9.0 (git+https://github.com/paritytech/trie)", "hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -574,7 +581,7 @@ dependencies = [ "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -672,11 +679,11 @@ dependencies = [ [[package]] name = "uint" -version = "0.4.1" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -751,9 +758,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" +"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" "checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb" "checksum environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db746025e3ea695bfa0ae744dbacd5fcfc8db51b9760cf8bd0ab69708bb93c49" -"checksum fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d5ec8112f00ea8a483e04748a85522184418fd1cf02890b626d8fc28683f7de" +"checksum fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e71c99c903a9fe54baed1bc701b43daba8c6dc6d4aec89a32f667ab6b3094c4" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" @@ -793,7 +801,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" -"checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "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 scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" @@ -803,12 +810,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" "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 syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.15.6 (registry+https://github.com/rust-lang/crates.io-index)" = "854b08a640fc8f54728fb95321e3ec485b365a97fe47609797c671addd1dde69" "checksum trie-db 0.9.0 (git+https://github.com/paritytech/trie)" = "" "checksum trie-root 0.9.0 (git+https://github.com/paritytech/trie)" = "" "checksum twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f85be565a110ed72ed7048cf56570db04ce0a592c98aa59b7dacde3e5718750" -"checksum uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646" +"checksum uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4630460173a57c0af94b8306091e018025d988473f641a4af754b6cde980e1e3" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" diff --git a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm index 736d1d423b..ff19b2bdf7 100644 Binary files a/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm and b/substrate/core/test-runtime/wasm/target/wasm32-unknown-unknown/release/substrate_test_runtime.compact.wasm differ diff --git a/substrate/core/transaction-pool/graph/src/pool.rs b/substrate/core/transaction-pool/graph/src/pool.rs index 9f343c23d1..fe1f2d2aee 100644 --- a/substrate/core/transaction-pool/graph/src/pool.rs +++ b/substrate/core/transaction-pool/graph/src/pool.rs @@ -358,7 +358,7 @@ mod tests { /// Hash the extrinsic. fn hash(&self, uxt: &ExtrinsicFor) -> Self::Hash { - (uxt.transfer.from.low_u64() << 5) + uxt.transfer.nonce + (uxt.transfer.from.to_low_u64_be() << 5) + uxt.transfer.nonce } } diff --git a/substrate/core/trie/src/lib.rs b/substrate/core/trie/src/lib.rs index 68dacf2668..06598ed63b 100644 --- a/substrate/core/trie/src/lib.rs +++ b/substrate/core/trie/src/lib.rs @@ -428,7 +428,7 @@ mod tests { #[test] fn random_should_work() { - let mut seed = ::Out::new(); + let mut seed = ::Out::zero(); for test_i in 0..10000 { if test_i % 50 == 0 { println!("{:?} of 10000 stress tests done", test_i); @@ -439,7 +439,7 @@ mod tests { journal_key: 0, value_mode: ValueMode::Index, count: 100, - }.make_with(&mut seed.0); + }.make_with(seed.as_fixed_bytes_mut()); let real = trie_root::(x.clone()); let mut memdb = MemoryDB::default(); diff --git a/substrate/node/cli/src/chain_spec.rs b/substrate/node/cli/src/chain_spec.rs index 53cf074767..5058f0de60 100644 --- a/substrate/node/cli/src/chain_spec.rs +++ b/substrate/node/cli/src/chain_spec.rs @@ -191,7 +191,7 @@ fn testnet_genesis(initial_authorities: Vec, upgrade_key: AccountId }), council_seats: Some(CouncilSeatsConfig { active_council: endowed_accounts.iter() - .filter(|a| initial_authorities.iter().find(|&b| a.0 == b.0).is_none()) + .filter(|a| initial_authorities.iter().find(|&b| a.as_bytes() == b.0).is_none()) .map(|a| (a.clone(), 1000000)).collect(), candidacy_bond: 10, voter_bond: 2, diff --git a/substrate/node/executor/src/lib.rs b/substrate/node/executor/src/lib.rs index 2e9bd1099d..fd68aadd51 100644 --- a/substrate/node/executor/src/lib.rs +++ b/substrate/node/executor/src/lib.rs @@ -268,7 +268,10 @@ mod tests { use trie::ordered_trie_root; let extrinsics = extrinsics.into_iter().map(sign).collect::>(); - let extrinsics_root = ordered_trie_root::(extrinsics.iter().map(Encode::encode)).0.into(); + let extrinsics_root = ordered_trie_root::(extrinsics.iter() + .map(Encode::encode)) + .to_fixed_bytes() + .into(); let mut digest = generic::Digest::::default(); if let Some(changes_root) = changes_root { diff --git a/substrate/node/runtime/src/lib.rs b/substrate/node/runtime/src/lib.rs index 6dad8ca740..d1afc82c44 100644 --- a/substrate/node/runtime/src/lib.rs +++ b/substrate/node/runtime/src/lib.rs @@ -145,7 +145,7 @@ impl timestamp::Trait for Runtime { pub struct SessionKeyConversion; impl Convert for SessionKeyConversion { fn convert(a: AccountId) -> SessionKey { - a.0.into() + a.to_fixed_bytes().into() } } diff --git a/substrate/node/runtime/wasm/Cargo.lock b/substrate/node/runtime/wasm/Cargo.lock index dc519d15fb..355963104b 100644 --- a/substrate/node/runtime/wasm/Cargo.lock +++ b/substrate/node/runtime/wasm/Cargo.lock @@ -84,6 +84,11 @@ name = "crunchy" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "crunchy" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "elastic-array" version = "0.10.0" @@ -99,13 +104,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "fixed-hash" -version = "0.2.2" +version = "0.3.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)", - "rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "static_assertions 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -458,11 +465,6 @@ dependencies = [ "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustc-hex" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "rustc-hex" version = "2.0.1" @@ -840,6 +842,11 @@ name = "stable_deref_trait" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "static_assertions" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "substrate-keyring" version = "0.1.0" @@ -866,8 +873,8 @@ dependencies = [ "base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", - "fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)", "hash-db 0.9.0 (git+https://github.com/paritytech/trie)", "hash256-std-hasher 0.9.0 (git+https://github.com/paritytech/trie)", "hex-literal 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -879,7 +886,7 @@ dependencies = [ "serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)", "sr-std 0.1.0", "twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)", "untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "wasmi 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -960,11 +967,11 @@ dependencies = [ [[package]] name = "uint" -version = "0.4.1" +version = "0.5.0-beta.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", + "crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1039,9 +1046,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" "checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" "checksum crunchy 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a2f4a431c5c9f662e1200b7c7f02c34e91361150e382089a8f2dec3ba680cbda" +"checksum crunchy 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c240f247c278fa08a6d4820a6a222bfc6e0d999e51ba67be94f44c905b2161f2" "checksum elastic-array 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "88d4851b005ef16de812ea9acdb7bece2f0a40dd86c07b85631d7dafa54537bb" "checksum environmental 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db746025e3ea695bfa0ae744dbacd5fcfc8db51b9760cf8bd0ab69708bb93c49" -"checksum fixed-hash 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0d5ec8112f00ea8a483e04748a85522184418fd1cf02890b626d8fc28683f7de" +"checksum fixed-hash 0.3.0-beta.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4e71c99c903a9fe54baed1bc701b43daba8c6dc6d4aec89a32f667ab6b3094c4" "checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" @@ -1082,7 +1090,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rayon 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b614fe08b6665cb9a231d07ac1364b0ef3cb3698f1239ee0c4c3a88a524f54c8" "checksum rayon-core 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b055d1e92aba6877574d8fe604a63c8b5df60f60e5982bf7ccbb1338ea527356" "checksum ring 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6f7d28b30a72c01b458428e0ae988d4149c20d902346902be881e3edc4bb325c" -"checksum rustc-hex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0ceb8ce7a5e520de349e1fa172baeba4a9e8d5ef06c47471863530bc4972ee1e" "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 safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7f7bf422d23a88c16d5090d455f182bc99c60af4df6a345c63428acf5129e347" @@ -1093,12 +1100,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_derive 1.0.79 (registry+https://github.com/rust-lang/crates.io-index)" = "31569d901045afbff7a9479f793177fe9259819aff10ab4f89ef69bbc5f567fe" "checksum smallvec 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "153ffa32fd170e9944f7e0838edf824a754ec4c1fc64746fcc9fe1f8fa602e5d" "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 syn 0.14.9 (registry+https://github.com/rust-lang/crates.io-index)" = "261ae9ecaa397c42b960649561949d69311f08eeaea86a65696e6e46517cf741" "checksum syn 0.15.6 (registry+https://github.com/rust-lang/crates.io-index)" = "854b08a640fc8f54728fb95321e3ec485b365a97fe47609797c671addd1dde69" "checksum trie-db 0.9.0 (git+https://github.com/paritytech/trie)" = "" "checksum trie-root 0.9.0 (git+https://github.com/paritytech/trie)" = "" "checksum twox-hash 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4f85be565a110ed72ed7048cf56570db04ce0a592c98aa59b7dacde3e5718750" -"checksum uint 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "754ba11732b9161b94c41798e5197e5e75388d012f760c42adb5000353e98646" +"checksum uint 0.5.0-beta.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4630460173a57c0af94b8306091e018025d988473f641a4af754b6cde980e1e3" "checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum untrusted 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f392d7819dbe58833e26872f5f6f0d68b7bbbe90fc3667e98731c4a15ad9a7ae" diff --git a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm index 5021eb25b6..36962bb6a1 100644 Binary files a/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm and b/substrate/node/runtime/wasm/target/wasm32-unknown-unknown/release/node_runtime.compact.wasm differ