Skip to content

Commit

Permalink
Invalidate session when relay is out of tolerance
Browse files Browse the repository at this point in the history
Added logic to invalidate the session with code 90 if the relay's session block height is not within the node's tolerance. This prevents the relay from being processed further and stops new relays from being initiated, ensuring that notifications are accurate and timely.
  • Loading branch information
jorgecuesta committed Aug 9, 2024
1 parent b93e2fd commit c289d2b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/cmd/rpc/mesh/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ func notifyServicer(r *pocketTypes.Relay) {

// Safety measure to not ask for an app session within range
if !ns.ServicerNode.Node.CanHandleRelayWithinTolerance(r.Proof.SessionBlockHeight) {
// invalidate session with code 90
ns.IsValid = false
ns.Error = NewSdkErrorFromPocketSdkError(pocketTypes.NewSealedEvidenceError(ModuleName))
// here we are late to notify servicer about the work done, so this session needs to be invalidated, to avoid
// new relays and prevent all the code till here on notify
LogRelay(r, fmt.Sprintf(
"notify - unable to delivery because relay session height is not within tolerance of fullNode session_height=%d",
ns.ServicerNode.Node.GetLatestSessionBlockHeight(),
Expand Down

0 comments on commit c289d2b

Please sign in to comment.