Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Performance of --fork could be improved with memoization #471

Closed
area opened this issue Aug 22, 2019 · 2 comments
Closed

Performance of --fork could be improved with memoization #471

area opened this issue Aug 22, 2019 · 2 comments

Comments

@area
Copy link
Contributor

area commented Aug 22, 2019

Expected Behavior

When forking a provider, ganache-core should only have to query the provider once for the code/nonce/balance that exists at a particular address at the safeBlockNumber. As the response will not change, any repeated lookups should be cached.

Current Behavior

Even if ganache has queried the code/nonce/balance at a particular address and block number before, it will query the provider again despite the fact this will not have changed

Possible Solution

Memoize the calls to the fallback provider, as I have done here, for example.

Context

While testing upgrades for our dapp, we wish to fork mainnet to test against the current state, but we see a large number of repeated calls to infura when we open our dapp and browse around against our forked ganache-cli - not good for them, or our API limits!

@davidmurdoch
Copy link
Member

Ah, nice. This looks great! I'm assuming this works because forking always passes a blockNumber and never a tag like "latest"?

If you want to write some tests for these memoized methods I'd love to pull this in!

@area
Copy link
Contributor Author

area commented Aug 13, 2020

I think this has effectively been done in #581 and can be closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants