ar-io / arns-service

Koa microservice that leverages Warp to support the ArNS Portal and ar.io observers.
https://api.arns.app
GNU Affero General Public License v3.0
19 stars 4 forks source link

fix(gql): fix cacheKey construction for gql interactions #82

Closed dtfiedler closed 9 months ago

dtfiedler commented 9 months ago

The same cache key is being set for varying blockheights, causing the read through cache to return incorrect interactions when a new request with a different blockHeight is created before the cache has expired.

CC @arielmelendez

Logs before:

Reading through to wallet interactions for contract... {"blockHeightFilter":1321450,"cacheKey":"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U-this.blockHeight","contractTxId":"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U","method":"GET","path":"/v1/contract/bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U/interactions","timestamp":"2023-12-13T08:48:13.463Z","trace":"ecd1e3"}

Specifically: "cacheKey":"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U-this.blockHeight"

Logs after:

Reading through to wallet interactions for contract... {"blockHeightFilter":1321450,"cacheKey":"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U-1321450","contractTxId":"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U","method":"GET","path":"/v1/contract/bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U/interactions","timestamp":"2023-12-13T08:57:46.165Z","trace":"b2ea0e"}

Updated: "cacheKey":"bLAgYxAdX2Ry-nt6aH2ixgvJXbpsEYm28NgJgyqfs-U-1321450"