Skip to content

Commit

Permalink
bugfix txpool replace nonce offset (#1736)
Browse files Browse the repository at this point in the history
  • Loading branch information
bas-vk authored Dec 6, 2024
1 parent 9d34d1c commit b9ae483
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions core/node/crypto/chain_txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,9 @@ func (pool *pendingTransactionPool) checkPendingTransactions(ctx context.Context

log := dlog.FromCtx(ctx).With("chain", pool.chainID)

// grab the latest nonce, pending transactions with a nonce lower or equal are included in the chain and should
// grab the latest nonce, pending transactions with a nonce lower are included in the chain and should
// have a receipt available.
nonce, err := pool.client.NonceAt(ctx, pool.wallet.Address, nil)
nonce, err := pool.client.NonceAt(ctx, pool.wallet.Address, head.Number)
if err != nil {
log.Warn("unable to get tx pool nonce", "err", err)
return
Expand All @@ -327,7 +327,7 @@ func (pool *pendingTransactionPool) checkPendingTransactions(ctx context.Context
// drop transactions that have a receipt available from the pool and check others if it is time to send a
// replacement transactions
pool.pendingTxs.Range(func(ptxNonce uint64, ptx *txPoolPendingTransaction) bool {
ptxConfirmed := ptxNonce <= nonce
ptxConfirmed := ptxNonce < nonce

if ptxConfirmed {
ptx.receiptPolls++
Expand Down
4 changes: 1 addition & 3 deletions core/node/crypto/chain_txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ import (
"time"

"github.com/ethereum/go-ethereum"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/stretchr/testify/require"

"github.com/river-build/river/core/node/base/test"
"github.com/river-build/river/core/node/crypto"
"github.com/river-build/river/core/node/infra"
"github.com/stretchr/testify/require"
)

func TestNewTransactionPoolWithReplaceTx(t *testing.T) {
Expand Down

0 comments on commit b9ae483

Please sign in to comment.