fix(katana-provider): temporarily invalidate cache if nonce or class hash is default value #1850
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
invalidate the local nonce or class hash value for forked provider if they are
0
.The reason why we do this is because the nonce and class hash are stored within the same struct (ie
GenericContractInfo
), and to give some context, forked provider works like this:these steps are done for each of the methods within the
StateProvider
trait. So when theStateProvider::nonce()
is called, it will find in local, if not found then fallback to remote network. Once it receives the value from the remote network, it will store locally in theGenericContractInfo
struct. AND BECAUSE this struct is used to store both the nonce AND the class hash, so when we create it for the first time (either thruStateProvider::nonce()
orStateProvider::class_hash_of_contract()
), the other field would be set to its default value.The issue happens when you're calling
StateProvider::class_hash_of_contract()
afterStateProvider::nonce()
(or vice versa), the class hash returned will beZERO
. Because it sees that the correspondingGenericContractInfo
exist and extract the class hash from there.NOTE:
this would mainly be a temporary fix until we're able to use a better data types to represent 'not yet fetched' and 'default value'.