From 441fb593eb975c1eb66d6f4b745b6e187e783cab Mon Sep 17 00:00:00 2001 From: Lukasz Zimnoch Date: Thu, 11 Apr 2024 10:02:35 +0200 Subject: [PATCH] Increase deposit sweep frequency So far, deposit sweeps were supposed to happen every 48 hours. This frequency was good for the early days of the system but starts to be insufficient now, when a significant number of deposits land every day. To optimize the deposit sweep process, we are increasing its frequency to 12 hours. (cherry picked from commit 610ef1866e641b953cfa0bc17eaad150b7101537) --- pkg/tbtc/coordination.go | 5 ++--- pkg/tbtc/coordination_test.go | 17 ++++++++++------- pkg/tbtc/node.go | 4 ++++ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/pkg/tbtc/coordination.go b/pkg/tbtc/coordination.go index fcf8b9e5f1..b11a3b2ce9 100644 --- a/pkg/tbtc/coordination.go +++ b/pkg/tbtc/coordination.go @@ -540,10 +540,9 @@ func (ce *coordinationExecutor) getActionsChecklist( actions = append(actions, ActionRedemption) // Other actions should be checked with a lower frequency. The default - // frequency is every 16 coordination windows. - frequencyWindows := uint64(16) + // frequency is every 4 coordination windows. + frequencyWindows := uint64(4) - // TODO: Consider increasing frequency for the active wallet in the future. if windowIndex%frequencyWindows == 0 { actions = append(actions, ActionDepositSweep) } diff --git a/pkg/tbtc/coordination_test.go b/pkg/tbtc/coordination_test.go index b5ce492920..394bd6ae7c 100644 --- a/pkg/tbtc/coordination_test.go +++ b/pkg/tbtc/coordination_test.go @@ -557,10 +557,12 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) { coordinationBlock: 2700, expectedChecklist: []WalletActionType{ActionRedemption}, }, + // Heartbeat randomly selected for the 4th coordination window. "block 3600": { coordinationBlock: 3600, expectedChecklist: []WalletActionType{ ActionRedemption, + ActionDepositSweep, ActionHeartbeat, }, }, @@ -568,7 +570,6 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) { coordinationBlock: 4500, expectedChecklist: []WalletActionType{ActionRedemption}, }, - // Heartbeat randomly selected for the 6th coordination window. "block 5400": { coordinationBlock: 5400, expectedChecklist: []WalletActionType{ @@ -581,7 +582,10 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) { }, "block 7200": { coordinationBlock: 7200, - expectedChecklist: []WalletActionType{ActionRedemption}, + expectedChecklist: []WalletActionType{ + ActionRedemption, + ActionDepositSweep, + }, }, "block 8100": { coordinationBlock: 8100, @@ -597,13 +601,15 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) { }, "block 10800": { coordinationBlock: 10800, - expectedChecklist: []WalletActionType{ActionRedemption}, + expectedChecklist: []WalletActionType{ + ActionRedemption, + ActionDepositSweep, + }, }, "block 11700": { coordinationBlock: 11700, expectedChecklist: []WalletActionType{ActionRedemption}, }, - // Heartbeat randomly selected for the 14th coordination window. "block 12600": { coordinationBlock: 12600, expectedChecklist: []WalletActionType{ @@ -614,14 +620,11 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) { coordinationBlock: 13500, expectedChecklist: []WalletActionType{ActionRedemption}, }, - // 16th coordination window so, all actions should be on the checklist. "block 14400": { coordinationBlock: 14400, expectedChecklist: []WalletActionType{ ActionRedemption, ActionDepositSweep, - ActionMovedFundsSweep, - ActionMovingFunds, }, }, } diff --git a/pkg/tbtc/node.go b/pkg/tbtc/node.go index fa70d1264d..121c11f605 100644 --- a/pkg/tbtc/node.go +++ b/pkg/tbtc/node.go @@ -610,6 +610,8 @@ func (n *node) handleRedemptionProposal( // handleMovingFundsProposal handles an incoming moving funds proposal by // orchestrating and dispatching an appropriate wallet action. +// +//lint:ignore U1000 This function will be used in the future. func (n *node) handleMovingFundsProposal( wallet wallet, proposal *MovingFundsProposal, @@ -678,6 +680,8 @@ func (n *node) handleMovingFundsProposal( // handleMovedFundsSweepProposal handles an incoming moved funds sweep proposal // by orchestrating and dispatching an appropriate wallet action. +// +//lint:ignore U1000 This function will be used in the future. func (n *node) handleMovedFundsSweepProposal( wallet wallet, proposal *MovedFundsSweepProposal,