Skip to content

Commit

Permalink
Improved inactivity claim submission process
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Apr 29, 2024
1 parent bd181a9 commit bbbfaf5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 6 additions & 4 deletions pkg/tbtc/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (ha *heartbeatAction) execute() error {
)
defer cancelHeartbeatCtx()

signature, activeOperatorsCount, _, err := ha.signingExecutor.sign(
signature, activeOperatorsCount, signingEndBlock, err := ha.signingExecutor.sign(
heartbeatCtx,
messageToSign,
ha.startBlock,
Expand Down Expand Up @@ -189,12 +189,14 @@ func (ha *heartbeatAction) execute() error {
// The value of consecutive heartbeat failures exceeds the threshold.
// Proceed with operator inactivity notification.
err = ha.inactivityClaimExecutor.publishClaim(
// Leave the list empty. Some operators were inactive during the
// heartbeat because they were simply unstaking and therefore should not
// be punished.
// Leave the list of inactive operators empty even if some operators
// were inactive during signing heartbeat. The inactive operators could
// simply be in the process of unstaking and therefore should not be
// punished.
[]group.MemberIndex{},
true,
messageToSign,
signingEndBlock,
)
if err != nil {
return fmt.Errorf(
Expand Down
6 changes: 5 additions & 1 deletion pkg/tbtc/inactivity.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const (
// by the given member to avoid all members submitting the same inactivity claim
// at the same time.
inactivityClaimSubmissionDelayStepBlocks = 3
// inactivityClaimMaximumSubmissionBlocks determines the maximum block
// duration of inactivity claim submission procedure.
inactivityClaimMaximumSubmissionBlocks = 60
)

// errInactivityClaimExecutorBusy is an error returned when the inactivity claim
Expand Down Expand Up @@ -70,6 +73,7 @@ func (ice *inactivityClaimExecutor) publishClaim(
inactiveMembersIndexes []group.MemberIndex,
heartbeatFailed bool,
message *big.Int,
startBlock uint64,
) error {
if lockAcquired := ice.lock.TryAcquire(1); !lockAcquired {
return errInactivityClaimExecutorBusy
Expand Down Expand Up @@ -121,7 +125,7 @@ func (ice *inactivityClaimExecutor) publishClaim(

defer wg.Done()

inactivityClaimTimeoutBlock := uint64(0) // TODO: Set the value of timeout block
inactivityClaimTimeoutBlock := startBlock + inactivityClaimMaximumSubmissionBlocks

go func(signer *signer) {
ctx, cancelCtx := withCancelOnBlock(
Expand Down

0 comments on commit bbbfaf5

Please sign in to comment.