Skip to content

feat(cli): read-only native-state activation preflight command#781

Merged
github-actions[bot] merged 1 commit into
mainfrom
chore/native-state-preflight-tool
Jun 3, 2026
Merged

feat(cli): read-only native-state activation preflight command#781
github-actions[bot] merged 1 commit into
mainfrom
chore/native-state-preflight-tool

Conversation

@satyakwok
Copy link
Copy Markdown
Collaborator

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)

  1. binary version
  2. chain height
  3. tip hash
  4. state_root (from the tip block header — no trie init needed)
  5. SRC-20 ContractRegistry canonical hash
  6. NFT NftRegistry canonical hash
  7. NATIVE_STATE_IN_TRIE gate state (enabled + activation height)
  8. NFT_TOKENOP gate state
  9. verdict: READY / WARNING / NOT_READY + notes

Text by default; --json for deterministic machine output (sorted keys).

Read-only by construction

Same Storage::open + load_blockchain pattern as the existing state 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-memory Blockchain, 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_root across all validators before pinning a height (per the playbook). The tool prints that reminder.

Files

  • bin/sentrix/src/commands/state.rscmd_state_preflight + pure builder + renderers + tests
  • bin/sentrix/src/main.rsStateCommands::Preflight { json } + dispatch
  • src/core/mod.rs — re-export sentrix_core::fork_heights through 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)

  • Cross-validator agreement is still a manual comparison (run preflight on every node, diff the hashes/state_root).
  • Hash-commitment, not reconstruction — divergence recovery is resync-from-canonical.
  • Coordinated halt-all/simul-start with an identical pinned height remains an operator step.

No deploy, no validators touched, no RPC/explorer/wallet/marketplace/bridge, no fork enabled.

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.
@satyakwok satyakwok self-assigned this Jun 3, 2026
@satyakwok satyakwok marked this pull request as ready for review June 3, 2026 20:05
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@satyakwok, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 95cf5005-8d9c-4ec5-8a4e-046dabab1d1a

📥 Commits

Reviewing files that changed from the base of the PR and between 3e6be04 and 95c73b9.

📒 Files selected for processing (3)
  • bin/sentrix/src/commands/state.rs
  • bin/sentrix/src/main.rs
  • src/core/mod.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/native-state-preflight-tool

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions github-actions Bot enabled auto-merge (squash) June 3, 2026 20:05
@github-actions github-actions Bot merged commit 8df5075 into main Jun 3, 2026
19 checks passed
@satyakwok satyakwok deleted the chore/native-state-preflight-tool branch June 3, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant