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

Unable to request contract storage state root without storage values in RPC v0.8 #263

Open
GMKrieger opened this issue Dec 30, 2024 · 0 comments

Comments

@GMKrieger
Copy link

GMKrieger commented Dec 30, 2024

Problem Statement

In RPC v0.8, it is not possible to request a contract's storage state root without also requesting storage values. This is a regression from previous functionality used by SNOS (pathfinder_getStorageProof) and breaks certain use cases where only the root hash is needed.

Previous Behavior (pathfinder_getStorageProof)
The ContractData struct previously provided both pieces of information:

pub struct ContractData {
    pub root: Felt,
    pub storage_proofs: Vec<Vec<TrieNode>>,
}

Importantly, the endpoint accepted an empty array of keys, making it possible to retrieve just the root for contracts without storage keys (e.g., newly deployed but unused contracts).

Current Implementation (v0.8)
The new modular approach separates proofs into distinct components:

pub struct StorageProof {
    pub classes_proof: Vec<NodeHashToNodeMappingItem>,
    pub contracts_proof: ContractsProof,
    pub contracts_storage_proofs: Vec<Vec<NodeHashToNodeMappingItem>>,
    pub global_roots: GlobalRoots,
}

Issue Details
In the current implementation there's no way to retrieve the root when there are no storage keys to request.
This limitation breaks functionality for cases where:

  • Only the contract state root is needed
  • Working with newly deployed contracts without storage
  • Verifying contract existence without needing storage values

Proposed Solution
We need to modify the RPC to allow:

  • Requesting contract state root independently of storage values
  • Maintaining backward compatibility with existing storage proof requests
  • Preserving the modular approach of v0.8

On the pathfinder, there's an open PR with a temporary solution to this issue: eqlabs/pathfinder#2463

It checks if there are storage keys on the request, and if not, sends back a single node with the node hash (the root). This works, but requires some ugly checks to confirm what kind of data is being received and there's no good explanation for this without the proper context, making the code hard to maintain.

@GMKrieger GMKrieger changed the title Unable to Request Contract Storage State Root Without Storage Values in RPC v0.8 Unable to request contract storage state root without storage values in RPC v0.8 Dec 30, 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

1 participant