Skip to content

Bind native module manifest grants to the issued IPC instance - #75

Merged
secsovereign merged 1 commit into
BTCDecoded:mainfrom
keegreil:codex/native-module-manifest-grants
Nov 22, 2026
Merged

secsovereign merged 1 commit into
BTCDecoded:mainfrom
keegreil:codex/native-module-manifest-grants

Conversation

@keegreil

@keegreil keegreil commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The native loader registered a manifest's capabilities under the module name, but the API hub looks them up using the issued IPC instance ID. As a result, a module declaring read_mempool fell back to the legacy read-only defaults and its normal transaction read was refused.

Change

  • Install nonempty manifest grants under the exact instance ID before starting the subprocess. Empty manifests keep the existing read-only defaults; those defaults do not include mempool access. WASM remains unchanged.
  • Revoke native grants and their issued identity at teardown. Use the IPC handle for unregistering CLI state rather than locking the running accept loop.
  • Check subscription requests before applying their side effects. Skip the monitor's chain-tip query when the manifest does not grant chain-state reads; process and resource supervision stay enabled.

This makes native manifest policy effective, so module authors relying on an undeclared default capability should audit their nonempty manifests.

Verification

@secsovereign secsovereign left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review (draft)

Correct fix for the second GridPool/ZMQ failure mode: hub authz keyed the session by issued IPC id, while native spawn registered grants under the module name, so read_mempool fell through to legacy read-only and GetMempoolTransaction returned ReadMempool denied despite a correct module.toml.

What looks good

  • bind_native_grants registers nonempty capability lists on the instance id before spawn; empty/absent keeps legacy defaults (no undeclared mempool). Documented in MODULE_SYSTEM.md.
  • Subscribe registration moved to after a successful hub response — denied subscribe no longer mutates event-manager state.
  • Revoke / unregister on spawn failure, crash monitor exit, unload, and dependent teardown — including hub unregister by instance id.
  • Chain-tip heartbeat gated on ReadChainState so a mempool-only grant does not get a free chain read via the supervisor.
  • Unit test covers grant-on-instance / deny-on-other-id / revoke-on-unload.

Ask before merge

  1. Land #73 first (session demux). This PR does not replace that; ZMQ still needs the single reader for event/reply interleaving.
  2. Confirm the intentional behavior change: nonempty capability lists are exact (no silent legacy mempool). Any in-tree module with a partial list needs read_mempool / read_blockchain spelled out — ZMQ’s manifest already does.
  3. Mark ready for review once rebased on #73 (or on main after #73) and CI is green. Same url RUSTSEC-2026-0592 hard-fail as #73 will hit until main bumps url ≥2.5.9.
  4. Small nit: crash path now revokes by id via ipc_handle without taking the old server mutex — good; double-check Windows/cfg paths still compile (unix-only revoke is fine).

Merge posture

Want this after #73. Together with blvm-zmq 0.1.7 / #1 this is the node half of restoring hashblock/rawblock + mempool reads for GridPool.

@secsovereign
secsovereign marked this pull request as ready for review November 22, 2026 19:03
@secsovereign
secsovereign merged commit a3e76e7 into BTCDecoded:main Nov 22, 2026
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.

2 participants