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.
  • Loading branch information
lukasz-zimnoch committed Apr 11, 2024
1 parent ede24a3 commit 610ef18
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
6 changes: 2 additions & 4 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 All @@ -552,7 +551,6 @@ func (ce *coordinationExecutor) getActionsChecklist(
actions = append(actions, ActionMovedFundsSweep)
}

// TODO: Consider increasing frequency for old wallets in the future.
if windowIndex%frequencyWindows == 0 {
actions = append(actions, ActionMovingFunds)
}
Expand Down
21 changes: 16 additions & 5 deletions pkg/tbtc/coordination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,18 +557,21 @@ 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,
ActionMovedFundsSweep,
ActionMovingFunds,
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 +584,12 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) {
},
"block 7200": {
coordinationBlock: 7200,
expectedChecklist: []WalletActionType{ActionRedemption},
expectedChecklist: []WalletActionType{
ActionRedemption,
ActionDepositSweep,
ActionMovedFundsSweep,
ActionMovingFunds,
},
},
"block 8100": {
coordinationBlock: 8100,
Expand All @@ -597,13 +605,17 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) {
},
"block 10800": {
coordinationBlock: 10800,
expectedChecklist: []WalletActionType{ActionRedemption},
expectedChecklist: []WalletActionType{
ActionRedemption,
ActionDepositSweep,
ActionMovedFundsSweep,
ActionMovingFunds,
},
},
"block 11700": {
coordinationBlock: 11700,
expectedChecklist: []WalletActionType{ActionRedemption},
},
// Heartbeat randomly selected for the 14th coordination window.
"block 12600": {
coordinationBlock: 12600,
expectedChecklist: []WalletActionType{
Expand All @@ -614,7 +626,6 @@ 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{
Expand Down

0 comments on commit 610ef18

Please sign in to comment.