From 220bdcb575897780a1b9d09e7cbbead30fcf42b3 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 19 Dec 2024 14:58:50 +0300 Subject: [PATCH] [#185] native: Issue session token on the previous epoch Consider 2 nodes, A and B. Because of the race condition, A has epoch N, and B has (still) epoch N-1. Creating session token and putting object on the node A will set issuing epoch to N, thus failing validation on the node B. Signed-off-by: Evgenii Stratonikov --- internal/native/native.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/internal/native/native.go b/internal/native/native.go index bb92ed8..b15173b 100644 --- a/internal/native/native.go +++ b/internal/native/native.go @@ -118,11 +118,16 @@ func (n *Native) Connect(endpoint, hexPrivateKey string, dialTimeout, streamTime tok.SetAuthKey(&key) tok.SetExp(exp) + res, err := cli.NetworkInfo(n.vu.Context(), client.PrmNetworkInfo{}) + if err != nil { + return nil, err + } + + prevEpoch := res.Info().CurrentEpoch() - 1 + tok.SetNbf(prevEpoch) + tok.SetIat(prevEpoch) + if prepareLocally && maxObjSize > 0 { - res, err := cli.NetworkInfo(n.vu.Context(), client.PrmNetworkInfo{}) - if err != nil { - return nil, err - } if uint64(maxObjSize) > res.Info().MaxObjectSize() { return nil, fmt.Errorf("max object size must be not greater than %d bytes", res.Info().MaxObjectSize()) } -- 2.45.2