diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index ced8c736c..b9348c997 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -373,15 +373,18 @@ impl Client where V: Verifier { let block_number = self.block_number(id.clone()); - // check that the block is not too old -- blocks within `HISTORY` blocks of the best will - // always be available. - if self.state_db.does_pruning() && self.best_block_number() >= block_number + HISTORY { - return None; - } + self.block_header(id).and_then(|header| { + let root = HeaderView::new(&header).state_root(); + // check that the block is not too old -- blocks within `HISTORY` blocks of the best will + // always be available. If the block could be too old, check if its state root is valid. + if self.state_db.does_pruning() + && self.best_block_number() >= block_number + HISTORY + && self.state_db.exists(root) { + return None; + } - self.block_header(id).map(|header| { let db = self.state_db.lock().unwrap().boxed_clone(); - State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce()) + Some(State::from_existing(db, HeaderView::new(&header).state_root(), self.engine.account_start_nonce())) }) }