diff --git a/l1-contracts/src/governance/Governance.sol b/l1-contracts/src/governance/Governance.sol index 32bc7485557d..da7488433f6d 100644 --- a/l1-contracts/src/governance/Governance.sol +++ b/l1-contracts/src/governance/Governance.sol @@ -48,13 +48,13 @@ contract Governance is IGovernance { configuration = DataStructures.Configuration({ proposeConfig: DataStructures.ProposeConfiguration({ - lockDelay: Timestamp.wrap(3600), + lockDelay: Timestamp.wrap(60), lockAmount: 1000e18 }), - votingDelay: Timestamp.wrap(3600), - votingDuration: Timestamp.wrap(3600), - executionDelay: Timestamp.wrap(3600), - gracePeriod: Timestamp.wrap(3600), + votingDelay: Timestamp.wrap(60), + votingDuration: Timestamp.wrap(60), + executionDelay: Timestamp.wrap(60), + gracePeriod: Timestamp.wrap(60), quorum: 0.1e18, voteDifferential: 0.04e18, minimumVotes: 1000e18 diff --git a/l1-contracts/src/governance/libraries/ConfigurationLib.sol b/l1-contracts/src/governance/libraries/ConfigurationLib.sol index 482dee7ff901..9e542ed7c888 100644 --- a/l1-contracts/src/governance/libraries/ConfigurationLib.sol +++ b/l1-contracts/src/governance/libraries/ConfigurationLib.sol @@ -16,7 +16,7 @@ library ConfigurationLib { uint256 internal constant VOTES_LOWER = 1; - Timestamp internal constant TIME_LOWER = Timestamp.wrap(3600); + Timestamp internal constant TIME_LOWER = Timestamp.wrap(60); Timestamp internal constant TIME_UPPER = Timestamp.wrap(30 * 24 * 3600); function withdrawalDelay(DataStructures.Configuration storage _self) diff --git a/l1-contracts/src/governance/libraries/DataStructures.sol b/l1-contracts/src/governance/libraries/DataStructures.sol index 5e18aa9d90eb..9c8062d27539 100644 --- a/l1-contracts/src/governance/libraries/DataStructures.sol +++ b/l1-contracts/src/governance/libraries/DataStructures.sol @@ -44,6 +44,7 @@ library DataStructures { uint256 nea; } + // @notice if this changes, please update the enum in governance.ts enum ProposalState { Pending, Active, diff --git a/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol b/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol index ae437f23c223..71eb413adb93 100644 --- a/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol +++ b/l1-contracts/test/governance/governance/finaliseWithdraw.t.sol @@ -98,6 +98,9 @@ contract FinaliseWithdrawTest is GovernanceBase { uint256 withdrawalCount = governance.withdrawalCount(); for (uint256 i = 0; i < withdrawalCount; i++) { DataStructures.Withdrawal memory withdrawal = governance.getWithdrawal(i); + if (Timestamp.unwrap(withdrawal.unlocksAt) <= block.timestamp) { + continue; + } assertGt(withdrawal.unlocksAt, block.timestamp); uint256 time = diff --git a/spartan/aztec-network/files/config/config-prover-env.sh b/spartan/aztec-network/files/config/config-prover-env.sh index 073547821d48..e8cc47b46d1c 100644 --- a/spartan/aztec-network/files/config/config-prover-env.sh +++ b/spartan/aztec-network/files/config/config-prover-env.sh @@ -7,7 +7,11 @@ output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js get-no echo "$output" -boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+') +boot_node_enr="" +if [ "$P2P_ENABLED" = "true" ]; then + # Only look for boot node ENR if P2P is enabled + boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+') +fi rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}') registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}') inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}') diff --git a/spartan/aztec-network/files/config/config-validator-env.sh b/spartan/aztec-network/files/config/config-validator-env.sh index c584a0d2d237..368ce98b93f0 100644 --- a/spartan/aztec-network/files/config/config-validator-env.sh +++ b/spartan/aztec-network/files/config/config-validator-env.sh @@ -7,7 +7,11 @@ output=$(node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js get-no echo "$output" -boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+') +boot_node_enr="" +if [ "$P2P_ENABLED" = "true" ]; then + # Only look for boot node ENR if P2P is enabled + boot_node_enr=$(echo "$output" | grep -oP 'Node ENR: \Kenr:[a-zA-Z0-9\-\_\.]+') +fi rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}') registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}') inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}') diff --git a/spartan/aztec-network/files/config/deploy-l1-contracts.sh b/spartan/aztec-network/files/config/deploy-l1-contracts.sh index c3a9b761c4ed..3ff6801d0091 100755 --- a/spartan/aztec-network/files/config/deploy-l1-contracts.sh +++ b/spartan/aztec-network/files/config/deploy-l1-contracts.sh @@ -1,6 +1,17 @@ #!/bin/bash set -exu +# If REGISTRY_CONTRACT_ADDRESS is already set, skip deployment and just write the file +if [ -n "${REGISTRY_CONTRACT_ADDRESS:-}" ]; then + echo "Registry address already set. Skipping deployment." + # Write the addresses to a file in the shared volume + cat </shared/contracts/contracts.env +export REGISTRY_CONTRACT_ADDRESS=$REGISTRY_CONTRACT_ADDRESS +EOF + cat /shared/contracts/contracts.env + exit 0 +fi + SALT=${1:-$RANDOM} CHAIN_ID=$2 VALIDATOR_ADDRESSES=$3 @@ -9,10 +20,15 @@ VALIDATOR_ADDRESSES=$3 output="" MAX_RETRIES=5 RETRY_DELAY=15 +TEST_ACCOUNTS=${TEST_ACCOUNTS:-false} +TEST_ACCOUNTS_ARG="" +if [ "$TEST_ACCOUNTS" = "true" ]; then + TEST_ACCOUNTS_ARG="--test-accounts" +fi for attempt in $(seq 1 $MAX_RETRIES); do # Construct base command - base_cmd="LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --test-accounts" + base_cmd="LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts $TEST_ACCOUNTS_ARG" # Add account - use private key if set, otherwise use mnemonic if [ -n "${L1_DEPLOYMENT_PRIVATE_KEY:-}" ]; then @@ -38,32 +54,12 @@ done || { echo "$output" # Extract contract addresses using grep and regex -rollup_address=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}') registry_address=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}') -inbox_address=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}') -outbox_address=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}') -fee_juice_address=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}') -staking_asset_address=$(echo "$output" | grep -oP 'Staking Asset Address: \K0x[a-fA-F0-9]{40}') -fee_juice_portal_address=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}') -coin_issuer_address=$(echo "$output" | grep -oP 'CoinIssuer Address: \K0x[a-fA-F0-9]{40}') -reward_distributor_address=$(echo "$output" | grep -oP 'RewardDistributor Address: \K0x[a-fA-F0-9]{40}') -governance_proposer_address=$(echo "$output" | grep -oP 'GovernanceProposer Address: \K0x[a-fA-F0-9]{40}') -governance_address=$(echo "$output" | grep -oP 'Governance Address: \K0x[a-fA-F0-9]{40}') slash_factory_address=$(echo "$output" | grep -oP 'SlashFactory Address: \K0x[a-fA-F0-9]{40}') # Write the addresses to a file in the shared volume cat </shared/contracts/contracts.env -export ROLLUP_CONTRACT_ADDRESS=$rollup_address export REGISTRY_CONTRACT_ADDRESS=$registry_address -export INBOX_CONTRACT_ADDRESS=$inbox_address -export OUTBOX_CONTRACT_ADDRESS=$outbox_address -export FEE_JUICE_CONTRACT_ADDRESS=$fee_juice_address -export STAKING_ASSET_CONTRACT_ADDRESS=$staking_asset_address -export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$fee_juice_portal_address -export COIN_ISSUER_CONTRACT_ADDRESS=$coin_issuer_address -export REWARD_DISTRIBUTOR_CONTRACT_ADDRESS=$reward_distributor_address -export GOVERNANCE_PROPOSER_CONTRACT_ADDRESS=$governance_proposer_address -export GOVERNANCE_CONTRACT_ADDRESS=$governance_address export SLASH_FACTORY_CONTRACT_ADDRESS=$slash_factory_address EOF diff --git a/spartan/aztec-network/templates/boot-node.yaml b/spartan/aztec-network/templates/boot-node.yaml index ee87b5fcfca3..ab3d17c4857f 100644 --- a/spartan/aztec-network/templates/boot-node.yaml +++ b/spartan/aztec-network/templates/boot-node.yaml @@ -76,7 +76,6 @@ spec: volumeMounts: - name: config mountPath: /shared/config - {{- if .Values.bootNode.deployContracts }} - name: deploy-l1-contracts {{- include "aztec-network.image" . | nindent 10 }} command: @@ -99,6 +98,10 @@ spec: - name: scripts mountPath: /scripts env: + - name: TEST_ACCOUNTS + value: "{{ .Values.aztec.testAccounts }}" + - name: REGISTRY_CONTRACT_ADDRESS + value: "{{ .Values.bootNode.contracts.registryAddress }}" - name: TELEMETRY value: "{{ .Values.telemetry.enabled }}" - name: INIT_VALIDATORS @@ -133,7 +136,6 @@ spec: fieldPath: metadata.namespace - name: USE_GCLOUD_LOGGING value: "{{ .Values.telemetry.useGcloudLogging }}" - {{- end }} containers: - name: boot-node {{- include "aztec-network.image" . | nindent 10 }} @@ -168,14 +170,8 @@ spec: mountPath: /shared/config - name: boot-node-data mountPath: {{ .Values.bootNode.dataDir }} - {{- if .Values.bootNode.deployContracts }} - name: scripts-output mountPath: /shared/contracts - {{- else }} - - name: contracts-env - mountPath: /shared/contracts/contracts.env - subPath: contracts.env - {{- end }} env: - name: POD_IP valueFrom: @@ -253,6 +249,8 @@ spec: value: "{{ .Values.telemetry.useGcloudLogging }}" - name: OTEL_EXCLUDE_METRICS value: "{{ .Values.telemetry.excludeMetrics }}" + - name: TEST_ACCOUNTS + value: "{{ .Values.aztec.testAccounts }}" {{- if .Values.blobSink.enabled }} - name: BLOB_SINK_URL value: {{ include "aztec-network.blobSinkUrl" . }} @@ -277,35 +275,11 @@ spec: persistentVolumeClaim: claimName: boot-node-data {{- end }} - {{- if .Values.bootNode.deployContracts }} - name: scripts configMap: name: {{ include "aztec-network.fullname" . }}-scripts - name: scripts-output emptyDir: {} - {{- else }} - - name: contracts-env - configMap: - name: {{ include "aztec-network.fullname" . }}-contracts-env - {{- end }} -{{- if not .Values.bootNode.deployContracts }} ---- -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "aztec-network.fullname" . }}-contracts-env - labels: - {{- include "aztec-network.labels" . | nindent 4 }} -data: - contracts.env: | - export ROLLUP_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.rollupAddress }} - export REGISTRY_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.registryAddress }} - export INBOX_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.inboxAddress }} - export OUTBOX_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.outboxAddress }} - export FEE_JUICE_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.feeJuiceAddress }} - export STAKING_ASSET_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.stakingAssetAddress }} - export FEE_JUICE_PORTAL_CONTRACT_ADDRESS={{ .Values.bootNode.contracts.feeJuicePortalAddress }} -{{- end }} --- # Headless service for StatefulSet DNS entries apiVersion: v1 diff --git a/spartan/aztec-network/templates/prover-node.yaml b/spartan/aztec-network/templates/prover-node.yaml index 6e09de1f2403..f8647627a3ab 100644 --- a/spartan/aztec-network/templates/prover-node.yaml +++ b/spartan/aztec-network/templates/prover-node.yaml @@ -113,6 +113,9 @@ spec: mountPath: /scripts - name: config mountPath: /shared/config + env: + - name: P2P_ENABLED + value: "{{ .Values.proverNode.p2p.enabled }}" containers: - name: prover-node @@ -225,6 +228,8 @@ spec: value: "{{ .Values.telemetry.useGcloudLogging }}" - name: OTEL_EXCLUDE_METRICS value: "{{ .Values.telemetry.excludeMetrics }}" + - name: TEST_ACCOUNTS + value: "{{ .Values.aztec.testAccounts }}" {{- if .Values.blobSink.enabled }} - name: BLOB_SINK_URL value: {{ include "aztec-network.blobSinkUrl" . }} diff --git a/spartan/aztec-network/templates/pxe.yaml b/spartan/aztec-network/templates/pxe.yaml index 14bfc3f0371e..30755072acd6 100644 --- a/spartan/aztec-network/templates/pxe.yaml +++ b/spartan/aztec-network/templates/pxe.yaml @@ -117,6 +117,8 @@ spec: value: "{{ .Values.telemetry.excludeMetrics }}" - name: L1_CHAIN_ID value: "{{ .Values.ethereum.chainId }}" + - name: TEST_ACCOUNTS + value: "{{ .Values.aztec.testAccounts }}" ports: - name: http containerPort: {{ .Values.pxe.service.nodePort }} diff --git a/spartan/aztec-network/templates/setup-l2-contracts.yaml b/spartan/aztec-network/templates/setup-l2-contracts.yaml index c08e53296ef8..7cebe0b4ae8b 100644 --- a/spartan/aztec-network/templates/setup-l2-contracts.yaml +++ b/spartan/aztec-network/templates/setup-l2-contracts.yaml @@ -65,7 +65,7 @@ spec: done echo "PXE service is ready!" set -e - node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts --skipProofWait + LOG_LEVEL=debug node --no-warnings /usr/src/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts --skipProofWait echo "L2 contracts initialized" env: - name: K8S_POD_UID diff --git a/spartan/aztec-network/templates/transaction-bot.yaml b/spartan/aztec-network/templates/transaction-bot.yaml index 38a806f29e23..00e310bbbd0e 100644 --- a/spartan/aztec-network/templates/transaction-bot.yaml +++ b/spartan/aztec-network/templates/transaction-bot.yaml @@ -164,6 +164,8 @@ spec: value: "{{ .Values.telemetry.excludeMetrics }}" - name: L1_CHAIN_ID value: "{{ .Values.ethereum.chainId }}" + - name: TEST_ACCOUNTS + value: "{{ .Values.aztec.testAccounts }}" ports: - name: http containerPort: {{ .Values.bot.service.nodePort }} diff --git a/spartan/aztec-network/templates/validator.yaml b/spartan/aztec-network/templates/validator.yaml index 09b57ded0c6d..f71c4acefb39 100644 --- a/spartan/aztec-network/templates/validator.yaml +++ b/spartan/aztec-network/templates/validator.yaml @@ -117,6 +117,9 @@ spec: mountPath: /scripts - name: config mountPath: /shared/config + env: + - name: P2P_ENABLED + value: "{{ .Values.validator.p2p.enabled }}" containers: - name: validator {{- include "aztec-network.image" . | nindent 10 }} @@ -237,6 +240,8 @@ spec: value: "{{ .Values.telemetry.useGcloudLogging }}" - name: OTEL_EXCLUDE_METRICS value: "{{ .Values.telemetry.excludeMetrics }}" + - name: TEST_ACCOUNTS + value: "{{ .Values.aztec.testAccounts }}" {{- if .Values.blobSink.enabled }} - name: BLOB_SINK_URL value: {{ include "aztec-network.blobSinkUrl" . }} diff --git a/spartan/aztec-network/values.yaml b/spartan/aztec-network/values.yaml index f692c552b07f..43baad434de8 100644 --- a/spartan/aztec-network/values.yaml +++ b/spartan/aztec-network/values.yaml @@ -59,7 +59,8 @@ aztec: extraAccounts: 10 botKeyIndexStart: 3000 - l1Salt: "" # leave empty for random salt + l1Salt: "42" # leave empty for random salt + testAccounts: true bootNode: peerIdPrivateKey: "" diff --git a/spartan/aztec-network/values/1-validators.yaml b/spartan/aztec-network/values/1-validators.yaml index ba3d9e14e3e7..31a5692f2d2b 100644 --- a/spartan/aztec-network/values/1-validators.yaml +++ b/spartan/aztec-network/values/1-validators.yaml @@ -3,6 +3,8 @@ telemetry: validator: replicas: 1 + sequencer: + minTxsPerBlock: 0 validator: disabled: false diff --git a/spartan/bootstrap.sh b/spartan/bootstrap.sh index 47609095be92..17e2c51503b5 100755 --- a/spartan/bootstrap.sh +++ b/spartan/bootstrap.sh @@ -61,6 +61,7 @@ function test_cmds { echo "$hash timeout -v 20m ./spartan/bootstrap.sh test-kind-transfer" echo "$hash timeout -v 30m ./spartan/bootstrap.sh test-kind-4epochs" echo "$hash timeout -v 30m ./spartan/bootstrap.sh test-kind-transfer-blob-with-sink" + echo "$hash timeout -v 30m ./spartan/bootstrap.sh test-kind-upgrade-rollup-version" fi } @@ -129,6 +130,10 @@ case "$cmd" in # export OVERRIDES="blobSink.enabled=true" ./bootstrap.sh test-kind-transfer ;; + "test-kind-upgrade-rollup-version") + export OVERRIDES="bot.enabled=false" + NAMESPACE=upgrade-rollup-version FRESH_INSTALL=${FRESH_INSTALL:-true} INSTALL_METRICS=false ./scripts/test_kind.sh src/spartan/upgrade_rollup_version.test.ts ci.yaml + ;; "test-local") # Isolate network stack in docker. docker_isolate ../scripts/run_native_testnet.sh -i -val 3 diff --git a/spartan/scripts/deploy_kind.sh b/spartan/scripts/deploy_kind.sh index c057eabc7eb2..1b4890a9fdaa 100755 --- a/spartan/scripts/deploy_kind.sh +++ b/spartan/scripts/deploy_kind.sh @@ -9,6 +9,9 @@ # AZTEC_DOCKER_TAG (default: current git commit) # INSTALL_TIMEOUT (default: 30m) # OVERRIDES (default: "", no overrides) +# +# Note on OVERRIDES: +# You can use like OVERRIDES="replicas=3,resources.limits.cpu=1" source $(git rev-parse --show-toplevel)/ci3/source @@ -18,6 +21,7 @@ set -x namespace="$1" values_file="${2:-default.yaml}" sepolia_deployment="${3:-false}" +helm_instance="${4:-spartan}" # Default values for environment variables chaos_values="${CHAOS_VALUES:-}" @@ -90,9 +94,9 @@ fi # Install the Helm chart echo "Cleaning up any existing Helm releases..." -helm uninstall spartan -n "$namespace" 2>/dev/null || true -kubectl delete clusterrole spartan-aztec-network-node 2>/dev/null || true -kubectl delete clusterrolebinding spartan-aztec-network-node 2>/dev/null || true +helm uninstall "$helm_instance" -n "$namespace" 2>/dev/null || true +kubectl delete clusterrole "$helm_instance"-aztec-network-node 2>/dev/null || true +kubectl delete clusterrolebinding "$helm_instance"-aztec-network-node 2>/dev/null || true helm_set_args=( --set images.aztec.image="aztecprotocol/aztec:$aztec_docker_tag" @@ -118,7 +122,7 @@ if [ "$sepolia_deployment" = "true" ]; then set -x fi -helm upgrade --install spartan ../aztec-network \ +helm upgrade --install "$helm_instance" ../aztec-network \ --namespace "$namespace" \ --create-namespace \ "${helm_set_args[@]}" \ diff --git a/spartan/scripts/test_kind.sh b/spartan/scripts/test_kind.sh index 5f0a6b4bea8e..fc3db8451161 100755 --- a/spartan/scripts/test_kind.sh +++ b/spartan/scripts/test_kind.sh @@ -24,6 +24,7 @@ set -x # Main positional parameter test=$1 values_file="${2:-default.yaml}" +helm_instance="${3:-spartan}" # Default values for environment variables namespace="${NAMESPACE:-test-kind}" @@ -74,7 +75,7 @@ trap cleanup SIGINT SIGTERM EXIT stern_pid="" function copy_stern_to_log { # Start stern in a subshell, capture its PID, and pipe output to cache_log so it is uploaded - stern spartan -n "$namespace" >"logs/kind-$namespace.log" &>/dev/null & + stern "$helm_instance" -n "$namespace" >"logs/kind-$namespace.log" &>/dev/null & stern_pid=$! } @@ -83,7 +84,7 @@ copy_stern_to_log # uses VALUES_FILE, CHAOS_VALUES, AZTEC_DOCKER_TAG and INSTALL_TIMEOUT optional env vars if [ "$fresh_install" != "no-deploy" ]; then - deploy_result=$(OVERRIDES="$OVERRIDES" ./deploy_kind.sh $namespace $values_file $sepolia_run) + deploy_result=$(OVERRIDES="$OVERRIDES" ./deploy_kind.sh $namespace $values_file $sepolia_run $helm_instance) fi # Find 6 free ports between 9000 and 10000 @@ -124,7 +125,7 @@ fi echo "RUNNING TEST: $test" # Run test locally. export K8S="local" -export INSTANCE_NAME="spartan" +export INSTANCE_NAME="$helm_instance" export SPARTAN_DIR="$(pwd)/.." export NAMESPACE="$namespace" export HOST_PXE_PORT="$forwarded_pxe_port" diff --git a/spartan/scripts/upgrade_rollup_with_lock.sh b/spartan/scripts/upgrade_rollup_with_lock.sh new file mode 100755 index 000000000000..128604fe4f79 --- /dev/null +++ b/spartan/scripts/upgrade_rollup_with_lock.sh @@ -0,0 +1,136 @@ +#!/bin/bash + +set -exu + +# NOTICE: This script is intended for non-production (i.e. testnet) use only. + +# Deploys a new rollup contract and uses proposeWithLock to propose an upgrade. +# It then waits for the proposal to be active, and then votes in favor of it. +# Finally it waits for the proposal to be executable, and then executes it. +# +# It will also optionally mint/deposit governance tokens. +# +# Example usage: +# +# L1_CHAIN_ID=1337 \ +# ETHEREUM_HOST=http://localhost:8545 \ +# MNEMONIC="test test test test test test test test test test test junk" \ +# ./upgrade_rollup_with_lock.sh \ +# --aztec-docker-tag c5e2b43044862882a68de47cac07b7116e74e51e \ +# --registry 0x29f815e32efdef19883cf2b92a766b7aebadd326 \ +# --address 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 \ +# --deposit-amount 200000000000000000000000 \ +# --mint +# +# where: +# - aztec-docker-tag is the tag of the aztec docker image to use. +# - registry is the address of the registry contract. +# - address is the address that corresponds to whatever mnemonic/private key you are using. +# - deposit-amount is optional, and if provided, will deposit the specified amount of governance tokens to the address. +# - mint is optional, and if provided, will mint the governance tokens to the address before depositing. +# +# It can also be used locally by providing an --aztec-bin argument to the path of the aztec binary. +# For example, --aztec-bin /usr/src/yarn-project/aztec/dest/bin/index.js + +# export AZTEC_BIN=/home/mitch/aztec-clones/alpha/yarn-project/aztec/dest/bin/index.js +# L1_CHAIN_ID=1337 \ +# ./spartan/scripts/upgrade_rollup_with_lock.sh \ +# --aztec-bin $AZTEC_BIN \ +# --registry 0x29f815e32efdef19883cf2b92a766b7aebadd326 \ +# --address 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 \ +# --deposit-amount 10000000000000000 \ +# --mint + +# First set from environment variables if they exist +DEPOSIT_AMOUNT="" +MINT="" +SALT=$((RANDOM % 1000000)) +# The default path to the aztec binary within the docker image +AZTEC_BIN="/usr/src/yarn-project/aztec/dest/bin/index.js" +AZTEC_DOCKER_TAG="" + +# Parse command line arguments (these will override env vars if provided) +while [[ $# -gt 0 ]]; do + case $1 in + --aztec-docker-tag) + AZTEC_DOCKER_TAG="$2" + shift 2 + ;; + --aztec-bin) + AZTEC_BIN="$2" + shift 2 + ;; + --deposit-amount) + DEPOSIT_AMOUNT="$2" + shift 2 + ;; + --salt) + SALT="$2" + shift 2 + ;; + --registry) + REGISTRY="$2" + shift 2 + ;; + --address) + MY_ADDR="$2" + shift 2 + ;; + --mint) + MINT="--mint" + shift 1 + ;; + *) + echo "Unknown parameter: $1" + exit 1 + ;; + esac +done + +# Validate required arguments +if [ -z "$REGISTRY" ]; then + echo "Error: --registry argument is required" + exit 1 +fi + +if [ -z "$MY_ADDR" ]; then + echo "Error: --address argument is required" + exit 1 +fi + +# Only need this in the docker case +cleanup() { + # Add error handling and force removal + rm -rf .env.tmp 2>/dev/null || true +} + +# if aztec-docker-tag is set, use it +if [ -n "$AZTEC_DOCKER_TAG" ]; then + IMAGE_NAME="aztecprotocol/aztec:${AZTEC_DOCKER_TAG}" + EXE="docker run --rm --network=host --env-file .env.tmp $IMAGE_NAME $AZTEC_BIN" + # Check if the image exists locally before pulling it + if ! docker images $IMAGE_NAME -q; then + echo "Pulling docker image $IMAGE_NAME" + docker pull $IMAGE_NAME + fi + trap cleanup EXIT INT TERM HUP QUIT + # Create a temporary .env file + env > .env.tmp +else + EXE="node --no-warnings $AZTEC_BIN" +fi + + +# if DEPOSIT_AMOUNT is set, we deposit governance tokens +if [ -n "$DEPOSIT_AMOUNT" ]; then + echo "Depositing $DEPOSIT_AMOUNT governance tokens to $MY_ADDR" + $EXE deposit-governance-tokens -r $REGISTRY --recipient $MY_ADDR -a $DEPOSIT_AMOUNT $MINT +fi + +PAYLOAD=$($EXE deploy-new-rollup -r $REGISTRY --salt $SALT --json --test-accounts | jq -r '.payloadAddress') + +PROPOSAL_ID=$($EXE propose-with-lock -r $REGISTRY --payload-address $PAYLOAD --json | jq -r '.proposalId') + +$EXE vote-on-governance-proposal --proposal-id $PROPOSAL_ID --in-favor true --wait true -r $REGISTRY + +$EXE execute-governance-proposal --proposal-id $PROPOSAL_ID --wait true -r $REGISTRY diff --git a/yarn-project/archiver/src/archiver/archiver.ts b/yarn-project/archiver/src/archiver/archiver.ts index f3e5c3c681b4..1515136b2f6f 100644 --- a/yarn-project/archiver/src/archiver/archiver.ts +++ b/yarn-project/archiver/src/archiver/archiver.ts @@ -180,7 +180,7 @@ export class Archiver implements ArchiveSource, Traceable { } if (blockUntilSynced) { - await this.sync(blockUntilSynced); + await this.syncSafe(blockUntilSynced); } this.runningPromise = new RunningPromise( @@ -198,6 +198,14 @@ export class Archiver implements ArchiveSource, Traceable { this.runningPromise.start(); } + private async syncSafe(initialRun: boolean) { + try { + await this.sync(initialRun); + } catch (error) { + this.log.error('Error during sync', { error }); + } + } + /** * Fetches logs from L1 contracts and processes them. */ diff --git a/yarn-project/aztec/src/cli/cmds/start_archiver.ts b/yarn-project/aztec/src/cli/cmds/start_archiver.ts index b0cf79be47ac..0ca8943a2497 100644 --- a/yarn-project/aztec/src/cli/cmds/start_archiver.ts +++ b/yarn-project/aztec/src/cli/cmds/start_archiver.ts @@ -1,10 +1,4 @@ -import { - Archiver, - type ArchiverConfig, - KVArchiverDataStore, - archiverConfigMappings, - getArchiverConfigFromEnv, -} from '@aztec/archiver'; +import { Archiver, type ArchiverConfig, KVArchiverDataStore, archiverConfigMappings } from '@aztec/archiver'; import { createLogger } from '@aztec/aztec.js'; import { createBlobSinkClient } from '@aztec/blob-sink/client'; import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; @@ -13,8 +7,8 @@ import { createStore } from '@aztec/kv-store/lmdb-v2'; import { ArchiverApiSchema } from '@aztec/stdlib/interfaces/server'; import { getConfigEnvVars as getTelemetryClientConfig, initTelemetryClient } from '@aztec/telemetry-client'; +import { getL1Config } from '../get_l1_config.js'; import { extractRelevantOptions } from '../util.js'; -import { validateL1Config } from '../validation.js'; export type { ArchiverConfig, DataStoreConfig }; @@ -24,7 +18,7 @@ export async function startArchiver( signalHandlers: (() => Promise)[], services: NamespacedApiHandlers, ): Promise<{ config: ArchiverConfig & DataStoreConfig }> { - const archiverConfig = extractRelevantOptions( + let archiverConfig = extractRelevantOptions( options, { ...archiverConfigMappings, @@ -33,7 +27,18 @@ export async function startArchiver( 'archiver', ); - await validateL1Config({ ...getArchiverConfigFromEnv(), ...archiverConfig }); + if (!archiverConfig.l1Contracts.registryAddress || archiverConfig.l1Contracts.registryAddress.isZero()) { + throw new Error('L1 registry address is required to start an Archiver'); + } + + const { addresses, config } = await getL1Config( + archiverConfig.l1Contracts.registryAddress, + archiverConfig.l1RpcUrls, + archiverConfig.l1ChainId, + ); + + archiverConfig.l1Contracts = addresses; + archiverConfig = { ...archiverConfig, ...config }; const storeLog = createLogger('archiver:lmdb'); const store = await createStore('archiver', archiverConfig, storeLog); diff --git a/yarn-project/aztec/src/cli/cmds/start_node.ts b/yarn-project/aztec/src/cli/cmds/start_node.ts index 6e399295af6f..04f449db7a46 100644 --- a/yarn-project/aztec/src/cli/cmds/start_node.ts +++ b/yarn-project/aztec/src/cli/cmds/start_node.ts @@ -1,9 +1,5 @@ import { getInitialTestAccounts } from '@aztec/accounts/testing'; -import { - type AztecNodeConfig, - aztecNodeConfigMappings, - getConfigEnvVars as getNodeConfigEnvVars, -} from '@aztec/aztec-node'; +import { type AztecNodeConfig, aztecNodeConfigMappings, getConfigEnvVars } from '@aztec/aztec-node'; import { NULL_KEY } from '@aztec/ethereum'; import type { NamespacedApiHandlers } from '@aztec/foundation/json-rpc/server'; import type { LogFn } from '@aztec/foundation/log'; @@ -19,8 +15,8 @@ import { getGenesisValues } from '@aztec/world-state/testing'; import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts'; import { createAztecNode, deployContractsToL1 } from '../../sandbox.js'; +import { getL1Config } from '../get_l1_config.js'; import { extractNamespacedOptions, extractRelevantOptions } from '../util.js'; -import { validateL1Config } from '../validation.js'; export async function startNode( options: any, @@ -31,7 +27,8 @@ export async function startNode( // options specifically namespaced with --node.