From 30c9e6a73946555b7534ce38bed382a1eb433b1d Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Fri, 19 Jan 2024 14:41:15 -0500 Subject: [PATCH 1/6] Remove start lock + add logging --- common/txmgr/tracker.go | 8 ++++++-- common/txmgr/txmgr.go | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/common/txmgr/tracker.go b/common/txmgr/tracker.go index 3ef2fc07208..c5a1074cb3a 100644 --- a/common/txmgr/tracker.go +++ b/common/txmgr/tracker.go @@ -92,8 +92,7 @@ func NewTracker[ } func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(_ context.Context) (err error) { - tr.lock.Lock() - defer tr.lock.Unlock() + tr.lggr.Infow("Abandoned transaction tracking enabled") return tr.StartOnce("Tracker", func() error { return tr.startInternal() }) @@ -115,6 +114,8 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) startIntern tr.lggr.Infow("no abandoned txes found, skipping runLoop") return nil } + + tr.lggr.Infow(fmt.Sprintf("%d abandoned txes found, starting runLoop", len(tr.txCache))) tr.wg.Add(1) go tr.runLoop() return nil @@ -211,6 +212,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) trackAbando return fmt.Errorf("tracker already started") } + tr.lggr.Infow("Retrieving non fatal transactions from txStore") nonFatalTxes, err := tr.txStore.GetNonFatalTransactions(ctx, tr.chainID) if err != nil { return fmt.Errorf("failed to get non fatal txes from txStore: %w", err) @@ -239,6 +241,8 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) HandleTxesB } func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) handleTxesByState(ctx context.Context, blockHeight int64) error { + tr.lggr.Infow("Handling transactions by state") + for id, atx := range tr.txCache { tx, err := tr.txStore.GetTxByID(ctx, atx.id) if err != nil { diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index 25c3b9beb35..88a13ab10df 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -195,6 +195,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx return fmt.Errorf("Txm: Tracker failed to start: %w", err) } + b.logger.Infow("Txm starting runLoop") b.wg.Add(1) go b.runLoop() <-b.chSubbed From 460b479ae8dfd8bb8c0fdf6c2dcf6bf16f6b8cbf Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Fri, 19 Jan 2024 15:10:47 -0500 Subject: [PATCH 2/6] Add loggs --- common/txmgr/txmgr.go | 1 + 1 file changed, 1 insertion(+) diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index 88a13ab10df..7a43825df20 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -191,6 +191,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx return fmt.Errorf("Txm: Estimator failed to start: %w", err) } + b.logger.Infow("Txm starting tracker") if err := ms.Start(ctx, b.tracker); err != nil { return fmt.Errorf("Txm: Tracker failed to start: %w", err) } From 7fb29270e1ca74d925237d76edc95c4fe7cf9c07 Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Fri, 19 Jan 2024 15:33:56 -0500 Subject: [PATCH 3/6] Update tracker.go --- common/txmgr/tracker.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/common/txmgr/tracker.go b/common/txmgr/tracker.go index c5a1074cb3a..595bde4c8b8 100644 --- a/common/txmgr/tracker.go +++ b/common/txmgr/tracker.go @@ -92,18 +92,22 @@ func NewTracker[ } func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(_ context.Context) (err error) { - tr.lggr.Infow("Abandoned transaction tracking enabled") + tr.lggr.Info("Abandoned transaction tracking enabled") return tr.StartOnce("Tracker", func() error { return tr.startInternal() }) } func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) startInternal() (err error) { + tr.lock.Lock() + defer tr.lock.Unlock() + tr.ctx, tr.ctxCancel = context.WithCancel(context.Background()) if err := tr.setEnabledAddresses(); err != nil { return fmt.Errorf("failed to set enabled addresses: %w", err) } + tr.lggr.Info("Enabled addresses set") if err := tr.trackAbandonedTxes(tr.ctx); err != nil { return fmt.Errorf("failed to track abandoned txes: %w", err) @@ -115,7 +119,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) startIntern return nil } - tr.lggr.Infow(fmt.Sprintf("%d abandoned txes found, starting runLoop", len(tr.txCache))) + tr.lggr.Infof("%d abandoned txes found, starting runLoop", len(tr.txCache)) tr.wg.Add(1) go tr.runLoop() return nil From d88d65a9f8a08de04a307cafb3eb930b77811e53 Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Fri, 19 Jan 2024 15:35:06 -0500 Subject: [PATCH 4/6] Update tracker.go --- common/txmgr/tracker.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/txmgr/tracker.go b/common/txmgr/tracker.go index 595bde4c8b8..c1c0f36050e 100644 --- a/common/txmgr/tracker.go +++ b/common/txmgr/tracker.go @@ -216,7 +216,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) trackAbando return fmt.Errorf("tracker already started") } - tr.lggr.Infow("Retrieving non fatal transactions from txStore") + tr.lggr.Info("Retrieving non fatal transactions from txStore") nonFatalTxes, err := tr.txStore.GetNonFatalTransactions(ctx, tr.chainID) if err != nil { return fmt.Errorf("failed to get non fatal txes from txStore: %w", err) @@ -245,7 +245,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) HandleTxesB } func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) handleTxesByState(ctx context.Context, blockHeight int64) error { - tr.lggr.Infow("Handling transactions by state") + tr.lggr.Info("Handling transactions by state") for id, atx := range tr.txCache { tx, err := tr.txStore.GetTxByID(ctx, atx.id) From 0ce34b13d651deec606546f09401e1ed517d9caf Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Fri, 19 Jan 2024 16:35:16 -0500 Subject: [PATCH 5/6] Update common/txmgr/txmgr.go Co-authored-by: Jordan Krage --- common/txmgr/txmgr.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index 7a43825df20..928d5c7c8ac 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -191,7 +191,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx return fmt.Errorf("Txm: Estimator failed to start: %w", err) } - b.logger.Infow("Txm starting tracker") + b.logger.Info("Txm starting tracker") if err := ms.Start(ctx, b.tracker); err != nil { return fmt.Errorf("Txm: Tracker failed to start: %w", err) } From 67b6dbae0260d554368e57b0d43c50d049588d6c Mon Sep 17 00:00:00 2001 From: Dylan Tinianov Date: Fri, 19 Jan 2024 16:55:44 -0500 Subject: [PATCH 6/6] Update logging --- common/txmgr/tracker.go | 6 +++--- common/txmgr/txmgr.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/txmgr/tracker.go b/common/txmgr/tracker.go index c1c0f36050e..8b66668c41e 100644 --- a/common/txmgr/tracker.go +++ b/common/txmgr/tracker.go @@ -115,7 +115,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) startIntern tr.isStarted = true if len(tr.txCache) == 0 { - tr.lggr.Infow("no abandoned txes found, skipping runLoop") + tr.lggr.Info("no abandoned txes found, skipping runLoop") return nil } @@ -134,7 +134,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Close() err } func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) closeInternal() error { - tr.lggr.Infow("stopping tracker") + tr.lggr.Info("stopping tracker") if !tr.isStarted { return fmt.Errorf("tracker not started") } @@ -164,7 +164,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) runLoop() { } } case <-ttlExceeded.C: - tr.lggr.Infow("ttl exceeded") + tr.lggr.Info("ttl exceeded") tr.MarkAllTxesFatal(tr.ctx) return case <-tr.ctx.Done(): diff --git a/common/txmgr/txmgr.go b/common/txmgr/txmgr.go index 928d5c7c8ac..358554947cc 100644 --- a/common/txmgr/txmgr.go +++ b/common/txmgr/txmgr.go @@ -196,7 +196,7 @@ func (b *Txm[CHAIN_ID, HEAD, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) Start(ctx return fmt.Errorf("Txm: Tracker failed to start: %w", err) } - b.logger.Infow("Txm starting runLoop") + b.logger.Info("Txm starting runLoop") b.wg.Add(1) go b.runLoop() <-b.chSubbed