feat(consensus): implement ZIP 235 behind a build feature - #858
Closed
evan-forbes wants to merge 5 commits into
Closed
feat(consensus): implement ZIP 235 behind a build feature#858evan-forbes wants to merge 5 commits into
evan-forbes wants to merge 5 commits into
Conversation
Implements ZIP 235 "Network Sustainability Mechanism: Burning of Transaction Fees", gated on the new `zip235` cargo feature. The feature enables `zip233`, because ZIP 233's `zip233Amount` field carries the burn, and because ZIP 235 must deploy at the same time as or after it. - `minimum_fee_burn` is `floor(block_miner_fees * 6 / 10)`, the ZIP's 60% with the rounding in the miner's favour. - `miner_fees_are_valid` rejects a coinbase whose `zip233Amount` is below that minimum, from NU7 activation onwards. It also adds the coinbase's own `zip233Amount` to its total output value: that value comes out of the same block subsidy and fees as its outputs. - `TransactionTemplate::new_coinbase` burns exactly the minimum and pays the miner the block subsidy plus the remaining 40% of the fees. Burning more is the miner's to choose, not this node's.
Merges the ZIP 233 feature fix and carries it into ZIP 235: - `ZIP235_ENABLED` requires `ZIP233_ENABLED`, so it is false in a build that sets the feature without `RUSTFLAGS='--cfg zcash_unstable="nu7"'`, where the `zip233Amount` field that carries the burn does not exist. - The `Builder::set_zip233_amount` call is gated on the cfg as well as the feature, because that is exactly when `zakura-primitives` compiles the setter. `cargo check --all-features` sets the feature but not the cfg, so gating on the feature alone failed to compile. `TransactionTemplate::new_coinbase` takes the money reserve, so `zakura-rpc` takes a major version bump.
The comments quoted "Network Sustainability Mechanism: Burning of Transaction Fees", which is not ZIP 235's title. ZIP 235 is "Remove 60% of Transaction Fees From Circulation", and unlike ZIPs 233 and 234 it does not carry the "Network Sustainability Mechanism" prefix.
# Conflicts: # crates/zakurad/Cargo.toml
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #857 (ZIP 233) → #856 (ZIP 2003) → #851 (ZIP 218). Fourth of the remaining NU7 consensus changes.
Implements ZIP 235 "Remove 60% of Transaction Fees From Circulation" behind the off-by-default
zip235cargo feature, which enableszip233because that ZIP'szip233Amountfield carries the burn, and because ZIP 235 "MUST be deployed at the same time or after ZIP 233".Ported from the merged upstream zebra#10357. ZIP 235 is on the
zcash/zipsNU7 milestone rather than the poll ballot, but it is the third leg of the NSM alongside ZIPs 233 and 234.Consensus
minimum_fee_burnisfloor(block_miner_fees * 6 / 10)— the ZIP's 60%, with the rounding in the miner's favour.miner_fees_are_validrejects a coinbase whosezip233Amountis below that minimum, from NU7 activation onwards.zip233Amountto its total output value, because that value comes out of the same block subsidy and fees as its outputs. Without this a compliant coinbase would fail the NU6 "total output MUST equal total input" rule.Block templates
TransactionTemplate::new_coinbaseburns exactly the minimum and pays the miner the block subsidy plus the remaining 40% of the fees, so a template this node produces passes its own verifier. Burning more than the minimum is the miner's choice to make, not this node's, so templates do not.The burn is set through
Builder::set_zip233_amountafter the outputs are added, so the builder's value balance already reflects the reduced miner reward. That setter only exists in a build that compileszakura-primitives' ZIP 233 code, so the call is#[cfg(feature = "zip235")].Tests
zip235_coinbase_must_burn_sixty_percent_of_feescovers the boundary in both build configurations: burning exactly 600 of 1000 zatoshi in fees is valid, burning more is valid, and burning 599 or nothing is rejected withInsufficientFeeBurnunder the feature. Without the feature there is no minimum, and the test asserts the burn still balances against the coinbase's total output value.Both configurations pass all 731 tests across
zakura-chain,zakura-consensus, andzakura-rpc; clippy clean. Azip235CI job mirrors thezip233one.