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
69 changes: 45 additions & 24 deletions scripts/run_native_testnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This script sets up and runs a native testnet for the Aztec network.

Steps:
1. Parse command-line arguments for custom test script and number of validators.
1. Parse command-line arguments for custom test script, number of validators, and logging level.
2. Set up the base command for running the native network test, including:
- Running the specified test script
- Deploying L1 and L2 contracts
Expand All @@ -21,9 +21,7 @@ Usage:
./run_native_testnet.sh [options]

Options:
-h: Display help message
-t: Specify a custom test script (default: ./test-transfer.sh)
-v: Specify the number of validators (default: 3)
see display_help() below
'

# Function to display help message
Expand All @@ -33,51 +31,74 @@ display_help() {
echo "Options:"
echo " -h Display this help message"
echo " -t Specify the test script file (default: ./test-transfer.sh)"
echo " -v Specify the number of validators (default: 3)"
echo " -val Specify the number of validators (default: 3)"
echo " -v Set logging level to verbose"
echo " -vv Set logging level to debug"
echo " -i Run interleaved (default: false)"
echo
echo "Example:"
echo " $0 -t ./custom-test.sh -v 5"
echo " $0 -t ./custom-test.sh -val 5 -v"
}

# Default values
TEST_SCRIPT="./test-transfer.sh"
NUM_VALIDATORS=3
LOG_LEVEL="info"
INTERLEAVED=false

# Parse command line arguments
while getopts "ht:v:" opt; do
case $opt in
h)
while [[ $# -gt 0 ]]; do
case $1 in
-h)
display_help
exit 0
;;
t) TEST_SCRIPT="$OPTARG"
-t)
TEST_SCRIPT="$2"
shift 2
;;
v) NUM_VALIDATORS="$OPTARG"
-val)
NUM_VALIDATORS="$2"
shift 2
;;
\?) echo "Invalid option -$OPTARG" >&2
display_help
exit 1
-v)
if [[ $LOG_LEVEL == "info" ]]; then
LOG_LEVEL="verbose"
elif [[ $LOG_LEVEL == "verbose" ]]; then
LOG_LEVEL="debug"
fi
shift
;;
-i)
INTERLEAVED=true
shift
;;
-vv)
LOG_LEVEL="debug"
shift
;;
*)
echo "Invalid option: $1" >&2
display_help
exit 1
;;
esac
done

## Set log level for all child commands
export LOG_LEVEL

# Base command
BASE_CMD="./yarn-project/end-to-end/scripts/native_network_test.sh \
BASE_CMD="INTERLEAVED=$INTERLEAVED ./yarn-project/end-to-end/scripts/native_network_test.sh \
$TEST_SCRIPT \
./deploy-l1-contracts.sh \
./deploy-l2-contracts.sh \
./boot-node.sh \
./ethereum.sh \
\"./prover-node.sh false\" \
\"./prover-node.sh 8078 false\" \
./pxe.sh \
./transaction-bot.sh"

# Generate validator commands
for ((i=0; i<NUM_VALIDATORS; i++))
do
PORT=$((8081 + i))
BASE_CMD+=" \"./validator.sh $PORT\""
done
./transaction-bot.sh \
\"./validators.sh $NUM_VALIDATORS\""

# Execute the command
eval $BASE_CMD
4 changes: 2 additions & 2 deletions scripts/tmux_split_args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ session_name=$1
# Kill any existing tmux session with the same name
tmux kill-session -t "$session_name" 2>/dev/null || true

# Start a new tmux session
tmux new-session -d -s "$session_name"
# Start a new tmux session with log level set
tmux new-session -d -s "$session_name" -e LOG_LEVEL=${LOG_LEVEL:-"debug"}

shift 1
commands=("$@")
Expand Down
8 changes: 8 additions & 0 deletions spartan/aztec-network/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ http://{{ include "aztec-network.fullname" . }}-boot-node-0.{{ include "aztec-ne
{{- end -}}
{{- end -}}

{{- define "aztec-network.validatorUrl" -}}
{{- if .Values.validator.externalTcpHost -}}
http://{{ .Values.validator.externalTcpHost }}:{{ .Values.validator.service.nodePort }}
{{- else -}}
http://{{ include "aztec-network.fullname" . }}-validator-0.{{ include "aztec-network.fullname" . }}-validator.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.validator.service.nodePort }}
{{- end -}}
{{- end -}}

{{- define "aztec-network.metricsHost" -}}
http://{{ include "aztec-network.fullname" . }}-metrics.{{ .Release.Namespace }}
{{- end -}}
Expand Down
10 changes: 10 additions & 0 deletions spartan/aztec-network/templates/pxe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ spec:
echo "Waiting for boot node..."
sleep 5
done
- name: wait-for-validator-service
image: {{ .Values.images.curl.image }}
command:
- /bin/sh
- -c
- |
until curl --head --silent {{ include "aztec-network.validatorUrl" . }}/status; do
echo "Waiting for validator service..."
sleep 5
done
containers:
- name: pxe
image: "{{ .Values.images.aztec.image }}"
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,16 @@ network-test-fake-proofs:
COPY ../scripts/+scripts/run_interleaved.sh scripts/run_interleaved.sh
WORKDIR /usr/src/yarn-project
# All script arguments are in the end-to-end/scripts/native-network folder
ENV LOG_LEVEL=verbose
RUN INTERLEAVED=true end-to-end/scripts/native_network_test.sh \
./test-transfer.sh \
./deploy-l1-contracts.sh \
./deploy-l2-contracts.sh \
./boot-node.sh \
./ethereum.sh \
"./prover-node.sh false" \
./pxe.sh
"./prover-node.sh 8078 false" \
./pxe.sh \
"./validator.sh 8081 40401"

publish-npm:
FROM +build
Expand Down
10 changes: 8 additions & 2 deletions yarn-project/archiver/src/archiver/archiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,14 @@ export class Archiver implements ArchiveSource {
if (number === 'latest') {
number = await this.store.getSynchedL2BlockNumber();
}
const headers = await this.store.getBlockHeaders(number, 1);
return headers.length === 0 ? undefined : headers[0];
try {
const headers = await this.store.getBlockHeaders(number, 1);
return headers.length === 0 ? undefined : headers[0];
} catch (e) {
// If the latest is 0, then getBlockHeaders will throw an error
this.log.error(`getBlockHeader: error fetching block number: ${number}`);
return undefined;
}
}

