Skip to content

Commit

Permalink
fix addBalance for delayGasFee (bnb-chain#25)
Browse files Browse the repository at this point in the history
Make the change into the merged mainDB instead of slotDB to avoid
the concurrency issue

Co-authored-by: Sunny <[email protected]>
  • Loading branch information
DavidZangNR and sunny2022da committed Dec 11, 2024
1 parent 9c1c7dd commit f98be3a
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions core/parallel_state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,28 +622,30 @@ func (p *ParallelStateProcessor) confirmTxResults(statedb *state.StateDB, gp *Ga
}

resultTxIndex := result.txReq.txIndex

var root []byte
header := result.txReq.block.Header()

isByzantium := p.config.IsByzantium(header.Number)
isEIP158 := p.config.IsEIP158(header.Number)
result.slotDB.FinaliseForParallel(isByzantium || isEIP158, statedb)

// merge slotDB into mainDB
statedb.MergeSlotDB(result.slotDB, result.receipt, resultTxIndex, result.result.delayFees)

delayGasFee := result.result.delayFees
// add delayed gas fee
if delayGasFee != nil {
if delayGasFee.TipFee != nil {
result.slotDB.AddBalance(delayGasFee.Coinbase, delayGasFee.TipFee)
statedb.AddBalance(delayGasFee.Coinbase, delayGasFee.TipFee)
}
if delayGasFee.BaseFee != nil {
result.slotDB.AddBalance(params.OptimismBaseFeeRecipient, delayGasFee.BaseFee)
statedb.AddBalance(params.OptimismBaseFeeRecipient, delayGasFee.BaseFee)
}
if delayGasFee.L1Fee != nil {
result.slotDB.AddBalance(params.OptimismL1FeeRecipient, delayGasFee.L1Fee)
statedb.AddBalance(params.OptimismL1FeeRecipient, delayGasFee.L1Fee)
}
}
var root []byte
header := result.txReq.block.Header()

isByzantium := p.config.IsByzantium(header.Number)
isEIP158 := p.config.IsEIP158(header.Number)
result.slotDB.FinaliseForParallel(isByzantium || isEIP158, statedb)

// merge slotDB into mainDB
statedb.MergeSlotDB(result.slotDB, result.receipt, resultTxIndex, result.result.delayFees)

// Do IntermediateRoot after mergeSlotDB.
if !isByzantium {
Expand Down

0 comments on commit f98be3a

Please sign in to comment.