[#185] native: Issue session token on the previous epoch
All checks were successful
Tests and linters / Lint (pull_request) Successful in 3m43s
DCO action / DCO (pull_request) Successful in 6m44s
Tests and linters / Tests with -race (pull_request) Successful in 8m22s
Tests and linters / Tests (pull_request) Successful in 8m54s

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 <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2024-12-19 14:58:50 +03:00
parent 76fd5c9706
commit 220bdcb575
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg

View file

@ -118,11 +118,16 @@ func (n *Native) Connect(endpoint, hexPrivateKey string, dialTimeout, streamTime
tok.SetAuthKey(&key) tok.SetAuthKey(&key)
tok.SetExp(exp) tok.SetExp(exp)
if prepareLocally && maxObjSize > 0 {
res, err := cli.NetworkInfo(n.vu.Context(), client.PrmNetworkInfo{}) res, err := cli.NetworkInfo(n.vu.Context(), client.PrmNetworkInfo{})
if err != nil { if err != nil {
return nil, err return nil, err
} }
prevEpoch := res.Info().CurrentEpoch() - 1
tok.SetNbf(prevEpoch)
tok.SetIat(prevEpoch)
if prepareLocally && maxObjSize > 0 {
if uint64(maxObjSize) > res.Info().MaxObjectSize() { if uint64(maxObjSize) > res.Info().MaxObjectSize() {
return nil, fmt.Errorf("max object size must be not greater than %d bytes", res.Info().MaxObjectSize()) return nil, fmt.Errorf("max object size must be not greater than %d bytes", res.Info().MaxObjectSize())
} }