Skip to content

Commit 168b9da

Browse files
committed
cmd/evm: fix blob gas used on invalid transactions
1 parent 8d03918 commit 168b9da

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
140140
rejectedTxs []*rejectedTx
141141
includedTxs types.Transactions
142142
gasUsed = uint64(0)
143+
blobGasUsed = uint64(0)
143144
receipts = make(types.Receipts, 0)
144145
txIndex = 0
145146
)
@@ -189,7 +190,6 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
189190
evm := vm.NewEVM(vmContext, vm.TxContext{}, statedb, chainConfig, vmConfig)
190191
core.ProcessBeaconBlockRoot(*beaconRoot, evm, statedb)
191192
}
192-
var blobGasUsed uint64
193193

194194
for i := 0; txIt.Next(); i++ {
195195
tx, err := txIt.Tx()
@@ -210,15 +210,15 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
210210
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
211211
continue
212212
}
213+
txBlobGas := uint64(0)
213214
if tx.Type() == types.BlobTxType {
214-
txBlobGas := uint64(params.BlobTxBlobGasPerBlob * len(tx.BlobHashes()))
215+
txBlobGas = uint64(params.BlobTxBlobGasPerBlob * len(tx.BlobHashes()))
215216
if used, max := blobGasUsed+txBlobGas, uint64(params.MaxBlobGasPerBlock); used > max {
216217
err := fmt.Errorf("blob gas (%d) would exceed maximum allowance %d", used, max)
217218
log.Warn("rejected tx", "index", i, "err", err)
218219
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
219220
continue
220221
}
221-
blobGasUsed += txBlobGas
222222
}
223223
tracer, err := getTracerFn(txIndex, tx.Hash())
224224
if err != nil {
@@ -247,6 +247,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
247247
if hashError != nil {
248248
return nil, nil, nil, NewError(ErrorMissingBlockhash, hashError)
249249
}
250+
blobGasUsed += txBlobGas
250251
gasUsed += msgResult.UsedGas
251252

252253
// Receipt:

0 commit comments

Comments
 (0)