Skip to content

fix(tests): update test_c8_adm_double_credit_poc to exercise settle_epoch_rip200 rollback (#8353) - #8421

Merged
Scottcjn merged 2 commits into
Scottcjn:mainfrom
Cid-oe:fix-c8-poc-test
Sep 18, 2026
Merged

Scottcjn merged 2 commits into
Scottcjn:mainfrom
Cid-oe:fix-c8-poc-test

Conversation

@Cid-oe

@Cid-oe Cid-oe commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Diagnosis & Summary of Changes

Fixes #8353.

Root Cause Analysis

In node/test_c8_adm_double_credit_poc.py, the test did not invoke settle_epoch_rip200() at all. Instead, it directly hardcoded two identical INSERT INTO balances queries on a raw connection without a rollback between them, asserting that the balance equaled a single credit. Because it never invoked settle_epoch_rip200(), it never exercised the actual db.rollback() mechanism (lines 257-260 of node/rewards_implementation_rip200.py) added to purge uncommitted ADM partial writes before standard fallback.

Solution

  • Updated node/test_c8_adm_double_credit_poc.py to import and invoke settle_epoch_rip200().
  • Configured a stub settle_epoch_with_anti_double_mining that performs uncommitted writes to the shared connection (balances and ledger) and then raises an exception.
  • Verified that settle_epoch_rip200() catches the failure, cleanly issues db.rollback(), and transitions to the standard fallback path.
  • Verified that the miner receives exactly one single credit (1,500,000 uRTC) and that the uncommitted ADM ledger rows are purged, leaving only the standard epoch reward entry.

Verification

  • python3 node/test_c8_adm_double_credit_poc.py -> PASS
  • python3 node/test_wt3_adm_fallback_double_credit_poc.py -> PASS

Claiming RTC wallet: RTC8b1fb717791b0a7b72649342b5c7c7bd822786af

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related labels Sep 15, 2026
@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!

@Scottcjn Scottcjn left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Approved. This is a genuinely useful test: it drives the real settle_epoch_rip200, and when I removed the db.rollback() at line 260, it fails. So it actually guards the #6250 fix, which the old PoC test never did.

@Scottcjn
Scottcjn merged commit f76ec5a into Scottcjn:main Sep 18, 2026
11 of 12 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

RTC Reward

This merged PR earned 5 RTC — sent to RTC8b1fb717791b0a7b72649342b5c7c7bd822786af.

RustChain Bounty Program

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) BCOS-L2 Beacon Certified Open Source tier BCOS-L2 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_c8_adm_double_credit_poc fails on main: fallback still double-credits after ADM writes in the PoC scenario

2 participants