LF-Decentralized-Trust-labs / paladin

Programmable privacy for EVM
https://lf-decentralized-trust-labs.github.io/paladin
Apache License 2.0
15 stars 6 forks source link

Infinite scrolling #411

Closed gabriel-indik closed 3 days ago

gabriel-indik commented 2 weeks ago

Add infinite scrolling for events. The goal is to ensure that the feature works as expected before expanding it to all other queries (transactions, events and submissions). With the changes in place, events are not retrieved 10 at a time. When scrolling down, 10 more will be incrementally loaded until all events have been loaded. Visually the UI should feel virtually identical. It may load slightly faster at first since we are now fetching fewer results. The way to perform the pagination is done based on https://github.com/kaleido-io/paladin/blob/63f3ef44541245a56aea7c2434bc53191ab33271/core/go/pkg/blockindexer/event_streams.go#L542-L546.

This can be seen applied in ui/client/src/queries/events.ts as follows:

 let requestPayload: any = {
    jsonrpc: "2.0",
    id: Date.now(),
    method: RpcMethods.bidx_QueryIndexedEvents,
    params: [
      {
        limit: constants.EVENT_QUERY_LIMIT,
        sort: ["blockNumber DESC", "transactionIndex DESC", "logIndex DESC"],
      }
    ]
  };

  if (pageParam !== undefined) {
    requestPayload.params[0].or = [
      {
        "lessThan": [
          {
            "field": "blockNumber",
            "value": pageParam.blockNumber
          }
        ]
      },
      {
        "equal": [{
          "field": "blockNumber",
          "value": pageParam.blockNumber
        }],
        "or": [
          {
            "lessThan": [{
              "field": "transactionIndex",
              "value": pageParam.transactionIndex
            }]
          },
          {
            "equal": [{
              "field": "transactionIndex",
              "value": pageParam.transactionIndex
            }],
            "lessThan": [{
              "field": "logIndex",
              "value": pageParam.logIndex
            }]
          }
        ]
      }
    ]
  }
gabriel-indik commented 1 week ago

Infinite scrolling has been added to the indexer. Transactions and events are now loaded 10 at a time. Note that the logic for retrieving receipts and full transactions had to be updated in order to fetch those incrementally. Infinite scrolling as also been added to the submissions panel.

In all cases, 10 items at a time are being retrieved. When scrolling, 10 more will be incrementally loaded.

gabriel-indik commented 1 week ago

With regards to the registry, that is something that will likely require a conversation before we go ahead and add infinite scrolling. This is because currently the UI is making some seamless simplification of the data by aggregating the entries from all registries in one list. We may want to revisit this and instead show registry entries grouped by registry.