-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·240 lines (200 loc) · 6.53 KB
/
run.sh
File metadata and controls
executable file
·240 lines (200 loc) · 6.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/usr/bin/env bash
# Copyright (C) 2023, Ava Labs, Inc. All rights reserved.
# See the file LICENSE for licensing terms.
set -e
# Set the CGO flags to use the portable version of BLST
#
# We use "export" here instead of just setting a bash variable because we need
# to pass this flag to all child processes spawned by the shell.
export CGO_CFLAGS="-O -D__BLST_PORTABLE__"
# to run E2E tests (terminates cluster afterwards)
# MODE=test ./scripts/run.sh
if ! [[ "$0" =~ scripts/run.sh ]]; then
echo "must be run from repository root"
exit 255
fi
VERSION=1.10.1
MODE=${MODE:-run}
LOGLEVEL=${LOGLEVEL:-info}
AVALANCHE_LOG_LEVEL=${AVALANCHE_LOG_LEVEL:-INFO}
STATESYNC_DELAY=${STATESYNC_DELAY:-0}
PROPOSER_MIN_BLOCK_DELAY=${PROPOSER_MIN_BLOCK_DELAY:-0}
if [[ ${MODE} != "run" && ${MODE} != "run-single" ]]; then
STATESYNC_DELAY=500000000 # 500ms
PROPOSER_MIN_BLOCK_DELAY=100000000 # 100ms
fi
echo "Running with:"
echo VERSION: ${VERSION}
echo MODE: ${MODE}
echo STATESYNC_DELAY: ${STATESYNC_DELAY}
echo PROPOSER_MIN_BLOCK_DELAY: ${PROPOSER_MIN_BLOCK_DELAY}
############################
# build avalanchego
# https://github.com/ava-labs/avalanchego/releases
GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
AVALANCHEGO_PATH=/tmp/avalanchego-v${VERSION}/avalanchego
AVALANCHEGO_PLUGIN_DIR=/tmp/avalanchego-v${VERSION}/plugins
if [ ! -f "$AVALANCHEGO_PATH" ]; then
echo "building avalanchego"
CWD=$(pwd)
# Clear old folders
rm -rf /tmp/avalanchego-v${VERSION}
mkdir -p /tmp/avalanchego-v${VERSION}
rm -rf /tmp/avalanchego-src
mkdir -p /tmp/avalanchego-src
# Download src
cd /tmp/avalanchego-src
git clone https://github.com/ava-labs/avalanchego.git
cd avalanchego
git checkout v${VERSION}
# Build avalanchego
./scripts/build.sh
mv build/avalanchego /tmp/avalanchego-v${VERSION}
cd ${CWD}
else
echo "using previously built avalanchego"
fi
############################
############################
echo "building tokenvm"
# delete previous (if exists)
rm -f /tmp/avalanchego-v${VERSION}/plugins/tHBYNu8ikqo4MWMHehC9iKB9mR5tB3DWzbkYmTfe9buWQ5GZ8
# rebuild with latest code
go build -buildvcs=false \
-o /tmp/avalanchego-v${VERSION}/plugins/tHBYNu8ikqo4MWMHehC9iKB9mR5tB3DWzbkYmTfe9buWQ5GZ8 \
./cmd/tokenvm
echo "building token-cli"
go build -v -o /tmp/token-cli ./cmd/token-cli
# log everything in the avalanchego directory
find /tmp/avalanchego-v${VERSION}
############################
############################
# Always create allocations (linter doesn't like tab)
echo "creating allocations file"
cat <<EOF > /tmp/allocations.json
[{"address":"token1rvzhmceq997zntgvravfagsks6w0ryud3rylh4cdvayry0dl97nsjzf3yp", "balance":1000000000000}]
EOF
GENESIS_PATH=$2
if [[ -z "${GENESIS_PATH}" ]]; then
echo "creating VM genesis file with allocations"
rm -f /tmp/tokenvm.genesis
/tmp/token-cli genesis generate /tmp/allocations.json \
--max-block-units 4000000 \
--window-target-units 100000000000 \
--window-target-blocks 30 \
--genesis-file /tmp/tokenvm.genesis
else
echo "copying custom genesis file"
rm -f /tmp/tokenvm.genesis
cp ${GENESIS_PATH} /tmp/tokenvm.genesis
fi
############################
############################
echo "creating vm config"
rm -f /tmp/tokenvm.config
rm -rf /tmp/tokenvm-e2e-profiles
cat <<EOF > /tmp/tokenvm.config
{
"mempoolSize": 10000000,
"mempoolPayerSize": 10000000,
"mempoolExemptPayers":["token1rvzhmceq997zntgvravfagsks6w0ryud3rylh4cdvayry0dl97nsjzf3yp"],
"parallelism": 5,
"streamingBacklogSize": 10000000,
"gossipMaxSize": 32768,
"gossipProposerDepth": 1,
"buildProposerDiff": 1,
"verifyTimeout": 5,
"trackedPairs":["*"],
"preferredBlocksPerSecond": 3,
"continuousProfilerDir":"/tmp/tokenvm-e2e-profiles/*",
"logLevel": "${LOGLEVEL}",
"stateSyncServerDelay": ${STATESYNC_DELAY}
}
EOF
mkdir -p /tmp/tokenvm-e2e-profiles
############################
############################
echo "creating subnet config"
rm -f /tmp/tokenvm.subnet
cat <<EOF > /tmp/tokenvm.subnet
{
"proposerMinBlockDelay": ${PROPOSER_MIN_BLOCK_DELAY}
}
EOF
############################
############################
echo "building e2e.test"
# to install the ginkgo binary (required for test build and run)
go install -v github.com/onsi/ginkgo/v2/ginkgo@v2.1.4
# alert the user if they do not have $GOPATH properly configured
if ! command -v ginkgo &> /dev/null
then
echo -e "\033[0;31myour golang environment is misconfigued...please ensure the golang bin folder is in your PATH\033[0m"
echo -e "\033[0;31myou can set this for the current terminal session by running \"export PATH=\$PATH:\$(go env GOPATH)/bin\"\033[0m"
exit
fi
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.4.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" &
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 "killall avalanche-network-runner"
echo ""
exit
fi
echo "avalanche-network-runner shutting down..."
killall avalanche-network-runner
}
trap cleanup EXIT
echo "running e2e tests"
./tests/e2e/e2e.test \
--ginkgo.v \
--network-runner-log-level verbo \
--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=/tmp/tokenvm.genesis \
--vm-config-path=/tmp/tokenvm.config \
--subnet-config-path=/tmp/tokenvm.subnet \
--output-path=/tmp/avalanchego-v${VERSION}/output.yaml \
--mode=${MODE}
############################
if [[ ${MODE} == "run" || ${MODE} == "run-single" ]]; then
echo "cluster is ready!"
# We made it past initialization and should avoid shutting down the network
KEEPALIVE=true
fi