Deduplicate token serialization #1434

Open
opened 2025-12-28 17:22:59 +00:00 by sami · 0 comments
Owner

Originally created by @cthulhu-rider on GitHub (Jun 19, 2025).

https://github.com/nspcc-dev/neofs-node/pull/3369#discussion_r2156974449

full bearer/session token BLOB is a concatenation of 2 fields:

  1. body
  2. signature

currently, SN calculates it twice per-request:

  1. to access token cache
  2. to check the signature

body participates in both cases, but encoded twice

Describe the solution you'd like

marshal token once and reuse

Describe alternatives you've considered

originally, token comes in a binary format over gRPC. Then it's decoded to generated proto struct instance by gRPC lib functions, then we encode it again. So, we have extra decode-to-encode round. The best way would be:

  1. take token BLOB
  2. check everything needed with it
  3. decode

this is the most efficient approach. At the same time, it is quite challenging according to the API of used gRPC lib. This improvement is not limited to tokens and can be extended to many other cases

Originally created by @cthulhu-rider on GitHub (Jun 19, 2025). https://github.com/nspcc-dev/neofs-node/pull/3369#discussion_r2156974449 ## Is your feature request related to a problem? Please describe. full bearer/session token BLOB is a concatenation of 2 fields: 1. body 2. signature currently, SN calculates it twice per-request: 1. to access token cache 2. to check the signature body participates in both cases, but encoded twice ## Describe the solution you'd like marshal token once and reuse ## Describe alternatives you've considered originally, token comes in a binary format over gRPC. Then it's decoded to generated proto struct instance by gRPC lib functions, then we encode it again. So, we have extra decode-to-encode round. The best way would be: 1. take token BLOB 2. check everything needed with it 3. decode this is the most efficient approach. At the same time, it is quite challenging according to the API of used gRPC lib. This improvement is not limited to tokens and can be extended to many other cases
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
nspcc-dev/neofs-node#1434
No description provided.