Repository navigation
fix(api-server): page token transactions by offset instead of cursor - #2135
Closed
nullPointerEnjoyer wants to merge 10 commits into
Closed
nullPointerEnjoyer wants to merge 10 commits into
nullPointerEnjoyer wants to merge 10 commits into
Conversation
- Bump workspace version to 1.4.1 - Changelog: 1.4.1 section (wallet rescan fix; neutral PoS seal indexing entry) - Extend testnet checkpoints to height 818500 (step 500, from local synced testnet node via chainstate_get_block_ids_as_checkpoints; ~2.5k blocks behind tip 821011 at generation time)
- release_linux.yml: the RPM smoke-test step never sourced packaging/images.env, so $FEDORA_IMAGE was empty and docker tried to pull the script path as an image name. - win installers: declare TARGETDISTARCH x64. Without it the installers are 32-bit, so their HKLM\SOFTWARE uninstall entries land in WOW6432Node and the (64-bit PowerShell) smoke check cannot see them; files and PATH install fine, masking the issue until the registry assertion.
- rpc docs: regenerate node-daemon/docs/RPC{,_DEV}.md and
wallet-rpc-daemon/docs/RPC.md for the 1.4.1 version bump; the
expect-file tests embed CARGO_PKG_VERSION and failed on all three
OS legs of the build workflow.
- win installers: replace the invalid TARGETDISTARCH x64 line with the
proper NSIS mechanism: a shared MintlayerRequireX64 macro
(common.nsh) that aborts on 32-bit Windows and switches the registry
view to 64-bit via SetRegView, inserted from .onInit and un.onInit
(the uninstaller is a separate process). This keeps the uninstall
entries in the native HKLM\SOFTWARE hive as the smoke test expects,
which the previous commit intended but implemented as a command NSIS
rejects ("Invalid command: TARGETDISTARCH").
- arch smoke test: pacman has no IgnoreArch directive (that is a
makepkg flag), so installing the foreign-architecture package failed
with "package architecture is not valid". Add the foreign arch to
the Architecture option of /etc/pacman.conf instead, and update the
stale IgnoreArch comments in test-local.sh and release_linux.yml.
The previous fix added the foreign arch to pacman's Architecture list, which lets the amd64-only Arch image *install* the aarch64 package, but its binaries still cannot execute there: there is no aarch64 userland, so every binary dies under qemu with exit 255 (the ELF interpreter /lib/ld-linux-aarch64.so.1 does not exist). Docker Hub publishes no arm64 Arch image at all (library/archlinux and archlinux/archlinux are both amd64-only), so unlike the deb/rpm legs there is no --platform linux/arm64 escape hatch. For foreign-architecture packages, smoke-arch.sh now assembles a chroot of the Arch Linux ARM rootfs and runs the same checks inside it: pacman -U installs the package with dependencies from the arm repos, pacman hooks run under emulation (sysusers creates the mintlayer user), and the binaries execute through the host's qemu binfmt handlers already registered for the deb/rpm arm64 legs. Chroot quirks handled: - pacman's download sandbox user switch fails under the container seccomp profile: pass --disable-sandbox inside the chroot - /proc is not mounted, so /etc/mtab (pacman free-space check) is a static copy of the container's mount table - pacman-key --populate needs process substitution (/dev/fd), which requires /proc: initialize the chroot keyring with the container's amd64 pacman-key via --gpgdir instead of the emulated one - /work is not visible in the chroot: script, lib.sh and the package are copied in Verified locally against the pinned CI image with a synthetic aarch64 package exercising install, sysusers hook, binaries, systemd-analyze, and man page checks, plus an x86_64 package for the native path.
The route handler for GET /api/v2/token/{id}/transactions passes the
request's page offset (skip-N, default 0) but the storage layer treated
the parameter as a cursor (return transactions older than the given
tx_global_index). With the default offset of 0, the cursor predicate
matched nothing and the endpoint returned an empty page for every token
that had no transaction at global index zero.
Align the storage layer with the offset semantics the HTTP API (and every
other paginated endpoint) documents: return the newest transactions
starting at the given offset. An offset past the end of the result set
yields an empty page. Rename the parameter to offset in the trait,
implementations, and wrappers.
Add a storage-level regression test pinning the skip-N semantics of the get_token_transactions offset parameter: the default page starts at the newest transaction, the offset skips entries, and an offset at or past the end of the list yields an empty page instead of an error, including for offsets too large to represent in the database's integer type.
Five postgres queries cast the page offset to a bigint with , which wraps offsets above i64::MAX to a negative number. Postgres then rejects the negative OFFSET and the endpoint fails with an internal error. Guard the conversion the same way the token id queries already do: an offset too big for a bigint is past the end of any result set, so return an empty page.
Truncating the offset to usize with 'as' can wrap an offset that exceeds the pointer width into a small number, silently returning the first page instead of an empty one. Skip by usize::MAX instead, which is always past the end of any in-memory result set. Also deduplicate the bigint offset guard in the postgres queries into a single helper.
nullPointerEnjoyer
requested review from
ImplOfAnImpl,
anyxem and
erubboli
as code owners
October 8, 2026 08:30
Collaborator
Author
|
Closing: v1.4.1 has already shipped with this bug, so the release branch won't take the fix. The fix rides the master port in #2136 instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/v2/token/{id}/transactionsreturned an empty page for every token: the route passesthe request's page offset (skip-N, default 0), but the storage layer interpreted the parameter
as a cursor (
WHERE tx_global_index < $2). With the default offset of 0 the predicate matchednothing, so the endpoint always returned an empty list.
endpoint) uses: newest-first list,
offsetentries skipped, empty page at or past the end.Trait parameter renamed to
offsetacross trait, both backends, and wrappers.set, so both backends return an empty page (postgres previously wrapped
as i64in five otherqueries, yielding 500s; the in-memory backend previously truncated
as usizein seven queries).Test plan
token_transactions_offset_paging(runs against bothbackends): default page starts at the newest transaction, offset skips entries, offsets at/past
the end (including u64::MAX) yield an empty page instead of an error.
./do_checks.shgreen; OCR review clean.