Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: remove storage_commitment and class_commitment BlockHeader fields #2411

Open
kkovaacs opened this issue Nov 27, 2024 · 0 comments
Open
Assignees

Comments

@kkovaacs
Copy link
Contributor

During syncing from the feeder gateway we store the interim storage_commitment and class_commitment fields in the block header. These values are not taken from the feeder gateway response but are the root commitment for the storage and classes Merkle trees respectively. The state_commitment (also present in the block header from the feeder gateway) is then calculated from these two commitments. Both storage and class commitments are stored in the block_headers table in our storage.

Our state diff batching changes in P2P checkpoint sync can't properly calculate these values because that would require calculating the root commitment of the Merkle trees for each block -- which is exactly we'd like to avoid by using batching.

It turns out that there are only very few places where we actually use these values:

  • The pathfinder_subscribe JSON-RPC method that returns these fields for new headers. There are no known users to this API, so this is something we can probably just remove / break having provided an equivalent standards-compliant interface in JSON-RPC 0.8.0.
  • The state revert code used during reorgs: both the storage and class commitments are used as safeguards. After updating and committing the respective Merkle tree the commitment value from the revert target is used to double-check that we have the correct state. We could just as well use the state_commitment instead to check the resulting state: the only thing we're losing is the granularity of the check (we won't be able to differentiate between a storage commitment mismatch and a class commitment mismatch).

Ideally we should remove both fields from our codebase and storage.

@sistemd sistemd self-assigned this Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants