Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 40 additions & 0 deletions .github/workflows/nightly-devnet-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Devnet network tests
on:
workflow_dispatch:
schedule:
# Run nightly at 0300
- cron: "0 3 * * *"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
# This path is a workaround because the runner does not have perms to upload files anywhere else
STATE_S3_BASE_PATH: s3://aztec-ci-artifacts/build-cache
STATE_S3_KEY: build-cache/devnet-nightly-tests-state.json
AZTEC_VERSION: 0.85.0-alpha-testnet.2
NODE_URL: http://34.169.170.55:8080
L1_URL: http://34.169.72.63:8545
FAUCET_URL: http://34.169.129.31:8086

jobs:
cli-wallet:
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2

- name: Checkout smoke tests (note that this is not pinned to a version, the CLI wallet installed is though)
uses: actions/checkout@v4
with:
sparse-checkout: |
spartan/devnet-smoke-tests

- name: Run smoke tests
run: |
./spartan/devnet-smoke-tests/main.sh
81 changes: 81 additions & 0 deletions spartan/devnet-smoke-tests/create_new_accounts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
new_accounts_per_run=2
new_accounts="[]"
max_accounts=2

total_account_count=$(jq '.accounts | length' state.json)
if [ "$total_account_count" -lt "$max_accounts" ]; then

# New accounts should be the min(num_new_accounts, max_accounts - total_account_count)
num_new_accounts=$(( new_accounts_per_run < (max_accounts - total_account_count) ? new_accounts_per_run : (max_accounts - total_account_count) ))
for i in $(seq 1 $num_new_accounts); do
new_account=$(aztec-wallet \
create-account \
-a main \
--register-only \
--json \
| grep -Pzo '(?s)\{.*\}')

new_account=$(echo "$new_account" | jq '. + {"needs_setup": true}')

echo "$new_account" | jq '.'

# We assume we are an end user without access to the prefunded L1 account. Thus we have to
# create an L1 account, drip eth to it, then use this account to bridge fee juice.
l1_account=$(aztec \
create-l1-account \
--json)

l1_private_key=$(echo "$l1_account" | jq -r '.privateKey')
l1_address=$(echo "$l1_account" | jq -r '.address')

aztec \
drip-faucet \
-t ETH \
-a $l1_address \
-u $FAUCET_URL

aztec-wallet \
bridge-fee-juice 1000000000000000000 accounts:main \
--mint \
--l1-rpc-urls $L1_URL \
--l1-chain-id 1337 \
--l1-private-key $l1_private_key

# We sleep here because it seems that the wait option on bridging is a bit flaky and sometimes we need to
# wait another block (slot duration is 36s and picked 40s due to it being a nice round number)
echo "Sleeping 40 seconds before deploying to wait for L1 -> L2 message existence"
sleep 40s

# We only use the prover on the first iteration of the loop to avoid duplicating identical proofs
prover_to_use=$(get_prover $((i == 1)))

aztec-wallet $prover_to_use \
deploy-account \
-f accounts:main \
--payment method=fee_juice,claim

new_accounts=$(echo "$new_accounts" | jq --argjson acc "$new_account" '. += [$acc]')
done
fi

echo "$new_accounts" | jq '.'

add_to_state ".accounts" "$new_accounts"

# Test account deployment works with sponsoredFPC, we don't actually save this account though because we would like
# the persistent accounts that we use to have a healthy balance of fee juice
aztec-wallet \
create-account \
-a sponsored-fpc \
--register-only

aztec-wallet \
register-contract $SPONSORED_FPC_ADDRESS SponsoredFPC \
-f accounts:sponsored-fpc \
--salt 0

prover_to_use="-p native"
aztec-wallet $prover_to_use \
deploy-account \
-f accounts:sponsored-fpc \
$SPONSORED_FPC_PAYMENT_METHOD
66 changes: 66 additions & 0 deletions spartan/devnet-smoke-tests/deploy_amm_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
amm_contract_count=$(jq '.contracts | map(select(.type=="amm")) | length' state.json)
max_amm_contracts=1
amm_contracts_per_run=1
accounts=$(jq -c '.accounts[]' state.json)

# Check the amm contract count and create more if current < max_amm_contracts
if [ "$amm_contract_count" -lt "$max_amm_contracts" ]; then
new_amm_contracts="[]"

num_new_amm_contracts=$(( amm_contracts_per_run < (max_amm_contracts - amm_contract_count) ? amm_contracts_per_run : (max_amm_contracts - amm_contract_count) ))
for i in $(seq 1 $num_new_amm_contracts); do
admin_and_minter_address=$(select_random_account "$accounts")

token_symbol_base="$((amm_contract_count + i))_TKN"
token_name_base="$((amm_contract_count + i))_Token"

# We don't want to prove any token deployments because we already have done so in the token tests
prover_to_use_when_deploying_token="-p none"

