Skip to content

Expose StateDB object #52

@AusIV

Description

@AusIV

Rationale

The StateDB gives managed access to a lot of state related information

Implementation

Start with the following interface:

type StateDB interface {
  func StartPrefetcher(namespace string)
  func StopPrefetcher()
  func Error() error
  func AddLog(log []byte) // RLP encoded *types.Log
  func GetLogs(hash core.Hash, blockHash core.Hash) [][]byte // List of RLP encoded *types.Log
  func Logs() [][]byte // List of RLP encoded *types.Log
  func AddPreimage(hash core.Hash, preimage []byte)
  func Preimages() map[core.Hash][]byte
  func AddRefund(gas uint64)
  func SubRefund(gas uint64)
  func Exist(addr core.Address) bool
  func Empty(addr core.Address) bool
  func GetBalance(addr core.Address) *big.Int
  func GetNonce(addr core.Address) uint64
  func TxIndex() int
  func GetCode(addr core.Address) []byte
  func GetCodeSize(addr core.Address) int
  func GetCodeHash(addr core.Address) core.Hash
  func GetState(addr core.Address, hash core.Hash) core.Hash
  func GetProof(addr core.Address) ([][]byte, error)
  func GetProofByHash(addrHash core.Hash) ([][]byte, error)
  func GetStorageProof(a core.Address, key core.Hash) ([][]byte, error)
  func GetCommittedState(addr core.Address, hash core.Hash) core.Hash
  func Database() Database
  func HasSuicided(addr core.Address) bool
  func AddBalance(addr core.Address, amount *big.Int)
  func SubBalance(addr core.Address, amount *big.Int)
  func SetBalance(addr core.Address, amount *big.Int)
  func SetNonce(addr core.Address, nonce uint64)
  func SetCode(addr core.Address, code []byte)
  func SetState(addr core.Address, key, value core.Hash)
  func SetStorage(addr core.Address, storage map[core.Hash]core.Hash)
  func Suicide(addr core.Address) bool
  func GetOrNewStateObject(addr core.Address) *stateObject
  func CreateAccount(addr core.Address)
  func Copy() *StateDB
  func Snapshot() int
  func RevertToSnapshot(revid int)
  func GetRefund() uint64
  func Finalise(deleteEmptyObjects bool)
  func IntermediateRoot(deleteEmptyObjects bool) core.Hash
  func Prepare(thash core.Hash, ti int)
  func Commit(deleteEmptyObjects bool) (core.Hash, error)
  func AddAddressToAccessList(addr core.Address)
  func AddSlotToAccessList(addr core.Address, slot core.Hash)
  func AddressInAccessList(addr core.Address) bool
  func SlotInAccessList(addr core.Address, slot core.Hash) (addressPresent bool, slotPresent bool)
}

Implement a wrapper in plugeth's plugins/wrappers package that translates between a core.state.StateDB object and this interface.

This object can then be exposed to the backend by proxying the ethapi.Backend's StateAndHeaderByNumber function to provide access to the statedb.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions