Skip to content

Commit

Permalink
Merge branch 'txmv2_stuck_tx_detection' into txmv2_enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
dimriou committed Nov 19, 2024
2 parents 409ac1a + 946d2cb commit 6828e38
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions core/chains/evm/txm/storage/inmemory_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,17 +223,17 @@ func TestMarkTransactionsConfirmed(t *testing.T) {
assert.Equal(t, types.TxConfirmed, ctx1.State)
assert.Equal(t, types.TxUnconfirmed, ctx2.State)
assert.Equal(t, utxs[0], ctx2.ID)
assert.Equal(t, 0, len(ctxs))
assert.Empty(t, ctxs)
})
t.Run("prunes confirmed transactions map if it reaches the limit", func(t *testing.T) {
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
for i := 0; i < maxQueuedTransactions; i++ {
_, err := insertConfirmedTransaction(m, uint64(i))

Check failure on line 231 in core/chains/evm/txm/storage/inmemory_store_test.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion int -> uint64 (gosec)
assert.NoError(t, err)
}
assert.Equal(t, maxQueuedTransactions, len(m.ConfirmedTransactions))
assert.Len(t, m.ConfirmedTransactions, maxQueuedTransactions)
m.MarkTransactionsConfirmed(maxQueuedTransactions)
assert.Equal(t, (maxQueuedTransactions - maxQueuedTransactions/pruneSubset), len(m.ConfirmedTransactions))
assert.Len(t, m.ConfirmedTransactions, (maxQueuedTransactions - maxQueuedTransactions/pruneSubset))
})
}

Expand Down Expand Up @@ -261,13 +261,13 @@ func TestUpdateTransactionBroadcast(t *testing.T) {
hash := testutils.NewHash()
t.Run("fails if unconfirmed transaction was not found", func(t *testing.T) {
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
var nonce uint64 = 0
var nonce uint64
assert.Error(t, m.UpdateTransactionBroadcast(0, nonce, hash))
})

t.Run("fails if attempt was not found for a given transaction", func(t *testing.T) {
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
var nonce uint64 = 0
var nonce uint64
tx, err := insertUnconfirmedTransaction(m, nonce)
assert.NoError(t, err)
assert.Error(t, m.UpdateTransactionBroadcast(0, nonce, hash))
Expand All @@ -280,7 +280,7 @@ func TestUpdateTransactionBroadcast(t *testing.T) {

t.Run("updates transaction's and attempt's broadcast times", func(t *testing.T) {
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
var nonce uint64 = 0
var nonce uint64
tx, err := insertUnconfirmedTransaction(m, nonce)
assert.NoError(t, err)
attempt := &types.Attempt{TxID: tx.ID, Hash: hash}
Expand All @@ -303,7 +303,7 @@ func TestUpdateUnstartedTransactionWithNonce(t *testing.T) {
})

t.Run("fails if there is already another unstarted transaction with the same nonce", func(t *testing.T) {
var nonce uint64 = 0
var nonce uint64
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
insertUnstartedTransaction(m)
_, err := insertUnconfirmedTransaction(m, nonce)
Expand All @@ -314,7 +314,7 @@ func TestUpdateUnstartedTransactionWithNonce(t *testing.T) {
})

t.Run("updates unstarted transaction to unconfirmed and assigns a nonce", func(t *testing.T) {
var nonce uint64 = 0
var nonce uint64
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
insertUnstartedTransaction(m)

Expand Down Expand Up @@ -350,7 +350,7 @@ func TestDeleteAttemptForUnconfirmedTx(t *testing.T) {

t.Run("deletes attempt of unconfirmed transaction", func(t *testing.T) {
hash := testutils.NewHash()
var nonce uint64 = 0
var nonce uint64
m := NewInMemoryStore(logger.Test(t), fromAddress, testutils.FixtureChainID)
tx, err := insertUnconfirmedTransaction(m, nonce)
assert.NoError(t, err)
Expand All @@ -360,7 +360,7 @@ func TestDeleteAttemptForUnconfirmedTx(t *testing.T) {
err = m.DeleteAttemptForUnconfirmedTx(nonce, attempt)
assert.NoError(t, err)

assert.Equal(t, 0, len(tx.Attempts))
assert.Len(t, tx.Attempts, 0)
})
}

Expand All @@ -375,8 +375,8 @@ func TestPruneConfirmedTransactions(t *testing.T) {
}
prunedTxIDs := m.pruneConfirmedTransactions()
left := total - total/pruneSubset
assert.Equal(t, left, len(m.ConfirmedTransactions))
assert.Equal(t, total/pruneSubset, len(prunedTxIDs))
assert.Len(t, m.ConfirmedTransactions, left)
assert.Len(t, prunedTxIDs, total/pruneSubset)
}

func insertUnstartedTransaction(m *InMemoryStore) *types.Transaction {
Expand Down
2 changes: 1 addition & 1 deletion core/chains/evm/txm/txm.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ type Keystore interface {
type Config struct {
EIP1559 bool
BlockTime time.Duration
RetryBlockThreshold uint64
RetryBlockThreshold uint16
EmptyTxLimitDefault uint64
}

Expand Down
4 changes: 2 additions & 2 deletions core/chains/evm/txmgr/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func NewTxmV2(
config := txm.Config{
EIP1559: fCfg.EIP1559DynamicFees(),
BlockTime: *txmV2Config.BlockTime(),
RetryBlockThreshold: fCfg.BumpThreshold(),
RetryBlockThreshold: uint16(fCfg.BumpThreshold()),

Check failure on line 135 in core/chains/evm/txmgr/builder.go

View workflow job for this annotation

GitHub Actions / lint

G115: integer overflow conversion uint64 -> uint16 (gosec)
EmptyTxLimitDefault: fCfg.LimitDefault(),
}
var c txm.Client
Expand All @@ -142,7 +142,7 @@ func NewTxmV2(
c = clientwrappers.NewChainClient(client)
}
t := txm.NewTxm(lggr, chainID, c, attemptBuilder, inMemoryStoreManager, stuckTxDetector, config, keyStore)
return txm.NewTxmOrchestrator[common.Hash, *evmtypes.Head](lggr, chainID, t, inMemoryStoreManager, fwdMgr, keyStore, attemptBuilder), nil
return txm.NewTxmOrchestrator(lggr, chainID, t, inMemoryStoreManager, fwdMgr, keyStore, attemptBuilder), nil
}

// NewEvmResender creates a new concrete EvmResender
Expand Down

0 comments on commit 6828e38

Please sign in to comment.