token_0_address=$(aztec-wallet $prover_to_use_when_deploying_token \
deploy Token \
--args $admin_and_minter_address "${token_name_base}_0" "${token_symbol_base}_0" 18 \
-f $admin_and_minter_address \
| get_contract_address)

token_1_address=$(aztec-wallet $prover_to_use_when_deploying_token \
deploy Token \
--args $admin_and_minter_address "${token_name_base}_1" "${token_symbol_base}_1" 18 \
-f $admin_and_minter_address \
| get_contract_address)

token_liquidity_address=$(aztec-wallet $prover_to_use_when_deploying_token \
deploy Token \
--args $admin_and_minter_address "${token_name_base}_liquidity" "${token_symbol_base}_liquidity" 18 \
-f $admin_and_minter_address \
| get_contract_address)

# We only use the prover on the first iteration of the loop to avoid duplicating identical proofs
prover_to_use_when_deploying_amm=$(get_prover $((i == 1)))

amm_address=$(aztec-wallet $prover_to_use_when_deploying_amm \
deploy AMM \
--args $token_0_address $token_1_address $token_liquidity_address \
-f $admin_and_minter_address \
| get_contract_address)

aztec-wallet $prover_to_use_when_deploying_amm \
send set_minter \
-ca $token_liquidity_address \
--args $amm_address true \
-f $admin_and_minter_address

new_amm_contract=$(jq -n \
--arg token_0_address "$token_0_address" \
--arg token_1_address "$token_1_address" \
--arg token_liquidity_address "$token_liquidity_address" \
--arg amm_address "$amm_address" \
--arg admin_and_minter "$admin_and_minter_address" \
'{"token_0_address": $token_0_address, "token_1_address": $token_1_address, "token_liquidity_address": $token_liquidity_address, "amm_address": $amm_address, "type": "amm", "admin_and_minter": $admin_and_minter, "needs_setup": true}')
new_amm_contracts=$(echo "$new_amm_contracts" | jq --argjson contract "$new_amm_contract" '. += [$contract]')
done

echo "$new_amm_contracts" | jq '.'

add_to_state ".contracts" "$new_amm_contracts"
fi
36 changes: 36 additions & 0 deletions spartan/devnet-smoke-tests/deploy_nft_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
nft_contract_count=$(jq '.contracts | map(select(.type=="nft")) | length' state.json)
max_nft_contracts=1
nft_contracts_per_run=1
accounts=$(jq -c '.accounts[]' state.json)

# Check the current nft contract count and create more if current < max_nft_contract
if [ "$nft_contract_count" -lt "$max_nft_contracts" ]; then
new_nft_contracts="[]"

num_new_nft_contracts=$(( nft_contracts_per_run < (max_nft_contracts - nft_contract_count) ? nft_contracts_per_run : (max_nft_contracts - nft_contract_count) ))
for i in $(seq 1 $num_new_nft_contracts); do
admin_and_minter_address=$(select_random_account "$accounts")

nft_symbol="NFB_$((nft_contract_count + i))}"
nft_name="NonFungibullish_$((nft_contract_count + i))"

# We only use the prover on the first iteration of the loop to avoid duplicating idential proofs
prover_to_use=$(get_prover $((i == 1)))

new_nft_contract_address=$(aztec-wallet $prover_to_use \
deploy NFT \
--args $admin_and_minter_address $nft_name $nft_symbol \
-f $admin_and_minter_address \
| get_contract_address)

new_nft_contract=$(jq -n \
--arg address "$new_nft_contract_address" \
--arg admin_and_minter "$admin_and_minter_address" \
'{"address": $address, "type": "nft", "token_id": 1, "admin_and_minter": $admin_and_minter, "needs_setup": true}')
new_nft_contracts=$(echo "$new_nft_contracts" | jq --argjson contract "$new_nft_contract" '. += [$contract]')
done

echo "$new_nft_contracts" | jq '.'

add_to_state ".contracts" "$new_nft_contracts"
fi
37 changes: 37 additions & 0 deletions spartan/devnet-smoke-tests/deploy_token_contracts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
token_contract_count=$(jq '.contracts | map(select(.type=="token")) | length' state.json)
max_token_contracts=1
token_contracts_per_run=1
accounts=$(jq -c '.accounts[]' state.json)

# Check the current token contract count and create more if current < max_token_contracts
if [ "$token_contract_count" -lt "$max_token_contracts" ]; then
new_token_contracts="[]"

num_new_token_contracts=$(( token_contracts_per_run < (max_token_contracts - token_contract_count) ? token_contracts_per_run : (max_token_contracts - token_contract_count) ))
for i in $(seq 1 $num_new_token_contracts); do
admin_and_minter_address=$(select_random_account "$accounts")

token_symbol="TKN_$((token_contract_count + i))"
token_name="Token_$((token_contract_count + i))"

