IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.06k stars 721 forks source link

[BUG] - Cardano-cli reporting different slotNo from EKG api #2450

Closed siovador closed 3 years ago

siovador commented 3 years ago

Internal/External External

Area Other

Summary When setting up a new Cardano pool I used the Cardano-cli to find the slot number. However this number differs from other sources such as the EKG api as well as the number reported at adapools.org. When running a longer running test to check if the values are equal, it appears they very in equality.

Steps to reproduce

  1. curl -s -m 300 -H 'Accept: application/json' "http://127.0.0.1:12788/" |python3 -m json.tool|grep -A 5 slot "slotInEpoch": { "int": { "type": "g", "val": 266961 } }, "slotNum": { "int": { "type": "g", "val": 23335761 } },

  2. cardano-cli query tip --mainnet | jq -r ‘.slotNo’ 23335800

Expected behavior I expect the cli to return the same integer as the EKG api. The EKG api appears to return the number reported by other sources such as adapools.org, which is often used as a pool configuration standard to make sure you are on the correct slotNo therefore leading me to believe they gather their slotNo from a node via the EKG, as does gLiveView script produced by the guild operations team. I began to investigate the node and cli source but feel this issue may slow down pool deployment to new operators therefore was worth bringing to the attention of people more seasoned with this codebase.

When scripting the slotNo enumeration it appears to be a non deterministic return with many instances showing equality between EKG and the cli, and others high or low without knowing which source is correct.

System info (please complete the following information):

Thank You

erikd commented 3 years ago

The difference between those two values 23335800 - 23335761 == 39 is roughly two blocks (on average, only 1 in 20 slots are occupied by blocks). If the difference was bigger, I would be concerned.

Running:

bin/cardano-cli.sh query tip --mainnet ; curl -s -m 300 -H 'Accept: application/json' "http://127.0.0.1:12788/"  | jq -r .cardano.node.metrics.slotNum

I get the same value for slot number obtained in the two different ways, 2 times out of 3. Occasionally the timing will be just right to make the two slot numbers different.

This is not a bug.

erikd commented 3 years ago

When scripting the slotNo enumeration it appears to be a non deterministic return with many instances showing equality between EKG and the cli, and others high or low without knowing which source is correct.

This is just the way things work. Slot number usually goes up by a count of about 20, but will occasionally go backwards due to chain rollbacks.

erikd commented 3 years ago

Can we close this?