Skip to content

Commit

Permalink
Reduce heartbeat probability to 6.25%
Browse files Browse the repository at this point in the history
The currently used probability of 12.5% means that a completely idle wallet
will perform a heartbeat every 4 coordination windows on average
(or 8 in the worst case) so, every 3600 blocks (~12 hours assuming a
coordination every 900 blocks and 12 seconds per Ethereum block).

User acceptance tests executed on our Sepolia testnet (10 live wallets) shown
that such a value often leads to simultaneous heartbeats for several wallets
at the same time. This, in turn, can cause increased resource comsumption
for individual nodes and harm some signing processes. Although nothing bad
happens if those are just heartbeats, this may be problematic for redemptions
and deposit sweeps. In order to lower the risk of signing failures, we are
lowering the heartbeat probability to 6.25%.

The probability of 6.25% means that a completely idle wallet
will perform a heartbeat every 8 coordination windows on average
(or 16 in the worst case) so, every 7200 blocks (~24 hours assuming a
coordination every 900 blocks and 12 seconds per Ethereum block).
  • Loading branch information
lukasz-zimnoch committed Dec 19, 2023
1 parent 98ef3fd commit c89a3c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/tbtc/coordination.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const (
// coordinationHeartbeatProbability is the probability of proposing a
// heartbeat action during the coordination procedure, assuming no other
// higher-priority action is proposed.
coordinationHeartbeatProbability = float64(0.125)
coordinationHeartbeatProbability = float64(0.0625)
// coordinationMessageReceiveBuffer is a buffer for messages received from
// the broadcast channel needed when the coordination follower is
// temporarily too slow to handle them. Keep in mind that although we
Expand Down
9 changes: 5 additions & 4 deletions pkg/tbtc/coordination_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,10 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) {
},
"block 3600": {
coordinationBlock: 3600,
expectedChecklist: []WalletActionType{ActionRedemption},
expectedChecklist: []WalletActionType{
ActionRedemption,
ActionHeartbeat,
},
},
"block 4500": {
coordinationBlock: 4500,
Expand All @@ -579,7 +582,6 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) {
coordinationBlock: 5400,
expectedChecklist: []WalletActionType{
ActionRedemption,
ActionHeartbeat,
},
},
"block 6300": {
Expand Down Expand Up @@ -615,7 +617,6 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) {
coordinationBlock: 12600,
expectedChecklist: []WalletActionType{
ActionRedemption,
ActionHeartbeat,
},
},
"block 13500": {
Expand Down Expand Up @@ -643,7 +644,7 @@ func TestCoordinationExecutor_GetActionsChecklist(t *testing.T) {

// Build an arbitrary seed based on the coordination block number.
seed := sha256.Sum256(
big.NewInt(int64(window.coordinationBlock) + 1).Bytes(),
big.NewInt(int64(window.coordinationBlock) + 2).Bytes(),
)

checklist := executor.getActionsChecklist(window.index(), seed)
Expand Down

0 comments on commit c89a3c0

Please sign in to comment.