Repository navigation
Conversation
Add HTTP and Unix-domain-socket transports for the shared Admin JSON-RPC API, with an attach console for trusted node operators. Include transport configuration, socket permissions, request handling, bounded client lifecycle, and startup isolation regression tests.
…ken count restrict
Add peer management to Admin HTTP and IPC, including active-peer inspection, persistent IP blocking, and optional IPC text output. Implement the management APIs and TCP connection policy in the built-in p2p module. Retain the standalone blocked-ips option and consolidate its tests in StartAppArgsTest. Base the change on feature/admin_rpc with java-tron 4.8.3.
# Conflicts: # common/src/main/resources/reference.conf # framework/build.gradle # framework/src/main/java/org/tron/core/config/args/Args.java # framework/src/main/java/org/tron/core/config/args/CommandLineArguments.java # framework/src/main/java/org/tron/core/services/admin/AdminJsonRpc.java # framework/src/main/java/org/tron/core/services/admin/AdminJsonRpcImpl.java # framework/src/main/java/org/tron/core/services/admin/AdminJsonRpcRequestHandler.java # framework/src/main/java/org/tron/core/services/admin/http/AdminRpcHttpService.java # framework/src/main/java/org/tron/core/services/admin/http/AdminRpcServlet.java # framework/src/main/java/org/tron/core/services/admin/http/VirtualHostValidator.java # framework/src/main/java/org/tron/core/services/admin/ipc/client/IpcClient.java # framework/src/main/java/org/tron/core/services/admin/ipc/client/IpcConsoleCommands.java # framework/src/main/java/org/tron/core/services/admin/ipc/client/IpcResponse.java # framework/src/main/java/org/tron/core/services/admin/ipc/server/IpcRequestHandler.java # framework/src/main/java/org/tron/core/services/admin/ipc/server/IpcSocketFiles.java # framework/src/main/java/org/tron/core/services/jsonrpc/JsonRpcServlet.java # framework/src/main/java/org/tron/program/FullNode.java # framework/src/test/java/org/tron/core/services/admin/http/AdminRpcServletTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/client/IpcClientTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/client/IpcConsoleCommandsTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/client/IpcResponseTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/server/AdminJsonRpcRequestTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/server/IpcRequestHandlerTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/server/IpcServiceTest.java # framework/src/test/java/org/tron/core/services/admin/ipc/server/IpcSocketFilesTest.java # framework/src/test/java/org/tron/program/FullNodeTest.java # gradle/verification-metadata.xml
…ating request for two jsonrpc services
# Conflicts: # p2p/src/main/java/org/tron/p2p/P2pService.java # p2p/src/main/java/org/tron/p2p/connection/business/pool/ConnPoolService.java # p2p/src/main/java/org/tron/p2p/utils/NetUtil.java # p2p/src/test/java/org/tron/p2p/connection/ChannelManagerTest.java # p2p/src/test/java/org/tron/p2p/connection/ConnPoolServiceTest.java
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?
Adds runtime peer management to Admin JSON-RPC over HTTP and IPC, so operators can adjust active nodes, inspect connections, and block malicious IPs without restarting FullNode.
The API adds
admin_addPeer,admin_removePeer,admin_disconnectPeer,admin_listActivePeers,admin_blockIp,admin_unblockIp, andadmin_listBlockedIps. Mutations return a sharedPeerOperationResult; active-peer queries reuse the connection, latency, and synchronization statistics used byPeerConnection.log(). The IPC client also supports optional text-table output foradmin_listActivePeers.The five mutating Admin methods emit INFO-level write-attempt logs. Each line records the method and endpoint/IP target; unsafe or overlong targets appear as
omitted. The log indicates an attempted call, not a successful mutation.Why are these changes required?
Operators need to disconnect or block identified malicious peers and add trusted endpoints promptly when investigating degraded connectivity or network isolation. Persistent manual IP blocking keeps those decisions effective across node restarts.
Implementation
This PR builds on the Admin HTTP/IPC framework introduced in upstream PR #6979 and targets
release_v4.8.3. It adds peer-management APIs to that framework, together with the supporting behavior and tests inframeworkand:p2p.frameworkowns Admin HTTP/IPC dispatch, operation coordination, peer statistics, and persistence of normalized IPs andblockedAtMillistimestamps inCommonStore["blocked-ips"].p2pprovidesaddActiveNode,removeActiveNode,disconnect, andreplaceBlockedIps, plus TCP admission, dialing, candidate filtering, and disconnection enforcement.ConnectionPolicypublishes an immutable IP set through a volatile reference and normalizes IPv4-mapped IPv6 addresses for matching.P2pConfig.blockedIpssupplies the initial policy; runtime changes update the policy without writing back to startup configuration.p2p-standalone.jarretains--blocked-ips/-b. Its argument coverage is consolidated inStartAppArgsTest, and the module README documents startup and runtime usage.Behavior and compatibility
Active peers
admin_addPeeradds an endpoint to the active-node set without adding it totrustNodesor waiting for a successful connection. It rejects endpoints whose IP is manually blocked.admin_removePeerremoves an active endpoint and disconnects its current connection.admin_disconnectPeerdisconnects the exact endpoint without removing it from the active-node set, so it may reconnect later.admin_listActivePeersreports current connection, latency, and synchronization statistics. Mutations reportsuccess,changed, anddisconnectedCount, distinguishing a successful no-op from a business failure.node.dynamicConfig.enableis enabled, add/remove operations return a structured failure directing operators to updatenode.active. The other peer-management operations remain available.Manual IP blocklist
admin_blockIpandadmin_unblockIpaccept IPv4 or IPv6 literals. Repeated blocking is a successful no-op that preserves the originalblockedAtMillistimestamp; unblocking an absent IP is also a successful no-op.admin_listBlockedIpsreturns normalized IPs and their timestamps.Network scope and compatibility
Connect.protoaddsDisconnectReason.REQUESTED = 0x0Ffor explicit disconnects. The existing disconnect message structure, consensus rules, and chain-data formats remain unchanged.JSON-RPC behavior
JsonRpcRequestValidator. Admin follows the existing public endpoint: explicitid: nulland empty method names are invalid; numeric IDs are not limited to signed 64-bit values;params: nullpasses envelope validation and reaches method binding.Testing
Validation on macOS ARM64 / JDK 17 includes:
./gradlew clean build -x testand./gradlew test(full multi-module suite, completed during development)./gradlew :framework:checkstyleMain :framework:checkstyleTest :plugins:checkstyleMain(completed during development)check_reference_conf.py,check_reference_comments.py, andcheck_math_usage.sh(completed during development)./gradlew :framework:test --tests org.tron.core.services.admin.AdminJsonRpcImplTest./gradlew :framework:test --tests org.tron.core.services.admin.ipc.server.AdminJsonRpcRequestTest --tests org.tron.core.services.jsonrpc.JsonRpcServletTest./gradlew :framework:checkstyleMain :framework:checkstyleTest(after the logging and validation changes)Coverage includes startup policy installation, persistence and corrupt-data recovery, update ordering and retries, idempotency, concurrent mutations, dynamic-config restrictions, IP normalization, and TCP inbound/outbound rejection. HTTP/IPC dispatch, error codes, peer statistics, IPC text output, network lifecycle, and effective-connection compatibility have regression tests. The standalone p2p JAR build and
--blocked-ipshelp invocation were also checked during development.Open item before upstream submission
Issue #6989 requires audit logging in the shared Admin invocation path before state-changing peer-management methods are submitted upstream. The PR includes method-level logs for invoked write attempts on HTTP and IPC, including notifications that reach the method. These are operational logs, not the complete audit required by the issue: they do not uniformly record transport, caller context, outcomes, JSON-RPC errors, or business failures (
success: false), and accepted endpoint/IP targets appear in the logs. The shared-path audit, which must exclude raw parameters, response payloads, credentials, and sensitive paths, remains open before upstream submission.