diff --git a/zebra-consensus/src/block/check.rs b/zebra-consensus/src/block/check.rs index 70340678326..e01df642d3c 100644 --- a/zebra-consensus/src/block/check.rs +++ b/zebra-consensus/src/block/check.rs @@ -261,7 +261,7 @@ pub fn miner_fees_are_valid( .map_err(|_| SubsidyError::SumOverflow)?; let should_allow_unclaimed_subsidy = - NetworkUpgrade::current(network, height) <= NetworkUpgrade::Nu5; + NetworkUpgrade::current(network, height) < NetworkUpgrade::Nu6; if if should_allow_unclaimed_subsidy { left > right diff --git a/zebra-consensus/src/block/subsidy/funding_streams.rs b/zebra-consensus/src/block/subsidy/funding_streams.rs index e4577a75ea5..9dd2bcf6122 100644 --- a/zebra-consensus/src/block/subsidy/funding_streams.rs +++ b/zebra-consensus/src/block/subsidy/funding_streams.rs @@ -35,7 +35,7 @@ pub fn funding_stream_values( let range = FUNDING_STREAM_HEIGHT_RANGES.get(&network.kind()).unwrap(); if range.contains(&height) { let block_subsidy = block_subsidy(height, network)?; - let funding_stream_numerators = if current_network_upgrade <= Nu5 { + let funding_stream_numerators = if current_network_upgrade < Nu6 { PRE_NU6_FUNDING_STREAM_RECEIVER_NUMERATORS.iter() } else { POST_NU6_FUNDING_STREAM_RECEIVER_NUMERATORS.iter() diff --git a/zebra-consensus/src/block/subsidy/general.rs b/zebra-consensus/src/block/subsidy/general.rs index d7013c84ed4..a40620642a8 100644 --- a/zebra-consensus/src/block/subsidy/general.rs +++ b/zebra-consensus/src/block/subsidy/general.rs @@ -7,7 +7,10 @@ use std::collections::HashSet; use zebra_chain::{ amount::{Amount, Error, NonNegative}, block::{Height, HeightDiff}, - parameters::{Network, NetworkUpgrade::*}, + parameters::{ + Network, + NetworkUpgrade::{self, *}, + }, transaction::Transaction, }; @@ -108,6 +111,40 @@ pub fn miner_subsidy(height: Height, network: &Network) -> Result Amount { + let Some(nu6_activation_height) = NetworkUpgrade::Nu6.activation_height(network) else { + return Amount::zero(); + }; + + let &deferred_amount_per_block = funding_stream_values(nu6_activation_height, network) + .expect("we always expect a funding stream hashmap response even if empty") + .get(&FundingStreamReceiver::Deferred) + .expect("we expect a lockbox funding stream after NU5"); + + let funding_stream_height_range = FUNDING_STREAM_HEIGHT_RANGES + .get(&network.kind()) + .expect("must have funding stream height range on all networks"); + + // `min(height, last_height_with_deferred_pool_contribution) - (nu6_activation_height - 1)`, + // funding stream height range end bound is not incremented since it's an exclusive end bound + let num_blocks_with_lockbox_output = height + .next() + .expect("should be a valid height") + .min(funding_stream_height_range.end) + - nu6_activation_height; + + (deferred_amount_per_block + * u64::try_from(num_blocks_with_lockbox_output) + .expect("num blocks with lockbox funding stream should fit in u64")) + .expect("lockbox input value should fit in Amount") +} + /// Returns all output amounts in `Transaction`. pub fn output_amounts(transaction: &Transaction) -> HashSet> { transaction