Node state and upgrades
Developers12.5.9+

Node state and upgrades

Know whether a node can answer: health, the warming-up answers with the block store progress, sync state, network upgrades, the release operators must run, and the upgrade notice.

A client that talks to a node should know, before it trusts an answer, whether the node is started, synced and on the release the network needs. These routes tell it. All are public GET routes under /api/v1.

Health #

GET /health is the cheap probe (cached 1 second). Use it for load balancers and before a batch of calls.

Shell
curl -s https://givelotus.org/api/v1/health
JSON
{"status":"ok","height":1433874,"best_block_hash":"00000000010d37f7...","median_time":1795721123,"ibd":false,
 "indexer":{"mode":"sync","tip_height":1433874,"index_height":1433874,"behind":0},
 "uptime_seconds":13122,"version":12050900,"subversion":"/lotusd:12.5.9(EB32.0)/"}
FieldMeaning
statusok, or syncing during the initial block download
height, best_block_hash, median_timeThe node's tip and its median time past
ibdtrue during the initial block download
indexerThe explorer indexer: mode (sync or async), tip_height, index_height, behind. With async, more counters follow. Address answers wait for behind to be 0
versionNumeric version: 12050900 is 12.5.9
subversionThe user agent the node announces on P2P

While the node starts #

The HTTP port opens before the chain is loaded. Until the node is ready, every route answers:

HTTP
HTTP/1.1 503 Service Unavailable
Retry-After: 2
X-Node-State: starting

{"error":"node_warming_up","message":"Rebuilding module indices from genesis…","status":503}

message says what the node is doing. Retry after Retry-After; do not treat it as an error of your request. The Chronik routes answer the same state in their own format.

12.5.9+

The first start of 12.5.9 converts the block files into one SQLite database, a few minutes on mainnet. While that conversion runs (or when the node refused to start for lack of disk space), the 503 body also carries blockstore, the conversion's progress (the values below are an example):

JSON
{"error":"node_warming_up","message":"...","status":503,
 "blockstore":{"mode":"sqlite","phase":"copy","active":true,"percent":41,
   "blocks_done":588000,"blocks_total":1432760,"bytes_done":2210000000,"bytes_total":5400000000,
   "files_done":120,"files_total":290,"started_at":1795700000,"phase_started_at":1795700012,
   "rate_bytes_per_s":11000000,"eta_seconds":290,"resumed":false,"refusal":null,"message":"..."}}
blockstore fieldMeaning
modesqlite or flat (-blockstore)
phasenone (nothing to convert), preflight, copy, filters, verify, commit_index, txindex, remove_flat, done, refused or failed
activeA conversion is running now
percent, blocks_*, bytes_*, files_*Progress, done and total
rate_bytes_per_s, eta_secondsSpeed and time left (-1 when unknown)
resumedThe conversion resumed after a stop
refusalnull, or why the node refused to start (for example, not enough free disk)

The same object is in GET /chain, GET /chain/sync and getblockchaininfo once the node runs, and in GET /api/v1/startup/status, the state of every startup step.

Sync state #

RouteUse
GET /chainTip, difficulty, replay_protection, blockstore, network
GET /chain/syncheight, headers, initial_block_download, verification_progress, blocks and transactions a second, remaining_blocks, eta_seconds, indexer, blockstore
GET /chain/tipThe tip block only

While the node is not at the tip, every /addresses and /scripts route answers 503 syncing with the node's height and headers, never an old balance. Ask another node, or wait.

Network upgrades #

GET /upgrades lists every network upgrade of the chain the node is on, with its activation time and state, and says which release operators must run before the next one.

Shell
curl -s https://givelotus.org/api/v1/upgrades
JSON
{"chain":"main","tip_height":1433877,"tip_mtp":1795721627,"initial_block_download":false,
 "node_version":"v12.5.9","client_version":12050900,"next":"napoleon",
 "required_release":"12.5.9","required_before":1797886200,"required_release_met":true,
 "upgrades":[ ...,
  {"name":"napoleon","label":"Napoleon","display":"Napoleon","activation_time":1797886200,"active":false,
   "active_since_height":null,"seconds_until":2164573,"overridden":false,
   "features":["mmv2","mmv3","mmv3-tracks","contracts","coinbase-height","miner-fund"],
   "required_release":"12.5.9","required_release_source":"option","upstream_name":"secondKings",
   "feature_times":{"mmv2":{"activation_time":1797886200,"active":false}, ...}},
  {"name":"firstChronicles","label":"1st Chronicles","display":"Jena","activation_time":1813587000, ...}]}
FieldMeaning
nameThe identifier (napoleon, firstChronicles, ...). Match on it in code: it never changes
labelThe former display name, kept for older programs
display (12.5.9)The name to show people: Pavie, Detmold, Hase, Toulon, Lodi, Arcole, Rivoli, Marengo, Ulm, Austerlitz, Napoleon, Jena
activation_timeMedian time past at which it activates. Upgrades activate by the chain's median time past, never by height or clock
active, active_since_height, seconds_untilState on this node. seconds_until counts against tip_mtp, which runs 10 to 15 minutes behind the clock
overriddenAn activation-time option moved it (test networks only)
required_release, required_release_source (12.5.9)The release operators must run before this upgrade, and where the number comes from; null when the node states none
top-level next, required_release, required_before, required_release_met (12.5.9)The same for the next upgrade: the release, its deadline (the activation time), and whether this node's build is that release or newer

Where the required release comes from #

The number is the highest of three sources, named in required_release_source:

SourceValue
builtinWritten in the code: 12.5.8 for Napoleon. This is the minimum for the chain's rules
optionThe node operator's own -upgradenotice=<version>,<mtp>, when <mtp> is exactly the upgrade's activation time. The public fleet runs it with 12.5.9, so its nodes say 12.5.9
quorumThe upgrade notice below, when it applies for that same deadline. A single peer never raises it

So two honest nodes can show different numbers. The rules of Napoleon are followed by every node of 12.5.8 or later; 12.5.9 adds no consensus rule.

The upgrade notice #

Nodes tell each other which release they run (P2P message upgnotice, see P2P integration). When at least 3 network groups of a node's outbound peers, and at least 51% of them, announce the same newer release, the node shows a notice. GET /upgrades/notice gives the whole picture; getupgradenotice over JSON-RPC is the same.

Shell
curl -s https://givelotus.org/api/v1/upgrades/notice
FieldMeaning
own_versionThis node's release
announcedWhat this node announces: version, required_before, page, from_option
noticeapplies, counted_by (netgroup, or peer after the 5-minute fallback), version, page, required_before, deadline_passed, groups_for, deadline_groups_for, groups_counted, message, since
rulequorum_pct (51), min_groups (3), peer_fallback_after_s (300), peer_fallback_active, counted_connections, page_base
peersEach peer's announcement and whether it counted

The notice never downloads or installs anything. The link it shows is built by the node from three integers, as https://lotusia.network/upgrades/<major>.<minor>.<patch>/: no text or URL from the network is ever shown. The route is not cached.

For a program, the useful part is: if notice.applies is true, a newer release is widely run; if required_release_met of /upgrades is false, the node will not follow the chain after the deadline.

Source share/www/docs/api-node-state.md in the lotusd repository
Checked against src/api/health_handler.cpp src/api/api_server.cpp src/api/chain_handler.cpp src/api/upgrades_handler.cpp src/upgradenotice.cpp src/upgradenotice.h src/blockstore_ui.cpp doc/upgrade-notice.md doc/blockstore-sqlite.md