Skip to content

Commit

Permalink
Hotfix attempt for Canary : v2.8.0-rc0 upgrade fails on Polygon. (#11828
Browse files Browse the repository at this point in the history
) (#11839)

* Remove start lock + add logging

* Add loggs

* Update tracker.go

* Update tracker.go

* Update common/txmgr/txmgr.go

Co-authored-by: Jordan Krage <jmank88@gmail.com>

* Update logging

---------

Co-authored-by: Jordan Krage <jmank88@gmail.com>
(cherry picked from commit 6133df8)
  • Loading branch information
DylanTinianov authored Jan 22, 2024
1 parent c8203bd commit 0d4f232
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 13 additions & 5 deletions common/txmgr/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,34 @@ 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.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)
}

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
}

tr.lggr.Infof("%d abandoned txes found, starting runLoop", len(tr.txCache))
tr.wg.Add(1)
go tr.runLoop()
return nil
Expand All @@ -129,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")
}
Expand Down Expand Up @@ -159,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():
Expand Down Expand Up @@ -211,6 +216,7 @@ func (tr *Tracker[CHAIN_ID, ADDR, TX_HASH, BLOCK_HASH, R, SEQ, FEE]) trackAbando
return fmt.Errorf("tracker already started")
}

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)
Expand Down Expand Up @@ -239,6 +245,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.Info("Handling transactions by state")

for id, atx := range tr.txCache {
tx, err := tr.txStore.GetTxByID(ctx, atx.id)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions common/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ 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.Info("Txm starting tracker")
if err := ms.Start(ctx, b.tracker); err != nil {
return fmt.Errorf("Txm: Tracker failed to start: %w", err)
}

b.logger.Info("Txm starting runLoop")
b.wg.Add(1)
go b.runLoop()
<-b.chSubbed
Expand Down

0 comments on commit 0d4f232

Please sign in to comment.