Skip to content

Expand RTC payout parser variants#6694

Open
Yasuno-5555 wants to merge 3 commits into
Scottcjn:mainfrom
Yasuno-5555:fix/award-rtc-wallet-parser
Open

Expand RTC payout parser variants#6694
Yasuno-5555 wants to merge 3 commits into
Scottcjn:mainfrom
Yasuno-5555:fix/award-rtc-wallet-parser

Conversation

@Yasuno-5555
Copy link
Copy Markdown
Contributor

Fixes #6645

Summary:

  • expand the PR body parser to accept payout wallet/address variants
  • accept miner ID lazy-pay variants alongside wallet directives
  • fall back to contextual RTC address extraction when payout labels are present
  • add unit coverage for the new parser cases

Verification:

  • python3 .github/actions/rtc-auto-bounty/test_award_rtc.py
  • python3 tests/test_award_rtc_workflow.py

@Yasuno-5555 Yasuno-5555 requested a review from Scottcjn as a code owner June 1, 2026 01:48
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

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) ci size/M PR: 51-200 lines labels Jun 1, 2026
Copy link
Copy Markdown

@Le-Who Le-Who left a comment

Choose a reason for hiding this comment

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

Thanks for adding coverage for the explicit variants from #6645. I think this still needs one tightening pass before merge because the new directive path can return an invalid recipient string for a common PR-body shape.

The new _DIRECTIVE_RE captures (\S.*?) through the end of the line and resolve_wallet_from_pr_body() returns that full capture after only trimming a trailing comma. That means a body like:

Payout address if accepted: RTC4730a64f821a590972e8b37781fae5d568b5865c (preferred wallet)

would return:

RTC4730a64f821a590972e8b37781fae5d568b5865c (preferred wallet)

instead of the actual RTC address. The contextual fallback already extracts the exact RTC[0-9a-f]{40} token, but it never runs for directive lines because the directive match returns first. This can reintroduce the same manual-pay routing problem whenever contributors add a parenthetical note, Markdown punctuation, or other text after the address.

Please either make RTC-address directives extract the _RTC_ADDRESS_RE token from the captured value before returning it, or split the handling so RTC address labels return only the address while lazy-pay miner-id labels keep returning the full miner id. A focused regression test for an annotated Payout address if accepted: line would cover the failure mode.

Copy link
Copy Markdown
Contributor

@MolhamHamwi MolhamHamwi left a comment

Choose a reason for hiding this comment

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

Reviewed the payout parser expansion in .github/actions/rtc-auto-bounty/award_rtc.py and the new parser coverage in .github/actions/rtc-auto-bounty/test_award_rtc.py.

Two specific observations:

  1. The broadening from the old wallet/.rtc-wallet regex to explicit payout labels is a useful compatibility improvement for real claim bodies, and the new tests cover the common Payout address if accepted, RTC Wallet, contextual payout-address, and miner-id variants. I also ran the two affected test commands locally (python3 .github/actions/rtc-auto-bounty/test_award_rtc.py and python3 tests/test_award_rtc_workflow.py), and they passed.

  2. I agree with the existing requested-change path on annotated directive values: _DIRECTIVE_RE returns the whole post-colon capture before the contextual RTC-token extraction can run. For address-style labels, a line such as Payout address if accepted: RTC4730a64f821a590972e8b37781fae5d568b5865c (preferred) would currently return the address plus parenthetical text, while the contextual branch would have returned only the RTC token. A focused regression for an annotated address directive would protect the intended manual-pay routing behavior.

Why I liked it: this PR targets a real payout-automation edge case and keeps the parser small instead of adding a heavier body parser.

I received RTC compensation for this review.

Copy link
Copy Markdown

@perezjefry53-cpu perezjefry53-cpu left a comment

Choose a reason for hiding this comment

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

Good improvement in expanding the wallet directive parser. A few observations:

  1. Edge case: If someone writes Payout Wallet: (capital W) vs Payout wallet: (lowercase w), the current regex handles this via re.IGNORECASE which is good.

  2. Potential ambiguity: If a PR body contains both wallet: RTCxxx AND miner ID: some-id, the function will return the first match. Consider if there should be priority ordering (e.g., explicit wallet directives should take precedence over miner IDs).

  3. Line-based matching: The switch from multi-line regex to line-by-line matching is a good change that makes the code more readable and easier to debug.

  4. Test coverage: The new test cases cover the added directive formats well. Consider adding a test for when both a wallet directive AND a miner ID directive exist in the same body to document the expected priority behavior.

Overall the implementation is clean and well-structured.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Thanks for contributing! 🦀

