-
Notifications
You must be signed in to change notification settings - Fork 8
add-validator feature #79
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
Open
serjs
wants to merge
5
commits into
dappnode:main
Choose a base branch
from
serjs:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a09d0fa
New alpha add-validator feature
serjs 052b526
Put back updated charon version
serjs ad0c11a
ADd P2P relay to add-validators, yml params for UI
serjs be285bf
Change logic for --no-verify flag. Use only when state file is present
serjs e4f0751
Fix service name for cluster-5
serjs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| #!/bin/bash | ||
|
|
||
| # VARS | ||
| SERVICE_OK=0 | ||
| ATTEMPTS=0 | ||
| MAX_ATTEMPTS=10 | ||
| INFO="[ INFO | container-add-validator:]" | ||
|
|
||
| # Function that runs the validator addition logic | ||
| run_validator_logic() { | ||
| echo "${INFO} Add validators for $CHARON_SERVICE_NAME" | ||
|
|
||
| # Check if ADD_VALIDATOR is setting in config for current running service | ||
| if [[ "$ADD_VALIDATOR_TARGET_CLUSTER" =~ (^|,)($CHARON_SERVICE_NAME)(,|$) ]]; then | ||
| echo "${INFO} Start running charon add-validators command" | ||
|
|
||
| charon alpha add-validators \ | ||
| --data-dir="$CHARON_ROOT_DIR" \ | ||
| --num-validators "$ADD_VALIDATOR_NUM_VALIDATORS" \ | ||
| --withdrawal-addresses="$ADD_VALIDATOR_WITHDRAWAL_ADDRESS" \ | ||
| --fee-recipient-addresses="$ADD_VALIDATOR_FEE_RECEPIENT_ADDRESS" \ | ||
| --p2p-relays https://4.relay.obol.dev \ | ||
| --output-dir=/tmp/.charon | ||
|
|
||
| if [[ $? -ne 0 ]]; then | ||
| echo "${INFO} charon add-validators failed. Exiting..." | ||
| rm -f /import/add_validator | ||
| rm -rf /tmp/.charon | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "${INFO} Stopping charon and lodestar during upgrade processes..." | ||
| supervisorctl stop charon lodestar | ||
|
|
||
| echo "${INFO} Upgrade .charon directory with backing up previous .charon to /tmp/.charon" | ||
| cp -r "$CHARON_ROOT_DIR" /tmp/.charon.bck && mv /tmp/.charon "$CHARON_ROOT_DIR" | ||
|
|
||
| echo "${INFO} Starting charon and lodestar processes..." | ||
| supervisorctl start charon lodestar | ||
|
|
||
| while [[ "$ATTEMPTS" -lt "$MAX_ATTEMPTS" ]]; do | ||
| if supervisorctl status charon | grep -q "RUNNING"; then | ||
| SERVICE_OK=1 | ||
| break | ||
| fi | ||
|
|
||
| echo "${INFO} charon not ready, waiting 2 seconds... (Attempt ${ATTEMPTS}/${MAX_ATTEMPTS})" | ||
| sleep 3 | ||
| ATTEMPTS=$((ATTEMPTS + 1)) | ||
| done | ||
|
|
||
| if [[ "$SERVICE_OK" -eq 1 ]]; then | ||
| echo "${INFO} Validator(s) added, charon is running." | ||
| touch "$CHARON_ROOT_DIR/.charon_added_validator_state" | ||
| else | ||
| echo "${INFO} Validator(s) was not added, restoring .charon state folder to previous one and restart cluster. Check logs for more details" | ||
| mv /tmp/.charon.bck "$CHARON_ROOT_DIR" | ||
| supervisorctl restart charon lodestar | ||
| fi | ||
| fi | ||
| } | ||
|
|
||
| # Watch for the creation of /import/add_validator and trigger logic | ||
| inotifywait -m /import -e create | | ||
| while read path action file; do | ||
| if [ "$file" == "add_validator" ]; then | ||
| echo "${INFO} Trigger file detected, executing validator logic..." | ||
| run_validator_logic | ||
| rm -f /import/add_validator | ||
| fi | ||
| done | ||
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please override the default relays list (see
--p2p-relays) to use justhttps://4.relay.obol.dev- we keep this as an isolated relay for DKGs to not interfere with the default [0, 1 & 2] which are used for running clusters.The command uses p2p network under the hood. An isolated relay ensures that
add-validatorsinstances will not interfere withcharon runinstances (those running a live cluster).Otherwise, relay starts rejecting new connections because theses are the same peers having the same peer ID and they cannot connect twice to the same relay.
Hope this makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback! Do we need to have option to set any other relays in future? I mean, do I need to add optional not required (by default) field for setting non default (https://4.relay.obol.dev in our case) p2p-relays during add-validators?