From c289d2baf686cbff95d168fe12b36aa875498513 Mon Sep 17 00:00:00 2001 From: "Jorge S. Cuesta" Date: Fri, 9 Aug 2024 12:36:40 -0400 Subject: [PATCH] Invalidate session when relay is out of tolerance 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. --- app/cmd/rpc/mesh/relay.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/cmd/rpc/mesh/relay.go b/app/cmd/rpc/mesh/relay.go index 6f406db96..6f60205ac 100644 --- a/app/cmd/rpc/mesh/relay.go +++ b/app/cmd/rpc/mesh/relay.go @@ -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(),