Skip to content

Commit

Permalink
Increase deposit sweep frequency
Browse files Browse the repository at this point in the history
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 610ef18)
  • Loading branch information
lukasz-zimnoch committed Apr 11, 2024
1 parent c41edaf commit 441fb59
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
5 changes: 2 additions & 3 deletions pkg/tbtc/coordination.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
17 changes: 10 additions & 7 deletions pkg/tbtc/coordination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,18 +557,19 @@ 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,
},
},
"block 4500": {
coordinationBlock: 4500,
expectedChecklist: []WalletActionType{ActionRedemption},
},
// Heartbeat randomly selected for the 6th coordination window.
"block 5400": {
coordinationBlock: 5400,
expectedChecklist: []WalletActionType{
Expand All @@ -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,
Expand All @@ -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{
Expand All @@ -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,
},
},
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/tbtc/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 441fb59

Please sign in to comment.