go icon indicating copy to clipboard operation
go copied to clipboard

Cursor Pagination Issue on Stellar Horizon Server v2.26.1 (also v2.28.1)

Open Hathoriel opened this issue 1 year ago • 0 comments

What version are you using?

We are currently using Horizon Server version 2.26.1 on our node. The public Horizon server is on version 2.28.1. Both servers have same issue.

What did you do?

We observed an issue with cursor-based pagination on our Horizon instance. For replication, you can follow these steps:

  1. Go to node's Horizon endpoint: https://horizon.stellar.org/ledgers
  2. Attempt to navigate the ledgers using cursor-based pagination in the _links.prev.href field.

An example from the public Horizon server that illustrates the expected behavior:

  • Start here: https://horizon.stellar.org/ledgers?cursor=216445057270546432&limit=10&order=asc
  • Click on _links.prev.href to go to https://horizon.stellar.org/ledgers?cursor=216445061565513728&limit=10&order=desc
  • Click on _links.prev.href to go to https://horizon.stellar.org/ledgers?cursor=216445057270546432&limit=10&order=asc

As you can see, it is the loop we can travel with _links.prev.href infinitely.

This wrong cursor pagination is available on all endpoints, not only on /ledgers.

What did you expect to see?

We expected the cursor pagination to allow us to navigate back to the previous ledger records accurately.

What did you see instead?

The cursor does not correctly navigate to the previous records. Specifically, when trying to go back using the links.prev.href from a desc order page, it does not return to the correct previous page. Instead, it goes back to the starting point or does not navigate correctly through the ledger records.

On the public - https://horizon.stellar.org/ is version 2.28.1 On our node is version 2.26.1 https://01-gravelines-068-02.rpc.tatum.io/

The cursor is not working as expected. When I am here: https://horizon.stellar.org/ledgers?cursor=216445057270546432&limit=10&order=asc And I click here: https://horizon.stellar.org/ledgers?cursor=216445061565513728&limit=10&order=desc And then again, I click on the links.prev.href, I get: https://horizon.stellar.org/ledgers?cursor=216445057270546432&limit=10&order=asc But it should give me the previous ledger.

Hathoriel avatar Feb 16 '24 11:02 Hathoriel