Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the --beacon-nodes list to be updated at runtime #6551

Open
wants to merge 7 commits into
base: unstable
Choose a base branch
from

Conversation

macladson
Copy link
Member

@macladson macladson commented Oct 29, 2024

Proposed Changes

Adds a new /lighthouse API call to the VC which allows the list of beacon nodes to be updated dynamically at runtime.

An entirely new beacon node list is provided to the VC so it effectively adds, removes or reorders nodes to match the new list.

This can then be used in Siren, which will enable a "drag to reorder" system along with adding and removing beacon nodes while the VC is on. This will make it unnecessary to reboot the VC when a users want to simply add or remove a BN from the list.

Usage

curl -X POST http://127.0.0.1:5062/lighthouse/beacon/update \
 -H "Authorization: Bearer $(cat ${DATADIR}/validators/api-token.txt)" \
 -H "Content-Type: application/json" \
 -d "{\"beacon_nodes\":[\"http://beacon-node1:5052\",\"http://beacon-node2:5052\",\"http://beacon-node3:5052\"]}" | jq

The new nodes should start appearing in the VC logs, but you can also check which nodes the VC is connected to using:

curl -X GET http://127.0.0.1:5062/lighthouse/ui/fallback_health -H "Authorization: Bearer $(cat ${DATADIR}/validators/api-token.txt)" | jq

Additional Information

The current design rebuilds the candidate list from scratch and then swaps it in. While I don't expect this process to take a long time, it's possible some API queries will fail during the swap over. Another option is to mutate the list in place, which prevents BNs which are present in both the old and new lists from being removed.

@macladson macladson added work-in-progress PR is a work-in-progress val-client Relates to the validator client binary labels Oct 29, 2024
@macladson macladson changed the title Allow the --beacon-node list to be updated at runtime Allow the --beacon-nodes list to be updated at runtime Oct 29, 2024
@macladson macladson force-pushed the dynamic-beacon-nodes branch from 02eb997 to 9ab780d Compare December 2, 2024 09:33
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that adding or removing proposer nodes is currently not possible.
The main reason I didn't include it is because if no proposer nodes are included when the VC is initialized, the proposer_node field in BlockService is set to None. So any future attempts to add proposer nodes will require the entire BlockService to be updated.

I suspect we need to rework the way proposer nodes work anyway. I might look into that for a separate PR.

@macladson macladson added ready-for-review The code is ready for review and removed work-in-progress PR is a work-in-progress labels Dec 2, 2024
@macladson macladson requested a review from chong-he December 2, 2024 12:23
Copy link
Member

@chong-he chong-he left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done some testing and it is a nice feature to have! During testing, the order of the beacon nodes are successfully re-ordered (verify by querying the GET health endpoint and it shows the index field is re-ordered).

One thing I wonder is how does the unsuccessful POST query look like? I try to insert a non-existing beacon-node in the data field:

DATADIR=/var/lib/lighthouse_test1
curl -X POST http://localhost:5062/lighthouse/beacon/update \
 -H "Authorization: Bearer $(sudo cat ${DATADIR}/validators/api-token.txt)" \
 -H "Content-Type: application/json" \
 -d "{\"beacon_nodes\":[\"http://localhost:5052\",\"http://localhost:5053\",\"http://not-exist:5054\"]}" | jq

The response is as if it reorders the beacon node (including the non-existing one):

{
  "data": {
    "new_beacon_nodes_list": [
      "http://localhost:5052/",
      "http://localhost:5053/",
      "http://not-exist:5054/"
    ]
  }
}

The VC will throw logs of the non-existing beacon node.

Would it be possible to have a check on the beacon nodes used in the --beacon-nodes flag to check the existence of the beacon node in the POST query? That would be nice as it will prevent incorrect POST query to succeed.

book/src/api-vc-endpoints.md Outdated Show resolved Hide resolved
book/src/api-vc-sig-header.md Outdated Show resolved Hide resolved
@macladson
Copy link
Member Author

macladson commented Dec 4, 2024

Thanks for the review!

Would it be possible to have a check on the beacon nodes used in the --beacon-nodes flag to check the existence of the beacon node in the POST query? That would be nice as it will prevent incorrect POST query to succeed.

I think liveness checking each beacon node is beyond the scope of this API. So long as each value is a valid URL, the beacon node could become "online" at any time so it should be added to the list. I think it makes sense that it is up to the user to provide beacon nodes which are running, just like it is up to the user to provide beacon nodes to the --beacon-nodes CLI flag.

Note that the API will error in the event a value is not a valid URL, or if the list is empty.

@mrabino1
Copy link

Is there a target release number to have this functionality pulled in?

@michaelsproul michaelsproul added the v6.1.0 New release c. Q1 2025 label Dec 13, 2024
@michaelsproul
Copy link
Member

Added to v6.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-review The code is ready for review v6.1.0 New release c. Q1 2025 val-client Relates to the validator client binary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants