You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TrieState() method defined in StorageState is responsible for retrieving the state trie for a given block hash. It retrieves the Trie associated to the block hash and returns a *rtstorage.TrieState. This method is almost exclusively called before calling Instance.SetContextStorage to be able track storage changes by a runtime instance. There are methods in TrieState that handle storage changes as well as starting, rolling back, and committing transactions. The changes are handled through storageDiff currently, which keep all the changes in memory before commiting, and applying them to a new in-memory trie to compute the state root. StoreTrie is explicitly called to persist the trie in InmemoryStorageState to be accessible later.
Given that storing a block and it's associated storage changes are handled in one BlockImportOperation, we should remove the StoreTrie method entirely from StorageState. Rather BlockState.AddBlock should accept an introduced OverlayedChanges type analagous to the substrate primitive. I propose creating an interface around TrieState first. Second, we create a new type that implements TrieState which combines the read-only TrieBackend of the block hash, as well as the OverlayedChanges type that can be extracted before calling AddBlock. This new TrieState will be passed into the runtime instance. This introduced implementation of TrieState is analagous to the substrate primitive sp_statemachine::ext::Ext and the analgous trait to the TrieState interface is sp_externalities::Externalities. By following this approach, it should limit the amount of changes within the wazero runtime instance code.
Acceptance Criteria
Introduce TrieState interface and replace occurrences where storage.TrieState are used with new interface.
Given that all usages of TrieState.Trie() are called just to calculate the hash, we should modify any usages of TrieState.Trie() to a new method that will return the state root.
Issue Summary
Taken from design doc:
Acceptance Criteria
TrieState
interface and replace occurrences wherestorage.TrieState
are used with new interface.TrieState
implementation usingOverlayedChanges
issue Introduce and ImplementOverlayedChanges
#4462 to track changesTrieState.Trie()
are called just to calculate the hash, we should modify any usages ofTrieState.Trie()
to a new method that will return the state root.Ext
type introduced in IntroduceExternalities
interface. UtilizeOverlayedChanges
in newExt
type that fulfillsExternalities
#4465.The text was updated successfully, but these errors were encountered: