diff --git a/txpool/pool.go b/txpool/pool.go index cadcf68e9..052009cf0 100644 --- a/txpool/pool.go +++ b/txpool/pool.go @@ -235,7 +235,14 @@ func (sc *SendersCache) mergeStateChanges(stateChanges map[string]senderInfo, un id = sc.senderID sc.senderIDs[addr] = id } - sc.senderInfo[id] = newSenderInfo(v.nonce, v.balance) + old, ok := sc.senderInfo[id] + if ok { + old.nonce = v.nonce + old.balance = v.balance + v.txNonce2Tx = old.txNonce2Tx + } else { + sc.senderInfo[id] = newSenderInfo(v.nonce, v.balance) + } } /* @@ -253,8 +260,10 @@ func (sc *SendersCache) mergeStateChanges(stateChanges map[string]senderInfo, un id = sc.senderID sc.senderIDs[string(unwindedTxs.senders.At(i))] = id } - if _, ok := stateChanges[string(unwindedTxs.senders.At(i))]; !ok { - sc.senderInfo[id] = newSenderInfo(0, *uint256.NewInt(0)) + if _, ok := sc.senderInfo[id]; !ok { + if _, ok := stateChanges[string(unwindedTxs.senders.At(i))]; !ok { + sc.senderInfo[id] = newSenderInfo(0, *uint256.NewInt(0)) + } } } @@ -265,8 +274,10 @@ func (sc *SendersCache) mergeStateChanges(stateChanges map[string]senderInfo, un id = sc.senderID sc.senderIDs[string(minedTxs.senders.At(i))] = id } - if _, ok := stateChanges[string(minedTxs.senders.At(i))]; !ok { - sc.senderInfo[id] = newSenderInfo(0, *uint256.NewInt(0)) + if _, ok := sc.senderInfo[id]; !ok { + if _, ok := stateChanges[string(minedTxs.senders.At(i))]; !ok { + sc.senderInfo[id] = newSenderInfo(0, *uint256.NewInt(0)) + } } //if v, ok := stateChanges[string(minedTxs.senders.At(i))]; ok { @@ -550,11 +561,11 @@ func (p *TxPool) setBaseFee(protocolBaseFee, pendingBaseFee uint64) (uint64, uin func (p *TxPool) OnNewBlock(stateChanges map[string]senderInfo, unwindTxs, minedTxs TxSlots, protocolBaseFee, pendingBaseFee, blockHeight uint64, senders *SendersCache) error { t := time.Now() + protocolBaseFee, pendingBaseFee = p.setBaseFee(protocolBaseFee, pendingBaseFee) if err := senders.onNewBlock(stateChanges, unwindTxs, minedTxs, blockHeight); err != nil { return err } //log.Debug("[txpool] new block", "unwinded", len(unwindTxs.txs), "mined", len(minedTxs.txs), "protocolBaseFee", protocolBaseFee, "blockHeight", blockHeight) - protocolBaseFee, pendingBaseFee = p.setBaseFee(protocolBaseFee, pendingBaseFee) if err := unwindTxs.Valid(); err != nil { return err }