Skip to content

Conversation

@mariopil
Copy link
Contributor

Motivation

This PR implements ZIP-234 and ZIP-235.

Specifications & References

ZIP-234, ZIP-235

Solution

This PR is implemented above #8930 which implements the ZIP-233. It smoothes the issuance curve (ZIP-234) and introduces the split between miner fees (40%) and the amount that is burned (60%, ZIP-235). Some of the code used in the block semantical verification for block subsidy calculation has been moved into the write task, as now the block subsidy calculation relies on the current amount of money_reserve which is obtained from pool value balance at height-1- therefore the previous block must be already present at least in the non-finalized best chain.

Tests

For testing purposes, a local testnet network was set up. It contained two nodes—a zebra and a zcashd one (with the ZIP-234 & 235 implemented, too, PR zcash/zcash#6970). A transaction in a new format containing the burn_amount field was created and added to the block by zcashd. The zebra node synced with zcashd without any errors and accepted the block.

A couple of unit tests were also added.

Follow-up Work

PR Author's Checklist

  • The PR name will make sense to users.
  • The PR provides a CHANGELOG summary.
  • The solution is tested.
  • The documentation is up to date.
  • The PR has a priority label.

PR Reviewer's Checklist

  • The PR Author's checklist is complete.
  • The PR resolves the issue.

@mariopil mariopil requested review from a team as code owners October 18, 2024 13:14
@mariopil mariopil requested review from upbqdn and removed request for a team October 18, 2024 13:14
@mpguerra mpguerra requested review from arya2 and conradoplg October 21, 2024 07:40
@arya2 arya2 added the do-not-merge Tells Mergify not to merge this PR label Oct 26, 2024
@mariopil mariopil force-pushed the nsm-zip-234-235 branch 2 times, most recently from 1ba587c to bb23624 Compare November 5, 2024 11:46
@arya2 arya2 removed the do-not-merge Tells Mergify not to merge this PR label Dec 7, 2024
@mpguerra mpguerra added the no-review-reminders Turn off review reminders label Jan 13, 2025
@jackgavigan
Copy link
Contributor

jackgavigan commented Jan 16, 2025

@mariopil Does this PR need to be refreshed when the NSM ZIPs are finalized?

@mariopil
Copy link
Contributor Author

@mariopil Does this PR need to be refreshed when the NSM ZIPs are finalized?

Yes. Currently, the implementation of both 234 and 235 zips is under one feature flag, but they will be covered by separate feature flags.

Copy link
Collaborator

@conradoplg conradoplg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a first pass review, I mostly looked into the feature gating and overall structure

(block::Height(903_000), Heartwood),
(block::Height(1_046_400), Canopy),
(block::Height(1_687_104), Nu5),
// TODO: Update NU6 activation height once it's been specified.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: Update NU6 activation height once it's been specified.

Comment on lines 309 to 321
#[cfg(zcash_unstable = "nsm")]
pub fn has_burn_amount(&self) -> bool {
self.burn_amount() > Amount::<NonNegative>::zero()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"burn" reference

Comment on lines 121 to 122
// > The NSM burn_amount field [ZIP-233] must be set at minimum to 60% of miner fees [ZIP-235].
burn_amount: burn_amount.unwrap_or_else(|| ((miner_fee * 6).unwrap() / 10).unwrap()),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"burn" mentioned

let orchard_shielded_data = (&mut limited_reader).zcash_deserialize_into()?;

// Denoted as `burn_amount` in the spec.
let burn_amount = (&mut limited_reader).zcash_deserialize_into()?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"burn" mentioned

.field(&"private")
.finish(),
Witnessed(_id) => f.debug_tuple("WtxId").field(&"private").finish(),
Witnessed(id) => f.debug_tuple("WtxId").field(id).finish(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Witnessed(id) => f.debug_tuple("WtxId").field(id).finish(),
Witnessed(_id) => f.debug_tuple("WtxId").field(&"private").finish(),

Please don't change unrelated code

Comment on lines -611 to -622
// We can't get the block subsidy for blocks with heights in the slow start interval, so we
// omit the calculation of the expected deferred amount.
let expected_deferred_amount = if height > self.network.slow_start_interval() {
// See [ZIP-1015](https://zips.z.cash/zip-1015).
funding_stream_values(height, &self.network, block_subsidy(height, &self.network)?)?
.remove(&FundingStreamReceiver::Deferred)
} else {
None
};

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to zebra-state/src/service/write.rs write, write_blocks_from_channels().

// Get the `value_balance` to calculate the transaction fee.
let value_balance = tx.value_balance(&spent_utxos);

let burn_amount = match *tx {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"burn" mentioned


let burn_amount = match *tx {
#[cfg(zcash_unstable = "nsm")]
Transaction::ZFuture{ .. } => tx.burn_amount(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"burn" mentioned - sorry, at this point it's better for you to simply search for all instances of it

Copy link

@giddie giddie Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we've only just submitted PRs to adjust the ZIPs. We've not adjusted this code yet, especially since only 233 is targeted for inclusion in NU7.

block_time in datetime_full(),
relative_source_fund_heights in vec(0.0..1.0, 1..=MAX_TRANSPARENT_INPUTS),
transaction_version in 4_u8..=5,
transaction_version in 4_u8..=6,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be feature-gated

finalized_state: &ZebraDb,
non_finalized_state: &mut NonFinalizedState,
prepared: SemanticallyVerifiedBlock,
prepared: &mut SemanticallyVerifiedBlock,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document what is modified in the block

@oxarbitrage oxarbitrage added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Feb 3, 2025
@conradoplg conradoplg added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Jul 10, 2025
@conradoplg conradoplg added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Jul 22, 2025
@natalieesk natalieesk removed the request for review from upbqdn August 7, 2025 16:21
@oxarbitrage oxarbitrage added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Aug 7, 2025
@oxarbitrage oxarbitrage added do-not-merge Tells Mergify not to merge this PR and removed do-not-merge Tells Mergify not to merge this PR labels Oct 14, 2025
@conradoplg
Copy link
Collaborator

Needs rebasing/conflict solving

@arya2 arya2 added the do-not-merge Tells Mergify not to merge this PR label Nov 17, 2025
/// > transaction as the first transaction in the block.
///
/// <https://zips.z.cash/protocol/protocol.pdf#coinbasetransactions>
pub fn coinbase_is_first(block: &Block) -> Result<Arc<transaction::Transaction>, BlockError> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to zebra-state/src/service/check.rs

/// Returns `Ok(())` if the miner fees consensus rule is valid.
///
/// [7.1.2]: https://zips.z.cash/protocol/protocol.pdf#txnconsensus
pub fn miner_fees_are_valid(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to zebra-state/src/service/check.rs

/// the block subsidy in `block` is valid for `network`
///
/// [3.9]: https://zips.z.cash/protocol/protocol.pdf#subsidyconcepts
pub fn subsidy_is_valid(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to zebra-state/src/service/check.rs

@mariopil
Copy link
Contributor Author

The PR has been rebased and updated

@arya2 arya2 removed the do-not-merge Tells Mergify not to merge this PR label Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-review-reminders Turn off review reminders

Projects

None yet

7 participants