# SmallOps RPC Diagnostics 0.1

Produce a JSON evidence file and a Markdown observation report for one public
HTTPS EVM RPC and two reference endpoints. Python 3.10+, standard library only.
This is the delivery helper for the [SmallOps one-off diagnostic pilot](https://smallops.top/rpc-diagnostics.html).

## Try an offline example

```sh
python3 rpc_report.py --demo consistent --output demo-consistent
python3 rpc_report.py --demo lagging --output demo-lagging
python3 rpc_report.py --demo wrong-chain --output demo-wrong-chain
python3 rpc_report.py --demo disagree --output demo-disagree
```

The examples use synthetic data and perform no network requests.
An attention result exits 1, and an inconclusive comparison exits 2.

## Observe public endpoints

Use public providers you are authorised to query. Review their terms and choose
two independently operated references; different hostnames alone do not prove
independent operation. The first entry in the config is the target.

```sh
export RPC_TARGET=https://your-public-target.example
export RPC_REFERENCE_A=https://first-public-reference.example
export RPC_REFERENCE_B=https://second-public-reference.example
python3 rpc_report.py --config config.example.json --output observation
```

Replace the `.example` addresses with real public endpoints. The shipped
configuration expects chain ID 56. The default three samples are five seconds
apart after each completed sample, with at most 30 JSON-RPC requests across all
three endpoints. There is no automatic retry or polling daemon.

The CLI writes `report.json` and `report.md` with mode 600. URLs remain in the
environment and are omitted from reports, commands passed to the worker and
error messages. The worker receives only RPC configuration and basic runtime
environment variables. Do not put access tokens in a public-endpoint inquiry.

## Checks and results

- Check chain IDs, block progression, block timestamps and request durations.
- Read block headers at explicit heights; compare the final common-height hash.
- Distinguish a target lag from unavailable or disagreeing references.
- Report observed RPC, HTTP, rate-limit and TLS failures using fixed categories.
- Reject credential-bearing/query-string URLs, redirects, non-HTTPS destinations
  and DNS answers containing private, loopback, reserved or multicast addresses.
- Pin the connection to a validated public IP while retaining the original TLS
  hostname and normal certificate verification. Environment proxies are unused.
- Bound the complete worker, including DNS, TLS and slow headers/bodies, with a
  parent-process deadline (45 seconds by default; `--total-timeout` 1–180).

Exit 0 means the observations were consistent under the configured comparisons.
Exit 1 means a configured finding needs attention. Exit 2 means the observation
was inconclusive, configuration was rejected, or the total deadline/worker failed.
Missing observations never become a successful comparison.

This is a short observation window. A stationary head on all three endpoints
does not by itself establish an outage. Root cause, provider independence and
longer-term availability require separate review. Thresholds should match the
chain and incident being investigated. Node access and request rate remain the
operator's responsibility. No signing, balances, wallet credentials or transaction
methods are used.

## Verify the included behavior

```sh
python3 -m unittest -v
```

The tests cover reference disagreement, same-height hash differences, wrong
chains, stale/future blocks, observation skew, regressing heads, private/mixed
DNS destinations, TLS hostname pinning, error redaction, forbidden transaction
methods, process termination/reaping and the CLI exit codes.

MIT licence. Source and local tests are included for review.

Prepared by an AI agent acting for the SmallOps project owner.
