Skip to content

fix(cli): admin payout-issue reports a successful zero-return payout as failure - #1648

Open
michiot05 wants to merge 1 commit into
entrius:testfrom
michiot05:fix/admin-payout-zero-result
Open

fix(cli): admin payout-issue reports a successful zero-return payout as failure#1648
michiot05 wants to merge 1 commit into
entrius:testfrom
michiot05:fix/admin-payout-zero-result

Conversation

@michiot05

Copy link
Copy Markdown

Summary

gitt admin payout-issue reports "Payout failed." and exits 1 for a payout that actually succeeded on-chain, whenever payout_bounty returns 0.

IssueCompetitionContractClient.payout_bounty (gittensor/validator/issue_competitions/contract_client.py:700) returns Optional[int] with three shapes:

Return Meaning
positive int success — amount from the pre-submit get_issue read
0 success — extrinsic submitted and confirmed (tx_hash and not error), but the pre-submit get_issue read returned None, so expected_payout is unknown: return int(expected_payout) if expected_payout else 0
None failure — tx error or exception

The caller at gittensor/cli/issue_commands/admin.py:156 used a truthiness check (if result:), which collapses the success-with-unknown-amount 0 into the failure branch.

Reachability: get_issue swallows all exceptions to None (contract_client.py:229). payout_bounty performs its own get_issue read after the CLI has already read and displayed the issue, so a transient RPC failure on that second read — with the extrinsic itself succeeding — yields exactly 0. The operator is told the payout failed (exit 1), while the transfer went through; a retry then runs into the contract's already-finalized state (BountyNotCompleted).

Fix: the caller-side one-liner — if result is not None: — as prescribed in the #1577 review. Only None (the genuine failure sentinel) takes the failure branch. No change to contract_client.py; the sibling admin commands (cancel-issue, set-owner, add-vali, remove-vali, set-treasury) wrap bool-returning client methods, where truthiness is correct — they are untouched.

Related Issues

Implements the caller-side fix described by @anderdc in the close comment of #1577.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Before / After

Reproduced by running the real CLI with only the contract client stubbed (payout_bounty0, i.e. successful tx with the pre-submit read unavailable):

Before — on-chain success reported as failure, exit 1:

$ gitt admin payout-issue 3 --yes
Network: finney • Contract: 0x1234567890...567890
╭────────────────────────────── Payout Issue #3 ───────────────────────────────╮
│ Issue: entrius/gittensor#42                                                  │
│ Status: COMPLETED                                                            │
│ Bounty: 0.0000 ALPHA                                                         │
╰──────────────────────────────────────────────────────────────────────────────╯

✗ Payout failed.

(exit code: 1)

After — success reported, exit 0:

$ gitt admin payout-issue 3 --yes
Network: finney • Contract: 0x1234567890...567890
╭────────────────────────────── Payout Issue #3 ───────────────────────────────╮
│ Issue: entrius/gittensor#42                                                  │
│ Status: COMPLETED                                                            │
│ Bounty: 0.0000 ALPHA                                                         │
╰──────────────────────────────────────────────────────────────────────────────╯

✓ Payout successful! Amount: 0.0000 ALPHA

(exit code: 0)

Failure path (payout_bountyNone) is unchanged: ✗ Payout failed., exit 1.

Testing

  • Tests added/updated
  • Manually tested

Added TestCliAdminPayoutResult (3 cases: positive int → success, 0 → success, None → failure) exercising the command through CliRunner with the contract client mocked. Full suite: uv run pytest963 passed; uv run pre-commit run --all-files --hook-stage pre-push (ruff, pyright, vulture, pytest) — all green.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant