diff --git a/chain/src/txhashset/bitmap_accumulator.rs b/chain/src/txhashset/bitmap_accumulator.rs index ed87442b4f..5aab93cf42 100644 --- a/chain/src/txhashset/bitmap_accumulator.rs +++ b/chain/src/txhashset/bitmap_accumulator.rs @@ -340,7 +340,7 @@ impl From for Segment { } for (block_idx, block) in blocks.into_iter().enumerate() { - assert_eq!(block.inner.len(), BitmapBlock::NBITS as usize); + assert!(block.inner.len() <= BitmapBlock::NBITS as usize); let offset = block_idx * BitmapBlock::NCHUNKS; for (i, _) in block.inner.iter().enumerate().filter(|&(_, v)| v) { chunks @@ -412,7 +412,7 @@ impl Writeable for BitmapBlock { // Write raw bytes Writeable::write(&BitmapBlockSerialization::Raw, writer)?; let bytes = self.inner.to_bytes(); - assert_eq!(bytes.len(), Self::NBITS as usize / 8); + assert!(bytes.len() <= Self::NBITS as usize / 8); writer.write_fixed_bytes(&bytes)?; } diff --git a/core/src/core/pmmr/segment.rs b/core/src/core/pmmr/segment.rs index 33e3469729..771eaf3be7 100644 --- a/core/src/core/pmmr/segment.rs +++ b/core/src/core/pmmr/segment.rs @@ -464,6 +464,7 @@ where last_pos: u64, bitmap: Option<&Bitmap>, mmr_root: Hash, + hash_last_pos: u64, other_root: Hash, other_is_left: bool, ) -> Result<(), SegmentError> { @@ -476,6 +477,7 @@ where last, segment_root, segment_unpruned_pos, + hash_last_pos, other_root, other_is_left, ) @@ -708,6 +710,7 @@ impl SegmentProof { segment_last_pos: u64, segment_root: Hash, segment_unpruned_pos: u64, + hash_last_pos: u64, other_root: Hash, other_is_left: bool, ) -> Result<(), SegmentError> { @@ -719,9 +722,9 @@ impl SegmentProof { segment_unpruned_pos, )?; let root = if other_is_left { - (other_root, root).hash_with_index(last_pos) + (other_root, root).hash_with_index(hash_last_pos) } else { - (root, other_root).hash_with_index(last_pos) + (root, other_root).hash_with_index(hash_last_pos) }; if root == mmr_root { Ok(()) diff --git a/servers/src/common/adapters.rs b/servers/src/common/adapters.rs index 05daf28581..4043207eaa 100644 --- a/servers/src/common/adapters.rs +++ b/servers/src/common/adapters.rs @@ -539,7 +539,7 @@ where hash: Hash, id: SegmentIdentifier, ) -> Result, chain::Error> { - if RANGEPROOF_SEGMENT_HEIGHT_RANGE.contains(&id.height) { + if !RANGEPROOF_SEGMENT_HEIGHT_RANGE.contains(&id.height) { return Err(chain::ErrorKind::InvalidSegmentHeight.into()); } let segmenter = self.chain().segmenter()?;