Skip to content

Commit 4b4c443

Browse files
committed
Fix health check for rewards submissions
1 parent 915e15f commit 4b4c443

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

rocketpool/watchtower/submit-rewards-tree-stateless.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,16 @@ func (t *submitRewardsTree_Stateless) Run(nodeTrusted bool, state *state.Network
173173
currentIndex := state.NetworkDetails.RewardIndex
174174
currentIndexBig := big.NewInt(0).SetUint64(currentIndex)
175175

176+
// Check if the node has already submitted the rewards for the previous interval
177+
// In case we just had consensus, we want other nodes to also submit
178+
hasSubmitted, err := t.hasSubmittedTree(nodeAccount.Address, currentIndexBig.Sub(currentIndexBig, big.NewInt(1)))
179+
if err != nil {
180+
return fmt.Errorf("error checking if Merkle tree submission has already been processed: %w", err)
181+
}
182+
if !hasSubmitted { // didn't participate in the previous consensus. Decrement the index and submit it as a health check
183+
currentIndexBig = currentIndexBig.Sub(currentIndexBig, big.NewInt(1))
184+
}
185+
176186
// Check if rewards generation is already running
177187
t.lock.Lock()
178188
if t.isRunning {
@@ -194,10 +204,6 @@ func (t *submitRewardsTree_Stateless) Run(nodeTrusted bool, state *state.Network
194204
}
195205

196206
// Return if this node has already submitted the tree for the current interval and there's a file present
197-
hasSubmitted, err := t.hasSubmittedTree(nodeAccount.Address, currentIndexBig)
198-
if err != nil {
199-
return fmt.Errorf("error checking if Merkle tree submission has already been processed: %w", err)
200-
}
201207
if hasSubmitted {
202208
return nil
203209
}

0 commit comments

Comments
 (0)