feat(cli): read-only native-state activation preflight command#781
Conversation
Add `sentrix state preflight [--json]` — a read-only readiness check for the native-module state_root activation (gated by NATIVE_STATE_IN_TRIE_HEIGHT, still disabled). Helps operators run the activation playbook's pre-flight. Reports (per node): binary version, chain height, tip hash, state_root (from the tip header), SRC-20 ContractRegistry canonical hash, NFT NftRegistry canonical hash, both fork-gate states (enabled + activation height), and a local READY / WARNING / NOT_READY verdict with notes. Read-only by construction: same Storage::open + load_blockchain pattern as `state export`. No writes, no trie init/reset, no env mutation, no fork enablement, no network. Report-building is a pure function (build_preflight_report) so it's unit-tested without a DB. A single node can't prove cross-validator agreement — output is meant to be compared across all validators before pinning a height (see the activation playbook). Also re-exports sentrix_core::fork_heights through the `sentrix::core` facade (one line, matching the existing re-exports) so the bin can read the configured gate heights. Tests: empty-registry output stable + deterministic JSON; populated SRC-20 changes the hash; populated NFT changes the hash; disabled gates reported clearly; enabled native gate surfaces a WARNING with the pinned height.
|
Warning Review limit reached
More reviews will be available in 17 minutes and 25 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Draft — do not merge; for review. Read-only admin tooling; no protocol/consensus change, no fork enabled.
Adds
sentrix state preflight [--json]to support the activation playbook (#780) pre-flight for the native-module state_root commitment (#779), which remains gated off (NATIVE_STATE_IN_TRIE_HEIGHT = u64::MAX).What it reports (per node)
state_root(from the tip block header — no trie init needed)ContractRegistrycanonical hashNftRegistrycanonical hashNATIVE_STATE_IN_TRIEgate state (enabled + activation height)NFT_TOKENOPgate stateText by default;
--jsonfor deterministic machine output (sorted keys).Read-only by construction
Same
Storage::open+load_blockchainpattern as the existingstate export. It does not: write/mutate state, init or reset the trie, set env, enable any fork, or make network calls. The report-builder (build_preflight_report) is a pure function over an in-memoryBlockchain, so it's unit-tested without a DB.Single-node scope (called out in the output)
A node can't prove cross-validator agreement. The verdict is local; the operator must compare
src20_canonical_hash/nft_canonical_hash/state_rootacross all validators before pinning a height (per the playbook). The tool prints that reminder.Files
bin/sentrix/src/commands/state.rs—cmd_state_preflight+ pure builder + renderers + testsbin/sentrix/src/main.rs—StateCommands::Preflight { json }+ dispatchsrc/core/mod.rs— re-exportsentrix_core::fork_heightsthrough the facade (one line)Tests (6)
empty-registry stable + deterministic JSON · populated SRC-20 changes hash · populated NFT changes hash · disabled gates reported · enabled native gate → WARNING with pinned height.
Commands
cargo test --workspace✅ (67 suites, 0 fail) ·cargo fmt --check✅ ·cargo clippy --workspace --all-targets -D warnings✅Remaining manual activation risks (unchanged; tool surfaces, doesn't remove)
No deploy, no validators touched, no RPC/explorer/wallet/marketplace/bridge, no fork enabled.