From 2222b2898140cc272e7280afd8cacd6150e027ff Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Thu, 12 Oct 2017 19:23:58 +0000 Subject: [PATCH] Dump sumtrees state on error --- chain/src/pipe.rs | 1 + chain/src/sumtree.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/chain/src/pipe.rs b/chain/src/pipe.rs index f04314e58..8247ca831 100644 --- a/chain/src/pipe.rs +++ b/chain/src/pipe.rs @@ -265,6 +265,7 @@ fn validate_block(b: &Block, if utxo_root.hash != b.header.utxo_root || rproof_root.hash != b.header.range_proof_root || kernel_root.hash != b.header.kernel_root { + ext.dump(); return Err(Error::InvalidRoot); } diff --git a/chain/src/sumtree.rs b/chain/src/sumtree.rs index 561ae4e3b..abd48447a 100644 --- a/chain/src/sumtree.rs +++ b/chain/src/sumtree.rs @@ -284,6 +284,16 @@ impl<'a> Extension<'a> { self.rollback = true; } + /// Dumps the state of the 3 sum trees to stdout for debugging + pub fn dump(&self) { + println!("-- outputs --"); + self.output_pmmr.dump(); + println!("-- range proofs --"); + self.rproof_pmmr.dump(); + println!("-- kernels --"); + self.kernel_pmmr.dump(); + } + // Sizes of the sum trees, used by `extending` on rollback. fn sizes(&self) -> (u64, u64, u64) { (self.output_pmmr.unpruned_size(),