Skip to content

Commit

Permalink
Convert e2e tmpnet (#1249)
Browse files Browse the repository at this point in the history
* Remove TokenVM

* Remove tokenvm from CI/scripts/README

* Start e2e test refactor with workload logic decoupled from test declaration

* Move sync test w/ TODOs into e2e

* fix lint

* Add GenerateNBlocks helper

* fix lint

* fix count dec instead of inc

* Re-add state sync

* fmt

* Mark sync tests as pending

* fix lint

* Fix VMConfigPath -> VMConfig

* Add GenerateUntilCancel to handle concurrent sync + broadcast test case

* remove single line stop script

* fix shellcheck

* Skip syncing test

* Allow errors during broadcast txs while syncing

* fix lint

* move sync test back to separate job with higher timeout

* fix gh action yml

* cleanup

* Add passthrough args + ginkgo focus ping on mode=run

* fix lint

* fix unbound bash var

* Rename map util combinators

* Refactor e2e tests to use tmpnet

* Address nits

* Update workload factory interface

* Remove unnecessary ctx w/ timeout

* Replace describe with it

* fix merge

* Update describe/it

* add explicit longer context timeout than default (#1251)

* adjust timeout, balance, fees (#1262)

* defer cancel in state sync while broadcasting txs

* Update action timeout

* bump ago to tmpnet fix for subnet config

* Update e2e tests timeout back to 25m

* Update ago version to match go mod

* fix stop script

* Move entrypoint to morpheusvm test file

* fix lint

* bump to ago commit on master

* Add comments to WindowTargetUnits and MaxBlockUnits values in genesis construction

---------

Co-authored-by: Franfran <51274081+iFrostizz@users.noreply.github.com>
  • Loading branch information
aaronbuchwald and iFrostizz authored Aug 13, 2024
1 parent 9d31136 commit 4a6cafc
Show file tree
Hide file tree
Showing 13 changed files with 280 additions and 697 deletions.
4 changes: 2 additions & 2 deletions examples/morpheusvm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ava-labs/hypersdk/examples/morpheusvm
go 1.21.12

require (
github.com/ava-labs/avalanchego v1.11.10
github.com/ava-labs/avalanchego v1.11.11-0.20240813002618-d729e5c7ef9f
github.com/ava-labs/hypersdk v0.0.1
github.com/fatih/color v1.13.0
github.com/onsi/ginkgo/v2 v2.13.1
Expand All @@ -19,7 +19,7 @@ require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0 // indirect
github.com/ava-labs/coreth v0.13.7 // indirect
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions examples/morpheusvm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0 h1:xNbCMNqenaDr0bb35j27sqwa+C8t8BgRz51vXd6q0QM=
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0/go.mod h1:B7Ynk/avkCk49CCIWbM4j1UrPlqIi0IHCPAB2MZNvLw=
github.com/ava-labs/avalanchego v1.11.10 h1:QujciF5OEp5FwAoe/RciFF/i47rxU5rkEr6fVuUBS1Q=
github.com/ava-labs/avalanchego v1.11.10/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g=
github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/avalanchego v1.11.11-0.20240813002618-d729e5c7ef9f h1:h6gLvc8hHY+Ca0EhIq9Olqo4EHtOxF88NYv0EVSdfYI=
github.com/ava-labs/avalanchego v1.11.11-0.20240813002618-d729e5c7ef9f/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d h1:klPTcKVvqfA2KSKaRvQAO56Pd4XAqGhwgMTQ6/W+w7w=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
194 changes: 5 additions & 189 deletions examples/morpheusvm/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -e

# to run E2E tests (terminates cluster afterwards)
# MODE=test ./scripts/run.sh
MODE=${MODE:-run}
if ! [[ "$0" =~ scripts/run.sh ]]; then
echo "must be run from morpheusvm root"
exit 255
Expand All @@ -16,46 +17,7 @@ source ../../scripts/constants.sh
# shellcheck source=/scripts/common/utils.sh
source ../../scripts/common/utils.sh

VERSION=v1.11.10
MAX_UINT64=18446744073709551615
MODE=${MODE:-run}
LOG_LEVEL=${LOG_LEVEL:-INFO}
AGO_LOG_LEVEL=${AGO_LOG_LEVEL:-INFO}
AGO_LOG_DISPLAY_LEVEL=${AGO_LOG_DISPLAY_LEVEL:-INFO}
STATESYNC_DELAY=${STATESYNC_DELAY:-0}
MIN_BLOCK_GAP=${MIN_BLOCK_GAP:-100}
STORE_TXS=${STORE_TXS:-false}
UNLIMITED_USAGE=${UNLIMITED_USAGE:-false}
ADDRESS=${ADDRESS:-morpheus1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjk97rwu}
if [[ ${MODE} != "run" ]]; then
LOG_LEVEL=DEBUG
AGO_LOG_DISPLAY_LEVEL=INFO
STATESYNC_DELAY=100000000 # 100ms
MIN_BLOCK_GAP=250 #ms
STORE_TXS=true
UNLIMITED_USAGE=true
fi

WINDOW_TARGET_UNITS="40000000,450000,450000,450000,450000"
MAX_BLOCK_UNITS="1800000,15000,15000,2500,15000"
if ${UNLIMITED_USAGE}; then
WINDOW_TARGET_UNITS="${MAX_UINT64},${MAX_UINT64},${MAX_UINT64},${MAX_UINT64},${MAX_UINT64}"
# If we don't limit the block size, AvalancheGo will reject the block.
MAX_BLOCK_UNITS="1800000,${MAX_UINT64},${MAX_UINT64},${MAX_UINT64},${MAX_UINT64}"
fi

echo "Running with:"
echo LOG_LEVEL: "${LOG_LEVEL}"
echo AGO_LOG_LEVEL: "${AGO_LOG_LEVEL}"
echo AGO_LOG_DISPLAY_LEVEL: "${AGO_LOG_DISPLAY_LEVEL}"
echo VERSION: "${VERSION}"
echo MODE: "${MODE}"
echo STATESYNC_DELAY \(ns\): "${STATESYNC_DELAY}"
echo MIN_BLOCK_GAP \(ms\): "${MIN_BLOCK_GAP}"
echo STORE_TXS: "${STORE_TXS}"
echo WINDOW_TARGET_UNITS: "${WINDOW_TARGET_UNITS}"
echo MAX_BLOCK_UNITS: "${MAX_BLOCK_UNITS}"
echo ADDRESS: "${ADDRESS}"
VERSION=d729e5c7ef9f008c3e89cd7131148ad3acda2e34

############################
# build avalanchego
Expand Down Expand Up @@ -94,7 +56,6 @@ fi

############################

############################
echo "building morpheusvm"

# delete previous (if exists)
Expand All @@ -105,79 +66,6 @@ go build \
-o "${TMPDIR}"/avalanchego-"${VERSION}"/plugins/qCNyZHrs3rZX458wPJXPJJypPf6w423A84jnfbdP2TPEmEE9u \
./cmd/morpheusvm

echo "building morpheus-cli"
go build -v -o "${TMPDIR}"/morpheus-cli ./cmd/morpheus-cli

# log everything in the avalanchego directory
find "${TMPDIR}"/avalanchego-"${VERSION}"

############################

############################

# Always create allocations (linter doesn't like tab)
echo "creating allocations file"
cat <<EOF > "${TMPDIR}"/allocations.json
[
{"address":"${ADDRESS}", "balance":10000000000000000000}
]
EOF

GENESIS_PATH=$2
if [[ -z "${GENESIS_PATH}" ]]; then
echo "creating VM genesis file with allocations"
rm -f "${TMPDIR}"/morpheusvm.genesis
"${TMPDIR}"/morpheus-cli genesis generate "${TMPDIR}"/allocations.json \
--window-target-units "${WINDOW_TARGET_UNITS}" \
--max-block-units "${MAX_BLOCK_UNITS}" \
--min-block-gap "${MIN_BLOCK_GAP}" \
--genesis-file "${TMPDIR}"/morpheusvm.genesis
else
echo "copying custom genesis file"
rm -f "${TMPDIR}"/morpheusvm.genesis
cp "${GENESIS_PATH}" "${TMPDIR}"/morpheusvm.genesis
fi

############################

############################

echo "creating vm config"
rm -f "${TMPDIR}"/morpheusvm.config
rm -rf "${TMPDIR}"/morpheusvm-e2e-profiles
cat <<EOF > "${TMPDIR}"/morpheusvm.config
{
"mempoolSize": 10000000,
"mempoolSponsorSize": 10000000,
"mempoolExemptSponsors":["${ADDRESS}"],
"authVerificationCores": 2,
"rootGenerationCores": 2,
"transactionExecutionCores": 2,
"verifyAuth":true,
"storeTransactions": ${STORE_TXS},
"streamingBacklogSize": 10000000,
"logLevel": "${LOG_LEVEL}",
"continuousProfilerDir":"${TMPDIR}/morpheusvm-e2e-profiles/*",
"stateSyncServerDelay": ${STATESYNC_DELAY}
}
EOF
mkdir -p "${TMPDIR}"/morpheusvm-e2e-profiles

############################

############################

echo "creating subnet config"
rm -f "${TMPDIR}"/morpheusvm.subnet
cat <<EOF > "${TMPDIR}"/morpheusvm.subnet
{
"proposerMinBlockDelay": 0,
"proposerNumHistoricalBlocks": 50000
}
EOF

############################

############################
echo "building e2e.test"

Expand All @@ -186,89 +74,17 @@ prepare_ginkgo
ACK_GINKGO_RC=true ginkgo build ./tests/e2e
./tests/e2e/e2e.test --help

#################################
# download avalanche-network-runner
# https://github.com/ava-labs/avalanche-network-runner
ANR_REPO_PATH=github.com/ava-labs/avalanche-network-runner
ANR_VERSION=v1.8.1
# version set
go install -v "${ANR_REPO_PATH}"@"${ANR_VERSION}"

#################################
# run "avalanche-network-runner" server
GOPATH=$(go env GOPATH)
if [[ -z ${GOBIN+x} ]]; then
# no gobin set
BIN=${GOPATH}/bin/avalanche-network-runner
else
# gobin set
BIN=${GOBIN}/avalanche-network-runner
fi

killall avalanche-network-runner || true

echo "launch avalanche-network-runner in the background"
$BIN server \
--log-level=verbo \
--port=":12352" \
--grpc-gateway-port=":12353" &
SERVER_PID=$!

############################
# By default, it runs all e2e test cases!
# Use "--ginkgo.skip" to skip tests.
# Use "--ginkgo.focus" to select tests.

KEEPALIVE=false
function cleanup() {
if [[ ${KEEPALIVE} = true ]]; then
echo "avalanche-network-runner is running in the background..."
echo ""
echo "use the following command to terminate:"
echo ""
echo "kill $SERVER_PID"
echo ""
echo "or"
echo ""
echo "./scripts/stop.sh"
exit
fi

echo "Shutting down avalanche-network-runner..."
kill "$SERVER_PID"
wait "$SERVER_PID"
echo "avalanche-network-runner server terminated"
}
trap cleanup EXIT

additional_args=("$@")

if [[ ${MODE} == "run" ]]; then
echo "applying ginkgo.focus=Ping to limit test cases on network setup"
echo "applying ginkgo.focus=Ping and --reuse-network to setup local network"
additional_args+=("--ginkgo.focus=Ping")
additional_args+=("--reuse-network")
fi

echo "running e2e tests"
./tests/e2e/e2e.test \
--ginkgo.v \
--network-runner-log-level verbo \
--avalanchego-log-level "${AGO_LOG_LEVEL}" \
--avalanchego-log-display-level "${AGO_LOG_DISPLAY_LEVEL}" \
--network-runner-grpc-endpoint="0.0.0.0:12352" \
--network-runner-grpc-gateway-endpoint="0.0.0.0:12353" \
--avalanchego-path="${AVALANCHEGO_PATH}" \
--avalanchego-plugin-dir="${AVALANCHEGO_PLUGIN_DIR}" \
--vm-genesis-path="${TMPDIR}"/morpheusvm.genesis \
--vm-config-path="${TMPDIR}"/morpheusvm.config \
--subnet-config-path="${TMPDIR}"/morpheusvm.subnet \
--output-path="${TMPDIR}"/avalanchego-"${VERSION}"/output.yaml \
--mode="${MODE}" \
--plugin-dir="${AVALANCHEGO_PLUGIN_DIR}" \
"${additional_args[@]}"


############################
if [[ ${MODE} == "run" ]]; then
echo "cluster is ready!"
# We made it past initialization and should avoid shutting down the network
KEEPALIVE=true
fi
7 changes: 6 additions & 1 deletion examples/morpheusvm/scripts/stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,9 @@

set -e

killall avalanche-network-runner
MORPHEUSVM_PATH=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
cd .. && pwd
)

ginkgo -v "$MORPHEUSVM_PATH"/tests/e2e/e2e.test -- --stop-network
Loading

0 comments on commit 4a6cafc

Please sign in to comment.