Skip to content
Draft
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
6 changes: 3 additions & 3 deletions scripts/local-testbed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ run_aggregator() {
backup_database_url=
committee_size=4 # Default value of 4 if no argument is provided
epoch_duration=1h
network=devnet
network=localnet
rust_log=info # Default RUST_LOG level
shards=10 # Default value of 4 if no argument is provided
tail_logs=false
Expand Down Expand Up @@ -231,8 +231,8 @@ if ! $use_existing_config; then
echo "
event_processor_config:
adaptive_downloader_config:
max_workers: 2
initial_workers: 2" | \
max_workers: 2
initial_workers: 2" | \
tee -a $working_dir/dryrun-node-*[0-9].yaml >/dev/null

# Add garbage collection configuration if enabled
Expand Down
191 changes: 191 additions & 0 deletions walrus.pman
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# Walrus local testbed — procman v0.15.2+ DSL format.
# Install procman: cargo install procman
# Book: https://wbbradley.github.io/procman
# Usage: procman walrus.pman -- --help

env {
WORKING_DIR = args.working_dir
WALRUS_EXISTING = args.existing
WALRUS_GC = args.gc
WALRUS_CONTRACT_DIR = args.contract_dir
WALRUS_DIR = module.dir
}

arg working_dir {
short = "w"
description = "The working directory for the testbed"
default = module.dir + "/working_dir"
}

arg existing {
short = "e"
type = bool
description = "Skip build and deploy, use existing config"
default = false
}

arg gc {
short = "g"
type = bool
description = "Enable garbage collection config patching"
default = false
}

arg aggregator {
short = "A"
type = bool
description = "Start an aggregator daemon"
default = false
}

arg rust_log {
short = "l"
description = "RUST_LOG level for nodes and aggregator"
default = "info"
}

arg contract_dir {
description = "Contract directory (use ./testnet-contracts for testnet)"
default = module.dir + "/contracts"
}

service sui {
env RUST_LOG = "on,error"
wait {
!connect "127.0.0.1:9123"
}
run "sui start --with-faucet --force-regenesis"
}

job build if !args.existing {
run """
cargo build --manifest-path $WALRUS_DIR/Cargo.toml --release \
--bin walrus \
--bin walrus-node \
--bin walrus-deploy \
--bin walrus-backup \
--features deploy,backup
"""
}

job deploy if !args.existing {
wait {
http "http://localhost:9123/" { status = 200 }
after @build
}
env {
WALRUS_CONTRACT_DIR = args.contract_dir
}

run """
COMMITTEE_SIZE="${WALRUS_COMMITTEE_SIZE:-4}"
SHARDS="${WALRUS_SHARDS:-10}"

if ! [ "$COMMITTEE_SIZE" -gt 0 ] 2>/dev/null; then
echo "Invalid: COMMITTEE_SIZE=$COMMITTEE_SIZE is not a valid positive integer."
exit 1
fi
if ! [ "$SHARDS" -ge "$COMMITTEE_SIZE" ] 2>/dev/null; then
echo "Invalid: SHARDS=$SHARDS must be >= COMMITTEE_SIZE=$COMMITTEE_SIZE."
exit 1
fi

EPOCH_DURATION="${WALRUS_EPOCH_DURATION:-1h}"
NETWORK="${WALRUS_NETWORK:-localnet}"
HOST_ADDRESS="${WALRUS_HOST_ADDRESS:-127.0.0.1}"

# Clean old build artifacts and configs
find $WALRUS_CONTRACT_DIR -name 'build' -type d -exec rm -rf {} +
rm -f "$WORKING_DIR"/dryrun-node-*.yaml
rm -f "$WORKING_DIR"/dryrun-node-*.log

# Build host address list
HOSTS=()
for i in $(seq 1 "$COMMITTEE_SIZE"); do
HOSTS+=("$HOST_ADDRESS")
done

# Deploy system contract
$WALRUS_DIR/target/release/walrus-deploy deploy-system-contract \
--working-dir "$WORKING_DIR" \
--sui-network "$NETWORK" \
--n-shards "$SHARDS" \
--host-addresses "${HOSTS[@]}" \
--storage-price 5 \
--write-price 1 \
--epoch-duration "$EPOCH_DURATION" \
--contract-dir "$WALRUS_CONTRACT_DIR" \
--with-wal-exchange

# Generate per-node configs
$WALRUS_DIR/target/release/walrus-deploy generate-dry-run-configs \
--working-dir "$WORKING_DIR"

# Append event processor config to all node configs
for f in "$WORKING_DIR"/dryrun-node-*[0-9].yaml; do
cat >> "$f" <<'NODEEOF'

event_processor_config:
adaptive_downloader_config:
max_workers: 2
initial_workers: 2
NODEEOF
done

# Append garbage collection config if enabled
if [ "$WALRUS_GC" = "true" ]; then
for f in "$WORKING_DIR"/dryrun-node-*[0-9].yaml; do
cat >> "$f" <<'GCEOF'

db_config:
global:
experimental_use_optimistic_transaction_db: true
garbage_collection:
enable_blob_info_cleanup: true
enable_data_deletion: true
GCEOF
done
fi
"""
}

job committee_report {
env RUST_LOG = args.rust_log
wait {
after @deploy
}
run """
cd $WORKING_DIR
$WALRUS_DIR/target/release/walrus info committee
"""
}

service nodes {
env RUST_LOG = args.rust_log
wait {
after @deploy
}
for node_config in glob("$WORKING_DIR/dryrun-node-*[0-9].yaml") {
env NODE_CONFIG = node_config
run """
CLEANUP_FLAG=""
if [ "$WALRUS_EXISTING" != "true" ]; then
CLEANUP_FLAG="--cleanup-storage"
fi
$WALRUS_DIR/target/release/walrus-node run --config-path "$NODE_CONFIG" $CLEANUP_FLAG
"""
}
}

service aggregator if args.aggregator {
env RUST_LOG = args.rust_log
wait {
after @deploy
}
run """
$WALRUS_DIR/target/release/walrus aggregator \
--config "$WORKING_DIR/client_config.yaml" \
--bind-address 127.0.0.1:31415 \
--metrics-address 127.0.0.1:27182
"""
}
Loading