-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(spartan): remove hardcoded keys and addresses - derive all from…
… mnemonic (#11672)
- Loading branch information
Showing
32 changed files
with
184 additions
and
789 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,20 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
# We get the index in the config map from the pod name, which will have the validator index within it | ||
KEY_INDEX=$(echo $POD_NAME | awk -F'-' '{print $NF}') | ||
# Add the index to the start index to get the private key index | ||
PRIVATE_KEY_INDEX=$((KEY_INDEX_START + KEY_INDEX)) | ||
|
||
# Get the private key from the mnemonic | ||
private_key=$(cast wallet private-key "$MNEMONIC" --mnemonic-index $PRIVATE_KEY_INDEX) | ||
|
||
# Note, currently writing both prover and sequencer keys for all nodes for convinience | ||
cat <<EOF >/shared/config/keys.env | ||
export VALIDATOR_PRIVATE_KEY=$private_key | ||
export L1_PRIVATE_KEY=$private_key | ||
export SEQ_PUBLISHER_PRIVATE_KEY=$private_key | ||
export PROVER_PUBLISHER_PRIVATE_KEY=$private_key | ||
EOF | ||
|
||
cat /shared/config/keys.env |
37 changes: 37 additions & 0 deletions
37
spartan/aztec-network/files/config/get-validator-addresses.sh
This file contains 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,37 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# Given a mnemonic and a start index, generate the validator addresses | ||
# (the number of replicas is given by the NUMBER_OF_VALIDATORS env variable) | ||
# Usage: | ||
# Requires: | ||
# - MNEMONIC | ||
# - KEY_INDEX_START | ||
# - NUMBER_OF_VALIDATORS | ||
# source /scripts/get-validator-addresses.sh | ||
|
||
# Initialize empty string for validator addresses | ||
VALIDATOR_ADDRESSES_LIST="" | ||
|
||
i=$KEY_INDEX_START | ||
while [ $i -lt $NUMBER_OF_VALIDATORS ]; do | ||
# Get the private key from the mnemonic | ||
private_key=$(cast wallet private-key "$MNEMONIC" --mnemonic-index $i) | ||
address=$(cast wallet address "$private_key") | ||
|
||
# Append address with comma if not first address | ||
if [ -n "$VALIDATOR_ADDRESSES_LIST" ]; then | ||
VALIDATOR_ADDRESSES_LIST="$VALIDATOR_ADDRESSES_LIST,$address" | ||
else | ||
VALIDATOR_ADDRESSES_LIST="$address" | ||
fi | ||
|
||
i=$((i + 1)) | ||
done | ||
|
||
cat <<EOF >./shared/config/validator-addresses | ||
export VALIDATOR_ADDRESSES=$VALIDATOR_ADDRESSES_LIST | ||
EOF | ||
|
||
cat ./shared/config/validator-addresses |
This file contains 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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
Oops, something went wrong.