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

feat: native tmux-based network e2e #9036

Merged
merged 36 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
96882cd
start of helm-based native tests
ludamad Oct 5, 2024
21b3925
start of helm-based native tests
ludamad Oct 5, 2024
5ca483e
checkin
ludamad Oct 5, 2024
50f03e0
update
ludamad Oct 5, 2024
aef20d0
commit all files
ludamad Oct 6, 2024
2084456
revert
ludamad Oct 6, 2024
2eaa3b0
ci vs not scripts
ludamad Oct 6, 2024
2fa5e68
better tests
ludamad Oct 6, 2024
4ac2fb2
rename
ludamad Oct 6, 2024
4d601f8
rename
ludamad Oct 6, 2024
3f778ed
go after improper usage
ludamad Oct 6, 2024
64f7ac9
iteration
ludamad Oct 6, 2024
d1da81d
improve script logging
ludamad Oct 6, 2024
15fd463
boot node no deploy redundantly
ludamad Oct 6, 2024
befc67c
iteration on tmux splits
ludamad Oct 6, 2024
ebea082
fixes
ludamad Oct 7, 2024
f9eb2bb
better errors
ludamad Oct 7, 2024
945594f
improve logging
ludamad Oct 7, 2024
8a9f242
Merge branch 'master' into ad/native-tmux-e2e
ludamad Oct 7, 2024
f87078f
try to stabilize network with 0 validators
ludamad Oct 7, 2024
2346ded
Iterative
ludamad Oct 7, 2024
df723cc
proverless fix
ludamad Oct 7, 2024
c1490f9
add waitForProven flag
ludamad Oct 7, 2024
e9a29f3
skip proof wait fix
ludamad Oct 7, 2024
d6a40fe
fix serialization issue with DeployProvenTx
ludamad Oct 7, 2024
09a6168
Merge remote-tracking branch 'origin/ad/native-tmux-e2e' into ad/nati…
ludamad Oct 7, 2024
e386ff2
Update action.yml
ludamad Oct 7, 2024
149c5f9
fix tx bot
ludamad Oct 7, 2024
0ed4ba5
revert
ludamad Oct 7, 2024
9d4b673
Merge remote-tracking branch 'origin/ad/native-tmux-e2e' into ad/nati…
ludamad Oct 7, 2024
65839a7
fix status
ludamad Oct 7, 2024
b52f8a9
Merge branch 'master' into ad/native-tmux-e2e
ludamad Oct 7, 2024
e568c10
Merge branch 'master' into ad/native-tmux-e2e
ludamad Oct 7, 2024
aedb22e
Merge branch 'master' into ad/native-tmux-e2e
ludamad Oct 8, 2024
fc8179d
formatting
ludamad Oct 8, 2024
d75ea98
Merge remote-tracking branch 'origin/ad/native-tmux-e2e' into ad/nati…
ludamad Oct 8, 2024
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ terraform.tfstate*
.bb_tmp

# Terraform
*.tfvars
*.tfvars

# tmux
tmux-client-*.log
33 changes: 33 additions & 0 deletions noir-projects/tmux-splits-stdin
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -eux
# Launches tmux with 1 window that has as many panes as lines of input
session_name=$1

# Kill any existing tmux session with the same name
tmux kill-session -t "$session_name" || true

# Start a new tmux session
tmux new-session -d -s "$session_name"

# Read commands from stdin into an array
commands=()
while IFS= read -r command; do
commands+=("$command")
done

