From 03a0c8aafdb10939ac896e5c05a6a2dea9d17687 Mon Sep 17 00:00:00 2001 From: 3alpha <15694175+3alpha@users.noreply.github.com> Date: Mon, 30 Nov 2026 15:25:13 +0100 Subject: [PATCH 1/2] docs: document node status reports and the nodes manifest field Adds a developer page on how a node package reports its sync phase through its healthcheck, documents `nodes` in the manifest reference and marks `chain` as no longer driving a status display. --- .../staker-packages/overview.md | 4 + docs/dev/node-status.md | 277 ++++++++++++++++++ .../multi-configuration.md | 2 + docs/dev/references/manifest.md | 53 +++- sidebars.js | 5 + 5 files changed, 333 insertions(+), 8 deletions(-) create mode 100644 docs/dev/node-status.md diff --git a/docs/dev/github-actions/staker-packages/overview.md b/docs/dev/github-actions/staker-packages/overview.md index 537b188db..d0506f8c6 100644 --- a/docs/dev/github-actions/staker-packages/overview.md +++ b/docs/dev/github-actions/staker-packages/overview.md @@ -8,6 +8,10 @@ llm_description: "Overview of CI/CD workflows for Dappnode staker packages inclu Staker packages require more complex CI than standard packages because they need integration testing on real Dappnode hardware. This ensures that execution clients, consensus clients, web3signer, and MEV-boost work correctly together in a real staking environment. +:::tip +Client packages also tell the dashboard what their client is doing (sync phase, progress, pre-start work) through a status report printed by their Docker healthcheck, using the shared helpers in `staker-package-scripts`. See [Node Status Reports](../../node-status.md). +::: + ## Architecture The staker package CI runs on a **GitHub self-hosted runner** with the following characteristics: diff --git a/docs/dev/node-status.md b/docs/dev/node-status.md new file mode 100644 index 000000000..9b01265d7 --- /dev/null +++ b/docs/dev/node-status.md @@ -0,0 +1,277 @@ +--- +title: "🩺 Node Status Reports" +llm_description: "How a node package declares its nodes in the manifest and reports what its client is doing through its Docker healthcheck, for the Dappnode dashboard." +--- + +# 🩺 Node Status Reports + +A node package can tell the Dappnode dashboard what its client is doing: which sync phase it is in and how far along, what it does before its API answers (for example downloading a snapshot), what keeps running after it reached the head, and which problems it sees. The package declares its nodes in the manifest field [`nodes`](./references/manifest.md#nodes), and the service's Docker healthcheck prints a small JSON **status report**. + +:::info +Today the dappmanager reads status reports from **execution clients** only: the service declared with `role: "execution"` and `report: "healthcheck"` in the package selected as execution client for a network in Stakers. The rest of the `nodes` field is defined but not used yet, see [Not used yet](#not-used-yet). +::: + +## What the user sees + +The dashboard shows a card for each staking network, with one row for the execution client and one for the consensus client. + +| Element | Example | Comes from | +| --- | --- | --- | +| State badge | Synced, Syncing, Waiting, Stalled | Dappmanager | +| Badge when the API does not answer | Starting, Stopped, Not responding | Dappmanager | +| Sync line, while not synced | `Downloading state · 42% · about 1 h 5 min left` | Phase from the report; percentage, distance behind and time left computed by the dappmanager | +| Progress bar | Measured, or a moving bar when nothing can be measured | Dappmanager, from the report's `progress` or `position` and `target` | +| Phase while the API does not answer | `Downloading snapshot · 37%` under a Starting badge | Report (`state: "starting"`) | +| Background line, once synced | `Indexing transactions in the background` | Report `background` | +| Warnings | `Low disk space` | Report `issues`, plus `No peers` from the dappmanager | +| Tooltip on the badge | `Latest block`, `Reports syncing`, `Package status report: Yes` | Dappmanager lines, then the report's `details` | + +## Who decides what + +The package says what its client is doing; the dappmanager decides the status. A report never makes a node show as synced. + +| Question | Decided by | +| --- | --- | +| Phase and how far along it is | Package | +| What happens before the API answers | Package | +| Work that continues after reaching the head | Package | +| Problems the client reports about itself | Package | +| Whether the execution client is synced: its latest block is at most 3 minutes old | Dappmanager | +| Waiting for the consensus client | Dappmanager | +| Stalled: a phase measured in blocks, or the catch-up to the head, has not moved for 5 minutes; or a node that is not synced has no peers | Dappmanager | +| Time left, and time and blocks behind | Dappmanager | +| Which address to call | Dappmanager | + +## Declare the nodes in the manifest + +`nodes` is keyed by compose service name. Shared fields go in the root `dappnode_package.json`; each variant manifest adds only `network` (the SDK merges root and variant manifests recursively). + +Root manifest: + +```json +"nodes": { + "reth": { + "role": "execution", + "probe": { "kind": "ethereum-execution", "rpcPort": 8545, "enginePort": 8551 }, + "report": "healthcheck" + } +} +``` + +Variant manifest (`package_variants/hoodi/dappnode_package.json`): + +```json +"nodes": { "reth": { "network": "hoodi" } } +``` + +- The key must be the compose service whose container runs the healthcheck. The SDK does not check it yet; a key that matches no service means the report is never read. +- `network` is the dappmanager network name: `mainnet`, `gnosis`, `hoodi`, `sepolia` or `lukso`. +- Use the ports the client really listens on. No hostnames or URLs anywhere. + +The full field description is in the [manifest reference](./references/manifest.md#nodes). + +## The status report + +One JSON object, printed as the **last line of stdout** of the healthcheck. At most 2,048 bytes. Only `version` and `state` are required. Leave out anything you do not know rather than sending `null` or `0`. + +| Field | Type and limits | Meaning | +| --- | --- | --- | +| `version` | `1` | Required. | +| `state` | `starting`, `syncing`, `synced` or `error` | Required. The client's own view. `starting`: the node's API does not answer yet (start-up, snapshot or checkpoint download, database opening). | +| `phase` | string, up to 60 characters | What the node is doing, e.g. `Downloading state`. Sentence case, no trailing period. | +| `progress` | number, 0-100 | Progress of the current phase as a percentage. Never 100 while the phase is still running: cap at 99.9. | +| `height` | integer | Latest block the node serves (number of `eth_getBlockByNumber("latest")`). | +| `headTime` | integer, Unix seconds | Timestamp of that block. | +| `position` | integer | For a phase measured in blocks: the block the phase has reached. May differ from `height`. | +| `target` | integer | The block the node syncs towards, when the client knows it. | +| `unit` | string, up to 20 characters | Unit of `height`, `position` and `target`. Default `blocks`. | +| `peers` | integer | Connected peers. | +| `awaitingTarget` | `true` | The client has nothing to sync towards yet. Omit otherwise. | +| `background` | string, up to 60 characters | Work that continues after reaching the head, e.g. `Indexing transactions`. | +| `issues` | up to 5 strings, up to 120 characters each | Problems the client reports about itself, e.g. `Low disk space`. | +| `details` | up to 8 `{ "label", "value" }` objects, each string up to 80 characters | Extra lines for the tooltip, already formatted. | + +For an execution client the dappmanager reads `state` (only `starting`, see below), `phase`, `progress`, `position`, `target`, `awaitingTarget`, `background`, `issues` and `details`. It takes the latest block and peers from the client's JSON-RPC, so `height`, `headTime`, `peers` and `unit` are not read today; include them anyway, they are cheap and useful for other consumers. + +Examples: + +```json +{"version":1,"state":"starting","phase":"Downloading snapshot","progress":37.5} +{"version":1,"state":"syncing","phase":"Executing blocks","position":21000000,"target":21500000,"height":20990000,"headTime":1730000000,"peers":25} +{"version":1,"state":"synced","height":21500000,"headTime":1732960000,"peers":31,"background":"Indexing transactions"} +``` + +### `progress` or `position` and `target` + +Measure a phase one way, not both. + +| The phase is | Send | The dappmanager shows | +| --- | --- | --- | +| Measured in blocks | `phase`, `position`, `target` (with `target` greater than `position`) | Percentage counted from where it first saw the phase, blocks behind, time left; Stalled after 5 minutes without movement | +| Measured as a share of its own work | `phase`, `progress` | The percentage and time left estimated from how fast it moves | +| Not measurable | `phase` only | The phase with a moving bar | + +The dappmanager tracks progress per phase name, so a new `phase` value starts a new measurement. Keep phase names stable: no counters or numbers in them. Use the same wording as other clients where it fits, e.g. `Downloading block headers`, `Downloading state`, `Healing state`, `Executing blocks`, `Catching up`. + +### `awaitingTarget` + +Send `awaitingTarget: true` when the client has nothing to sync towards, for example an execution client that no consensus client has driven since it started. The dappmanager then shows the node as Waiting for the consensus client while the consensus client is not at the head, and as Syncing with your `phase` (or `Starting to sync`) once it is. + +### `background` + +Work that goes on after the node reached the head. It is shown only while the node is synced, as ` in the background`, so write it as an activity: `Indexing transactions`, `Pruning old receipts`. + +### `issues` + +Short problems the client reports about itself, shown as warnings whether or not the node is synced. Do not report `No peers`: the dappmanager adds it from the peer count. + +### `details` + +Lines appended to the tooltip under the dappmanager's own lines, as `label: value`. Format values for people (`1,234,567`, `3 h 5 min`); they are shown as plain text. + +### `state` + +- `starting`: while the API does not answer and the container is running, the dashboard shows your `phase` and `progress` under the Starting badge. Use it for long pre-start work such as a snapshot download; let the entrypoint leave a marker the script can read (e.g. under `/tmp`). +- `syncing`, `synced`: the client's own view. The dappmanager ignores `synced` and decides by itself. +- `error`: the client cannot work. The healthcheck exits non-zero, so Docker marks the container unhealthy after `retries` failed runs. The dashboard does not treat this state specially today: send the reason as an issue. + +## Healthcheck conventions + +```yaml +services: + reth: + healthcheck: + test: ["CMD", "/usr/local/bin/node-status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 60s +``` + +| Rule | Why | +| --- | --- | +| Exactly one JSON object as the last line of stdout, nothing else on stdout. | The dappmanager parses only the last non-empty line. | +| Diagnostics, if any, go to stderr, are short and are written **before** the report. | Docker stores stdout and stderr together, at most 4,096 bytes per run. | +| Exit 0 for `starting`, `syncing` and `synced`; non-zero only for `error` or when nothing could be determined. | A syncing node must not be unhealthy. | +| Answer before the node's API is up: report `starting`, with a `phase` for long pre-start work. | The report is the only way to show what the client does before its API answers. | +| Every network call has its own 2-3 s timeout; stop after the first call that fails. | A run that exceeds the healthcheck `timeout` records no report. | +| Call only `127.0.0.1` or `localhost`. Write nothing to the data directory. | The script runs every interval inside the client's container. | +| Never print credentials or secrets. | Docker stores the output, and the report's strings are shown in the dashboard. | +| POSIX `sh`; depend only on `curl` and `jq`. | The images are Alpine or Debian based. | + +Make the script executable for the user the container runs as. Docker `ADD` from a URL creates files with mode 600: + +```Dockerfile +ADD ${STAKER_SCRIPTS_URL}/node_status_tools.sh /etc/profile.d/ +COPY node-status.sh /usr/local/bin/node-status +RUN chmod +r /etc/profile.d/node_status_tools.sh && chmod +rx /usr/local/bin/node-status +``` + +## Missing, stale or invalid reports + +A report can only add detail. Whatever the report says, the dappmanager decides from the client's own API whether it is synced. + +| Situation | What the dappmanager does | +| --- | --- | +| No `nodes` declaration, or no `report: "healthcheck"` | Does not read the healthcheck output. The tooltip shows `Package status report: No`. | +| No report | Judges the client from its JSON-RPC alone: Waiting if the consensus client is not at the head, otherwise `Catching up`, measured by how fast the latest block's timestamp closes on the clock. | +| Latest healthcheck run older than 3 intervals (90 s with a 30 s interval) | Treats it as no report. | +| Last line not JSON, over 2,048 bytes, `version` not `1` or unknown `state` | Treats it as no report. | +| A field with a wrong type or a negative number | Drops that field and keeps the rest. Unknown fields are ignored. | +| Strings too long or with control characters | Removes control characters and cuts them to the limits. `progress` is clamped to 0-100. | +| `state: "synced"` but the latest block is older than 3 minutes | Shows the node as syncing, waiting or stalled. | + +## Shared helpers for staker packages + +Staker packages use the helpers in [`node_status_tools.sh`](https://github.com/dappnode/staker-package-scripts) from `dappnode/staker-package-scripts`. Each package keeps its client-specific logic in its own script; the helpers call the local node with short timeouts, read Prometheus metrics and print a report that respects the limits above. Their full reference is in the repository README. + +| Function | Use | +| --- | --- | +| `ns_rpc [params]` | Calls the JSON-RPC on `127.0.0.1:${NS_RPC_PORT:-8545}` and prints the `result`. Exit 1 when the node does not answer. | +| `ns_http_get ` | GETs a local URL (`http://127.0.0.1` or `http://localhost` only). | +| `ns_metric [label=value ...]` | Reads Prometheus text on stdin and prints the value of a metric. | +| `ns_hex_to_dec`, `ns_json_get` | Convert a hex quantity; read a field of a JSON document. | +| `ns_block_head` | Prints `height= headTime=` of the latest block, to pass unquoted to `ns_emit`. | +| `ns_emit [key=value ...]` | Prints the report as one JSON line. Repeat `issue=` and `detail=