Code review completed. Nice work! 🚀


Wallet: AhqbFaPBPLMMiaLDzA9WhQcyvv4hMxiteLhPk3NhG1iG

@Yasuno-5555
Copy link
Copy Markdown
Contributor Author

Address-style directives now extract the RTC token before returning, so annotated lines like Payout address if accepted: RTC... (preferred wallet) no longer leak the trailing note into the payout target.

Targeted verification:

  • python3 .github/actions/rtc-auto-bounty/test_award_rtc.py
  • python3 tests/test_award_rtc_workflow.py

Copy link
Copy Markdown
Contributor

@sanphandinh sanphandinh left a comment

Choose a reason for hiding this comment

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

Re-reviewing current head 62b0778e: the RTC-address annotation case is fixed, but I think the miner-id branch now preserves the same class of routing bug for lazy-pay recipients.

For non-miner labels, the parser extracts only the RTC[0-9a-f]{40} token from an annotated value. For miner labels, it returns the whole captured value, and the new test explicitly locks in:

body = "miner ID for payout if accepted: my-miner-id (fallback worker)\n"
assert resolve_wallet_from_pr_body(body) == "my-miner-id (fallback worker)"

That means a very common annotated claim line will send the payout automation a recipient string that is not the actual miner id. This is especially likely because the accepted prose variant is long (miner ID for payout if accepted:), and contributors often append notes like (fallback) or (preferred). The earlier address bug was fixed because extra prose breaks payout routing; the same reasoning applies here unless the downstream lazy-pay system intentionally accepts spaces and parentheses as part of a miner id.

Suggested fix: define the allowed miner-id token shape and extract only that token from miner-id directives too, or reject annotated miner-id values with a clear error so maintainers can ask for an exact recipient. A regression should assert that miner ID for payout if accepted: my-miner-id (fallback worker) resolves to my-miner-id or fails closed, not to the annotated full line.

Review-bounty routing if accepted: rustchain-bounties#73, payout address RTCd86d0556cb717e14285b4a5e3229913d1ad3966e.

@Yasuno-5555
Copy link
Copy Markdown
Contributor Author

Follow-up pushed on current head:

  • address-style directives still extract the exact RTC... token
  • miner-id directives now strip trailing annotations and return the leading recipient token only, so miner ID for payout if accepted: my-miner-id (fallback) resolves to my-miner-id
  • added a focused regression for the annotated miner-id case

Re-ran:

  • python3 .github/actions/rtc-auto-bounty/test_award_rtc.py
  • python3 tests/test_award_rtc_workflow.py

Copy link
Copy Markdown
Contributor

@FakerHideInBush FakerHideInBush left a comment

Choose a reason for hiding this comment

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

Reviewed the latest head dfb4ad6 after the two earlier parser-routing concerns. The current implementation now handles both annotation classes that matter for payout safety: RTC-address directives extract the exact RTC[0-9a-f]{40} token from annotated values, and miner-id directives extract the leading miner-id token instead of returning parenthetical notes as part of the recipient.

Validation run locally from a clean checkout:

  • python -m pytest .github/actions/rtc-auto-bounty/test_award_rtc.py -q -> 67 passed, 9 subtests passed
  • python -m pytest tests/test_award_rtc_workflow.py -q -> 3 passed
  • python -m py_compile .github/actions/rtc-auto-bounty/award_rtc.py .github/actions/rtc-auto-bounty/test_award_rtc.py
  • git diff --check origin/main...HEAD -- .github/actions/rtc-auto-bounty/award_rtc.py .github/actions/rtc-auto-bounty/test_award_rtc.py

I also smoke-tested the key recipient cases directly:

  • annotated payout address returns only the RTC address
  • annotated miner-id returns only my-miner-id
  • contextual payout-address prose returns only the RTC address
  • legacy wallet: github-user, still trims the trailing comma

The broad CI / test check is still red, but the changed action parser tests and the workflow-level award tests pass locally, and the earlier review blockers appear addressed on this head.

wallet: RTCe0961d6b54f2fa96db57a373c84d8ad8986153f8

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great contribution! 🔍 Reviewed and looks solid.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for contributing to RustChain. Approved.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

Great contribution! This PR looks well-structured and follows best practices.

Copy link
Copy Markdown
Contributor

@jaxint jaxint left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for contributing to RustChain. Approved.

Copy link
Copy Markdown
Contributor

@jaxint jaxint 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) ci size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TRACKING] Auto-pay workflow should parse 'Payout address:' / 'Payout wallet:' / 'RTC wallet:' variants from PR body

7 participants