cardano-foundation / cardano-graphql

GraphQL API for Cardano
Apache License 2.0
262 stars 104 forks source link

Question about blocks 'protocolVersion' #580

Closed CyberCyclone closed 3 years ago

CyberCyclone commented 3 years ago

I noticed a while ago that blocks contains a 'protocolVersion' field. On the cardano-testnet telegram group it was mentioned that you could get the protocol version that node can support.

Is 'protocolVersion' what they meant and if so, how do we read it? I can't seem to find anything on google and db-sync has no mention of what it means.

E.g, some blocks have

"protocolVersion": {
          "major": 5,
          "minor": 0
        }

and some have

"protocolVersion": {
          "major": 4
          "minor": 0
        }

My guess is that the 5 is most likely nodes that have upgraded to cardano-node 1.29.0 and support Alonzo, but I thought that would be represented by a 3.

Thanks!

rhyslbw commented 3 years ago

The protocol version on the mainnet and testnet aligns as follows:

  1. Byron
  2. Shelley
  3. Allegra
  4. Mary
  5. Alonzo

The property on Block is actually a signal from the block producer, rather than the protocol version that produced the block. It indicates they are prepared to move to this version, and while most of the time this does align with the production protocol version, it can't be relied on for most use-cases

get the protocol version that node can support.

That's done via a local state query, which I've been wanting to expose over the GraphQL API. Until then you can access this via Ogmios directly:

https://ogmios.dev/api/modules/_cardano_ogmios_client.StateQuery.html#currentProtocolParameters

What language are you writing in?

CyberCyclone commented 3 years ago

Thanks for the clarification.

My use case is to find what percentage of nodes are running under what node version. PoolTools way is to have a script installed on each server that reports back. I don't like that approach and I was looking into seeing if it could be retrieved from the blocks being produced.

While getting it based on the era is a way, it doesn't seem as accurate for what I'm after. E.g, seeing what nodes are running 1.27.0 vs 1.29.0.

Ogmios seems to let you know what version itself is running, which is useful for another scenario but not what I'm after I think.

I'm using JavaScript / Typescript.

rhyslbw commented 3 years ago

There's no information in the blocks to reveal the software version, so the only option right now is to rely on node operators installing the reporting script and querying the collector. Nodes running 1.29.0 on the mainnet now will be stamping major version 4, and then 5 once the protocol upgrade completes.

CyberCyclone commented 3 years ago

Awesome, thanks for clarifying!