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

Expose StateDB object #52

Open
AusIV opened this issue Aug 5, 2022 · 0 comments
Open

Expose StateDB object #52

AusIV opened this issue Aug 5, 2022 · 0 comments

Comments

@AusIV
Copy link
Contributor

AusIV commented Aug 5, 2022

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.

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