public getTxEffect(txHash: TxHash): Promise<TxEffect | undefined> {
Expand Down
8 changes: 0 additions & 8 deletions yarn-project/aztec-node/src/aztec-node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export type AztecNodeConfig = ArchiverConfig &
WorldStateConfig &
Pick<ProverClientConfig, 'bbBinaryPath' | 'bbWorkingDirectory' | 'realProofs'> &
P2PConfig & {
/** Whether the sequencer is disabled for this node. */
disableSequencer: boolean;

/** Whether the validator is disabled for this node */
disableValidator: boolean;
};
Expand All @@ -36,11 +33,6 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
...proverClientConfigMappings,
...worldStateConfigMappings,
...p2pConfigMappings,
disableSequencer: {
env: 'SEQ_DISABLED',
description: 'Whether the sequencer is disabled for this node.',
...booleanConfigHelper(),
},
disableValidator: {
env: 'VALIDATOR_DISABLED',
description: 'Whether the validator is disabled for this node.',
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ export class AztecNodeService implements AztecNode {
const validatorClient = createValidatorClient(config, p2pClient, telemetry);

// now create the sequencer
const sequencer = config.disableSequencer
const sequencer = config.disableValidator
? undefined
: await SequencerClient.new(
config,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/aztec/src/cli/cmds/start_node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const startNode = async (
}

if (!options.sequencer) {
nodeConfig.disableSequencer = true;
nodeConfig.disableValidator = true;
} else {
const sequencerConfig = extractNamespacedOptions(options, 'sequencer');
let account;
Expand Down
6 changes: 3 additions & 3 deletions yarn-project/end-to-end/scripts/native-network/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
l1-contracts.env
l2-contracts.env
*.log
state/*.env
state/*.json
*.log
12 changes: 7 additions & 5 deletions yarn-project/end-to-end/scripts/native-network/boot-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname
# Starts the Boot Node

# Set environment variables
export PORT="8080"
export LOG_LEVEL="debug"
export DEBUG="aztec:*,-aztec:avm_simulator:*"
export PORT=${PORT:-"8080"}
export DEBUG=${DEBUG:-"aztec:*,-aztec:avm_simulator:*"}
export LOG_LEVEL=${LOG_LEVEL:-"debug"}
export ETHEREUM_HOST="http://127.0.0.1:8545"
export P2P_ENABLED="true"
export VALIDATOR_DISABLED="true"
Expand All @@ -22,16 +22,18 @@ export P2P_TCP_ANNOUNCE_ADDR="127.0.0.1:40400"
export P2P_UDP_ANNOUNCE_ADDR="127.0.0.1:40400"
export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400"
export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400"
export OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=""
export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=""
export VALIDATOR_PRIVATE_KEY="0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a"
REPO=$(git rev-parse --show-toplevel)

echo "Waiting for l1 contracts to be deployed..."
until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env ] ; do
until [ -f "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env ] ; do
sleep 1
done
echo "Done waiting."

source "$REPO"/yarn-project/end-to-end/scripts/native-network/l1-contracts.env
source "$REPO"/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env

function filter_noise() {
grep -Ev "node_getProvenBlockNumber|getBlocks|Last block mined|Running random nodes query|Not creating block because not enough txs in the pool|Peers to connect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ exec > >(tee -a "$(dirname $0)/logs/${SCRIPT_NAME}.log") 2> >(tee -a "$(dirname

set -eu

# Check for validator addresses
if [ $# -gt 0 ]; then
INIT_VALIDATORS="true"
VALIDATOR_ADDRESSES="$1"
else
INIT_VALIDATORS="false"
fi

echo "Waiting for Anvil to be up at port 8545..."
until curl -s -X POST -H 'Content-Type: application/json' \
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
Expand All @@ -20,7 +28,11 @@ echo "Done waiting."

# Run the deploy-l1-contracts command and capture the output
export ETHEREUM_HOST="http://127.0.0.1:8545"
output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --salt 1337)
if [ "$INIT_VALIDATORS" = "true" ]; then
output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --validators "$VALIDATOR_ADDRESSES" --salt 1337)
else
output=$(node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-l1-contracts --salt 1337)
fi

echo "$output"

Expand All @@ -32,8 +44,8 @@ OUTBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K
FEE_JUICE_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Fee Juice Address: \K0x[a-fA-F0-9]{40}')
FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Fee Juice Portal Address: \K0x[a-fA-F0-9]{40}')

# Save contract addresses to l1-contracts.env
cat << EOCONFIG > $(git rev-parse --show-toplevel)/yarn-project/end-to-end/scripts/native-network/l1-contracts.env
# Save contract addresses to state/l1-contracts.env
cat << EOCONFIG > $(git rev-parse --show-toplevel)/yarn-project/end-to-end/scripts/native-network/state/l1-contracts.env
export ROLLUP_CONTRACT_ADDRESS=$ROLLUP_CONTRACT_ADDRESS
export REGISTRY_CONTRACT_ADDRESS=$REGISTRY_CONTRACT_ADDRESS
export INBOX_CONTRACT_ADDRESS=$INBOX_CONTRACT_ADDRESS
Expand All @@ -42,4 +54,4 @@ export FEE_JUICE_CONTRACT_ADDRESS=$FEE_JUICE_CONTRACT_ADDRESS
export FEE_JUICE_PORTAL_CONTRACT_ADDRESS=$FEE_JUICE_PORTAL_CONTRACT_ADDRESS
EOCONFIG

echo "Contract addresses saved to l1-contracts.env"
echo "Contract addresses saved to state/l1-contracts.env"
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export PXE_URL="http://127.0.0.1:8079"
node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js setup-protocol-contracts $ARGS
echo "Deployed L2 contracts"
# Use file just as done signal
echo "" > l2-contracts.env
echo "Wrote to l2-contracts.env to signal completion"
sleep 5
function close_tmux_pane() {
tmux kill-pane -t $(tmux display -p '#{pane_id}')
}
close_tmux_pane 2>/dev/null || true
echo "" > state/l2-contracts.env
echo "Wrote to state/l2-contracts.env to signal completion"

# sleep 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, for me it was killing the wrong tmix pane, I've left it there and alerted Adam

# function close_tmux_pane() {
# tmux kill-pane -t $(tmux display -p '#{pane_id}')
# }
# close_tmux_pane 2>/dev/null || true
Loading