filecoin-project / lotus

Reference implementation of the Filecoin protocol, written in Go
https://lotus.filecoin.io/
Other
2.85k stars 1.27k forks source link

Make the `GetTipsetByHeight` in-memory skip list cache persistent for finalised tipsets #12568

Open aarshkshah1992 opened 1 month ago

aarshkshah1992 commented 1 month ago

When a Lotus node starts up, it kicks-off a "prefilling" of the in-memory GetTipsetByHeight cache in a go-routine. See here.

On Archival nodes, this pre-filling can take hours (RPC queries for tipsets way in the past will take a really long time/fail till this cache is pre-filled). However, because the cache is in-memory, the pre-filling needs to be done all over again once the node restarts.

Once the ChainIndexer ships -> we should re-engineer the GetTipsetByHeight cache to use the persistent ChainIndexer atleast for finalised tipsets. We should also investigate if there's a strong reason to not do this for non-finalised tipsets.

This will improve UX for Archival RPC providers and also speed up RPC queries for finalised tipsets immediately after node boot up.

aarshkshah1992 commented 1 month ago

Glif's archival node only took 3 hours for the hydration all the way upto genesis. So it's bad but not that bad.

BigLep commented 1 month ago

Relevant slack threads:

aarshkshah1992 commented 3 weeks ago

Note that we need the ChainIndexer to be deployed and backfilled on nodes before we can use it to replace the skiplist in the tipset cache.