@@ -163,17 +163,19 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
163163 rnd := common .BigToHash (pre .Env .Random )
164164 vmContext .Random = & rnd
165165 }
166- // If excessBlobGas is defined, add it to the vmContext.
166+ // Calculate the BlobBaseFee
167+ var excessBlobGas uint64
167168 if pre .Env .ExcessBlobGas != nil {
168- vmContext .ExcessBlobGas = pre .Env .ExcessBlobGas
169+ excessBlobGas := * pre .Env .ExcessBlobGas
170+ vmContext .BlobBaseFee = eip4844 .CalcBlobFee (excessBlobGas )
169171 } else {
170172 // If it is not explicitly defined, but we have the parent values, we try
171173 // to calculate it ourselves.
172174 parentExcessBlobGas := pre .Env .ParentExcessBlobGas
173175 parentBlobGasUsed := pre .Env .ParentBlobGasUsed
174176 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 )
177179 }
178180 }
179181 // 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,
189191 }
190192 var blobGasUsed uint64
191193 for i , tx := range txs {
192- if tx .Type () == types .BlobTxType && vmContext .ExcessBlobGas == nil {
194+ if tx .Type () == types .BlobTxType && vmContext .BlobBaseFee == nil {
193195 errMsg := "blob tx used but field env.ExcessBlobGas missing"
194196 log .Warn ("rejected tx" , "index" , i , "hash" , tx .Hash (), "error" , errMsg )
195197 rejectedTxs = append (rejectedTxs , & rejectedTx {i , errMsg })
@@ -322,8 +324,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
322324 h := types .DeriveSha (types .Withdrawals (pre .Env .Withdrawals ), trie .NewStackTrie (nil ))
323325 execRs .WithdrawalsRoot = & h
324326 }
325- if vmContext .ExcessBlobGas != nil {
326- execRs .CurrentExcessBlobGas = (* math .HexOrDecimal64 )(vmContext . ExcessBlobGas )
327+ if vmContext .BlobBaseFee != nil {
328+ execRs .CurrentExcessBlobGas = (* math .HexOrDecimal64 )(& excessBlobGas )
327329 execRs .CurrentBlobGasUsed = (* math .HexOrDecimal64 )(& blobGasUsed )
328330 }
329331 // Re-create statedb instance with new root upon the updated database
0 commit comments