Skip to content

docs: add pre-Canopy consensus check audit#10441

Open
zmanian wants to merge 4 commits intoZcashFoundation:mainfrom
zmanian:audit/pre-canopy-checks
Open

docs: add pre-Canopy consensus check audit#10441
zmanian wants to merge 4 commits intoZcashFoundation:mainfrom
zmanian:audit/pre-canopy-checks

Conversation

@zmanian
Copy link
Copy Markdown
Contributor

@zmanian zmanian commented Mar 30, 2026

Motivation

Closes #10184

As Zebra becomes the single Zcash node implementation, it is important to explicitly document which consensus rules are not enforced for pre-Canopy blocks (which rely on mandatory checkpoint verification).

Solution

Added pre-canopy-check-audit.md with a systematic audit of all upgrade-gated and semantic-only consensus checks across zebra-consensus, zebra-state, and zebra-chain.

Key Findings

  • 12 checks documented: upgrade-gated rules, semantic-only checks, and their risk assessments
  • 2 explicitly documented validation gaps:
    1. Pre-Heartwood coinbase Output description prohibition (code comment acknowledges this)
    2. Block header commitment contextual equality validation (Sapling root, chain history root)
  • Checkpoint verifier coverage: PoW, equihash, difficulty, Merkle root, duplicate tx detection, and transaction network upgrade consistency are all enforced even for checkpointed blocks
  • Future concerns: detailed list of checks that would need attention if mandatory checkpoint height is ever lowered or custom testnets skip pre-Canopy checkpoints

Methodology

  • Systematically searched zebra-consensus/src/ and zebra-state/src/service/check.rs for NetworkUpgrade comparisons, height-gated logic, and checkpoint vs semantic verification paths
  • Cross-referenced checkpoint verifier (checkpoint.rs:579-633) to distinguish checks that ARE enforced from those that are not
  • Verified all line numbers and code references against source

AI Disclosure

Used Claude Code for codebase search and initial finding enumeration. All findings were cross-referenced against source code and reviewed with multiple rounds of code review (both automated and manual).

zmanian and others added 4 commits March 5, 2026 08:17
Add comprehensive unit tests for policy functions added in ZcashFoundation#10314:
- count_script_push_ops: PUSHDATA1/2/4, mixed types, truncated scripts
- extract_p2sh_redeemed_script: existing + edge cases
- script_sig_args_expected: P2PK, multisig via script classification
- are_inputs_standard: P2PKH accept/reject, wrong stack depth,
  non-standard spent outputs, P2SH with standard/non-standard redeemed
  scripts, sigops boundary, multi-input rejection
- p2sh_sigop_count: P2SH/non-P2SH/multi-input summation

Also adds defensive improvements:
- saturating_add for sigop count arithmetic
- debug_assert_eq for input/spent_output alignment
- Expanded doc comments with correctness notes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove unnecessary Hash derive from NonStandardTransactionError
- Move p2pkh_lock_script, p2sh_lock_script, p2pk_lock_script to module
  level in policy.rs as #[cfg(test)] pub(super) functions, eliminating
  duplication between policy::tests and tests::vectors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Systematic audit of consensus checks in zebra-consensus and zebra-state
that are not enforced for pre-Canopy blocks due to mandatory checkpoint
verification.

Key findings:
- 12 upgrade-gated or semantic-only checks documented
- 2 explicitly documented validation gaps (pre-Heartwood coinbase
  Output descriptions, block header commitment contextual equality)
- Checkpoint verifier covers PoW, Merkle root, and tx consistency
- Risk assessment and future-change concerns for custom testnets

Closes ZcashFoundation#10184
@zmanian
Copy link
Copy Markdown
Contributor Author

zmanian commented Mar 31, 2026

@conradoplg This is ready for review — CI workflows need maintainer approval to run (fork PR). Could you approve the Actions runs when you get a chance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

List checks which are not done pre-Canopy

1 participant