From d4670375f8899d0d67941758a5ecef55a29ee6bb Mon Sep 17 00:00:00 2001 From: skoupidi Date: Wed, 23 Jul 2025 13:14:35 +0300 Subject: [PATCH] blockchain/mod.rs: bound randomx vm keys to be before optional height --- src/blockchain/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/blockchain/mod.rs b/src/blockchain/mod.rs index 2f51d67b4..8872bbdf4 100644 --- a/src/blockchain/mod.rs +++ b/src/blockchain/mod.rs @@ -434,7 +434,7 @@ impl Blockchain { /// Grab the RandomX VM current and next key, based on provided key /// changing height and delay. Optionally, a height can be provided - /// to get the keys at it. + /// to get the keys before it. /// /// NOTE: the height calculation logic is verified using test: // test_randomx_keys_retrieval_logic @@ -446,7 +446,7 @@ impl Blockchain { ) -> Result<([u8; 32], [u8; 32])> { // Grab last known block header let last = match height { - Some(h) => &self.get_headers_by_heights(&[h])?[0], + Some(h) => &self.get_headers_by_heights(&[if h != 0 { h - 1 } else { 0 }])?[0], None => &self.last_header()?, };