Skip to content

[UTXO-BUG] make genesis rollback atomic and re-run safe#2060

Merged
Scottcjn merged 1 commit intoScottcjn:mainfrom
createkr:sec/issue2819-utxo-rollback-atomicity
Apr 4, 2026
Merged

[UTXO-BUG] make genesis rollback atomic and re-run safe#2060
Scottcjn merged 1 commit intoScottcjn:mainfrom
createkr:sec/issue2819-utxo-rollback-atomicity

Conversation

@createkr
Copy link
Copy Markdown
Contributor

@createkr createkr commented Apr 4, 2026

Summary

This PR fixes a UTXO migration safety bug where rollback_genesis() could run without an explicit transaction boundary, making partial deletion state possible if an error occurred between the rollback steps.

Root cause

rollback_genesis() performed multiple destructive DELETE operations without wrapping them in a single BEGIN IMMEDIATE / COMMIT block and without an explicit ROLLBACK on failure. That made rollback non-atomic and undermined re-run safety for genesis migration.

What changed

  • Wrapped rollback_genesis() in a single BEGIN IMMEDIATE transaction
  • Added explicit ROLLBACK handling on error
  • Switched to timeout-aware SQLite connection setup for rollback
  • Kept the fix tightly scoped to the rollback path
  • Added focused regression tests covering:
    • migration creates genesis state
    • rollback removes all genesis data
    • rollback idempotency on empty state
    • re-run safety after rollback
    • no partial state after rollback
    • connection mode consistency

Validation

Added node/test_rollback_atomicity.py with 6 focused tests for rollback atomicity and re-run safety.

Scope

  • node/utxo_genesis_migration.py
  • node/test_rollback_atomicity.py

Payout Wallet

RTC1d48d848a5aa5ecf2c5f01aa5fb64837daaf2f35

@github-actions github-actions bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related labels Apr 4, 2026
@github-actions github-actions bot added the size/L PR: 201-500 lines label Apr 4, 2026
@Scottcjn
Copy link
Copy Markdown
Owner

Scottcjn commented Apr 4, 2026

Merged. 100 RTC — High (Bounty #2819). Non-atomic rollback could corrupt state across nodes. Good defensive fix.

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

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/L PR: 201-500 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants