From b57fd1799817c72abac6da0b12a44b2434e0146f Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Sun, 15 Mar 2020 21:19:01 +0200 Subject: [PATCH] Fix genesis bug in bench db (#5253) --- substrate/client/db/src/bench.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/substrate/client/db/src/bench.rs b/substrate/client/db/src/bench.rs index b6a6b3f8d4..05ec51f1c8 100644 --- a/substrate/client/db/src/bench.rs +++ b/substrate/client/db/src/bench.rs @@ -51,6 +51,7 @@ impl sp_state_machine::Storage> for StorageDb { path: PathBuf, root: Cell, + genesis_root: B::Hash, state: RefCell>>, db: Cell>>, genesis: as StateBackend>>::Transaction, @@ -74,6 +75,7 @@ impl BenchmarkingState { path, root: Cell::new(root), genesis: Default::default(), + genesis_root: Default::default(), }; state.reopen()?; @@ -82,11 +84,12 @@ impl BenchmarkingState { child_content.data.into_iter().map(|(k, v)| (k, Some(v))), child_content.child_info )); - let (root, transaction) = state.state.borrow_mut().as_mut().unwrap().full_storage_root( + let (root, transaction): (B::Hash, _) = state.state.borrow_mut().as_mut().unwrap().full_storage_root( genesis.top.into_iter().map(|(k, v)| (k, Some(v))), child_delta, ); state.genesis = transaction.clone(); + state.genesis_root = root.clone(); state.commit(root, transaction)?; Ok(state) } @@ -273,7 +276,7 @@ impl StateBackend> for BenchmarkingState { fn wipe(&self) -> Result<(), Self::Error> { self.kill()?; self.reopen()?; - self.commit(self.root.get(), self.genesis.clone())?; + self.commit(self.genesis_root.clone(), self.genesis.clone())?; Ok(()) } } @@ -283,4 +286,3 @@ impl std::fmt::Debug for BenchmarkingState { write!(f, "DB at {:?}", self.path) } } -