4

I'd like my wallet to be able to tell securely which cluster I am connected to (mainnet-beta, testnet, devnet), from on-chain information.

I see a few opportunities with getClusterNodes:

  1. From a first sight, shredVersion seems to provide unique identifiers per cluster, deterministically? All mainnet nodes queried return "shredVersion":56177, while all devnet nodes return "shredVersion":38642. Can this be trusted as accurate?
  2. The response will contain information about the nodes in the connected cluster. If the connected nodes are well-known mainnet-beta, devnet, or testnet nodes, you can infer which cluster you are connected to. Probabilistic, but could work.

I think anything regarding to recent block hashes, block height, slots and time etc.cannot be trusted, for example in presence of a chain reorg.

2 Answers 2

7

You can request the genesis hash with getGenesisHash method from the rpc endpoint and compare it to the ones below to get the cluster.

Devnet: EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG
Testnet: 4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY
Mainnet-beta: 5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d

Example

3

In general, I'd agree with the other poster that getGenesisHash is the way to go as those hashes do not / will not change for each cluster.

From a first sight, shredVersion seems to provide unique identifiers per cluster, deterministically?

Kind of. Shred version is 2 bytes of a hash that would be cluster specific. Two bytes is only ~65k possibilities so while unlikely, it is technically possible that these could collide (although we'd probably take an extra step to prevent this). However, it should be noted that as of now, the value for shred version changes after cluster restarts. So, whatever you're building would need to update whenever there are cluster restarts (hopefully not very often or ever).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.