feat(storage/state_update): store re-declared Cairo 0 class information #2237
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.
The Starknet feeder gateway returns inconsistent state diffs for some blocks:
old_declared_contracts
may contain classes that have already been declared in previous blocks.For example state update for block 6356 has class 0x0699053487675242dc0958e192c17fe4dd57d22238ad78e2e1807fa7919ffde0 in
old_declared_contracts
. However, that class was in fact first declared in block 6355 and then re-declared in 6356. This is an inconsistency in the state diff: even though a second DECLARE transaction was included in that block for the class it is not a diff so it should not have been included in the state diff at all.Pathfinder stores only the very first block a contract was declared at, so we cannot reproduce this (inconsistent) state diff at all -- which poses a problem that the state diff commitment calculated by Pathfinder using our representation of the state diff won't match the one from the feeder gateway (and Juno).
This PR adds a new
redeclared_classes
table storing class re-declarations data. When inserting a state update we take care of adding new rows here if the state update contains a re-declaration -- and then when retrieving the state update from storage we add re-declared classes to the set of Cairo classes declared at the block.This allows us to reproduce the exact same state diff as the one we've received from the feeder gateway (or from other nodes via P2P).
Closes #2234