From 01794612195f10c3a367a5f554360da23cc53e40 Mon Sep 17 00:00:00 2001 From: DavidZang <110075234+DavidZangNR@users.noreply.github.com> Date: Wed, 7 Aug 2024 09:56:23 +0800 Subject: [PATCH] fix addBalance for delayGasFee (#25) Make the change into the merged mainDB instead of slotDB to avoid the concurrency issue Co-authored-by: Sunny --- core/parallel_state_processor.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/core/parallel_state_processor.go b/core/parallel_state_processor.go index 018e66f19a..26f0637c37 100644 --- a/core/parallel_state_processor.go +++ b/core/parallel_state_processor.go @@ -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 {