feat(framework): support admin IPC and RPC - #82
Open
317787106 wants to merge 17 commits into
Open
Conversation
317787106
force-pushed
the
feature/admin_rpc
branch
from
July 31, 2026 09:13
e299fd9 to
147613e
Compare
317787106
force-pushed
the
feature/admin_rpc
branch
from
August 4, 2026 06:34
042981c to
a068c83
Compare
…return code when using --exec; use IPC frame; don't init args when using --attach; throw Tron_ERROR when output-directory is not exist
…rvice; add setErrorResolver for admin jsonrpc
…put-directory, else write in /tmp if path is too long; IPC client exist will not interpurt input
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.
What does this PR do?
This PR adds the Admin JSON-RPC transport foundation requested by tronprotocol/java-tron#6497. A single annotated
AdminJsonRpcinterface is shared by an HTTP endpoint and a local Unix-domain-socket service. The initialadmin_examplemethod verifies typed command dispatch and annotation-based JSON-RPC error handling; additional administrative methods can be added to the same interface.Admin HTTP RPC
The HTTP service is available to FullNode processes at
POST /adminand is disabled by default. It binds Jetty to the configured address and port. Enabling it on a non-loopback address emits a warning.The servlet validates the
Hostheader against the configured virtual-host allowlist, while accepting IPv4 and IPv6 literals. It acceptsapplication/json,application/json-rpc, andapplication/*+jsonmedia types, and rejects unsupported content types with HTTP 415. JSON-RPC parsing reuses a constrained object mapper with nesting-depth and token-count limits. JSON-RPC results, including protocol errors, use HTTP 200 responses.The configuration is:
Admin IPC service
The IPC service is also FullNode-only and disabled by default. By default it creates an endpoint at:
node.admin.ipc.socketDirectorycan select another socket root and must be an existing absolute directory on a POSIX-compatible filesystem. The service creates the private.ipcdirectory with owner-only access and sets the socket to0600. It refuses to replace a symbolic link or non-directory at the private directory path.The complete encoded socket path is limited to 100 bytes for portability across supported Unix-domain-socket implementations. If the path is longer, startup fails with guidance to configure a shorter
node.admin.ipc.socketDirectory; it does not silently relocate the endpoint.IPC uses newline-delimited, single-line JSON-RPC messages and the same
AdminJsonRpc, error resolver, and constrained JSON mapper as HTTP. Request size is bounded by the existingnode.rpc.maxMessageSizevalue, whose default is 4 MiB. Each client has a ten-minute idle timeout. The bounded client executor supports concurrent console sessions and immediately closes connections that arrive after all handlers are occupied. Unexpected accept failures use a five-second retry delay.Startup failures and normal shutdown both clean up owned sockets and the private directory. Shutdown closes active clients before stopping executors so blocked native socket reads do not unnecessarily delay node termination.
IPC console
The FullNode executable can attach to an active node without initializing another node instance:
A single command can be executed for scripting:
Attach mode is handled immediately after CLI argument parsing and before
CommonParameter, Logback, database, witness, or node services are initialized.--execrequires--attach, an empty socket path is rejected, and attach mode cannot be combined with--config.The JLine console derives command names, parameter names, and parameter types from the annotated Admin API. It supports quoted arguments, typed JSON conversion, sorted help, canonical command completion, formatted JSON results,
help,exit, andquit. One-shot execution returns a non-zero process status for invalid commands, JSON-RPC errors, communication failures, disconnection before a response, or the 30-second response timeout.Supporting changes
HttpServicenow supports binding a service to a specific listen address. The regular JSON-RPC servlet and the Admin transports share the new constrainedJsonRpcMapper, and supported JSON media-type matching is centralized inJsonRpcMediaType.The framework adds JLine for the interactive console and junixsocket for Unix-domain-socket support. Dependency verification metadata is updated accordingly.
Why are these changes required?
Administrative operations need a local, scriptable interface without starting a second node or exposing the existing public APIs as privileged management endpoints. The Unix-domain socket provides a private local transport, while the optional HTTP endpoint supports controlled integration when explicitly enabled.
Sharing one typed Admin API across both transports keeps command names, parameters, results, and JSON-RPC errors consistent. Explicit address binding, virtual-host validation, parser limits, filesystem permissions, bounded clients, and deterministic cleanup provide safer operational defaults.
Testing
The PR adds or updates tests covering:
The related Admin HTTP, IPC, CLI, configuration, and FullNode tests, together with production and test checkstyle checks, passed during development.
Follow-up
Runtime parameter export is split into stacked Draft PR #83. Peer management commands will be implemented separately on
feature/peer_managementusing the Admin transports introduced here.