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

StateNetwork refactor #649

Merged
merged 46 commits into from
Oct 18, 2024
Merged

StateNetwork refactor #649

merged 46 commits into from
Oct 18, 2024

Conversation

ScottyPoi
Copy link
Collaborator

@ScottyPoi ScottyPoi commented Oct 14, 2024

StateNetwork refactor and restructuring

Structure:

  • StateNetwork class
    • store, findContentLocally, sendFindContent
    • helper methods for store
      • receive[...]Offer, storeInterested[...]Nodes, forward[...]Offer
    • this.manager: StateManager
  • StateManager class
    • State lookup methods matching RPC methods
      • getAccount
      • getStorageAt
      • getCode
      • getBalance, getNonce, etc.
    • this.trie: PortalTrie
  • PortalTrie class
    • wrapper methods around trie walking and node lookup
    • find[...]Path(...)
    • lookup[...]TrieNode(...)
    • Fetches nodes with Network Lookup when not found locally
    • this.db: PortalTrieDB
      • Trie database extension that can find nodes in local DB or temporary node cache
  • PortalTrieDB class
    • extends DB interface for @ethereumjs/trie
    • this.db hooks directly to local StateNetwork DB
    • this.temp stores path nodes during trie walking
    • this.local maps nodeHash to DB content key for locally stored nodes

--

Distinction between new StateManager class and preexisting UltralightStateManager class

StateManager class is an attribute of StateNetwork. It enables state content lookup via StateNetwork retrieval methods. It exposes methods like getAccount, getCode, and getStorageAt.

UltralightStateManager class implements EVMStateManagerInterface from @ethereumjs/statemanager. It also contains state lookup methods like getAccount and getContractCode, and hooks into the methods provided in state.manager for state lookup.
It also implements state update methods. It can be used to instantiate an EVM during methods like eth_call

@ScottyPoi ScottyPoi marked this pull request as ready for review October 16, 2024 15:00
@ScottyPoi ScottyPoi merged commit 7cc05c4 into master Oct 18, 2024
5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants