Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Build executable heap with baseFee when London fork is enabled #1857

Merged
merged 23 commits into from
Sep 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
5 changes: 3 additions & 2 deletions txpool/account.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package txpool

import (
"math/big"
"sync"
"sync/atomic"

Expand Down Expand Up @@ -44,7 +45,7 @@ func (m *accountsMap) exists(addr types.Address) bool {

// getPrimaries collects the heads (first-in-line transaction)
// from each of the promoted queues.
func (m *accountsMap) getPrimaries() (primaries []*types.Transaction) {
func (m *accountsMap) getPrimaries(baseFee uint64) (primaries []*types.Transaction) {
m.Range(func(key, value interface{}) bool {
addressKey, ok := key.(types.Address)
rachit77 marked this conversation as resolved.
Show resolved Hide resolved
if !ok {
Expand All @@ -57,7 +58,7 @@ func (m *accountsMap) getPrimaries() (primaries []*types.Transaction) {
defer account.promoted.unlock()

// add head of the queue
if tx := account.promoted.peek(); tx != nil {
if tx := account.promoted.peek(); tx != nil && tx.GetGasFeeCap().Cmp(new(big.Int).SetUint64(baseFee)) >= 0 {
igorcrevar marked this conversation as resolved.
Show resolved Hide resolved
primaries = append(primaries, tx)
}

Expand Down
4 changes: 2 additions & 2 deletions txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func (p *TxPool) AddTx(tx *types.Transaction) error {
// ready for execution. (primaries)
func (p *TxPool) Prepare() {
// fetch primary from each account
primaries := p.accounts.getPrimaries()
primaries := p.accounts.getPrimaries(p.GetBaseFee())

// create new executables queue with base fee and initial transactions (primaries)
p.executables = newPricesQueue(p.GetBaseFee(), primaries)
rachit77 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -385,7 +385,7 @@ func (p *TxPool) Pop(tx *types.Transaction) {
p.updatePending(-1)

// update executables
if tx := account.promoted.peek(); tx != nil {
if tx := account.promoted.peek(); tx != nil && tx.GetGasFeeCap().Cmp(new(big.Int).SetUint64(p.GetBaseFee())) >= 0 {
p.executables.push(tx)
}
}
Expand Down