onflow / flow-evm-gateway

FlowEVM Gateway implements an Ethereum-equivalent JSON-RPC API for EVM clients to use
https://developers.flow.com/evm/about
Apache License 2.0
11 stars 9 forks source link

Access list API #144

Open sideninja opened 7 months ago

m-Peter commented 6 months ago

Relevant info:

m-Peter commented 6 months ago

After going through the relevant source code on Geth (https://github.com/ethereum/go-ethereum/blob/master/internal/ethapi/api.go#L1545-L1549), we will need to expose this method through the EVM contract.

Context:

// Apply the transaction with the access list tracer
tracer := logger.NewAccessListTracer(accessList, args.from(), to, precompiles)
config := vm.Config{Tracer: tracer.Hooks(), NoBaseFee: true}
vmenv := b.GetEVM(ctx, msg, statedb, header, &config, nil)
res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit))

The EVM Gateway does not have access to the Geth VM, so I think this is something that should be exposed as a Cadence function from the EVM contract. In turn, the EVM Gateway should call this new Cadence function, through a Cadence transaction.

sideninja commented 6 months ago

The implementation of this optimization feature should be done in the next phase.

sideninja commented 2 months ago

@m-Peter after we build local state will this be doable?

m-Peter commented 2 months ago

@sideninja Good question, I need to do some exploration on this, and see what needs to be done in order to support this.

m-Peter commented 2 months ago

@sideninja After checking this again, it seems that having a StateDB in EVM Gateway won't be enough to support the eth_createAccessList endpoint. We still need an instance of *gethVM.EVM, to be able to apply the message from the given transaction arguments.