Skip to content

feat(framework): support admin IPC and RPC - #82

Open
317787106 wants to merge 12 commits into
developfrom
feature/admin_rpc
Open

feat(framework): support admin IPC and RPC#82
317787106 wants to merge 12 commits into
developfrom
feature/admin_rpc

Conversation

@317787106

@317787106 317787106 commented Jul 31, 2026

Copy link
Copy Markdown
Owner

What does this PR do?

Implements the Admin RPC transport and geth-style local IPC console requested by tronprotocol/java-tron#6497.

Admin RPC

  • Adds the org.tron.core.services.admin package with a shared admin API for HTTP and IPC transports.
  • Adds admin_example as a typed example method.
  • Uses consistent annotation-based JSON-RPC error envelopes for HTTP and IPC without logging complete requests or sensitive exception details.

HTTP transport

  • Adds the configurable node.adminRpc.enable, node.adminRpc.listenAddress, and node.adminRpc.port options.
  • Binds Jetty to the configured literal listen address.
  • Emits a startup warning only when the resolved listen address is not loopback; IPv4, IPv6, and hostname loopback addresses are recognized.
  • Requires a supported JSON-RPC content type and uses the constrained JSON-RPC object mapper.
  • Documents the Admin RPC settings in reference.conf.

IPC transport and console

  • Adds node.ipcEnable and creates java-tron.<pid>.sock under --output-directory when the complete encoded absolute path is at most 100 bytes.
  • Falls back to /tmp/java-tron.<pid>.sock when the output-directory path is too long for a portable Unix-domain socket address.
  • Requires the selected socket directory to exist, validates POSIX socket support, and sets socket file permissions to owner read/write only (0600).
  • Rejects non-socket and symbolic-link endpoints when handling a stale path, and cleans up the active socket on shutdown.
  • Limits each framed, single-line IPC request to 4 MiB.
  • Supports concurrent attach clients, applies a ten-minute idle timeout, rejects excess clients cleanly, and backs off for one second after unexpected accept failures.
  • Provides typed command arguments, formatted output, canonical command completion, command help, and in-memory history.
  • Trims leading and trailing command whitespace while preserving whitespace inside quoted arguments.
  • Handles clean console exit without leaving the input thread interrupted, while unexpected server disconnects still wake blocked terminal input.
  • Avoids printing Java null after commands whose return value is null.

CLI

Interactive console:

java -jar FullNode.jar --attach <socket-path>

Execute one command and return an appropriate process exit code:

java -jar FullNode.jar --attach <socket-path> --exec "<command> [arguments]"
  • Rejects an empty --attach path, --exec without --attach, and unsupported node-startup options combined with attach mode.
  • Handles attach mode immediately after argument parsing and before CommonParameter, LogService, database, witness, or node-service initialization, so the console process does not open or rotate the running node log files.

Why are these changes required?

Administrative operations need a local, scriptable interface that does not require starting another node instance. The Unix-domain-socket console provides a secure-by-default local transport, while the optional loopback-bound HTTP Admin RPC supports controlled integration.

The framing, path-length fallback, idle timeout, accept backoff, deterministic disconnect handling, and consistent error envelopes make the console safe to operate across local development, containers, and deeply nested mounted output directories.

Testing

  • Added and updated tests for node configuration binding and attach argument validation.
  • Added HTTP tests for JSON-RPC content types, constrained mapping, literal address binding, and IPv4/IPv6/hostname loopback classification.
  • Added IPC service tests for socket path fallback, encoded multibyte path length, lifecycle, 0600 permissions, stale-path safety, request limits, concurrent clients, idle timeout, JSON-RPC errors, and teardown cleanup after stop failure.
  • Added IPC client tests for typed arguments, canonical completion, command whitespace, --exec, formatted output, clean exit, unexpected disconnects, and process exit codes.
  • Added a FullNode startup-order test verifying attach mode does not initialize LogService.
  • Ran the related Gradle test classes together with checkstyleMain and checkstyleTest.
  • Manually verified interactive attach, one-shot --exec, and commands surrounded by leading/trailing whitespace.

Follow-up

@317787106
317787106 force-pushed the feature/admin_rpc branch from e299fd9 to 147613e Compare July 31, 2026 09:13
@317787106 317787106 changed the title Feature/admin rpc feat(framework): support admin rpc Jul 31, 2026
@317787106 317787106 changed the title feat(framework): support admin rpc feat(framework): support admin IPC and RPC Aug 4, 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.

1 participant