Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed setting 0 value to baseFee #857

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions zk/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,7 @@ func (p *TxPool) OnNewBlock(ctx context.Context, stateChanges *remote.StateChang
return err
}

var baseFee uint64
if !p.ethCfg.AllowFreeTransactions {
baseFee = stateChanges.PendingBlockBaseFee
} else {
baseFee = uint64(0)
}

pendingBaseFee, baseFeeChanged := p.setBaseFee(baseFee)
pendingBaseFee, baseFeeChanged := p.setBaseFee(stateChanges.PendingBlockBaseFee, p.ethCfg.AllowFreeTransactions)
// Update pendingBase for all pool queues and slices
if baseFeeChanged {
p.pending.best.pendingBaseFee = pendingBaseFee
Expand Down Expand Up @@ -1048,10 +1041,23 @@ func addTxs(blockNum uint64, cacheView kvcache.CacheView, senders *sendersBatch,

return announcements, discardReasons, nil
}
func addTxsOnNewBlock(blockNum uint64, cacheView kvcache.CacheView, stateChanges *remote.StateChangeBatch,
senders *sendersBatch, newTxs types.TxSlots, pendingBaseFee uint64, blockGasLimit uint64,
pending *PendingPool, baseFee, queued *SubPool,
byNonce *BySenderAndNonce, byHash map[string]*metaTx, sendersWithChangedStateBeforeLimboTrim *LimboSendersWithChangedState, add func(*metaTx, *types.Announcements) DiscardReason, discard func(*metaTx, DiscardReason)) (types.Announcements, error) {
func addTxsOnNewBlock(
blockNum uint64,
cacheView kvcache.CacheView,
stateChanges *remote.StateChangeBatch,
senders *sendersBatch,
newTxs types.TxSlots,
pendingBaseFee uint64,
blockGasLimit uint64,
pending *PendingPool,
baseFee,
queued *SubPool,
byNonce *BySenderAndNonce,
byHash map[string]*metaTx,
sendersWithChangedStateBeforeLimboTrim *LimboSendersWithChangedState,
add func(*metaTx, *types.Announcements) DiscardReason,
discard func(*metaTx, DiscardReason),
) (types.Announcements, error) {
protocolBaseFee := calcProtocolBaseFee(pendingBaseFee)
if assert.Enable {
for _, txn := range newTxs.Txs {
Expand Down Expand Up @@ -1121,8 +1127,13 @@ func addTxsOnNewBlock(blockNum uint64, cacheView kvcache.CacheView, stateChanges
return announcements, nil
}

func (p *TxPool) setBaseFee(baseFee uint64) (uint64, bool) {
func (p *TxPool) setBaseFee(baseFee uint64, allowFreeTransactions bool) (uint64, bool) {
changed := false
if allowFreeTransactions {
changed = uint64(0) != p.pendingBaseFee.Load()
p.pendingBaseFee.Store(0)
}

if baseFee > 0 {
changed = baseFee != p.pendingBaseFee.Load()
p.pendingBaseFee.Store(baseFee)
Expand Down
Loading