Skip to content

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

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

Scottcjn merged 1 commit into
Scottcjn:mainfrom
createkr:sec/issue2819-utxo-rollback-atomicity

Conversation

@createkr

@createkr createkr commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

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

Scottcjn commented Apr 4, 2026

Copy link
Copy Markdown
Owner

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

@Scottcjn

Copy link
Copy Markdown
Owner

💰 First-poster bounty paid — part of 80 RTC for Bounty #2819 split.

This issue was the earliest report of its finding class on 2026-04-04. Today's first-poster ruling on Bounty #2819 (Red Team UTXO Implementation, 50-200 RTC range) split 135 RTC across the three earliest reporters; @createkr received 80 RTC as primary discoverer.

  • tx hash: afd25fbd8063bf1138ea394e087a8927
  • Pending ID: 1395
  • Confirms: ~24h

Thank you for the early diligence — your first-poster framework is now codified in the Self-Audit Credit Check policy.

— auto-triage 2026-05-10

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