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 10 forks source link

Validate transactions using local state #586

Open sideninja opened 1 month ago

sideninja commented 1 month ago

We should validate transactions using the local state (either with remote register API or local register index) instead of relying on the network to return invalid transaction error.

The problem we are facing now is that we have to wait for the network to process the transaction to figure out whether a nonce was incorrect, that is because we have no way to locally test if the nonce is correct for example. Once we have access to the state locally we can do such checks before submitting the transaction to the network and significantly lower the response time.

The transaction pool should then just return the hash of the transaction if valid or an error if invalid. The pool shouldn't have to wait for the transaction result, because that will anyway be done by requesting the transaction receipt.

At that point we should refactor the transaction pool https://github.com/onflow/flow-evm-gateway/blob/main/services/requester/pool.go