Skip to content

Commit

Permalink
merging
Browse files Browse the repository at this point in the history
  • Loading branch information
yashnevatia committed Jan 10, 2025
2 parents dc0c1a7 + 3dcfd1c commit 18ed1b4
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-ants-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

Updated TXM abandon transaction functionality to drop related attempts. #updated
5 changes: 5 additions & 0 deletions .changeset/silver-books-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chainlink": patch
---

#add #nops Add soneium config
36 changes: 36 additions & 0 deletions core/chains/evm/config/toml/defaults/Soneium_Mainnet.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
ChainID = '1868'
ChainType = 'optimismBedrock'
LinkContractAddress = '0x7ea13478Ea3961A0e8b538cb05a9DF0477c79Cd2'
FinalityDepth = 200
LogPollInterval = '2s'
NoNewHeadsThreshold = '40s'
MinIncomingConfirmations = 1
NoNewFinalizedHeadsThreshold = '120m' # Soneium can take upto 2Hours to finalize
FinalityTagEnabled = true

[GasEstimator]
EIP1559DynamicFees = true
PriceMin = '1 wei'
BumpMin = '1 mwei'

[GasEstimator.BlockHistory]
BlockHistorySize = 60

[GasEstimator.DAOracle]
OracleType = 'opstack'
OracleAddress = '0x420000000000000000000000000000000000000F'

[Transactions]
ResendAfterThreshold = '30s'

[HeadTracker]
HistoryDepth = 300

[NodePool]
SyncThreshold = 10

[OCR]
ContractConfirmations = 1

[OCR2.Automation]
GasLimit = 6500000
15 changes: 12 additions & 3 deletions core/chains/evm/txmgr/evm_tx_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1786,8 +1786,17 @@ func (o *evmTxStore) Abandon(ctx context.Context, chainID *big.Int, addr common.
var cancel context.CancelFunc
ctx, cancel = o.stopCh.Ctx(ctx)
defer cancel()
_, err := o.q.ExecContext(ctx, `UPDATE evm.txes SET state='fatal_error', nonce = NULL, error = 'abandoned' WHERE state IN ('unconfirmed', 'in_progress', 'unstarted') AND evm_chain_id = $1 AND from_address = $2`, chainID.String(), addr)
return err
return o.Transact(ctx, false, func(orm *evmTxStore) error {
var abandonedIDs []string
err := orm.q.SelectContext(ctx, &abandonedIDs, `UPDATE evm.txes SET state='fatal_error', nonce = NULL, error = 'abandoned' WHERE state IN ('unconfirmed', 'in_progress', 'unstarted') AND evm_chain_id = $1 AND from_address = $2 RETURNING id`, chainID.String(), addr)
if err != nil {
return fmt.Errorf("failed to mark transactions as abandoned: %w", err)
}
if _, err := orm.q.ExecContext(ctx, `DELETE FROM evm.tx_attempts WHERE eth_tx_id = ANY($1)`, pq.Array(abandonedIDs)); err != nil {
return fmt.Errorf("failed to delete attempts related to abandoned transactions: %w", err)
}
return nil
})
}

