Skip to content

Bug: Verifier returns exit code 0 despite missing transfer history #10

Closed

Description

@Chandain

Description
The verifier incorrectly returns exit code 0 even though two token transfers are missing from the ledger.

Steps to reproduce:

  1. Alice approves Bob with unlimited allowance.
  2. Bob calls transferFrom() to transfer 40 tokens from Alice to Charlie.
  3. Charlie transfers the same 40 tokens back to Alice.
  4. Alice revokes Bob's allowance.
  5. The ledger records neither the transfer initiated by Bob nor the return transfer initiated by Charlie.

Expected behavior:
The verifier should return exit code 1 because the ledger is missing two on-chain token movements.

Actual behavior:
The verifier returns exit code 0 (RESULT: OK), incorrectly reporting that the ledger is complete.

Root cause:
The verifier discovers transaction blocks using Alice's nonce. However, the transfers are initiated by Bob and Charlie, so Alice's nonce does not increase.

As a result, the verifier misses both transfers. Since Alice's final balance is unchanged and Bob's allowance has been revoked, the final state checks also fail to detect the missing history.

Regression test:

  • File: script/test_transferfrom_history.py
  • Test: test_round_trip_then_revoke
  • Expected exit code: 1
  • Actual exit code: 0
  • Result: AssertionError: 0 != 1

Note: This issue was reproduced using an offline mocked RPC scenario, not a live on-chain transaction.

Evidence:
`Traceback (most recent call last):
File "/home/richard/pull-request/source-mint/sourcemint-issue10-11f9a4f/script/test_transferfrom_history.py", line 234, in test_round_trip_then_revoke
self.assertEqual(code, 1, msg=output)
AssertionError: 0 != 1 : eth_getLogs read block 1 to 1
eth_getLogs read block 100 to 100
eth_getLogs read block 202 to 202
project-wallet transfers checked on-chain: 1
ledger entries matched: 1/1

RESULT: OK — every project-wallet movement is accounted for.`

verifier read block 1,100, 202 and missed 200, 201

commit: 11f9a4f
commit link: Chandain@11f9a4f

Activity

  1. gjwang commented on Nov 5, 2026

    @gjwang
    Contributor

    Reproduced on main 5c114b9 with your 11f9a4f regression, using mocked RPC only: four tests pass; test_round_trip_then_revoke fails because the verifier returns 0. It reads blocks 1, 100 and 202, missing 200–201.

    There is a second failure-priority problem in the allowance exception handler. Using the existing fixture with Bob also tracked makes block 200 visible and reports the unaccounted transfer. Changing only the subsequent allowance read to raise SourceUnavailable changes the result from 1 to 2, despite that already-observed violation.

    I'd separate confirmed violations from incomplete coverage: an observed unledgered transfer remains 1; matching sampled transfers, balances and current allowances without complete history should be inconclusive (2). A ledger entry absent from sampled blocks alone also isn't proof of a violation. This needs distinct evidence states rather than a blanket if not ok, since that flag currently mixes those cases.

    That would stop false verification while a complete, fixed-head history scan is worked out. The round-trip and failure-priority cases should both remain offline regressions; changing providers alone won't repair the sampling gap.

  2. khalidsaidi commented on Nov 16, 2026

    @khalidsaidi
    Owner

    @Chandain @gjwang — confirmed, and I'm sorry for the eleven days of silence. A reproduced correctness bug in the one script this project exists for deserved an answer the same day, not a fortnight later.

    The bug is real and it is mine. It came in with the redesign I pushed on 29 October, not from anything either of you wrote.

    That redesign replaced a continuous scan with nonce-based block discovery, on the reasoning that a nonce is monotonic so nothing can hide behind it. That reasoning only holds for movements our wallet signs. A transferFrom is signed by the spender, so our nonce never moves and the block is never read. I knew that much and thought the allowance check covered it — but a live allowance is only evidence while it is live. Revoke it afterwards, as step 4 of @Chandain's scenario does, and the last trace is gone. The balance nets to zero, the nonce never moved, the allowance reads zero, and the verifier reports success for a history it never saw.

    So the method cannot prove completeness, and the script claimed completeness anyway. That is precisely the failure this repository exists to make visible, which makes shipping it worse rather than better.

    @gjwang, the second finding is also correct and I had the same defect reasoning about it. The allowance loop returns 2 unconditionally, so an outage after an observed violation downgrades a finding to "could not verify". Your framing is the right one: a confirmed unledgered transfer is a finding, incomplete coverage is inconclusive, and a ledger entry simply absent from sampled blocks is neither. The single ok flag conflates all three and needs replacing with distinct states rather than patching.

    I'm reviewing #11 now and will come back on it today with something substantive rather than an acknowledgement. Both regression cases should land as permanent offline tests whatever the fix turns out to be.

    Both of you have a reward under REWARDS.md for this. @Chandain I have your address. @gjwang, if you'd like one, drop a Base address here — an address only, never a key — and if you'd rather not, that's genuinely fine and I won't raise it again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions