@@ -163,17 +163,19 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
163
163
rnd := common .BigToHash (pre .Env .Random )
164
164
vmContext .Random = & rnd
165
165
}
166
- // If excessBlobGas is defined, add it to the vmContext.
166
+ // Calculate the BlobBaseFee
167
+ var excessBlobGas uint64
167
168
if pre .Env .ExcessBlobGas != nil {
168
- vmContext .ExcessBlobGas = pre .Env .ExcessBlobGas
169
+ excessBlobGas := * pre .Env .ExcessBlobGas
170
+ vmContext .BlobBaseFee = eip4844 .CalcBlobFee (excessBlobGas )
169
171
} else {
170
172
// If it is not explicitly defined, but we have the parent values, we try
171
173
// to calculate it ourselves.
172
174
parentExcessBlobGas := pre .Env .ParentExcessBlobGas
173
175
parentBlobGasUsed := pre .Env .ParentBlobGasUsed
174
176
if parentExcessBlobGas != nil && parentBlobGasUsed != nil {
175
- excessBlobGas : = eip4844 .CalcExcessBlobGas (* parentExcessBlobGas , * parentBlobGasUsed )
176
- vmContext .ExcessBlobGas = & excessBlobGas
177
+ excessBlobGas = eip4844 .CalcExcessBlobGas (* parentExcessBlobGas , * parentBlobGasUsed )
178
+ vmContext .BlobBaseFee = eip4844 . CalcBlobFee ( excessBlobGas )
177
179
}
178
180
}
179
181
// If DAO is supported/enabled, we need to handle it here. In geth 'proper', it's
@@ -189,7 +191,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
189
191
}
190
192
var blobGasUsed uint64
191
193
for i , tx := range txs {
192
- if tx .Type () == types .BlobTxType && vmContext .ExcessBlobGas == nil {
194
+ if tx .Type () == types .BlobTxType && vmContext .BlobBaseFee == nil {
193
195
errMsg := "blob tx used but field env.ExcessBlobGas missing"
194
196
log .Warn ("rejected tx" , "index" , i , "hash" , tx .Hash (), "error" , errMsg )
195
197
rejectedTxs = append (rejectedTxs , & rejectedTx {i , errMsg })
@@ -322,8 +324,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
322
324
h := types .DeriveSha (types .Withdrawals (pre .Env .Withdrawals ), trie .NewStackTrie (nil ))
323
325
execRs .WithdrawalsRoot = & h
324
326
}
325
- if vmContext .ExcessBlobGas != nil {
326
- execRs .CurrentExcessBlobGas = (* math .HexOrDecimal64 )(vmContext . ExcessBlobGas )
327
+ if vmContext .BlobBaseFee != nil {
328
+ execRs .CurrentExcessBlobGas = (* math .HexOrDecimal64 )(& excessBlobGas )
327
329
execRs .CurrentBlobGasUsed = (* math .HexOrDecimal64 )(& blobGasUsed )
328
330
}
329
331
// Re-create statedb instance with new root upon the updated database
0 commit comments