-
Notifications
You must be signed in to change notification settings - Fork 21.1k
eth/gasestimator: check ErrGasLimitTooHigh conditions #32268
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
eth/gasestimator: check ErrGasLimitTooHigh conditions #32268
Conversation
Replace manual byte-by-byte XOR implementation with the optimized bitutil.XORBytes function. This improves performance by using word-sized operations on supported architectures while maintaining the same functionality. The optimized version processes data in bulk rather than one byte at a time --------- Co-authored-by: Felix Lange <fjl@twurst.com>
Improve binary search, preventing the potential overflow in certain L2 cases
Seems the `signal.result` was not sent back in shorten case, this will cause a deadlock. --------- Signed-off-by: jsvisa <delweng@gmail.com> Co-authored-by: Gary Rong <garyrong0905@gmail.com>
Adds the heal time and snap sync time to grafana --------- Co-authored-by: Gary Rong <garyrong0905@gmail.com>
eth/gasestimator/gasestimator.go
Outdated
@@ -62,6 +62,9 @@ func Estimate(ctx context.Context, call *core.Message, opts *Options, gasCap uin | |||
if call.GasLimit >= params.TxGas { | |||
hi = call.GasLimit | |||
} | |||
if hi >= params.MaxTxGas { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might break L2 projects whose transactions potentially consume more gas in order to amortize L1 costs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might have misunderstood the code, but even if the L2s specified gas higher than MaxTxGas
, wouldn't it err with ErrGasLimitTooHigh
and return error for the estimateGas call anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you are right!
I will ask L2 forks how they plan to integrate the EIP-7825 first, but generally your changes look good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The gas capping should only be applied for Osaka
// Cap the maximum gas allowance according to EIP-7825 if the estimation targets Osaka
if hi > params.MaxTxGas {
blockNumber, blockTime := opts.Header.Number, opts.Header.Time
if opts.BlockOverrides != nil {
if opts.BlockOverrides.Number != nil {
blockNumber = opts.BlockOverrides.Number.ToInt()
}
if opts.BlockOverrides.Time != nil {
blockTime = uint64(*opts.BlockOverrides.Time)
}
}
if opts.Config.IsOsaka(blockNumber, blockTime) {
hi = params.MaxTxGas
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
understood, thank you! I've updated the code to your suggestion 🙏
The `errors.new` function does not require string formatting, so its performance is better than that of `fmt.Errorf`.
…m#32269) Correct the error message in the ExecuteStatelessPayloadV4 function to reference newPayloadV4 and the Prague fork, instead of incorrectly referencing newPayloadV3 and Cancun. This improves clarity during debugging and aligns the error message with the actual function and fork being validated. No logic is changed. --------- Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
Alternative implementation of ethereum#32159
The errors.new function does not require string formatting, so its performance is better than that of fmt.Errorf.
This PR addresses a flakiness in the rollback test discussed in ethereum#32252 I found `nonce` collision caused transactions occasionally fail to send. I tried to change error message in the failed test like: ``` if err = client.SendTransaction(ctx, signedTx); err != nil { t.Fatalf("failed to send transaction: %v, nonce: %d", err, signedTx.Nonce()) } ``` and I occasionally got test failure with this message: ``` === CONT TestFlakyFunction/Run_#100 rollback_test.go:44: failed to send transaction: already known, nonce: 0 --- FAIL: TestFlakyFunction/Run_#100 (0.07s) ``` Although `nonces` are obtained via `PendingNonceAt`, we observed that, in rare cases (approximately 1 in 1000), two transactions from the same sender end up with the same nonce. This likely happens because `tx0` has not yet propagated to the transaction pool before `tx1` requests its nonce. When the test succeeds, `tx0` and `tx1` have nonces `0` and `1`, respectively. However, in rare failures, both transactions end up with nonce `0`. We modified the test to explicitly assign nonces to each transaction. By controlling the nonce values manually, we eliminated the race condition and ensured consistent behavior. After several thousand runs, the flakiness was no longer reproducible in my local environment. Reduced internal polling interval in `pendingStateHasTx()` to speed up test execution without impacting stability. It reduces test time for `TestTransactionRollbackBehavior` from about 7 seconds to 2 seconds.
Improvement: preallocate capacity for `logs` at first to avoid reallocating multi times.
Oops, the compilation is failing
|
This adds a cross-client protocol test for a recently discovered bug in Nethermind.
This pull request optimizes trie hashing by reducing memory allocation overhead. Specifically: - define a fullNodeEncoder pool to reuse encoders and avoid memory allocations. - simplify the encoding logic for shortNode and fullNode by getting rid of the Go interfaces.
This adds a method on vm.EVM to set the jumpdest cache implementation. It can be used to maintain an analysis cache across VM invocations, to improve performance by skipping the analysis for already known contracts. --------- Co-authored-by: lmittmann <lmittmann@users.noreply.github.com> Co-authored-by: Felix Lange <fjl@twurst.com>
8121be4
to
b58e83f
Compare
…imit estimation to continue estimating with lower caps
b58e83f
to
5ef01bb
Compare
Just realized you are opening the PR against Sorry I messed your branch, I thought it's against master |
@rjl493456442 Hi, sorry for taking a while to check back on this. I just created another PR to master with clean commit history since this isn't necessarily for fusaka specific. #32348 |
Implemented in the #32348 |
This PR makes 2 changes to how EIP-7825 behaves.
When
eth_estimateGas
oreth_createAccessList
is called without any gas limit in the payload, geth will choose the block's gas limit or theRPCGasCap
, which can be larger than themaxTxGas
.When this happens for
estimateGas
, the gas estimation just errors out and ends, when it should continue doing binary search to find the lowest possible gas limit.This PR will:
Add a check to see if
hi
is larger thanmaxTxGas
and cap it tomaxTxGas
if it's larger. And add a special case handling for gas estimation execute when it errs withErrGasLimitTooHigh
Decrease the
RPCGasCap
to 30M (== maxTxGas) to makecreateAccessList
choose 30M as the highest gas cap for the tx. This can also be fixed by adding a check like this to usemaxTxGas
when the specifiedRPCGasCap
is larger thanmaxTxGas
. I'd be glad to fix it either way!I've created this PR for fusaka-devnet-3 first, and will open another pr to master (or there is some periodic merges to master) if needed.