From d19bdb642e3c9f4c0bc751a913281f3a45709d56 Mon Sep 17 00:00:00 2001 From: Anton Gavrilov Date: Thu, 6 Dec 2018 11:02:15 +0100 Subject: [PATCH] Sort the storage for private state (#10018) --- ethcore/private-tx/src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ethcore/private-tx/src/lib.rs b/ethcore/private-tx/src/lib.rs index 5e480b7ed..5f7b5cde3 100644 --- a/ethcore/private-tx/src/lib.rs +++ b/ethcore/private-tx/src/lib.rs @@ -68,7 +68,7 @@ pub use messages::{PrivateTransaction, SignedPrivateTransaction}; pub use error::{Error, ErrorKind}; use std::sync::{Arc, Weak}; -use std::collections::{HashMap, HashSet}; +use std::collections::{HashMap, HashSet, BTreeMap}; use std::time::Duration; use ethereum_types::{H128, H256, U256, Address}; use hash::keccak; @@ -474,7 +474,9 @@ impl Provider where { fn snapshot_from_storage(storage: &HashMap) -> Bytes { let mut raw = Vec::with_capacity(storage.len() * 64); - for (key, value) in storage { + // Sort the storage to guarantee the order for all parties + let sorted_storage: BTreeMap<&H256, &H256> = storage.iter().collect(); + for (key, value) in sorted_storage { raw.extend_from_slice(key); raw.extend_from_slice(value); };