From 3fafe505a16095ece15bcd366838564332f040e4 Mon Sep 17 00:00:00 2001 From: hyphae-bot Date: Wed, 29 Apr 2026 06:18:54 -0700 Subject: [PATCH] fix(consensus): wrap funding stream address index to prevent out-of-bounds panic --- .../zebra-consensus/src/block/subsidy/funding_streams.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zebra-crosslink/zebra-consensus/src/block/subsidy/funding_streams.rs b/zebra-crosslink/zebra-consensus/src/block/subsidy/funding_streams.rs index bf73d567..2c57535a 100644 --- a/zebra-crosslink/zebra-consensus/src/block/subsidy/funding_streams.rs +++ b/zebra-crosslink/zebra-consensus/src/block/subsidy/funding_streams.rs @@ -36,10 +36,10 @@ fn funding_stream_address_index( )) .expect("no overflow should happen in this sub") as usize; - assert!(index > 0 && index <= num_addresses); - // spec formula will output an index starting at 1 but - // Zebra indices for addresses start at zero, return converted. - Some(index - 1) + assert!(index > 0); + // Wrap the index to prevent out-of-bounds panic when the address + // period spans more intervals than there are addresses (Crosslink fix). + Some((index - 1) % num_addresses) } /// Return the address corresponding to given height, network and funding stream receiver.