pokt-network / pocket

Official implementation of the Pocket Network Protocol v1
https://pokt.network
MIT License
61 stars 33 forks source link

[Utility] Cache session data in client #791

Closed adshmh closed 11 months ago

adshmh commented 1 year ago

Objective

Cache sessions client-side

Origin Document

754 and #778

Cache the retrieved sessions client-side.

Goals

Deliverable

Non-goals / Non-deliverables

General issue deliverables

Testing Methodology


Creator: @adshmh

adshmh commented 1 year ago

@Olshansk would appreciate a bit more context on the expectations here. More specifically, does this make sense?

  1. Client checks the local cache for a stored session (on permanent storage, to allow sharing the session between multiple invocations of the client)
  2. If a session is found --> verify against the current height
  3. If a session is not found or the stored session has expired (i.e. does not match the current height): fetch the current session and store in cache (permanent storage)

Also, wondering if it makes sense to cache and store older sessions: if there is a need on client-side to access old sessions this would make sense, but I can't think of one right now.

Olshansk commented 1 year ago

I recently had to do this in v0 tx-bot and hacked (keyword hacked) it together. See https://github.com/pokt-network/tx-bot/blob/main/rpc/req.go#L93

Client checks the local cache for a stored session (on permanent storage, to allow sharing the session between multiple invocations of the client)

What is permanent storage here? If it's just something simple like a text/binary file under /tmp, then 👍

If a session is found --> verify against the current height

If validation means "check if session is still useful given the nodes", then 👍

Otherwise, please provide more details.

If a session is not found or the stored session has expired (i.e. does not match the current height): fetch the current session and store in cache (permanent storage)

👍

Also, wondering if it makes sense to cache and store older sessions: if there is a need on client-side to access old sessions this would make sense, but I can't think of one right now.

Can't think of any reasons right now. If it's important, it'll come back up.