Custom rpc endpoints plugin#414
Merged
Merged
Conversation
andrewnguyen22
requested changes
Jun 16, 2026
andrewnguyen22
approved these changes
Jun 17, 2026
63e3e37 to
5f5a515
Compare
RichardJamesLopez
added a commit
to RichardJamesLopez/canopy
that referenced
this pull request
Jun 18, 2026
Re-ran proto _generate.sh against the merged proto set (upstream PR canopy-network#414 added RPC-endpoint fields to PluginConfig) and rebuilt dcb/web/dcb.wasm. Plugin, dcb/app and dcb/faucet build on the new core; the DcbStateEvent schema fix still resolves (9 tx + 1 event type URLs).
Makaveli912
added a commit
to Makaveli912/praxis-market
that referenced
this pull request
Jul 9, 2026
sendToPluginAsync() (block lifecycle) and sendDetachedAsync() (QueryState/custom RPC, e.g. /v1/query/markets) both released the p.l bookkeeping mutex before calling sendProtoMsg(), which performs an unlocked conn.Write(). Concurrent calls to either path could interleave writes on the same socket, corrupting the length-prefixed message stream. Symptom: hitting a custom RPC endpoint while the node is actively producing blocks intermittently crashes the node with: FSM log: 'unrecognized plugin_to_fsm message: <nil>' Plugin log: 'plugin socket read failed: EOF' This is present in the stock PR canopy-network#414 reference implementation, not introduced by Praxis-specific code. Fix: add a dedicated writeMu sync.Mutex held for the full duration of sendProtoMsg(), serializing all socket writes regardless of which call path triggered them. Bookkeeping (p.l) is left untouched so unrelated request-tracking isn't serialized behind blocking I/O. Verified: 50 concurrent /v1/query/markets requests against an actively block-producing node, zero crashes, all responses valid. Also fixes duplicate 'go' directive and stale checksum in plugin/go/go.mod/go.sum from an earlier bad merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a detached, read-only query path from plugins to Canopy so plugin builders can serve their own custom RPC endpoints for chain-specific data, without coupling Canopy core to plugin-specific routes.
What's added
Core
PluginQueryRequest/PluginQueryResponseproto messages + wire fields (lib/.proto/plugin.proto).PluginQueryProvider+handleQueryRequestinlib/plugin.go, backed by a controller-ownedTimeMachinesnapshot adapter (controller/controller.go). Detached queries are read-only (noStateWrite).custom_state_prefixes; core panics at handshake if any collides with a core-reserved prefix (1–15), andFSM.StateWriterejects writes to reserved prefixes (fsm/state.go,fsm/plugin_guard_test.go).Plugin SDKs (go, python, typescript, kotlin, csharp)
QueryState(height, read)client method + transport.rpcAddressconfig field and a skeleton HTTP server (rpc.*) that starts with no routes, ready for builders to add their own endpoints.custom_state_prefixesconfig plumbing.Docs & tutorial
TUTORIAL.md/AGENTS.mdfor every plugin document how to add custom RPC endpoints, including a full worked faucet/reward example that lives only in each plugin'stutorial/folder (with integration tests).