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
Currently the state.BlockState type is essentially used to store block history and to set finalization for stored blocks. The type state.BlockState does not have a corresponding interface that represents the entire public API of the type. After looking through the code, I've compiled the entire public interface of state.BlockState that is called by other packages. The interface is as follows:
typeBlockStateinterface {
AddBlock(*types.Block) errorAddBlockWithArrivalTime(block*types.Block, arrivalTime time.Time) errorBestBlock() (*types.Block, error)
BestBlockHash() common.HashBestBlockHeader() (*types.Header, error)
BestBlockNumber() (numberuint, errerror)
GenesisHash() common.HashGetBlockBody(hash common.Hash) (*types.Body, error)
GetBlockStateRoot(bhash common.Hash) (common.Hash, error)
GetBlockByHash(common.Hash) (*types.Block, error)
GetBlockByNumber(blockNumberuint) (*types.Block, error)
GetFinalisedHeader(round, setIDuint64) (*types.Header, error)
GetFinalisedHash(round, setIDuint64) (common.Hash, error)
GetHashesByNumber(blockNumberuint) ([]common.Hash, error) // not sure why we need this, use `GetHashByNumber`?GetHashByNumber(blockNumberuint) (common.Hash, error)
GetHeader(bhash common.Hash) (*types.Header, error)
GetHeaderByNumber(numuint) (*types.Header, error)
GetHighestFinalisedHeader() (*types.Header, error)
GetHighestFinalisedHash() (common.Hash, error)
GetHighestRoundAndSetID() (uint64, uint64, error)
GetJustification(common.Hash) ([]byte, error)
GetNonFinalisedBlocks() []common.Hash// can probably be achieved by getting last finalized, then traversing childrenGetSlotForBlock(common.Hash) (uint64, error)
HasFinalisedBlock(round, setIDuint64) (bool, error)
HasHeader(hash common.Hash) (bool, error)
HasJustification(hash common.Hash) (bool, error)
HasHeaderInDatabase(hash common.Hash) (bool, error) // can probably just use `HasHeader`SetFinalisedHash(hash common.Hash, rounduint64, setIDuint64) errorSetHeader(header*types.Header) errorSetJustification(hash common.Hash, data []byte) errorGetRuntime(blockHash common.Hash) (instance runtime.Instance, errerror) // can be achieved by retrieving digest from block and decodingHandleRuntimeChanges(newState*rtstorage.TrieState, in runtime.Instance, bHash common.Hash) error// will have to be recreatedCompareAndSetBlockData(bd*types.BlockData) errorIsDescendantOf(parent, child common.Hash) (bool, error)
LowestCommonAncestor(a, b common.Hash) (common.Hash, error)
NumberIsFinalised(blockNumberuint) (bool, error)
Range(startHash, endHash common.Hash) (hashes []common.Hash, errerror)
RangeInMemory(start, end common.Hash) ([]common.Hash, error)
StoreRuntime(blockHash common.Hash, runtime runtime.Instance)
FreeImportedBlockNotifierChannel(chchan*types.Block)
GetImportedBlockNotifierChannel() chan*types.BlockFreeFinalisedNotifierChannel(chchan*types.FinalisationInfo)
GetFinalisedNotifierChannel() chan*types.FinalisationInfoRegisterRuntimeUpdatedChannel(chchan<- runtime.Version) (uint32, error)
IsPaused() boolPause() error
}
StorageState is an interface that is locally defined in a number of packages. It represents the functionality regarding accessing the current TrieState which gives access to the underlying in memory state trie (canonically known as "storage") for a given hash. Generation of storage trie proofs is part of this interface as well. The interface with largest amount of methods is defined in dot/core. The implementation of these StorageState interfaces is implemented by the type state.InmemoryStorageState. I've compiled the entire public interface of state.InmemoryStorageState that is called by other packages. The interface is as follows:
The text was updated successfully, but these errors were encountered:
timwu20
changed the title
Introduce revised BlockState and TrieState interface for entire public API
Introduce revised BlockState and StorageState interface for entire public API
Jan 16, 2025
Issue Summary
From design doc:
Acceptance Criteria
BlockState
type is defined.NewBlockState
to return an interfaceBlockState
.BlockState
type to privateblockState
ordefaultBlockState
.StorageState
.Other information and links
blockState
interface.storageState
interface.The text was updated successfully, but these errors were encountered: