-
Notifications
You must be signed in to change notification settings - Fork 70
feat(core,miner): implement EIP-7934 - RLP execution block size limit #31990 #2237
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 |
|---|---|---|
|
|
@@ -62,6 +62,10 @@ const ( | |
| chainSideChanSize = 10 | ||
|
|
||
| txMatchGasLimit = 40000000 | ||
|
|
||
| // Block size is capped by the protocol at params.MaxBlockSize. During | ||
| // production keep a safety margin for auxiliary fields added to the block. | ||
| maxBlockSizeBufferZone = 1_000_000 | ||
|
gzliudan marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -90,6 +94,7 @@ type Work struct { | |
| signer types.Signer | ||
| state *state.StateDB // apply state changes here | ||
| tcount int // tx count in cycle | ||
| size uint64 // size of the block we are building | ||
| evm *vm.EVM | ||
|
|
||
| parentState *state.StateDB | ||
|
|
@@ -108,6 +113,15 @@ type Work struct { | |
| createdAt time.Time | ||
| } | ||
|
|
||
| // txFitsSize reports whether the transaction fits into the block size limit. | ||
| func (w *Work) txFitsSize(tx *types.Transaction) bool { | ||
|
gzliudan marked this conversation as resolved.
|
||
| // this Osaka-specific cap is not enforced pre-fork | ||
| if w.config.IsOsaka(w.header.Number) { | ||
| return w.size+tx.Size() < params.MaxBlockSize-maxBlockSizeBufferZone | ||
| } | ||
| return true | ||
| } | ||
|
|
||
| type Result struct { | ||
| Work *Work | ||
| Block *types.Block | ||
|
|
@@ -712,6 +726,7 @@ func (w *worker) makeCurrent(parent *types.Block, header *types.Header) error { | |
| config: w.chainConfig, | ||
| signer: types.MakeSigner(w.chainConfig, header.Number), | ||
| state: state, | ||
| size: uint64(header.Size()), | ||
| parentState: state.Copy(), | ||
|
gzliudan marked this conversation as resolved.
|
||
| tradingState: XDCxState, | ||
| lendingState: lendingState, | ||
|
|
@@ -1080,6 +1095,10 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr | |
| var coalescedLogs []*types.Log | ||
| // first priority for special Txs | ||
| for _, tx := range specialTxs { | ||
| if !w.txFitsSize(tx) { | ||
| log.Debug("Skipping oversized transaction", "hash", tx.Hash(), "size", tx.Size()) | ||
| continue | ||
| } | ||
|
Comment on lines
1097
to
+1101
|
||
| to := tx.To() | ||
| if w.header.Number.Uint64() >= common.DenylistHFNumber { | ||
| from := tx.From() | ||
|
|
@@ -1193,6 +1212,12 @@ func (w *Work) commitTransactions(mux *event.TypeMux, balanceFee map[common.Addr | |
| break | ||
| } | ||
| tx := resolvedTx | ||
| // if inclusion of the transaction would put the block size over the | ||
| // maximum we allow, don't add any more txs to the payload. | ||
| if !w.txFitsSize(tx) { | ||
| log.Debug("Skipping oversized transaction", "hash", tx.Hash(), "size", tx.Size()) | ||
| break | ||
|
gzliudan marked this conversation as resolved.
|
||
| } | ||
| to := tx.To() | ||
| if w.header.Number.Uint64() >= common.DenylistHFNumber { | ||
| from := tx.From() | ||
|
|
@@ -1330,6 +1355,7 @@ func (w *Work) commitTransaction(balanceFee map[common.Address]*big.Int, tx *typ | |
| } | ||
| w.txs = append(w.txs, tx) | ||
| w.receipts = append(w.receipts, receipt) | ||
| w.size += tx.Size() | ||
|
|
||
| return receipt.Logs, tokenFeeUsed, gas, nil | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.