Skip to content

api: token API leftovers (pages of transfers, TokenTransferGet, counters, cache lock in checkpoints) - #134

Merged
EnzinoBB merged 4 commits into
masterfrom
fix/api-token-leftovers
Oct 30, 2026
Merged

EnzinoBB merged 4 commits into
masterfrom
fix/api-token-leftovers

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Summary

The rest of the token API review after #128. API only.

  • Pages of transfers. TokenTransfersGet/TokenWalletTransfersGet do not list a failed transfer, but the offset and the limit counted it before addTokenResult dropped it, so pages came back short. It is now skipped before them.
  • TokenTransferGet listed any transaction id it was given, of any contract or of none, with count = 1, and the state lookup (*opers)[id] added an entry to the operations map for every id asked. It now answers NOT_FOUND unless the transaction is a transfer call to that token; count is the number listed. operationState() reads a state without adding to the map (also in addTokenResult).
  • Counters. 64-bit token counters in i32 API fields report the largest i32 instead of wrapping.
  • Cache lock in checkpoints. TokensMaster_Serializer saves, loads, clears and hashes the cache under TokensMaster's lock: the API changes it from the block store thread and, since api: a token cache that follows every token standard, in any build #128, from the background refresh, which can run while a checkpoint is saved.

Left as is: the format of tokens.dat (official checkpoints read it) and the diag API's tokenStandard, which reports what the deploy transaction declares.

Test plan

  • Private network CONTRACTS=1 TOKENS=1 TOKENS_VIA=5 TOKENS_STRICT_API=1 with the restart of n5: 0 failures; new checks: a page of 2 transfers holds 2 though a failed transfer lies between them, TokenTransferGet returns a transfer and refuses an approve() (the 2 findings are the wrong-type calls, refused by the API after api: refuse a contract call whose method the executor cannot find #132)
  • CI

🤖 Generated with Claude Code

…ers, cache lock in checkpoints)

- TokenTransfersGet/TokenWalletTransfersGet: a failed transfer is not listed, but it was counted
  by the offset and the limit before addTokenResult dropped it, so pages came back short. It is
  now skipped before them.
- TokenTransferGet listed any transaction id given, of any contract or none, and the state
  lookup ((*opers)[id]) added an entry for every id asked. It now answers NOT_FOUND unless the
  transaction is a transfer call to that token; count is the number listed.
- The state of an operation is read without adding to the map (operationState).
- 64-bit token counters in i32 API fields report the largest i32 instead of wrapping.
- TokensMaster_Serializer saves, loads, clears and hashes the cache under TokensMaster's lock:
  the API changes it from the block store thread and, since #128, from the background refresh,
  which can run while a checkpoint is saved.

tokens.py: a page of 2 transfers holds 2 though a failed transfer lies between them;
TokenTransferGet returns a transfer and refuses an approve().
EnzinoBB added a commit that referenced this pull request Oct 30, 2026
@EnzinoBB
EnzinoBB force-pushed the fix/api-token-leftovers branch from 3ea982d to 82b74de Compare October 30, 2026 14:29
@EnzinoBB
EnzinoBB merged commit b831523 into master Oct 30, 2026
5 of 6 checks passed
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