From fe2d0af06492be59fbfb9896353c0a8b43254994 Mon Sep 17 00:00:00 2001 From: yito88 Date: Mon, 13 Nov 2023 21:59:32 +0100 Subject: [PATCH] fix to get proofs even if no height is specified --- .../bug-fixes/2166-fix-proof-height.md | 2 ++ core/src/ledger/storage/mod.rs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 .changelog/unreleased/bug-fixes/2166-fix-proof-height.md diff --git a/.changelog/unreleased/bug-fixes/2166-fix-proof-height.md b/.changelog/unreleased/bug-fixes/2166-fix-proof-height.md new file mode 100644 index 0000000000..9c096ff531 --- /dev/null +++ b/.changelog/unreleased/bug-fixes/2166-fix-proof-height.md @@ -0,0 +1,2 @@ +- Fix to get the proof even if no height is specified + ([\#2166](https://github.com/anoma/namada/issues/2166)) \ No newline at end of file diff --git a/core/src/ledger/storage/mod.rs b/core/src/ledger/storage/mod.rs index d12352ee71..f82eee1cfc 100644 --- a/core/src/ledger/storage/mod.rs +++ b/core/src/ledger/storage/mod.rs @@ -808,6 +808,13 @@ where height: BlockHeight, store_type: Option, ) -> Result> { + // `0` means last committed height + let height = if height == BlockHeight(0) { + self.get_last_block_height() + } else { + height + }; + let epoch = self .block .pred_epochs @@ -935,6 +942,13 @@ where ) -> Result { use std::array; + // `0` means last committed height + let height = if height == BlockHeight(0) { + self.get_last_block_height() + } else { + height + }; + if height > self.get_last_block_height() { if let MembershipProof::ICS23(proof) = self .block @@ -972,6 +986,13 @@ where key: &Key, height: BlockHeight, ) -> Result { + // `0` means last committed height + let height = if height == BlockHeight(0) { + self.get_last_block_height() + } else { + height + }; + if height > self.get_last_block_height() { Err(Error::Temporary { error: format!(