diff --git a/spartan/aztec-network/templates/_helpers.tpl b/spartan/aztec-network/templates/_helpers.tpl index 526a9ab11ba..2e303c81112 100644 --- a/spartan/aztec-network/templates/_helpers.tpl +++ b/spartan/aztec-network/templates/_helpers.tpl @@ -190,3 +190,14 @@ affinity: nodeSelector: cloud.google.com/gke-ephemeral-storage-local-ssd: "true" {{- end -}} + +{{- define "aztec-network.waitForEthereum" -}} +echo "Awaiting ethereum node at ${ETHEREUM_HOST}" +until curl -s -X POST -H 'Content-Type: application/json' \ + -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}' \ + ${ETHEREUM_HOST} | grep 0x; do + echo "Waiting for Ethereum node ${ETHEREUM_HOST}..." + sleep 5 +done +echo "Ethereum node is ready!" +{{- end -}} diff --git a/spartan/aztec-network/templates/boot-node.yaml b/spartan/aztec-network/templates/boot-node.yaml index 6bada4fb7ac..b9d38ac3697 100644 --- a/spartan/aztec-network/templates/boot-node.yaml +++ b/spartan/aztec-network/templates/boot-node.yaml @@ -47,14 +47,7 @@ spec: - | source /shared/config/service-addresses cat /shared/config/service-addresses - echo "Awaiting ethereum node at ${ETHEREUM_HOST}" - until curl -s -X POST -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}' \ - ${ETHEREUM_HOST} | grep 0x; do - echo "Waiting for Ethereum node ${ETHEREUM_HOST}..." - sleep 5 - done - echo "Ethereum node is ready!" + {{- include "aztec-network.waitForEthereum" . | nindent 14 }} volumeMounts: - name: config mountPath: /shared/config @@ -66,6 +59,10 @@ spec: - -c - | source /shared/config/service-addresses + # it is possible that even though we asserted this above, the DNS resolver of *this* pod + # is not yet ready to resolve the ethereum host. + # so we need to wait for it to be ready. + {{- include "aztec-network.waitForEthereum" . | nindent 14 }} if [ "$(cast code --rpc-url ${ETHEREUM_HOST} 0x4e59b44847b379578588920ca78fbf26c0b4956c)" = "0x" ]; then echo "Deploying Deterministic Deployment Proxy" cast publish --rpc-url ${ETHEREUM_HOST} 0xf8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222 @@ -82,6 +79,7 @@ spec: cp /scripts/deploy-l1-contracts.sh /tmp/deploy-l1-contracts.sh chmod +x /tmp/deploy-l1-contracts.sh source /shared/config/service-addresses + {{- include "aztec-network.waitForEthereum" . | nindent 14 }} /tmp/deploy-l1-contracts.sh "{{ .Values.aztec.l1Salt }}" "{{ .Values.ethereum.chainId }}" "{{ join "," .Values.validator.validatorAddresses }}" volumeMounts: diff --git a/spartan/aztec-network/templates/faucet.yaml b/spartan/aztec-network/templates/faucet.yaml index d1b77b9fe79..4a3b492113f 100644 --- a/spartan/aztec-network/templates/faucet.yaml +++ b/spartan/aztec-network/templates/faucet.yaml @@ -40,15 +40,7 @@ spec: - | source /shared/config/service-addresses cat /shared/config/service-addresses - - echo "Awaiting ethereum node at ${ETHEREUM_HOST}" - until curl -s -X POST -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":67}' \ - ${ETHEREUM_HOST} | grep -q reth; do - echo "Waiting for Ethereum node ${ETHEREUM_HOST}..." - sleep 5 - done - echo "Ethereum node is ready!" + {{- include "aztec-network.waitForEthereum" . | nindent 14 }} volumeMounts: - name: config mountPath: /shared/config diff --git a/spartan/aztec-network/templates/prover-node.yaml b/spartan/aztec-network/templates/prover-node.yaml index f926c88fdfd..9b055ad3100 100644 --- a/spartan/aztec-network/templates/prover-node.yaml +++ b/spartan/aztec-network/templates/prover-node.yaml @@ -46,13 +46,8 @@ spec: - -c - | source /shared/config/service-addresses - until curl -s -X POST -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}' \ - ${ETHEREUM_HOST} | grep 0x; do - echo "Waiting for Ethereum node ${ETHEREUM_HOST}..." - sleep 5 - done - echo "Ethereum node is ready!" + cat /shared/config/service-addresses + {{- include "aztec-network.waitForEthereum" . | nindent 14 }} if [ "${PROVER_BROKER_ENABLED}" == "false" ]; then until curl -s -X POST ${PROVER_BROKER_HOST}/status; do diff --git a/spartan/aztec-network/templates/validator.yaml b/spartan/aztec-network/templates/validator.yaml index cd898b97bc1..38768f5fe55 100644 --- a/spartan/aztec-network/templates/validator.yaml +++ b/spartan/aztec-network/templates/validator.yaml @@ -49,15 +49,7 @@ spec: - | source /shared/config/service-addresses cat /shared/config/service-addresses - # First check ethereum node - until curl -s -X POST -H 'Content-Type: application/json' \ - -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":67}' \ - $ETHEREUM_HOST | grep 0x; do - echo "Waiting for Ethereum node ${ETHEREUM_HOST}..." - sleep 5 - done - echo "Ethereum node is ready!" - + {{- include "aztec-network.waitForEthereum" . | nindent 14 }} if [ "{{ .Values.validator.dynamicBootNode }}" = "true" ]; then echo "{{ include "aztec-network.pxeUrl" . }}" > /shared/pxe/pxe_url