-
Notifications
You must be signed in to change notification settings - Fork 71
feat(core,txpool,miner,params): implement eip-7825 tx gas limit cap #31824 #32230 #2210
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -556,11 +556,19 @@ func (pool *LegacyPool) Pending(filter txpool.PendingFilter) map[common.Address] | |
| txs := list.Flatten() | ||
|
|
||
| // If the miner requests tip enforcement, cap the lists now | ||
| if minTipBig != nil { | ||
| if minTipBig != nil || filter.GasLimitCap != 0 { | ||
| for i, tx := range txs { | ||
| if !tx.IsSpecialTransaction() && tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 { | ||
| txs = txs[:i] | ||
| break | ||
| if minTipBig != nil { | ||
| if !tx.IsSpecialTransaction() && tx.EffectiveGasTipIntCmp(minTipBig, baseFeeBig) < 0 { | ||
| txs = txs[:i] | ||
| break | ||
| } | ||
| } | ||
| if filter.GasLimitCap != 0 { | ||
| if tx.Gas() > filter.GasLimitCap { | ||
| txs = txs[:i] | ||
| break | ||
| } | ||
|
Comment on lines
+559
to
+571
|
||
| } | ||
| } | ||
|
gzliudan marked this conversation as resolved.
|
||
| } | ||
|
|
@@ -1351,6 +1359,21 @@ func (pool *LegacyPool) runReorg(done chan struct{}, reset *txpoolResetRequest, | |
| } | ||
| pool.mu.Lock() | ||
| if reset != nil { | ||
| if reset.newHead != nil && reset.oldHead != nil { | ||
| // Discard the transactions with the gas limit higher than the cap. | ||
| if pool.chainconfig.IsOsaka(reset.newHead.Number) && !pool.chainconfig.IsOsaka(reset.oldHead.Number) { | ||
| var hashes []common.Hash | ||
| pool.all.Range(func(hash common.Hash, tx *types.Transaction) bool { | ||
| if tx.Gas() > params.MaxTxGas { | ||
| hashes = append(hashes, hash) | ||
| } | ||
| return true | ||
| }) | ||
| for _, hash := range hashes { | ||
| pool.removeTx(hash, true, true) | ||
| } | ||
| } | ||
| } | ||
| // Reset from the old head to the new, rescheduling any reorged transactions | ||
| pool.reset(reset.oldHead, reset.newHead) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,6 +68,9 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types | |
| if rules.IsEIP1559 && tx.To() == nil && len(tx.Data()) > params.MaxInitCodeSize { | ||
| return fmt.Errorf("%w: code size %v, limit %v", core.ErrMaxInitCodeSizeExceeded, len(tx.Data()), params.MaxInitCodeSize) | ||
| } | ||
| if rules.IsOsaka && tx.Gas() > params.MaxTxGas { | ||
| return fmt.Errorf("%w: cap %d, tx %d", core.ErrGasLimitTooHigh, params.MaxTxGas, tx.Gas()) | ||
| } | ||
|
Comment on lines
+71
to
+73
|
||
| // Transactions can't be negative. This may never happen using RLP decoded | ||
| // transactions but may occur for transactions created using the RPC. | ||
| if tx.Value().Sign() < 0 { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.