From 5032336dc16cd07ece198f730f13a76526c77fe7 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Tue, 19 Nov 2024 16:00:16 +0200 Subject: [PATCH 1/2] Fix lint --- core/chains/evm/txm/storage/inmemory_store_test.go | 2 +- core/chains/evm/txm/txm_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/chains/evm/txm/storage/inmemory_store_test.go b/core/chains/evm/txm/storage/inmemory_store_test.go index d091628c8f7..9e905e88c42 100644 --- a/core/chains/evm/txm/storage/inmemory_store_test.go +++ b/core/chains/evm/txm/storage/inmemory_store_test.go @@ -360,7 +360,7 @@ func TestDeleteAttemptForUnconfirmedTx(t *testing.T) { err = m.DeleteAttemptForUnconfirmedTx(nonce, attempt) assert.NoError(t, err) - assert.Len(t, tx.Attempts, 0) + assert.Empty(t, tx.Attempts) }) } diff --git a/core/chains/evm/txm/txm_test.go b/core/chains/evm/txm/txm_test.go index ae7d1d82975..3f5e6541629 100644 --- a/core/chains/evm/txm/txm_test.go +++ b/core/chains/evm/txm/txm_test.go @@ -46,7 +46,7 @@ func TestLifecycle(t *testing.T) { txStore := storage.NewInMemoryStoreManager(lggr, testutils.FixtureChainID) assert.NoError(t, txStore.Add(addresses...)) txm := NewTxm(lggr, testutils.FixtureChainID, client, ab, txStore, config, keystore) - var nonce uint64 = 0 + var nonce uint64 // Start client.On("PendingNonceAt", mock.Anything, address1).Return(nonce, nil).Once() client.On("PendingNonceAt", mock.Anything, address2).Return(nonce, nil).Once() @@ -80,7 +80,7 @@ func TestTrigger(t *testing.T) { ab := mocks.NewAttemptBuilder(t) config := Config{BlockTime: 1 * time.Minute, RetryBlockThreshold: 10} txm := NewTxm(lggr, testutils.FixtureChainID, client, ab, txStore, config, keystore) - var nonce uint64 = 0 + var nonce uint64 // Start client.On("PendingNonceAt", mock.Anything, address).Return(nonce, nil).Once() servicetest.Run(t, txm) From b16643dfc2a9b96460eff057ce98b0e1d72a0e55 Mon Sep 17 00:00:00 2001 From: Dimitris Date: Tue, 19 Nov 2024 16:08:02 +0200 Subject: [PATCH 2/2] Fix lint --- core/chains/evm/config/chain_scoped_txmv2.go | 4 ++-- core/chains/evm/config/config.go | 2 +- core/chains/evm/config/toml/config.go | 6 ++--- .../clientwrappers/dual_broadcast_client.go | 8 +++---- core/chains/evm/txm/stuck_tx_detector.go | 24 +++++++++---------- core/chains/evm/txmgr/builder.go | 4 ++-- core/config/docs/chains-evm.toml | 4 ++-- docs/CONFIG.md | 8 +++---- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/core/chains/evm/config/chain_scoped_txmv2.go b/core/chains/evm/config/chain_scoped_txmv2.go index 5422f636443..e50148cfae4 100644 --- a/core/chains/evm/config/chain_scoped_txmv2.go +++ b/core/chains/evm/config/chain_scoped_txmv2.go @@ -20,6 +20,6 @@ func (t *txmv2Config) BlockTime() *time.Duration { return &d } -func (t *txmv2Config) CustomUrl() *url.URL { - return t.c.CustomUrl.URL() +func (t *txmv2Config) CustomURL() *url.URL { + return t.c.CustomURL.URL() } diff --git a/core/chains/evm/config/config.go b/core/chains/evm/config/config.go index fe049a173db..be61bfe02ee 100644 --- a/core/chains/evm/config/config.go +++ b/core/chains/evm/config/config.go @@ -106,7 +106,7 @@ type ClientErrors interface { type TxmV2 interface { Enabled() bool BlockTime() *time.Duration - CustomUrl() *url.URL + CustomURL() *url.URL } type Transactions interface { diff --git a/core/chains/evm/config/toml/config.go b/core/chains/evm/config/toml/config.go index 5c762508ac0..0f8b1eceee5 100644 --- a/core/chains/evm/config/toml/config.go +++ b/core/chains/evm/config/toml/config.go @@ -477,7 +477,7 @@ func (c *Chain) ValidateConfig() (err error) { type TxmV2 struct { Enabled *bool `toml:",omitempty"` BlockTime *commonconfig.Duration `toml:",omitempty"` - CustomUrl *commonconfig.URL `toml:",omitempty"` + CustomURL *commonconfig.URL `toml:",omitempty"` } func (t *TxmV2) setFrom(f *TxmV2) { @@ -489,8 +489,8 @@ func (t *TxmV2) setFrom(f *TxmV2) { t.BlockTime = f.BlockTime } - if v := f.CustomUrl; v != nil { - t.CustomUrl = f.CustomUrl + if v := f.CustomURL; v != nil { + t.CustomURL = f.CustomURL } } diff --git a/core/chains/evm/txm/clientwrappers/dual_broadcast_client.go b/core/chains/evm/txm/clientwrappers/dual_broadcast_client.go index 20073127350..aa3a2db10ee 100644 --- a/core/chains/evm/txm/clientwrappers/dual_broadcast_client.go +++ b/core/chains/evm/txm/clientwrappers/dual_broadcast_client.go @@ -26,14 +26,14 @@ type DualBroadcastClientKeystore interface { type DualBroadcastClient struct { c client.Client keystore DualBroadcastClientKeystore - customUrl *url.URL + customURL *url.URL } -func NewDualBroadcastClient(c client.Client, keystore DualBroadcastClientKeystore, customUrl *url.URL) *DualBroadcastClient { +func NewDualBroadcastClient(c client.Client, keystore DualBroadcastClientKeystore, customURL *url.URL) *DualBroadcastClient { return &DualBroadcastClient{ c: c, keystore: keystore, - customUrl: customUrl, + customURL: customURL, } } @@ -81,7 +81,7 @@ func (d *DualBroadcastClient) SendTransaction(ctx context.Context, tx *types.Tra func (d *DualBroadcastClient) signAndPostMessage(ctx context.Context, address common.Address, body []byte, urlParams string) (result string, err error) { bodyReader := bytes.NewReader(body) - postReq, err := http.NewRequestWithContext(ctx, http.MethodPost, d.customUrl.String()+"?"+urlParams, bodyReader) + postReq, err := http.NewRequestWithContext(ctx, http.MethodPost, d.customURL.String()+"?"+urlParams, bodyReader) if err != nil { return } diff --git a/core/chains/evm/txm/stuck_tx_detector.go b/core/chains/evm/txm/stuck_tx_detector.go index aeeed7085b1..68d8caf0ed1 100644 --- a/core/chains/evm/txm/stuck_tx_detector.go +++ b/core/chains/evm/txm/stuck_tx_detector.go @@ -19,7 +19,7 @@ import ( type StuckTxDetectorConfig struct { BlockTime time.Duration StuckTxBlockThreshold uint32 - DetectionApiUrl string + DetectionURL string } type stuckTxDetector struct { @@ -60,22 +60,22 @@ func (s *stuckTxDetector) timeBasedDetection(tx *types.Transaction) bool { return false } -type ApiResponse struct { +type APIResponse struct { Status string `json:"status,omitempty"` Hash common.Hash `json:"hash,omitempty"` } const ( - ApiStatusPending = "PENDING" - ApiStatusIncluded = "INCLUDED" - ApiStatusFailed = "FAILED" - ApiStatusCancelled = "CANCELLED" - ApiStatusUnknown = "UNKNOWN" + APIStatusPending = "PENDING" + APIStatusIncluded = "INCLUDED" + APIStatusFailed = "FAILED" + APIStatusCancelled = "CANCELLED" + APIStatusUnknown = "UNKNOWN" ) func (s *stuckTxDetector) dualBroadcastDetection(ctx context.Context, tx *types.Transaction) (bool, error) { for _, attempt := range tx.Attempts { - req, err := http.NewRequestWithContext(ctx, http.MethodGet, s.config.DetectionApiUrl+attempt.Hash.String(), nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, s.config.DetectionURL+attempt.Hash.String(), nil) if err != nil { return false, fmt.Errorf("failed to make request for txID: %v, attemptHash: %v - %w", tx.ID, attempt.Hash, err) } @@ -93,19 +93,19 @@ func (s *stuckTxDetector) dualBroadcastDetection(ctx context.Context, tx *types. return false, err } - var apiResponse ApiResponse + var apiResponse APIResponse err = json.Unmarshal(body, &apiResponse) if err != nil { return false, fmt.Errorf("failed to unmarshal response for txID: %v, attemptHash: %v - %w: %s", tx.ID, attempt.Hash, err, string(body)) } switch apiResponse.Status { - case ApiStatusPending, ApiStatusIncluded: + case APIStatusPending, APIStatusIncluded: return false, nil - case ApiStatusFailed, ApiStatusCancelled: + case APIStatusFailed, APIStatusCancelled: s.lggr.Debugf("TxID: %v with attempHash: %v was marked as failed/cancelled by the RPC. Transaction is now considered stuck and will be purged.", tx.ID, attempt.Hash) return true, nil - case ApiStatusUnknown: + case APIStatusUnknown: continue default: continue diff --git a/core/chains/evm/txmgr/builder.go b/core/chains/evm/txmgr/builder.go index 5e63c9e6b25..0c224af4326 100644 --- a/core/chains/evm/txmgr/builder.go +++ b/core/chains/evm/txmgr/builder.go @@ -120,7 +120,7 @@ func NewTxmV2( stuckTxDetectorConfig := txm.StuckTxDetectorConfig{ BlockTime: *txmV2Config.BlockTime(), StuckTxBlockThreshold: *txConfig.AutoPurge().Threshold(), - DetectionApiUrl: txConfig.AutoPurge().DetectionApiUrl().String(), + DetectionURL: txConfig.AutoPurge().DetectionApiUrl().String(), } stuckTxDetector = txm.NewStuckTxDetector(lggr, chainConfig.ChainType(), stuckTxDetectorConfig) } @@ -135,7 +135,7 @@ func NewTxmV2( } var c txm.Client if chainConfig.ChainType() == chaintype.ChainDualBroadcast { - c = clientwrappers.NewDualBroadcastClient(client, keyStore, txmV2Config.CustomUrl()) + c = clientwrappers.NewDualBroadcastClient(client, keyStore, txmV2Config.CustomURL()) } else { c = clientwrappers.NewChainClient(client) } diff --git a/core/config/docs/chains-evm.toml b/core/config/docs/chains-evm.toml index 1e50ff28585..cd99027e611 100644 --- a/core/config/docs/chains-evm.toml +++ b/core/config/docs/chains-evm.toml @@ -134,8 +134,8 @@ ResendAfterThreshold = '1m' # Default Enabled = false # Default # BlockTime controls the frequency of the backfill loop of TxmV2. BlockTime = '10s' # Example -# CustomUrl configures the base url of a custom endpoint used by the ChainDualBroadcast chain type. -CustomUrl = 'https://example.api.io' # Example +# CustomURL configures the base url of a custom endpoint used by the ChainDualBroadcast chain type. +CustomURL = 'https://example.api.io' # Example [EVM.Transactions.AutoPurge] # Enabled enables or disables automatically purging transactions that have been idenitified as terminally stuck (will never be included on-chain). This feature is only expected to be used by ZK chains. diff --git a/docs/CONFIG.md b/docs/CONFIG.md index 1020a2f3ce6..cf01ba73b32 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -9290,7 +9290,7 @@ ResendAfterThreshold controls how long to wait before re-broadcasting a transact [EVM.TxmV2] Enabled = false # Default BlockTime = '10s' # Example -CustomUrl = 'https://example.api.io' # Example +CustomURL = 'https://example.api.io' # Example ``` @@ -9306,11 +9306,11 @@ BlockTime = '10s' # Example ``` BlockTime controls the frequency of the backfill loop of TxmV2. -### CustomUrl +### CustomURL ```toml -CustomUrl = 'https://example.api.io' # Example +CustomURL = 'https://example.api.io' # Example ``` -CustomUrl configures the base url of a custom endpoint used by the ChainDualBroadcast chain type. +CustomURL configures the base url of a custom endpoint used by the ChainDualBroadcast chain type. ## EVM.Transactions.AutoPurge ```toml