// Find transactions by a field in the TxMeta blob and transaction states
Expand Down Expand Up @@ -1916,7 +1925,7 @@ func (o *evmTxStore) FindAttemptsRequiringReceiptFetch(ctx context.Context, chai
query := `
SELECT evm.tx_attempts.* FROM evm.tx_attempts
JOIN evm.txes ON evm.txes.ID = evm.tx_attempts.eth_tx_id
WHERE evm.tx_attempts.state = 'broadcast' AND evm.txes.state IN ('confirmed', 'confirmed_missing_receipt', 'fatal_error') AND evm.txes.evm_chain_id = $1 AND evm.txes.ID NOT IN (
WHERE evm.tx_attempts.state = 'broadcast' AND evm.txes.nonce IS NOT NULL AND evm.txes.state IN ('confirmed', 'confirmed_missing_receipt', 'fatal_error') AND evm.txes.evm_chain_id = $1 AND evm.txes.ID NOT IN (
SELECT DISTINCT evm.txes.ID FROM evm.txes
JOIN evm.tx_attempts ON evm.tx_attempts.eth_tx_id = evm.txes.ID
JOIN evm.receipts ON evm.receipts.tx_hash = evm.tx_attempts.hash
Expand Down
50 changes: 48 additions & 2 deletions core/chains/evm/txmgr/evm_tx_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1796,11 +1796,16 @@ func TestORM_FindAttemptsRequiringReceiptFetch(t *testing.T) {
// Terminally stuck transaction with receipt should NOT be picked up for receipt fetch
stuckTx := mustInsertTerminallyStuckTxWithAttempt(t, txStore, fromAddress, 1, blockNum)
mustInsertEthReceipt(t, txStore, blockNum, utils.NewHash(), stuckTx.TxAttempts[0].Hash)
// Fatal transactions with nil nonce and stored attempts should NOT be picked up for receipt fetch
fatalTxWithAttempt := mustInsertFatalErrorEthTx(t, txStore, fromAddress)
attempt := newBroadcastLegacyEthTxAttempt(t, fatalTxWithAttempt.ID)
err := txStore.InsertTxAttempt(ctx, &attempt)
require.NoError(t, err)

// Confirmed transaction without receipt should be picked up for receipt fetch
confirmedTx := mustInsertConfirmedEthTx(t, txStore, 0, fromAddress)
attempt := newBroadcastLegacyEthTxAttempt(t, confirmedTx.ID)
err := txStore.InsertTxAttempt(ctx, &attempt)
attempt = newBroadcastLegacyEthTxAttempt(t, confirmedTx.ID)
err = txStore.InsertTxAttempt(ctx, &attempt)
require.NoError(t, err)

attempts, err := txStore.FindAttemptsRequiringReceiptFetch(ctx, testutils.FixtureChainID)
Expand All @@ -1823,6 +1828,12 @@ func TestORM_FindAttemptsRequiringReceiptFetch(t *testing.T) {
// Terminally stuck transaction with receipt should NOT be picked up for receipt fetch
stuckTxWithReceipt := mustInsertTerminallyStuckTxWithAttempt(t, txStore, fromAddress, 1, blockNum)
mustInsertEthReceipt(t, txStore, blockNum, utils.NewHash(), stuckTxWithReceipt.TxAttempts[0].Hash)
// Fatal transactions with nil nonce and stored attempts should NOT be picked up for receipt fetch
fatalTxWithAttempt := mustInsertFatalErrorEthTx(t, txStore, fromAddress)
attempt := newBroadcastLegacyEthTxAttempt(t, fatalTxWithAttempt.ID)
err := txStore.InsertTxAttempt(ctx, &attempt)
require.NoError(t, err)

// Terminally stuck transaction without receipt should be picked up for receipt fetch
stuckTxWoutReceipt := mustInsertTerminallyStuckTxWithAttempt(t, txStore, fromAddress, 0, blockNum)

Expand Down Expand Up @@ -2008,6 +2019,41 @@ func TestORM_DeleteReceiptsByTxHash(t *testing.T) {
require.Len(t, etx2.TxAttempts[0].Receipts, 1)
}

func TestORM_Abandon(t *testing.T) {
t.Parallel()

db := pgtest.NewSqlxDB(t)
txStore := cltest.NewTestTxStore(t, db)
ctx := tests.Context(t)
ethKeyStore := cltest.NewKeyStore(t, db).Eth()
_, fromAddress := cltest.MustInsertRandomKeyReturningState(t, ethKeyStore)
etx1 := mustCreateUnstartedGeneratedTx(t, txStore, fromAddress, testutils.FixtureChainID)
etx2 := mustInsertInProgressEthTxWithAttempt(t, txStore, 1, fromAddress)
etx3 := mustInsertUnconfirmedEthTxWithAttemptState(t, txStore, 0, fromAddress, txmgrtypes.TxAttemptBroadcast)

err := txStore.Abandon(ctx, testutils.FixtureChainID, fromAddress)
require.NoError(t, err)

// transactions marked as fatal error with abandon reason, nil sequence, and no attempts
etx1, err = txStore.FindTxWithAttempts(ctx, etx1.ID)
require.NoError(t, err)
require.Equal(t, txmgrcommon.TxFatalError, etx1.State)
require.Nil(t, etx1.Sequence)
require.Empty(t, etx1.TxAttempts)

etx2, err = txStore.FindTxWithAttempts(ctx, etx2.ID)
require.NoError(t, err)
require.Equal(t, txmgrcommon.TxFatalError, etx2.State)
require.Nil(t, etx2.Sequence)
require.Empty(t, etx2.TxAttempts)

etx3, err = txStore.FindTxWithAttempts(ctx, etx3.ID)
require.NoError(t, err)
require.Equal(t, txmgrcommon.TxFatalError, etx3.State)
require.Nil(t, etx3.Sequence)
require.Empty(t, etx3.TxAttempts)
}

func mustInsertTerminallyStuckTxWithAttempt(t *testing.T, txStore txmgr.TestEvmTxStore, fromAddress common.Address, nonceInt int64, broadcastBeforeBlockNum int64) txmgr.Tx {
ctx := tests.Context(t)
broadcast := time.Now()
Expand Down
110 changes: 110 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5933,6 +5933,116 @@ GasLimitDefault = 400000

</p></details>

<details><summary>Soneium Mainnet (1868)</summary><p>

```toml
AutoCreateKey = true
BlockBackfillDepth = 10
BlockBackfillSkip = false
ChainType = 'optimismBedrock'
FinalityDepth = 200
FinalityTagEnabled = true
LinkContractAddress = '0x7ea13478Ea3961A0e8b538cb05a9DF0477c79Cd2'
LogBackfillBatchSize = 1000
LogPollInterval = '2s'
LogKeepBlocksDepth = 100000
LogPrunePageSize = 0
BackupLogPollerBlockDelay = 100
MinIncomingConfirmations = 1
MinContractPayment = '0.00001 link'
NonceAutoSync = true
NoNewHeadsThreshold = '40s'
LogBroadcasterEnabled = true
RPCDefaultBatchSize = 250
RPCBlockQueryDelay = 1
FinalizedBlockOffset = 0
NoNewFinalizedHeadsThreshold = '2h0m0s'

[Transactions]
Enabled = true
ForwardersEnabled = false
MaxInFlight = 16
MaxQueued = 250
ReaperInterval = '1h0m0s'
ReaperThreshold = '168h0m0s'
ResendAfterThreshold = '30s'

[Transactions.AutoPurge]
Enabled = false

[BalanceMonitor]
Enabled = true

[GasEstimator]
Mode = 'BlockHistory'
PriceDefault = '20 gwei'
PriceMax = '115792089237316195423570985008687907853269984665.640564039457584007913129639935 tether'
PriceMin = '1 wei'
LimitDefault = 500000
LimitMax = 500000
LimitMultiplier = '1'
LimitTransfer = 21000
EstimateLimit = false
BumpMin = '1 mwei'
BumpPercent = 20
BumpThreshold = 3
EIP1559DynamicFees = true
FeeCapDefault = '100 gwei'
TipCapDefault = '1 wei'
TipCapMin = '1 wei'

[GasEstimator.BlockHistory]
BatchSize = 25
BlockHistorySize = 60
CheckInclusionBlocks = 12
CheckInclusionPercentile = 90
TransactionPercentile = 60

[GasEstimator.FeeHistory]
CacheTimeout = '10s'

[GasEstimator.DAOracle]
OracleType = 'opstack'
OracleAddress = '0x420000000000000000000000000000000000000F'

[HeadTracker]
HistoryDepth = 300
MaxBufferSize = 3
SamplingInterval = '1s'
MaxAllowedFinalityDepth = 10000
FinalityTagBypass = true
PersistenceEnabled = true

[NodePool]
PollFailureThreshold = 5
PollInterval = '10s'
SelectionMode = 'HighestHead'
SyncThreshold = 10
LeaseDuration = '0s'
NodeIsSyncingEnabled = false
FinalizedBlockPollInterval = '5s'
EnforceRepeatableRead = true
DeathDeclarationDelay = '1m0s'
NewHeadsPollInterval = '0s'

[OCR]
ContractConfirmations = 1
ContractTransmitterTransmitTimeout = '10s'
DatabaseTimeout = '10s'
DeltaCOverride = '168h0m0s'
DeltaCJitterOverride = '1h0m0s'
ObservationGracePeriod = '1s'

[OCR2]
[OCR2.Automation]
GasLimit = 6500000

[Workflow]
GasLimitDefault = 400000
```

</p></details>

<details><summary>Soneium Sepolia (1946)</summary><p>

```toml
Expand Down

0 comments on commit 18ed1b4

Please sign in to comment.