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

fix: pass salt to deploy-l1-contracts.sh #10586

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/network-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ on:
required: true
type: string
default: testnet-deployment-mnemonic
deployment_salt:
description: The salt to use for this deployment. Defaults to random
required: false
type: string
default: ""
respect_tf_lock:
description: Whether to respect the Terraform lock
required: false
Expand Down Expand Up @@ -53,6 +58,10 @@ on:
description: The name of the secret which holds the boot node's contract deployment mnemonic
required: true
default: testnet-deployment-mnemonic
deployment_salt:
description: The salt to use for this deployment. Defaults to random
required: false
default: ""
respect_tf_lock:
description: Whether to respect the Terraform lock
required: false
Expand Down Expand Up @@ -82,6 +91,7 @@ jobs:
NAMESPACE: ${{ inputs.namespace }}
VALUES_FILE: ${{ inputs.values_file }}
DEPLOYMENT_MNEMONIC_SECRET_NAME: ${{ inputs.deployment_mnemonic_secret_name }}
DEPLOYMENT_SALT: ${{ inputs.deployment_salt }}
CHART_PATH: ./spartan/aztec-network
CLUSTER_NAME: aztec-gke
REGION: us-west1-a
Expand Down Expand Up @@ -153,6 +163,7 @@ jobs:
-var="GKE_CLUSTER_CONTEXT=${{ env.GKE_CLUSTER_CONTEXT }}" \
-var="AZTEC_DOCKER_IMAGE=${{ env.AZTEC_DOCKER_IMAGE }}" \
-var="L1_DEPLOYMENT_MNEMONIC=${{ steps.get-mnemonic.outputs.mnemonic }}" \
-var="L1_SALT=${DEPLOYMENT_SALT:-$RANDOM}" \
Copy link
Contributor Author

@alexghr alexghr Dec 12, 2024

Choose a reason for hiding this comment

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

NOTE: we set the random salt here such that it gets stored by helm as a value. If the boot node restarts it will reuse the same salt it was given at deployment time.

-out=tfplan \
-lock=${{ inputs.respect_tf_lock }}

Expand Down
7 changes: 4 additions & 3 deletions spartan/aztec-network/files/config/deploy-l1-contracts.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash
set -exu

CHAIN_ID=$1
SALT=$1
Copy link
Member

Choose a reason for hiding this comment

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

why switch order here?

CHAIN_ID=$2


# Run the deploy-l1-contracts command and capture the output
Expand All @@ -11,9 +12,9 @@ RETRY_DELAY=60
for attempt in $(seq 1 $MAX_RETRIES); do
# if INIT_VALIDATORS is true, then we need to pass the validators flag to the deploy-l1-contracts command
if [ "${INIT_VALIDATORS:-false}" = "true" ]; then
output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --mnemonic "$MNEMONIC" --validators $2 --l1-chain-id $CHAIN_ID) && break
output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --mnemonic "$MNEMONIC" --validators $3 --l1-chain-id $CHAIN_ID --salt $SALT) && break
Copy link
Member

Choose a reason for hiding this comment

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

perhaps need to handle the case of $SALT being undefined

else
output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --mnemonic "$MNEMONIC" --l1-chain-id $CHAIN_ID) && break
output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --mnemonic "$MNEMONIC" --l1-chain-id $CHAIN_ID --salt $SALT) && break
fi
echo "Attempt $attempt failed. Retrying in $RETRY_DELAY seconds..."
sleep "$RETRY_DELAY"
Expand Down
20 changes: 12 additions & 8 deletions spartan/aztec-network/templates/boot-node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,16 @@ spec:
- name: deploy-l1-contracts
image: {{ .Values.images.aztec.image }}
command:
[
"/bin/bash",
"-c",
"cp /scripts/deploy-l1-contracts.sh /tmp/deploy-l1-contracts.sh && \
chmod +x /tmp/deploy-l1-contracts.sh && \
source /shared/config/service-addresses && \
/tmp/deploy-l1-contracts.sh {{ .Values.ethereum.chainId }} \"{{ join "," .Values.validator.validatorAddresses }}\""
]
- /bin/bash
- -c
- |
cp /scripts/deploy-l1-contracts.sh /tmp/deploy-l1-contracts.sh
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, why were we copying the script elsewhere before running it?

Copy link
Contributor Author

@alexghr alexghr Dec 11, 2024

Choose a reason for hiding this comment

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

In #10580 I added a common script (now removed) to block for services to be avilable but I was getting permission errors. I couldn't figure out why so I just inlined the content into the pod.

Your comment above made me realise that it's probably becuase the scripts are mounted from a config map that's readonly.

chmod +x /tmp/deploy-l1-contracts.sh
source /shared/config/service-addresses

SALT=${SALT:-$RANDOM}
Copy link
Contributor Author

@alexghr alexghr Dec 12, 2024

Choose a reason for hiding this comment

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

Just a catch all for any deployments that don't use the workflow file (like local kind clusters)

echo "Using SALT=$SALT"
/tmp/deploy-l1-contracts.sh $SALT {{ .Values.ethereum.chainId }} "{{ join "," .Values.validator.validatorAddresses }}"
volumeMounts:
- name: scripts-output
mountPath: /shared/contracts
Expand All @@ -72,6 +74,8 @@ spec:
- name: scripts
mountPath: /scripts
env:
- name: SALT
value: "{{ .Values.aztec.l1Salt }}"
- name: TELEMETRY
value: "{{ .Values.telemetry.enabled }}"
- name: INIT_VALIDATORS
Expand Down
1 change: 1 addition & 0 deletions spartan/aztec-network/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ aztec:
epochProofClaimWindow: 13 # in L2 slots
realProofs: false
l1DeploymentMnemonic: "test test test test test test test test test test test junk" # the mnemonic used when deploying contracts
l1Salt: "" # leave empty for random salt

bootNode:
peerIdPrivateKey: ""
Expand Down
Loading