# Create the necessary number of panes
num_commands=${#commands[@]}
for ((i=1; i<num_commands; i++)); do
# Split the first pane each time
tmux split-window -t "$session_name:0.0" -h
tmux select-layout -t "$session_name:0" tiled
done

# Now send commands to each pane
for ((i=0; i<num_commands; i++)); do
tmux send-keys -t "$session_name:0.$i" "${commands[$i]}" C-m
done

echo "Commands have been queued in tmux session '${session_name}'."
echo "You can attach to this session with 'tmux attach-session -t ${session_name}' from a terminal."
echo "To detach, use backtick (`) (or your prefix) then d"
39 changes: 39 additions & 0 deletions scripts/tmux-split-args
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -eu
# Usage: tmux-splits-stdin <session-name> <command1> <command2>...

# Launches tmux with 1 window that has as many panes as commands
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"

shift 1
commands=("$@")

# Set pane-border-status to top and pane-border-format to display pane title
tmux set-option -t "$session_name" pane-border-status top
tmux set-option -t "$session_name" pane-border-format "#{pane_title}"

# Create the necessary number of panes and set titles
num_commands=${#commands[@]}
for ((i=0; i<num_commands; i++)); do
if [[ $i -gt 0 ]]; then
# Split the first pane each time
tmux split-window -t "$session_name:0.0" -h
tmux select-layout -t "$session_name:0" tiled
fi
# Set the pane title
tmux select-pane -t "$session_name:0.$i" -T "${commands[i]}"
done

# Now send commands to each pane
for ((i=0; i<num_commands; i++)); do
tmux send-keys -t "$session_name:0.$i" "${commands[$i]}" C-m
done

# Attach to the session
tmux attach-session -t "$session_name"
1 change: 0 additions & 1 deletion spartan/aztec-network/files/config/config-validator-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ aztec add-l1-validator --validator $address --rollup $rollup_address

aztec fast-forward-epochs --rollup $rollup_address --count 1


# Write the addresses to a file in the shared volume
cat <<EOF > /shared/contracts.env
export BOOTSTRAP_NODES=$boot_node_enr
Expand Down
53 changes: 53 additions & 0 deletions spartan/scripts/k8s_log_interleave.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
import subprocess
import json
import heapq

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

bundled because useful

# Get the list of pods
pods = subprocess.check_output(
['kubectl', 'get', 'pods', '-n', 'transfer', '-o', 'custom-columns=:metadata.name', '--no-headers'],
universal_newlines=True
).splitlines()

# Create a min-heap for sorting logs based on timestamp
heap = []

for pod in pods:
# Get logs for each pod
logs = subprocess.check_output(['kubectl', 'logs', '-n', 'transfer', pod], universal_newlines=True).splitlines()
for line in logs:
# Prefix with pod name
prefixed_line = f'[{pod}] {line}'
try:
# Remove the pod prefix
if line.startswith('['):
closing_bracket_index = line.find(']')
if closing_bracket_index != -1:
# Assume there's a space after the closing bracket
json_part = line[closing_bracket_index + 2:]
else:
json_part = line # No closing bracket found
else:
json_part = line

# Parse the JSON part
log_json = json.loads(json_part)

# Ensure log_json is a dictionary
if isinstance(log_json, dict):
timestamp = log_json.get('timestamp')
if timestamp:
# Use timestamp as the key for sorting
heapq.heappush(heap, (timestamp, prefixed_line))
else:
# log_json is not a dictionary; skip this line
continue
except (json.JSONDecodeError, ValueError, AttributeError) as e:
# Optionally print the error and the problematic line for debugging
# print(f"Error parsing line: {line}\nError: {e}")
continue # Skip lines that are not valid JSON dictionaries

# Extract and print logs in order
while heap:
_, log_line = heapq.heappop(heap)
print(log_line)
2 changes: 2 additions & 0 deletions yarn-project/end-to-end/scripts/native-network/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
l1-contracts.env
l2-contracts.env
34 changes: 34 additions & 0 deletions yarn-project/end-to-end/scripts/native-network/boot-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -eu
# Starts the Boot Node

# Set environment variables
export PORT="8080"
export LOG_LEVEL="debug"
export LOG_JSON="1"
export DEBUG="aztec:*,-aztec:avm_simulator:*"
export ETHEREUM_HOST="http://127.0.0.1:8545"
export P2P_ENABLED="true"
export VALIDATOR_DISABLED="true"
export SEQ_MAX_SECONDS_BETWEEN_BLOCKS="0"
export SEQ_MIN_TX_PER_BLOCK="1"
export P2P_TCP_ANNOUNCE_ADDR="0.0.0.0:40400"
Copy link
Member

Choose a reason for hiding this comment

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

I recall in the past i had issues where the announce addresses was not 127.0.0.1. But I cannot recall why - writing this just incase

export P2P_UDP_ANNOUNCE_ADDR="0.0.0.0:40400"
export P2P_TCP_LISTEN_ADDR="0.0.0.0:40400"
export P2P_UDP_LISTEN_ADDR="0.0.0.0:40400"
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
sleep 1
done

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

# Wait for anvil and deploy contracts
# source this script to get the L1 contract addresses in env
source "$REPO"/yarn-project/end-to-end/scripts/native-network/deploy-l1-contracts.sh

# Start the Aztec node with the sequencer and archiver
node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --node --archiver --sequencer --pxe
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Deploys L1 contracts and captures the output

set -eu

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}' \
http://127.0.0.1:8545 2>/dev/null | grep -q 'result' ; do
sleep 1
done

# 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)

echo "$output"

# Extract contract addresses using grep and regex
ROLLUP_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Rollup Address: \K0x[a-fA-F0-9]{40}')
REGISTRY_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'Registry Address: \K0x[a-fA-F0-9]{40}')
INBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L1 -> L2 Inbox Address: \K0x[a-fA-F0-9]{40}')
OUTBOX_CONTRACT_ADDRESS=$(echo "$output" | grep -oP 'L2 -> L1 Outbox Address: \K0x[a-fA-F0-9]{40}')
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
export ROLLUP_CONTRACT_ADDRESS=$ROLLUP_CONTRACT_ADDRESS
export REGISTRY_CONTRACT_ADDRESS=$REGISTRY_CONTRACT_ADDRESS
export INBOX_CONTRACT_ADDRESS=$INBOX_CONTRACT_ADDRESS
export OUTBOX_CONTRACT_ADDRESS=$OUTBOX_CONTRACT_ADDRESS
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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Deploys L2 contracts