# We only use the prover on the first iteration of the loop - while we need all tokens to be deployed, proving is
# expensive and a single successful run is enough for the purposes of a smoke test.
prover_to_use=$(get_prover $((i == 1)))

new_token_contract_address=$(aztec-wallet $prover_to_use \
deploy Token \
--args $admin_and_minter_address $token_name $token_symbol 18 \
-f $admin_and_minter_address \
| get_contract_address)

new_token_contract=$(jq -n \
--arg address "$new_token_contract_address" \
--arg admin_and_minter "$admin_and_minter_address" \
'{"address": $address, "type": "token", "admin_and_minter": $admin_and_minter, "needs_setup": true}')
new_token_contracts=$(echo "$new_token_contracts" | jq --argjson contract "$new_token_contract" '. += [$contract]')
done

echo "$new_token_contracts" | jq '.'

add_to_state ".contracts" "$new_token_contracts"
fi
4 changes: 4 additions & 0 deletions spartan/devnet-smoke-tests/get_sponsored_fpc_address.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SPONSORED_FPC_ADDRESS=$(aztec \
get-canonical-sponsored-fpc-address \
| awk '{print $NF}')
SPONSORED_FPC_PAYMENT_METHOD="--payment method=fpc-sponsored,fpc=$SPONSORED_FPC_ADDRESS"
7 changes: 7 additions & 0 deletions spartan/devnet-smoke-tests/install_aztec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Install aztec and set version
bash -i <(curl -s https://install.aztec.network)

# Add the bin directory to the current PATH
export PATH="$HOME/.aztec/bin:$PATH"

aztec-up -v $AZTEC_VERSION
60 changes: 60 additions & 0 deletions spartan/devnet-smoke-tests/main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
set -eux -o pipefail

# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

source "$SCRIPT_DIR/utils.sh"

# Check all required environment variables
check_env_var "STATE_S3_BASE_PATH"
check_env_var "STATE_S3_KEY"
check_env_var "AZTEC_VERSION"
check_env_var "NODE_URL"
check_env_var "L1_URL"
check_env_var "FAUCET_URL"

print_header "Retrieving state from S3"
source "$SCRIPT_DIR/retrieve_state.sh"

print_header "Installing Aztec"
source "$SCRIPT_DIR/install_aztec.sh"

print_header "Set SponsoredFPC payment method"
source "$SCRIPT_DIR/get_sponsored_fpc_address.sh"

print_header "Registering existing accounts from state"
source "$SCRIPT_DIR/register_existing_accounts_from_state.sh"

print_header "Creating new accounts"
source "$SCRIPT_DIR/create_new_accounts.sh"

print_header "Deploying token contracts"
source "$SCRIPT_DIR/deploy_token_contracts.sh"

print_header "Deploying AMM contracts"
source "$SCRIPT_DIR/deploy_amm_contracts.sh"

print_header "Deploying NFT contracts"
source "$SCRIPT_DIR/deploy_nft_contracts.sh"

print_header "Registering senders"
source "$SCRIPT_DIR/register_senders.sh"

print_header "Processing token contracts"
source "$SCRIPT_DIR/process_token_contracts.sh"

print_header "Processing AMM contracts"
source "$SCRIPT_DIR/process_amm_contracts.sh"

print_header "Processing NFT contracts"
source "$SCRIPT_DIR/process_nft_contracts.sh"

print_header "Marking setup of new accounts / contracts to be completed"
source "$SCRIPT_DIR/mark_setup_completed.sh"

# TODO (ek): Re-enable this when this flow has succeeded reliably
# print_header "Uploading new state to S3"
# source "$SCRIPT_DIR/upload_state.sh"

print_header "Tests have completed successfully"
source "$SCRIPT_DIR/print_stats.sh"
5 changes: 5 additions & 0 deletions spartan/devnet-smoke-tests/mark_setup_completed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Update contracts to set needs_setup=false for all contracts and accounts
jq '.contracts = (.contracts | map(. + {needs_setup: false}))' state.json > temp.json && mv temp.json state.json
jq '.accounts = (.accounts | map(. + {needs_setup: false}))' state.json > temp.json && mv temp.json state.json

echo "Updated all contracts and accounts in state.json with needs_setup=false"
10 changes: 10 additions & 0 deletions spartan/devnet-smoke-tests/print_stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# We print some basic stats about our run
account_count=$(jq '.accounts | length' state.json)
token_contract_count=$(jq '.contracts | map(select(.type=="token")) | length' state.json)
amm_contract_count=$(jq '.contracts | map(select(.type=="amm")) | length' state.json)
nft_contract_count=$(jq '.contracts | map(select(.type=="nft")) | length' state.json)

echo "Total accounts processed: $account_count"
echo "Total token contracts processed: $token_contract_count"
echo "Total amm contracts processed: $amm_contract_count"
echo "Total nft contracts processed: $nft_contract_count"
Loading