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

Merged
merged 1 commit into from
Oct 2, 2024

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.24%. Comparing base (da7280d) to head (7aae0c5).
Report is 2 commits behind head on main.

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.25%   61.24%   -0.02%     
==========================================
  Files         263      263              
  Lines       23275    23285      +10     
==========================================
+ Hits        14257    14260       +3     
- Misses       8011     8016       +5     
- Partials     1007     1009       +2     
Files with missing lines Coverage Δ
evmrpc/simulate.go 65.00% <70.00%> (+0.17%) ⬆️

... and 1 file with indirect coverage changes

@codchen codchen force-pushed the multitx-estimategas branch from 3ee6b8d to 7aae0c5 Compare October 2, 2024 03:45
@codchen codchen merged commit cc5d533 into main Oct 2, 2024
49 checks passed
@codchen codchen deleted the multitx-estimategas branch October 2, 2024 11:31
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.

2 participants