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

Implement read-only StorageState functionality to translation shim type #4467

Open
timwu20 opened this issue Jan 14, 2025 · 0 comments
Open

Comments

@timwu20
Copy link
Contributor

timwu20 commented Jan 14, 2025

Issue Summary

From design doc:

The following StorageState methods are relatively easy to implement in the translation shim by utilizing db.Backend.

GetStorage(root *common.Hash, key []byte) ([]byte, error)
GetStorageByBlockHash(bhash *common.Hash, key []byte) ([]byte, error)
GetKeysWithPrefix(root *common.Hash, prefix []byte) ([][]byte, error)
GetStorageChild(root *common.Hash, keyToChild []byte) (trie.Trie, error)
GetStorageFromChild(root *common.Hash, keyToChild, key []byte) ([]byte, error)
GetStateRootFromBlock(bhash *common.Hash) (*common.Hash, error)

StorageRoot() (common.Hash, error) 

Entries(root *common.Hash) (map[string][]byte, error)

LoadCode(hash *common.Hash) ([]byte, error)
LoadCodeHash(hash *common.Hash) (common.Hash, error)

GetStorageXXX methods are easily accessible by translating and implementing the StorageProvider trait for Client.

GetStateRootFromBlock can be retrieved from already introduced HeaderBackend interface which db.Backend implements. Same for StorageRoot.

Entries should be refactored to utilize an iterator where Entries is called. I propose refactoring this method to return a PairsIter which iterates through the keys and values.

LoadCode and LoadCodeHash should be trivially implemented by accessing the state trie for a given hash and retrieving the entry with key ":code".

Acceptance Criteria

  • Implement GetXXX methods
  • Implement StorageRoot method
  • Revise Entries function call to return iterator.
  • Update all references to Entries to use iterator.
  • Implement LoadCode and LoadCodeHash.
  • Unit tests.
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