Skip to content

Consensus: reject duplicate Spark mint coins - #1902

Draft
reubenyap wants to merge 1 commit into
masterfrom
codex/spark-duplicate-mint-hardening
Draft

Consensus: reject duplicate Spark mint coins#1902
reubenyap wants to merge 1 commit into
masterfrom
codex/spark-duplicate-mint-hardening

Conversation

@reubenyap

Copy link
Copy Markdown
Member

PR intention

Prevent duplicate Spark mint coins from corrupting the relationship between Spark coin-group counts, block-index mint entries, and the active minted-coin map. A duplicate can otherwise be counted and indexed more than once while the map stores it once, making a later disconnect capable of removing the wrong occurrence or hitting an assertion.

Provenance: this PR splits and reconstructs the duplicate-mint hardening from public commit 28251a690, authored June 19, 2026 on the public spark-coin-type-fix branch. That work predates the later external vulnerability report. This PR carries Firo's earlier hardening forward as a separate, current-master change. It was not initiated in response to that report.

The earlier commit is not cherry-picked unchanged because it depends on its parent coin-type commit, only covers direct OP_SPARKMINT outputs within one block, and has no dedicated tests. This reconstruction is independent of #1901 and also covers OP_SPARKSMINT, active-chain duplicates, and mempool behavior.

Code changes brief

  • Reject repeated Spark coin hashes across all mint-producing transactions in one block before any Spark state or block-index mutation.
  • Reject a candidate active-tip block that repeats a Spark coin already present in active-chain state.
  • Cover both direct OP_SPARKMINT coins and OP_SPARKSMINT coins created by Spark spends through the shared completed mint vector.
  • Avoid false duplicate results during VerifyDB historical reconnection, where the UTXO view is rewound but global Spark state is not.
  • Track Spark mint reservations and their transaction IDs independently in the main mempool and stem pool.
  • Reject duplicate coins within one transaction or across mempool transactions without assigning peer misbehavior points.
  • Remove a conflicting mempool transaction if an externally mined block confirms the same Spark coin.
  • Gate block-consensus enforcement behind a separate activation height. Public-network and regtest defaults remain disabled at INT_MAX in this draft pending historical-chain review and coordinated deployment heights.
  • Add tests for the activation boundary, both Spark coin types, active-chain and VerifyDB-style behavior, rejection before mutation, per-pool ownership, removal symmetry, and mempool duplicate policy.

Before this draft is made ready, the active histories must be scanned for pre-existing duplicate Spark coin identities and concrete network activation heights must be selected. git diff --check passes. Local CMake configuration reached dependency discovery but could not complete because the available Windows environment lacks bls-dash; compilation and the new tests therefore still require CI.

Reject duplicate Spark mint coins within a block or against the active chain before mutating Spark state. Track mint reservations per transaction pool so duplicate transactions are rejected and conflicts are evicted symmetrically.
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a3a3dc6-34ec-4606-b7d4-edbf91d3c232

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant