Skip to content

Support dynamic management of peers #6296

Closed

Description

@jwrct

Background

Java-tron currently does not support node operators to flexibly manage the peer list of a node. For example, when a node operator wants to disconnect a peer (this peer may have a large network delay, or is inactive, etc.), there is no better way than restarting the node. Obviously, restarting the node is not a wise choice, because it will have a relatively large impact on other services that rely on the normal operation of the node. Moreover, after restarting the node, the node that you want to disconnect may still be able to quickly connect to the local node. Therefore, it is necessary for java-tron to implement the function of dynamically managing the peer list of nodes to provide node operators with more options for better node management.

Rationale

By looking at the implementation of Ethereum, it is found that Ethereum implements the following interfaces:

  • AddPeer: Add a node to the static node list (the Ethereum node will actively initiate a connection with the static node).
  • RemovePeer: Delete the peer from the static list and disconnect the peer.
  • AddTrustedPeer: Set the connected peer as a trusted connection. Its connection will not be pruned later, nor will it be judged as a bad peer by the peer scoring mechanism.
  • RemoveTrustedPeer: Delete the trusted connection identifier of the connected peer.

Currently, java-tron already supports dynamic addition and deletion of active nodes and passive nodes by dynamically loading configuration files.

  • Active nodes: Active connection services will prioritize establishing connections with active nodes, and are not subject to the maximum number of connections.
  • Passive nodes: They will be added to the trusted node list, and are not subject to the maximum number of connections when passively connected.

Therefore, we can dynamically delete peers by dynamically loading configuration files.

Implementation

  1. Add a new configuration item node.removePeers in the configuration file:
    node.removePeers = [ "ip1:port", "ip2:port" ]

  2. node.removePeers configures dynamic update logic:

  • When the node starts, node.removePeers is loaded normally.

  • When the configuration file is loaded dynamically, the latest node.removePeers is loaded and the network address list in the configuration is traversed:
    a. Check whether the network address exists in the last cache removePeers. If it does, get the peer according to the network address. If it is successfully obtained, send a disconnect message to the peer with the reason code USER_REASON and disconnect.
    b. No processing is done in other cases.

  • Update the latest removePeers list to the cache.

Do you have ideas regarding the implementation of this feature?
yes
Are you willing to implement this feature?
yes

Activity

  1. fyyhtx commented on Apr 22, 2025

    @fyyhtx
    Contributor

    This feature looks very good, but I still have a question, if the connection of the specified peer is disconnected, will the reconnection request be accepted?

  2. jwrct commented on Apr 22, 2025

    @jwrct
    ContributorAuthor

    @fyyhtx Yes, a peer that is designated to be disconnected can be re-accepted, but only after it has passed the banding period. One thing to be clear is that we are not implementing a blacklist feature.

  3. jakamobiii commented on Apr 23, 2025

    @jakamobiii

    I tried to add active nodes and passive nodes without restarting the nodes, but it didn't seem to work. Is there a problem with the dynamic loading of configuration files function? Or does the dynamic loading of configuration files function need to be enabled?

  4. jwrct commented on Apr 23, 2025

    @jwrct
    ContributorAuthor

    @jakamobiii I guess you may not have enabled the dynamic configuration file loading function. You can set the configuration item node.dynamicConfig.enable to true and restart the node to try.

  5. fyyhtx commented on Apr 24, 2025

    @fyyhtx
    Contributor

    @jwrct Do you want to specify the peer you want to delete through configuration? As you said, the disconnected peer can still be accepted later. When you want to delete a peer again, but it already exists in the configuration, how to deal with this situation?

  6. SeriousCoding789 commented on Apr 24, 2025

    @SeriousCoding789
    Contributor

    @jwrct For Ethereum the RemovePeer action, will it be put into the blacklist and never be connected?

  7. jwrct commented on Apr 24, 2025

    @jwrct
    ContributorAuthor

    @Sunny6889 For the RemovePeer action of Ethereum, it will not be put into the blacklist and the connection can be established again later.

  8. SeriousCoding789 commented on Apr 24, 2025

    @SeriousCoding789
    Contributor

    @Sunny6889 For the RemovePeer action of Ethereum, it will not be put into the blacklist and the connection can be established again later.

    @jwrct So does it means Ethereum also does not have a blacklist feature?

  9. jwrct commented on Apr 24, 2025

    @jwrct
    ContributorAuthor

    @Sunny6889 Yes, I think so. I have checked the Ethereum code implementation and found nothing about it. If you have any new findings, please provide some clues, I will be very grateful.

  10. jwrct commented on Apr 24, 2025

    @jwrct
    ContributorAuthor

    @jwrct Do you want to specify the peer you want to delete through configuration? As you said, the disconnected peer can still be accepted later. When you want to delete a peer again, but it already exists in the configuration, how to deal with this situation?

    @fyyhtx Yes, by default, a new configuration file is loaded every 10 minutes. You can delete the peer information from the configuration after confirming that the peer has been deleted, or remove the existing configuration before deleting the peer, and wait 10 minutes before deleting the peer.

  11. fyyhtx commented on Apr 25, 2025

    @fyyhtx
    Contributor

    @jwrct Is there already a specific implementation plan? If so, could you share it with everyone for discussion to better optimize the plan?

  12. jwrct commented on Apr 25, 2025

    @jwrct
    ContributorAuthor

    @fyyhtx Yes, you're right. I already have an initial plan here:

    1. Add a new configuration item node.removePeers in the configuration file:
      node.removePeers = [ "ip1:port", "ip2:port" ]
    2. node.removePeers configures dynamic update logic:
    • When the node starts, node.removePeers is loaded normally.

    • When the configuration file is loaded dynamically, the latest node.removePeers is loaded and the network address list in the configuration is traversed:
      a. Check whether the network address exists in the last cache removePeers. If it does, get the peer according to the network address. If it is successfully obtained, send a disconnect message to the peer with the reason code USER_REASON and disconnect.
      b. No processing is done in other cases.

    • Update the latest removePeers list to the cache.

  13. fyyhtx commented on Apr 28, 2025

    @fyyhtx
    Contributor

    @jwrct You proposed to pass in the network address of the peer you want to delete by dynamically loading the configuration. I have to admit that this method is the simplest one to implement at present. However, I would like to say that this method has a disadvantage, that is, you need to log in to the server where the node is located every time, which may not be the most convenient way for some node operators.

  14. jwrct commented on Apr 28, 2025

    @jwrct
    ContributorAuthor

    @fyyhtx Your concerns are reasonable. Ethereum implements the peer you want to delete through an API with permission control. This method is indeed much more convenient for node operators. However, java-tron currently does not implement permission control for the API. We can consider implementing this first, and then specify the peer to be deleted in this way.

  15. 13 remaining items

  16. 317787106 commented on Sep 30, 2025

    @317787106
    Collaborator

    The access authentication architecture has been fully designed, and upon completion, it will allow for the continued support of dynamic peer management.

  17. 317787106 commented on Dec 24, 2025

    @317787106
    Collaborator

    @jwrct This feature can be implemented in the framework of #6497.

  18. waynercheung commented on May 15, 2026

    @waynercheung
    Collaborator

    @317787106 @jwrct Since this has been discussed in #6497 , would it make sense to close this one and continue the conversation there?

  19. halibobo1205 commented on May 15, 2026

    @halibobo1205
    Collaborator

    closed by #6497.

  20. moved this from Backlog to Done in java-tronon May 15, 2026
  21. moved this from Done to In Progress in java-tronon Sep 22, 2026
  22. SeriousCoding789 commented on Sep 22, 2026

    @SeriousCoding789
    Contributor

    Closing this in favour of #6989.

    Context for anyone arriving from a link: #6989 is the concrete implementation issue that finally lands the capability, so this is the right moment to close the original.

    What #6989 covers, on top of the Admin JSON-RPC framework from #6497:

    Method Purpose
    admin_addPeer / admin_removePeer Add or remove an active-node endpoint at runtime
    admin_disconnectPeer Drop one exact connection without touching active-node config
    admin_listActivePeers Inspect current peers and their runtime statistics
    admin_blockIp / admin_unblockIp / admin_listBlockedIps Persistent manual IP blocklist, surviving restart

    This is a superset of what was proposed here. The original design routed removal through a node.removePeers config entry applied on dynamic config reload; #6989 exposes it as an Admin request instead, which gives immediate structured feedback and avoids coupling an operational action to a config-file edit. It also adds the two things this issue did not cover: inspection of current peer
    state, and a persistent IP blocklist that survives a restart — the original concern that "the peer you disconnected can just reconnect right away" is only actually solved by that second one.

    @jwrct — thanks for the original write-up and the Ethereum comparison; the AddPeer / RemovePeer / trusted-peer semantics you documented carried directly into the method set above. Please follow along and comment on #6989 if anything from the original design is missing there.

  23. moved this from In Progress to Done in java-tronon Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions