How to calculate update progress?

How does the storagenode-updater calculates whether a node should be updated from the nodeID, seed and cursor? And how often does the updater checks version.storj.io?

1 Like

This is the check for whether the node needs to be updated:

Ultimately the cursor magic is checked in

I believe the updater checks every 15 min.

1 Like

Thanks, but can you translate this to Englishbash, please? :crazy_face:

It hashes rollout seed and node ID and compares the result with the cursor.

I was going to convert it to bash myself for my replacement updater for FreeBSD, but eventually did not get to it.

Asking Google Gemini to translate it to bash yields this, which is more or less correct on the first glance:

isRolloutCandidate() {
  local nodeID="$1" rolloutSeed="${2[@]:0:32}" rolloutCursor="${2[@]:32}"
  local hash=$(echo -n "$nodeID" | openssl dgst -sha256 -hex -mac "seed:${rolloutSeed}")
  [[ "$hash" <= "$rolloutCursor" ]] && echo "true" || echo "false"
}
1 Like

I’m a bit confused by this. Why does it take the first 32 characters from the second (and following) arguments for the seed and the remaining characters for the cursor? The seed has more than 32 characters. Apart from this, the openssl command fails with

Error initializing seed:6c261c93e6c41511e900ba09ac726587ba208c841dab5852a1fa76870de34b99 context
4097A8DFA17F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:../crypto/evp/evp_fetch.c:349:Global default library context, Algorithm (seed:6c261c93e6c41511e900ba09ac726587ba208c841dab5852a1fa76870de34b99 : 0), Properties (<null>)

here is my simplyfied script

#!/bin/bash
nodeID="$1"
rolloutSeed="$2"
rolloutCursor="$3"
hash=$(echo -n "$nodeID" | openssl dgst -sha256 -hex -mac "seed:${rolloutSeed}")
[[ "$hash" <= "$rolloutCursor" ]] && echo "true" || echo "false"

The last line gives a syntax error too, but this might be because of $hash being empty.

I’m using Ubuntu 22.04 with OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

Should openssl list -digest-algorithms|grep -i hmac return something?

This seems to do something without error message, though it doesn’t seem to be correct. I have nodes with a hash lower than the cursor which are not updated and vice versa. The same applies when I use
-macopt hexkey:$SEED

Here’s the script so far

#!/bin/bash
nodeID="$1"
rolloutSeed=$(curl -s https://version.storj.io|jq -r .processes.storagenode.rollout.seed)
rolloutCursor=$(curl -s https://version.storj.io|jq -r .processes.storagenode.rollout.cursor)
hash=$(echo -n "$nodeID" | openssl mac -digest sha256 -macopt hexkey:${rolloutSeed} HMAC)

echo "cursor $rolloutCursor"
echo "hash   $hash"

I didn’t test the script, but do you use the hexadecimal version of the NodeID? I thing the golang version uses the pure binary, while we usually use the base58 representation…

I use what you as a developer give us SNO’s in the dashboard. It looks like it is base58. Do I need to convert it to hex?

I thought it is quite clear from my attempts above that I’m not a developer. I didn’t think that such a simple task would be so complicated…

Ok, with the help of ChatGPT I have this now

#!/bin/bash

base58_to_hex() {
  local base58_string="$1"

  # Decode Base58 string to bytes
  local decoded_bytes=$(echo "$base58_string" | base58 -d | tr -d '\0')

  # Convert bytes to hexadecimal
  local hex_representation=$(xxd -p -c 1000000 <<< "$decoded_bytes")

  echo "$hex_representation"
}


nodeID="$1"
hex_nodeID=$(base58_to_hex $nodeID)
rolloutSeed=$(curl -s https://version.storj.io|jq -r .processes.storagenode.rollout.seed)
rolloutCursor=$(curl -s https://version.storj.io|jq -r .processes.storagenode.rollout.cursor)
hash=$(echo -n "$hex_nodeID" | openssl mac -digest sha256 -macopt hexkey:${rolloutSeed} HMAC)


echo "cursor $rolloutCursor"
echo "hash   $hash"

I will see if this works at the next rollout.

Now the next rollout started, but this script doen’t seem to do what it should. When I check with the nodeID from a node which received the update, the hash is greater than the cursor.