diff --git a/p2p/pkg/autodepositor/autodepositor.go b/p2p/pkg/autodepositor/autodepositor.go index e431be380..dfc8713f4 100644 --- a/p2p/pkg/autodepositor/autodepositor.go +++ b/p2p/pkg/autodepositor/autodepositor.go @@ -22,15 +22,10 @@ type BidderRegistryContract interface { WithdrawFromWindows(opts *bind.TransactOpts, windows []*big.Int) (*types.Transaction, error) } -type TxWatcher interface { - WaitForReceipt(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) -} - type AutoDepositTracker struct { startMu sync.Mutex isWorking bool eventMgr events.EventManager - watcher TxWatcher deposits sync.Map windowChan chan *blocktracker.BlocktrackerNewWindow brContract BidderRegistryContract @@ -43,14 +38,12 @@ func New( evtMgr events.EventManager, brContract BidderRegistryContract, optsGetter OptsGetter, - watcher TxWatcher, logger *slog.Logger, ) *AutoDepositTracker { return &AutoDepositTracker{ eventMgr: evtMgr, brContract: brContract, optsGetter: optsGetter, - watcher: watcher, windowChan: make(chan *blocktracker.BlocktrackerNewWindow, 1), logger: logger, } @@ -77,20 +70,11 @@ func (adt *AutoDepositTracker) Start( opts.Value = big.NewInt(0).Mul(amount, big.NewInt(2)) // Make initial deposit for the first two windows - txn, err := adt.brContract.DepositForWindows(opts, []*big.Int{startWindow, nextWindow}) - if err != nil { - return err - } - - receipt, err := adt.watcher.WaitForReceipt(ctx, txn) + _, err = adt.brContract.DepositForWindows(opts, []*big.Int{startWindow, nextWindow}) if err != nil { return err } - if receipt.Status != types.ReceiptStatusSuccessful { - return fmt.Errorf("initial deposit transaction failed: %d", receipt.Status) - } - adt.deposits.Store(startWindow.Uint64(), true) adt.deposits.Store(nextWindow.Uint64(), true) @@ -143,13 +127,6 @@ func (adt *AutoDepositTracker) Start( if err != nil { return err } - r, err := adt.watcher.WaitForReceipt(egCtx, txn) - if err != nil { - return err - } - if r.Status != types.ReceiptStatusSuccessful { - return fmt.Errorf("withdraw transaction failed: %d", r.Status) - } adt.logger.Info("withdraw from windows", "hash", txn.Hash(), "windows", withdrawWindows) for _, window := range withdrawWindows { adt.deposits.Delete(window.Uint64()) @@ -174,13 +151,6 @@ func (adt *AutoDepositTracker) Start( if err != nil { return err } - r, err := adt.watcher.WaitForReceipt(egCtx, txn) - if err != nil { - return err - } - if r.Status != types.ReceiptStatusSuccessful { - return fmt.Errorf("deposit transaction failed: %d", r.Status) - } adt.logger.Info( "deposited to next window", "hash", txn.Hash(), diff --git a/p2p/pkg/autodepositor/autodepositor_test.go b/p2p/pkg/autodepositor/autodepositor_test.go index 830349f79..d291f3fa9 100644 --- a/p2p/pkg/autodepositor/autodepositor_test.go +++ b/p2p/pkg/autodepositor/autodepositor_test.go @@ -33,14 +33,6 @@ func (m *MockBidderRegistryContract) WithdrawFromWindows(opts *bind.TransactOpts return m.WithdrawFromWindowsFunc(opts, windows) } -type MockTxWatcher struct { - WaitForReceiptFunc func(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) -} - -func (m *MockTxWatcher) WaitForReceipt(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) { - return m.WaitForReceiptFunc(ctx, tx) -} - func TestAutoDepositTracker_Start(t *testing.T) { t.Parallel() @@ -68,16 +60,9 @@ func TestAutoDepositTracker_Start(t *testing.T) { optsGetter := func(ctx context.Context) (*bind.TransactOpts, error) { return &bind.TransactOpts{}, nil } - watcher := &MockTxWatcher{ - WaitForReceiptFunc: func(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) { - return &types.Receipt{ - Status: 1, - }, nil - }, - } // Create AutoDepositTracker instance - adt := autodepositor.New(evtMgr, brContract, optsGetter, watcher, logger) + adt := autodepositor.New(evtMgr, brContract, optsGetter, logger) // Start AutoDepositTracker ctx := context.Background() @@ -168,16 +153,9 @@ func TestAutoDepositTracker_Start_CancelContext(t *testing.T) { optsGetter := func(ctx context.Context) (*bind.TransactOpts, error) { return &bind.TransactOpts{}, nil } - watcher := &MockTxWatcher{ - WaitForReceiptFunc: func(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) { - return &types.Receipt{ - Status: 1, - }, nil - }, - } // Create AutoDepositTracker instance - adt := autodepositor.New(evtMgr, brContract, optsGetter, watcher, logger) + adt := autodepositor.New(evtMgr, brContract, optsGetter, logger) // Start AutoDepositTracker with a cancelable context ctx, cancel := context.WithCancel(context.Background()) @@ -210,10 +188,9 @@ func TestAutoDepositTracker_Stop_NotRunning(t *testing.T) { optsGetter := func(ctx context.Context) (*bind.TransactOpts, error) { return &bind.TransactOpts{}, nil } - watcher := &MockTxWatcher{} // Create AutoDepositTracker instance - adt := autodepositor.New(evtMgr, brContract, optsGetter, watcher, logger) + adt := autodepositor.New(evtMgr, brContract, optsGetter, logger) // Stop AutoDepositTracker when not running _, err = adt.Stop() @@ -246,16 +223,9 @@ func TestAutoDepositTracker_IsWorking(t *testing.T) { optsGetter := func(ctx context.Context) (*bind.TransactOpts, error) { return &bind.TransactOpts{}, nil } - watcher := &MockTxWatcher{ - WaitForReceiptFunc: func(ctx context.Context, tx *types.Transaction) (*types.Receipt, error) { - return &types.Receipt{ - Status: 1, - }, nil - }, - } // Create AutoDepositTracker instance - adt := autodepositor.New(evtMgr, brContract, optsGetter, watcher, logger) + adt := autodepositor.New(evtMgr, brContract, optsGetter, logger) // Assert initial IsWorking status if adt.IsWorking() { diff --git a/p2p/pkg/node/node.go b/p2p/pkg/node/node.go index bedf67a0b..bac3c5cea 100644 --- a/p2p/pkg/node/node.go +++ b/p2p/pkg/node/node.go @@ -440,7 +440,6 @@ func NewNode(opts *Options) (*Node, error) { evtMgr, bidderRegistry, optsGetter, - monitor, opts.Logger.With("component", "auto_deposit_tracker"), )