set -eu

# Wait for PXE service to be ready
echo "Waiting for PXE service..."
until curl -s -X POST -H 'content-type: application/json' \
-d '{"jsonrpc":"2.0","method":"pxe_getNodeInfo","params":[],"id":67}' \
http://127.0.0.1:8079 | grep -q '"enr:-'; do
sleep 1
done
echo "PXE service is ready!"

# Deploy L2 contracts
export AZTEC_NODE_URL="http://127.0.0.1:8080"
node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js deploy-protocol-contracts
echo "Deployed L2 contracts"
# Use file just as done signal
echo "" > l2-contracts.env
14 changes: 14 additions & 0 deletions yarn-project/end-to-end/scripts/native-network/ethereum.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -eu
# Starts the Ethereum node using Anvil

# Ensure anvil is installed
command -v anvil >/dev/null 2>&1 || { echo >&2 "Anvil is not installed. Aborting."; exit 1; }

# Start Anvil with specified parameters
anvil \
--host 0.0.0.0 \
--block-time 12 \
--chain-id 31337 \
--gas-limit 1000000000 \
-p 8545
33 changes: 33 additions & 0 deletions yarn-project/end-to-end/scripts/native-network/prover-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -eu

# Starts the Prover Node
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
sleep 1
done

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

# Get node info from the boot node
output=$(node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js get-node-info -u $BOOT_NODE_URL)

# Extract boot node ENR
export BOOTSTRAP_NODES=$(echo "$output" | grep -oP 'Node ENR: \K.*')

# Set environment variables
export PORT="8080"
export LOG_LEVEL="debug"
export LOG_JSON="1"
export DEBUG="aztec:*"
export ETHEREUM_HOST="http://127.0.0.1:8545"
export PROVER_REAL_PROOFS="false"
export PROVER_AGENT_ENABLED="true"
export PROVER_PUBLISHER_PRIVATE_KEY="0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97"
export PROVER_COORDINATION_NODE_URL="127.0.0.1:8080"
export AZTEC_NODE_URL="127.0.0.1:8080"

# Start the Prover Node with the prover and archiver
node --no-warnings "$REPO"/yarn-project/aztec/dest/bin/index.js start --prover-node --prover --archiver
19 changes: 19 additions & 0 deletions yarn-project/end-to-end/scripts/native-network/pxe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
set -eu

# Starts the PXE (Private eXecution Environment) service
# Set environment variables
export ETHEREUM_HOST="http://127.0.0.1:8545"
export AZTEC_NODE_URL="http://127.0.0.1:8080"
export LOG_JSON="1"
export LOG_LEVEL="debug"
export DEBUG="aztec:*"
export PXE_PORT="http://127.0.0.1:8079"

echo "Waiting for Aztec Node..."
until curl -s http://127.0.0.1:8080/status; do
sleep 1
done

# Start the PXE service
node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --pxe
32 changes: 32 additions & 0 deletions yarn-project/end-to-end/scripts/native-network/transaction-bot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
set -eu
# Starts the transaction bot

# Wait for the Aztec Node to be ready
echo "Waiting for Aztec Node..."
until curl -s http://127.0.0.1:8080/status; do
sleep 1
done

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

# Set environment variables
export ETHEREUM_HOST="http://127.0.0.1:8545"
export AZTEC_NODE_URL="http://127.0.0.1:8080"
export LOG_JSON="1"
export LOG_LEVEL="debug"
export DEBUG="aztec:*"
export BOT_PRIVATE_KEY="0xcafe"
export BOT_TX_INTERVAL_SECONDS="5"
export BOT_PRIVATE_TRANSFERS_PER_TX="1"
export BOT_PUBLIC_TRANSFERS_PER_TX="0"
export BOT_NO_WAIT_FOR_TRANSFERS="true"
export BOT_NO_START="false"
export PXE_PROVER_ENABLED="false"
export PROVER_REAL_PROOFS="false"

# Start the bot
node --no-warnings $(git rev-parse --show-toplevel)/yarn-project/aztec/dest/bin/index.js start --pxe --bot
Loading
Loading