trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

consider updating persistent cache to get blocks from fork network by tag #3773

Open MicaiahReid opened 2 years ago

MicaiahReid commented 2 years ago

The persistent cache's get function doesn't currently allow passing the "earliest" tag to cache that request: https://github.com/trufflesuite/ganache/blob/2ec04fa2fe1dc3a5001da9f58a9629d64fdb2530/src/chains/ethereum/ethereum/src/forking/persistent-cache/persistent-cache.ts#L323-L351

This is kind of tricky to work around because of the way we lexicographically encode the requests to store/retrieve them efficiently in the database.

Because the persistent cache always needs to fetch the earliest block (to validate ancestry of the fork), we should cache this block in memory.

When the block manager is started, we are currently disabling the cache, so we should fix this once this issue is resolved. https://github.com/trufflesuite/ganache/pull/3755/files#r989390078

MicaiahReid commented 2 years ago

Related: #3755