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 EVM Object #53

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

Expose EVM Object #53

AusIV opened this issue Aug 5, 2022 · 0 comments

Comments

@AusIV
Copy link
Contributor

AusIV commented Aug 5, 2022

Rationale

The EVM object would be useful for simulating EVM functions, for use cases similar to Cardinal's Estimate Gas List

Implementation

Start with a plugeth-utils interface:

type EVM interface {
  func Reset(txCtx TxContext, statedb StateDB)
  func Cancel()
  func Cancelled() bool
  func Call(caller *core.Address, addr core.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error)
  func CallCode(caller *core.Address, addr core.Address, input []byte, gas uint64, value *big.Int) (ret []byte, leftOverGas uint64, err error)
  func DelegateCall(caller *core.Address, addr core.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
  func StaticCall(caller *core.Address, addr core.Address, input []byte, gas uint64) (ret []byte, leftOverGas uint64, err error)
  func Create(caller *core.Address, code []byte, gas uint64, value *big.Int) (ret []byte, contractAddr core.Address, leftOverGas uint64, err error)
  func Create2(caller *core.Address, code []byte, gas uint64, endowment *big.Int, salt *uint256.Int) (ret []byte, contractAddr core.Address, leftOverGas uint64, err error)
  func ChainConfig() *params.ChainConfig { return evm.chainConfig
}

Then in plugeth's plugins/wrappers, implement a wrapper object that takes a core.EVM object and translates calls to comply with the Plugeth-utils interface.

This could then be exposed through the PluGeth backend by proxying the internal/ethapi backend's GetEVM() call. Note that this will require the implmentation of #52 so that the StateDB can be passed through.

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