Skip to content

fix: preserve caller-owned UTXO DB connection#5573

Closed
iamdinhthuan wants to merge 1 commit into
Scottcjn:mainfrom
iamdinhthuan:fix-preserve-utxo-caller-conn
Closed

fix: preserve caller-owned UTXO DB connection#5573
iamdinhthuan wants to merge 1 commit into
Scottcjn:mainfrom
iamdinhthuan:fix-preserve-utxo-caller-conn

Conversation

@iamdinhthuan
Copy link
Copy Markdown
Contributor

Summary

  • keep UtxoDB.apply_transaction() from closing a caller-owned SQLite connection when rejecting an unauthorized mining_reward transaction
  • add a regression proving callers can continue using their explicit connection after the validation failure
  • preserve the existing no-extra-connection behavior for unauthorized mint attempts

Why

apply_transaction(..., conn=external_conn) accepts a caller-owned connection. The unauthorized public mining_reward guard returned False, but closed external_conn first, so callers could not inspect, roll back, or continue their transaction after a normal validation failure.

Bounty route

Tests

  • Red before fix: python3 -m pytest node/test_utxo_db.py::TestUtxoDB::test_user_supplied_mining_reward_preserves_external_conn -q failed with sqlite3.ProgrammingError: Cannot operate on a closed database
  • python3 -m pytest node/test_utxo_db.py::TestUtxoDB::test_user_supplied_mining_reward_preserves_external_conn node/test_utxo_db.py::TestUtxoDB::test_user_supplied_mining_reward_rejected_before_opening_db node/test_utxo_db.py -q -> 72 passed
  • python3 -m py_compile node/utxo_db.py node/test_utxo_db.py
  • git diff --check

Duplicate / safety check

  • Fresh exact PR/issue searches for caller-owned connection apply_transaction mining_reward and preserve caller owned UTXO connection returned no exact public duplicate immediately before push.
  • No private keys, tokens, account-private data, cookies, or credentials are included.

@github-actions
Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Non-doc PRs have a BCOS-L1 or BCOS-L2 label
  • Doc-only PRs are exempt from BCOS tier labels when they only touch docs/**, *.md, or common image/PDF files
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/S PR: 11-50 lines labels May 17, 2026
@iamdinhthuan
Copy link
Copy Markdown
Contributor Author

Closing this duplicate in favor of #5572, which has the same caller-owned UTXO connection patch and is linked to bounty claim Scottcjn/rustchain-bounties#10623.

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

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/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants