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

Add endpoint to estimate gas after simulating calls #1878

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented Oct 1, 2024

Describe your changes and provide context

There are cases when gas estimation needs to be done based on certain simulated states which cannot be statically inputted as state overrides. One example is to estimate gas for an ERC20 transferFrom while assuming the allowance is in place.

This PR (together with sei-protocol/go-ethereum#35) adds a new endpoint eth_estimateGasAfterCalls to support such use cases.

Testing performed to validate your change

unit test

@@ -95,6 +95,18 @@
return estimate, err
}

func (s *SimulationAPI) EstimateGasAfterCalls(ctx context.Context, args ethapi.TransactionArgs, calls []ethapi.TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *ethapi.StateOverride) (result hexutil.Uint64, returnErr error) {
startTime := time.Now()

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
Copy link

codecov bot commented Oct 1, 2024

Codecov Report

Attention: Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 61.12%. Comparing base (91f9abc) to head (3ee6b8d).

Files with missing lines Patch % Lines
evmrpc/simulate.go 70.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1878      +/-   ##
==========================================
- Coverage   61.24%   61.12%   -0.13%     
==========================================
  Files         263      263              
  Lines       23246    23256      +10     
==========================================
- Hits        14237    14215      -22     
- Misses       8006     8039      +33     
+ Partials     1003     1002       -1     
Flag Coverage Δ
61.12% <70.00%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
evmrpc/simulate.go 65.00% <70.00%> (+0.17%) ⬆️

... and 1 file with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant