*: add simulator e2e tests (#172)

* *: add simulator e2e tests

Signed-off-by: Gyuho Lee <[email protected]>

* lint-test: use Go 1.18

Signed-off-by: Gyuho Lee <[email protected]>

* cmd/simulator: use local subnet-evm version

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: remove go mod command

Signed-off-by: Gyuho Lee <[email protected]>

* cmd/simulator: use os.ReadFile

Signed-off-by: Gyuho Lee <[email protected]>

* *: update run.sh + e2e_test.go with latest network runner

Signed-off-by: Gyuho Lee <[email protected]>

* *: remove "mode"

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: fix genesis for e2e tests

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: fix "fi"

Signed-off-by: Gyuho Lee <[email protected]>

* test: skip shutdown for e2e

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: skip genesis when disabled nr

Signed-off-by: Gyuho Lee <[email protected]>

* e2e: skip

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: update

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: fix RUN_SIMULATOR

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: fix

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: fix

Signed-off-by: Gyuho Lee <[email protected]>

* test: skip shutdown when simular is enabled

Signed-off-by: Gyuho Lee <[email protected]>

* *: use avalanchego 1.7.17 for tests

Signed-off-by: Gyuho Lee <[email protected]>

* tests/e2e: remove "--enable-solidity-tests"

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: debug

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: fix

Signed-off-by: Gyuho Lee <[email protected]>

* run.sh: remove "set -x" debug mode

Signed-off-by: Gyuho Lee <[email protected]>

* go mod tidy

Signed-off-by: Gyuho Lee <[email protected]>

Signed-off-by: Gyuho Lee <[email protected]>
This commit is contained in:
Gyuho Lee
2022-08-24 21:01:58 -04:00
committed by GitHub
parent ec563e83b6
commit 98bdd260a9
14 changed files with 547 additions and 196 deletions
+18 -2
View File
@@ -63,10 +63,26 @@ jobs:
working-directory: ./contract-examples
- name: Run e2e tests
shell: bash
run: E2E=true scripts/run.sh
run: SKIP_NETWORK_RUNNER_START=true SKIP_NETWORK_RUNNER_SHUTDOWN=true ENABLE_SOLIDITY_TESTS=true scripts/run.sh
simulator_test:
name: Load testing with simulator
runs-on: ubuntu-latest
steps:
- name: Git checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Run simulator tests
shell: bash
run: SKIP_NETWORK_RUNNER_SHUTDOWN=true RUN_SIMULATOR=true scripts/run.sh
release:
needs: [lint_test] # TODO: re-add after flaky tests are fixed (unit_test, e2e_test)
needs: [lint_test, simulator_test] # TODO: re-add after flaky tests are fixed (unit_test, e2e_test)
runs-on: ubuntu-latest
steps:
- name: Git checkout
+3 -1
View File
@@ -99,7 +99,9 @@ and creates a `subnet-evm` genesis file. The usage of this script is
# to startup a local cluster (good for development)
cd ${HOME}/go/src/github.com/ava-labs/subnet-evm
git pull
./scripts/run.sh 1.7.13 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
# TODO: update the "avalanchego" version to latest
SKIP_NETWORK_RUNNER_SHUTDOWN=true ./scripts/run.sh 1.7.17 0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC
```
Note: make sure you check the version compatibility above between AvalancheGo and Subnet-evm and use the proper version of AvalancheGo.
-5
View File
@@ -1,5 +0,0 @@
endpoints:
- http://localhost:9650/ext/bc/C/rpc
base-fee: 25
priority-fee: 1
concurrency: 10
+15 -21
View File
@@ -3,46 +3,40 @@ module github.com/ava-labs/subnet-evm/cmd/simulator
go 1.18
require (
github.com/ava-labs/subnet-evm v0.2.6
github.com/ethereum/go-ethereum v1.10.20
github.com/spf13/viper v1.10.1
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
github.com/ava-labs/subnet-evm v0.0.0-00010101000000-000000000000
github.com/ethereum/go-ethereum v1.10.21
github.com/spf13/cobra v1.5.0
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4
sigs.k8s.io/yaml v1.3.0
)
// always depend on the local version
replace github.com/ava-labs/subnet-evm => ../..
require (
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/ava-labs/avalanchego v1.7.16 // indirect
github.com/ava-labs/avalanchego v1.7.18 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rjeczalik/notify v0.9.2 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.2 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
golang.org/x/text v0.3.7 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
+26 -48
View File
@@ -1,16 +1,13 @@
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VictoriaMetrics/fastcache v1.10.0 h1:5hDJnLsKLpnUEToub7ETuRu8RCkb40woBZAUiKonXzY=
github.com/ava-labs/avalanchego v1.7.16 h1:8IoVA5nBu1Efus9qcYmxI5aObuYlvEBcBbOcX2R8W8o=
github.com/ava-labs/avalanchego v1.7.16/go.mod h1:S0SlkuHBqr1EQL+N4XydI5c6q5A0YIpxAndAt3ellrM=
github.com/ava-labs/subnet-evm v0.2.6 h1:uBhsdjbeU/MJ4DTkuyClOyn8Rtq4mk/zjVo8fKrNg6I=
github.com/ava-labs/subnet-evm v0.2.6/go.mod h1:FaZCFYBJ6/4Tp1aDuXNhDW+wS+KlwVyIcpS4F0kShR8=
github.com/ava-labs/avalanchego v1.7.18 h1:x4PrTKIyUZkxhPjjf/a4hQLZDUB8netA6oFMw6Z1M+Q=
github.com/ava-labs/avalanchego v1.7.18/go.mod h1:Jo21X9sMxvkZNoo8B7GJbbelGrIJbwFPcMhwanink68=
github.com/btcsuite/btcd v0.23.1 h1:IB8cVQcC2X5mHbnfirLG5IZnkWYNTPlLZVrxUYSotbE=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -20,14 +17,12 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/ethereum/go-ethereum v1.10.20 h1:75IW830ClSS40yrQC1ZCMZCt5I+zU16oqId2SiQwdQ4=
github.com/ethereum/go-ethereum v1.10.20/go.mod h1:LWUN82TCHGpxB3En5HVmLLzPD7YSrEUFmFfN1nKkVN0=
github.com/ethereum/go-ethereum v1.10.21 h1:5lqsEx92ZaZzRyOqBEXux4/UR06m296RGzN3ol3teJY=
github.com/ethereum/go-ethereum v1.10.21/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/gballet/go-libpcsclite v0.0.0-20191108122812-4678299bea08 h1:f6D9Hr8xV8uYKlyuj8XIruxlh9WjVjdh1gIicAS7ays=
github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
@@ -40,51 +35,34 @@ github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0U
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE=
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs=
github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM=
github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rjeczalik/notify v0.9.2 h1:MiTWrPj55mNDHEiIX5YUSKefw/+lCQVoAFmD6oQm5w8=
github.com/rjeczalik/notify v0.9.2/go.mod h1:aErll2f0sUX9PXZnVNyeiObbmTlk5jnMoCa4QEjJeqM=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk=
github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU=
github.com/status-im/keycard-go v0.0.0-20200402102358-957c09536969 h1:Oo2KZNP70KE0+IUJSidPj/BFS/RXNHmKIJOdckzml2E=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5fl+nylMaIr9PVV1w343YRDtsy+Rwu7XI=
github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4=
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
@@ -92,33 +70,34 @@ github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefld
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/tyler-smith/go-bip39 v1.0.2 h1:+t3w+KwLXO6154GNJY+qUtIxLTmFjfUmpguQT1OlOT8=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d h1:sK3txAijHtOK88l68nt020reeT1ZdKLIYetKl95FzVY=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180926160741-c2ed4eda69e7/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b h1:2n253B2r0pYSmEV+UNCQoPfU/FiaizQEK5Gu4Bq4JE8=
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOvaw35nUYE279vF9UmsI8=
golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
@@ -129,12 +108,11 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=
gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
+113 -2
View File
@@ -5,12 +5,123 @@ package main
import (
"context"
"errors"
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"
"github.com/ava-labs/subnet-evm/cmd/simulator/worker"
"github.com/spf13/cobra"
"sigs.k8s.io/yaml"
)
func init() {
cobra.EnablePrefixMatching = true
}
func main() {
ctx := context.Background()
log.Fatal(worker.Run(ctx))
rootCmd := newCommand()
if err := rootCmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "simulator failed %v\n", err)
os.Exit(1)
}
}
var (
timeout time.Duration
keysDir string
networkRunnerOutputPath string
rpcEndpoints []string
concurrency int
baseFee uint64
priorityFee uint64
)
func newCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "simulator",
Short: "Load simulator for subnet-evm + C-chain",
SuggestFor: []string{"simulators"},
Run: runFunc,
}
cmd.PersistentFlags().DurationVarP(&timeout, "timeout", "t", time.Minute, "Duration to run simulator")
cmd.PersistentFlags().StringVarP(&keysDir, "keys", "k", ".simulator/keys", "Directory for key files")
cmd.PersistentFlags().StringVarP(&networkRunnerOutputPath, "network-runner-output", "o", "", "If non-empty, it loads the endpoints from the YAML and overwrites --config")
cmd.PersistentFlags().StringSliceVarP(&rpcEndpoints, "endpoints", "e", nil, "If non-empty, it loads the endpoints from the YAML and overwrites --config")
cmd.PersistentFlags().IntVarP(&concurrency, "concurrency", "c", 10, "Concurrency")
cmd.PersistentFlags().Uint64VarP(&baseFee, "base-fee", "f", 25, "Base fee")
cmd.PersistentFlags().Uint64VarP(&priorityFee, "priority-fee", "p", 1, "Base fee")
return cmd
}
func runFunc(cmd *cobra.Command, args []string) {
log.Printf("launching simulator with rpc endpoints %q or network runner output %q, timeout %v, concurrentcy %d, base fee %d, priority fee %d",
rpcEndpoints, networkRunnerOutputPath, timeout, concurrency, baseFee, priorityFee)
cfg := &worker.Config{
Endpoints: rpcEndpoints,
Concurrency: concurrency,
BaseFee: baseFee,
PriorityFee: priorityFee,
}
if networkRunnerOutputPath != "" {
log.Printf("loading network runner output %q", networkRunnerOutputPath)
b, err := os.ReadFile(networkRunnerOutputPath)
if err != nil {
log.Fatalf("failed to read network-runner output %v", err)
}
var ci networkRunnerClusterInfo
if err = yaml.Unmarshal(b, &ci); err != nil {
log.Fatalf("failed to parse network-runner output %v", err)
}
eps := make([]string, len(ci.URIs))
for i := range eps {
/*
e.g.,
uris:
- http://127.0.0.1:32945
- http://127.0.0.1:38948
- http://127.0.0.1:47203
- http://127.0.0.1:54708
- http://127.0.0.1:64435
endpoint: /ext/bc/oFzgVk4nzHApgcBAPXa7JLX5mhqAJnxQkiYD915tZ6LMPcPRu
*/
eps[i] = ci.URIs[i] + ci.Endpoint + "/rpc"
}
cfg.Endpoints = eps
}
ctx, cancel := context.WithTimeout(context.Background(), timeout)
errc := make(chan error)
go func() {
errc <- worker.Run(ctx, cfg, keysDir)
}()
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGTERM, syscall.SIGINT)
select {
case sig := <-sigs:
log.Printf("received OS signal %v; canceling context", sig.String())
cancel()
case err := <-errc:
cancel()
if !errors.Is(err, context.DeadlineExceeded) {
log.Fatalf("worker.Run returned an error %v", err)
}
}
}
type networkRunnerClusterInfo struct {
URIs []string `json:"uris"`
Endpoint string `json:"endpoint"`
}
+34 -42
View File
@@ -4,59 +4,51 @@
package worker
import (
"fmt"
"log"
"os"
"path/filepath"
"github.com/spf13/viper"
)
const (
endpointsKey = "endpoints"
baseFeeKey = "base-fee"
priorityFeeKey = "priority-fee"
concurrencyKey = "concurrency"
"sigs.k8s.io/yaml"
)
type Config struct {
Endpoints []string
Concurrency int
BaseFee uint64
PriorityFee uint64
Endpoints []string `json:"endpoints"`
Concurrency int `json:"concurrency"`
BaseFee uint64 `json:"base-fee"`
PriorityFee uint64 `json:"priority-fee"`
}
// LoadConfig parses and validates the [config] in [.simulator]
func LoadConfig() (*Config, error) {
v := viper.New()
v.SetConfigName("config")
v.AddConfigPath(".simulator")
if err := v.ReadInConfig(); err != nil {
return nil, fmt.Errorf("%w: unable to read config", err)
func LoadConfig(configPath string) (cfg *Config, err error) {
var d []byte
d, err = os.ReadFile(configPath)
if err != nil {
return nil, err
}
endpoints := v.GetStringSlice(endpointsKey)
if len(endpoints) == 0 {
log.Fatal("no available endpoints")
cfg = &Config{}
if err = yaml.Unmarshal(d, cfg); err != nil {
return nil, err
}
concurrency := v.GetInt(concurrencyKey)
if concurrency == 0 {
log.Fatal("concurrency is 0")
}
baseFee := v.GetUint64(baseFeeKey)
if baseFee == 0 {
log.Fatal("base fee is 0")
}
// We allow a priority fee of 0, so we don't check this
priorityFee := v.GetUint64(priorityFeeKey)
log.Printf(
"loaded config (endpoints=%v concurrency=%d base fee=%d priority fee=%d)\n",
endpoints,
baseFee,
priorityFee,
concurrency,
cfg.Endpoints,
cfg.BaseFee,
cfg.PriorityFee,
cfg.Concurrency,
)
return &Config{
Endpoints: endpoints,
Concurrency: concurrency,
BaseFee: baseFee,
PriorityFee: priorityFee,
}, nil
return cfg, nil
}
const fsModeWrite = 0o600
func (c *Config) Save(p string) error {
log.Printf("saving config to %q", p)
if err := os.MkdirAll(filepath.Dir(p), fsModeWrite); err != nil {
return err
}
ob, err := yaml.Marshal(c)
if err != nil {
return err
}
return os.WriteFile(p, ob, fsModeWrite)
}
+17 -27
View File
@@ -11,18 +11,13 @@ import (
"math/rand"
"time"
"github.com/ava-labs/subnet-evm/cmd/simulator/key"
"github.com/ava-labs/subnet-evm/cmd/simulator/metrics"
"github.com/ava-labs/subnet-evm/core/types"
"github.com/ava-labs/subnet-evm/ethclient"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
"golang.org/x/sync/errgroup"
"github.com/ava-labs/subnet-evm/cmd/simulator/key"
"github.com/ava-labs/subnet-evm/cmd/simulator/metrics"
)
const (
workerKeyDir = ".simulator/keys"
)
var (
@@ -54,11 +49,16 @@ func setupVars(cID *big.Int, bFee uint64, pFee uint64) {
minFunderBalance = new(big.Int).Add(maxTransferCost, requestAmount)
}
func createWorkers(ctx context.Context, keys []*key.Key, endpoints []string, desiredWorkers int) (*worker, []*worker, error) {
func createWorkers(ctx context.Context, keysDir string, endpoints []string, desiredWorkers int) (*worker, []*worker, error) {
keys, err := key.LoadAll(ctx, keysDir)
if err != nil {
return nil, nil, fmt.Errorf("unable to load keys: %w", err)
}
var master *worker
var workers []*worker
for i, k := range keys {
worker, err := newWorker(k, endpoints[i%len(endpoints)])
worker, err := newWorker(k, endpoints[i%len(endpoints)], keysDir)
if err != nil {
return nil, nil, err
}
@@ -83,9 +83,8 @@ func createWorkers(ctx context.Context, keys []*key.Key, endpoints []string, des
}
}
var err error
if master == nil {
master, err = newWorker(nil, endpoints[rand.Intn(len(endpoints))])
master, err = newWorker(nil, endpoints[rand.Intn(len(endpoints))], keysDir)
if err != nil {
return nil, nil, fmt.Errorf("unable to create master: %w", err)
}
@@ -93,7 +92,7 @@ func createWorkers(ctx context.Context, keys []*key.Key, endpoints []string, des
for len(workers) < desiredWorkers {
i := len(workers)
worker, err := newWorker(nil, endpoints[i%len(endpoints)])
worker, err := newWorker(nil, endpoints[i%len(endpoints)], keysDir)
if err != nil {
return nil, nil, fmt.Errorf("unable to create worker: %w", err)
}
@@ -112,7 +111,7 @@ type worker struct {
nonce uint64
}
func newWorker(k *key.Key, endpoint string) (*worker, error) {
func newWorker(k *key.Key, endpoint string, keysDir string) (*worker, error) {
client, err := ethclient.Dial(endpoint)
if err != nil {
return nil, fmt.Errorf("failed to create ethclient: %w", err)
@@ -124,7 +123,7 @@ func newWorker(k *key.Key, endpoint string) (*worker, error) {
return nil, fmt.Errorf("problem creating new private key: %w", err)
}
if err := k.Save(workerKeyDir); err != nil {
if err := k.Save(keysDir); err != nil {
return nil, fmt.Errorf("could not save key: %w", err)
}
}
@@ -276,13 +275,8 @@ func (w *worker) confirmTransaction(ctx context.Context, tx common.Hash) (*big.I
// Run attempts to apply load to a network specified in .simulator/config.yml
// and periodically prints metrics about the traffic it generates.
func Run(ctx context.Context) error {
c, err := LoadConfig()
if err != nil {
return fmt.Errorf("%w: cannot load config", err)
}
rclient, err := ethclient.Dial(c.Endpoints[0])
func Run(ctx context.Context, cfg *Config, keysDir string) error {
rclient, err := ethclient.Dial(cfg.Endpoints[0])
if err != nil {
return err
}
@@ -290,13 +284,9 @@ func Run(ctx context.Context) error {
if err != nil {
return err
}
setupVars(chainId, c.BaseFee, c.PriorityFee)
setupVars(chainId, cfg.BaseFee, cfg.PriorityFee)
ks, err := key.LoadAll(ctx, workerKeyDir)
if err != nil {
return fmt.Errorf("unable to load keys: %w", err)
}
master, workers, err := createWorkers(ctx, ks, c.Endpoints, c.Concurrency)
master, workers, err := createWorkers(ctx, keysDir, cfg.Endpoints, cfg.Concurrency)
if err != nil {
return fmt.Errorf("unable to load available workers: %w", err)
}
+58 -19
View File
@@ -6,11 +6,14 @@ set -e
# run without e2e tests
# ./scripts/run.sh
#
# run without e2e tests, and with simulator
# RUN_SIMULATOR=true ./scripts/run.sh
#
# run without e2e tests with DEBUG log level
# AVALANCHE_LOG_LEVEL=DEBUG ./scripts/run.sh
#
# run with e2e tests
# E2E=true ./scripts/run.sh
# ENABLE_SOLIDITY_TESTS=true ./scripts/run.sh
if ! [[ "$0" =~ scripts/run.sh ]]; then
echo "must be run from repository root"
exit 255
@@ -27,20 +30,29 @@ VERSION=$avalanche_version
DEFAULT_ACCOUNT="0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC"
GENESIS_ADDRESS=${GENESIS_ADDRESS-$DEFAULT_ACCOUNT}
MODE=${MODE:-run}
E2E=${E2E:-false}
if [[ ${E2E} == true ]]; then
MODE="test"
fi
SKIP_NETWORK_RUNNER_START=${SKIP_NETWORK_RUNNER_START:-false}
SKIP_NETWORK_RUNNER_SHUTDOWN=${SKIP_NETWORK_RUNNER_SHUTDOWN:-false}
RUN_SIMULATOR=${RUN_SIMULATOR:-false}
ENABLE_SOLIDITY_TESTS=${ENABLE_SOLIDITY_TESTS:-false}
AVALANCHE_LOG_LEVEL=${AVALANCHE_LOG_LEVEL:-INFO}
ANR_VERSION=$network_runner_version
GINKGO_VERSION=$ginkgo_version
GINKGO_SKIP_FLAGS="\[Precompiles\]"
if [[ ${ENABLE_SOLIDITY_TESTS} == true ]]; then
GINKGO_SKIP_FLAGS=""
fi
echo "Running with:"
echo AVALANCE_VERSION: ${VERSION}
echo ANR_VERSION: ${ANR_VERSION}
echo MODE: ${MODE}
echo GINKGO_VERSION: ${GINKGO_VERSION}
echo GENESIS_ADDRESS: ${GENESIS_ADDRESS}
echo SKIP_NETWORK_RUNNER_START: ${SKIP_NETWORK_RUNNER_START}
echo SKIP_NETWORK_RUNNER_SHUTDOWN: ${SKIP_NETWORK_RUNNER_SHUTDOWN}
echo RUN_SIMULATOR: ${RUN_SIMULATOR}
echo ENABLE_SOLIDITY_TESTS: ${ENABLE_SOLIDITY_TESTS}
echo GINKGO_SKIP_FLAGS: ${GINKGO_SKIP_FLAGS}
echo AVALANCHE_LOG_LEVEL: ${AVALANCHE_LOG_LEVEL}
############################
@@ -96,9 +108,8 @@ go build \
# Create genesis file to use in network (make sure to add your address to
# "alloc")
if [[ ${E2E} != true ]]; then
export CHAIN_ID=99999
echo "creating genesis"
export CHAIN_ID=99999
echo "creating genesis"
cat <<EOF >$BASEDIR/genesis.json
{
"config": {
@@ -142,7 +153,6 @@ if [[ ${E2E} != true ]]; then
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
EOF
fi
# If you'd like to try the airdrop feature, use the commented genesis
# cat <<EOF > ${BASEDIR}/genesis.json
@@ -215,14 +225,12 @@ $BIN server \
--grpc-gateway-port=":12343" &
PID=${!}
if [[ ${E2E} == true ]]; then
#################################
run_ginkgo() {
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.3
go install -v github.com/onsi/ginkgo/v2/ginkgo@${GINKGO_VERSION}
ACK_GINKGO_RC=true ginkgo build ./tests/e2e
#################################
# By default, it runs all e2e test cases!
# Use "--ginkgo.skip" to skip tests.
# Use "--ginkgo.focus" to select tests.
@@ -233,11 +241,36 @@ if [[ ${E2E} == true ]]; then
--network-runner-grpc-endpoint="0.0.0.0:12342" \
--avalanchego-path=${AVALANCHEGO_PATH} \
--avalanchego-plugin-dir=${AVALANCHEGO_PLUGIN_DIR} \
--vm-genesis-path=$BASEDIR/genesis.json \
--output-path=$BASEDIR/avalanchego-${VERSION}/output.yaml \
--mode=${MODE}
--skip-network-runner-start=${SKIP_NETWORK_RUNNER_START} \
--skip-network-runner-shutdown=${SKIP_NETWORK_RUNNER_SHUTDOWN} --ginkgo.skip "${GINKGO_SKIP_FLAGS}"
}
run_simulator() {
#################################
echo "building simulator"
pushd ./cmd/simulator
go install -v .
popd
echo "running simulator"
simulator \
--network-runner-output=$BASEDIR/avalanchego-${VERSION}/output.yaml \
--keys=./cmd/simulator/.simulator/keys \
--timeout=30s \
--concurrency=10 \
--base-fee=25 \
--priority-fee=1
}
if [[ ${SKIP_NETWORK_RUNNER_START} == false ]]; then
echo "running ginkgo"
run_ginkgo
# to fail the script if ginkgo failed
EXIT_CODE=$?
else
echo "running scripts/parser/main.go"
go run scripts/parser/main.go \
$BASEDIR/avalanchego-${VERSION}/output.yaml \
$CHAIN_ID $GENESIS_ADDRESS \
@@ -247,9 +280,15 @@ else
"$BASEDIR/genesis.json"
fi
# e.g., "RUN_SIMULATOR=true scripts/run.sh" to launch network runner + simulator
if [[ ${RUN_SIMULATOR} == true ]]; then
run_simulator
# to fail the script if simulator failed
EXIT_CODE=$?
fi
#################################
if [[ ${MODE} == "test" ]]; then
# "e2e.test" already terminates the cluster for "test" mode
if [[ ${SKIP_NETWORK_RUNNER_SHUTDOWN} == false ]]; then
# just in case tests are aborted, manually terminate them again
echo "network-runner RPC server was running on PID ${PID} as test mode; terminating the process..."
pkill -P ${PID} || true
+2
View File
@@ -5,3 +5,5 @@ subnet_evm_version=${SUBNET_EVM_VERSION:-'v0.2.9'}
# Don't export them as they're used in the context of other calls
avalanche_version=${AVALANCHE_VERSION:-'v1.7.18'}
network_runner_version=${NETWORK_RUNNER_VERSION:-'v1.2.0'}
ginkgo_version=${GINKGO_VERSION:-'v2.1.4'}
+176 -19
View File
@@ -5,19 +5,28 @@
package e2e
import (
"context"
"flag"
"fmt"
"os"
"testing"
"time"
"github.com/ava-labs/avalanche-network-runner/client"
"github.com/ava-labs/avalanche-network-runner/rpcpb"
"github.com/ava-labs/avalanchego/ids"
_ "github.com/ava-labs/subnet-evm/tests/e2e/ping"
"github.com/ava-labs/subnet-evm/tests/e2e/runner"
_ "github.com/ava-labs/subnet-evm/tests/e2e/solidity"
"github.com/ava-labs/subnet-evm/tests/e2e/utils"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/ginkgo/v2/formatter"
"github.com/onsi/gomega"
"gopkg.in/yaml.v2"
_ "github.com/ava-labs/subnet-evm/tests/e2e/ping"
_ "github.com/ava-labs/subnet-evm/tests/e2e/solidity"
)
func TestE2e(t *testing.T) {
func TestE2E(t *testing.T) {
gomega.RegisterFailHandler(ginkgo.Fail)
ginkgo.RunSpecs(t, "subnet-evm e2e test suites")
}
@@ -27,13 +36,16 @@ var (
gRPCEp string
gRPCGatewayEp string
execPath string
pluginDir string
outputFile string
pluginDir string
// sets the "avalanchego" exec path
execPath string
vmGenesisPath string
outputPath string
mode string
skipNetworkRunnerStart bool
skipNetworkRunnerShutdown bool
)
func init() {
@@ -75,22 +87,23 @@ func init() {
"VM genesis file path",
)
flag.StringVar(
&outputPath,
&outputFile,
"output-path",
"",
"output YAML path to write local cluster information",
)
flag.StringVar(
&mode,
"mode",
"test",
"'test' to shut down cluster after tests, 'run' to skip tests and only run without shutdown",
flag.BoolVar(
&skipNetworkRunnerStart,
"skip-network-runner-start",
false,
"'true' to skip network runner start",
)
flag.BoolVar(
&skipNetworkRunnerShutdown,
"skip-network-runner-shutdown",
false,
"'true' to skip network runner shutdown",
)
}
func GetOutputPath() string {
return outputPath
}
const vmName = "subnetevm"
@@ -108,15 +121,127 @@ func init() {
}
}
var subnetEVMRPCEps []string
var _ = ginkgo.BeforeSuite(func() {
utils.SetOutputFile(outputPath)
utils.SetOutputFile(outputFile)
utils.SetPluginDir(pluginDir)
utils.SetExecPath(execPath)
utils.SetPluginDir(pluginDir)
utils.SetVmGenesisPath(vmGenesisPath)
utils.SetSkipNetworkRunnerStart(skipNetworkRunnerStart)
utils.SetSkipNetworkRunnerShutdown(skipNetworkRunnerShutdown)
err := runner.InitializeRunner(execPath, gRPCEp, networkRunnerLogLevel)
gomega.Expect(err).Should(gomega.BeNil())
if utils.GetSkipNetworkRunnerStart() {
return
}
runnerCli := runner.GetClient()
gomega.Expect(runnerCli).ShouldNot(gomega.BeNil())
ginkgo.By("calling start API via network runner", func() {
outf("{{green}}sending 'start' with binary path:{{/}} %q\n", utils.GetExecPath())
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
resp, err := runnerCli.Start(
ctx,
utils.GetExecPath(),
client.WithPluginDir(utils.GetPluginDir()),
client.WithBlockchainSpecs(
[]*rpcpb.BlockchainSpec{
{
VmName: vmName,
Genesis: utils.GetVmGenesisPath(),
},
},
))
cancel()
gomega.Expect(err).Should(gomega.BeNil())
outf("{{green}}successfully started:{{/}} %+v\n", resp.ClusterInfo.NodeNames)
})
// TODO: network runner health should imply custom VM healthiness
// or provide a separate API for custom VM healthiness
// "start" is async, so wait some time for cluster health
outf("\n{{magenta}}sleeping before checking custom VM status...{{/}}\n")
time.Sleep(2 * time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
_, err = runnerCli.Health(ctx)
cancel()
gomega.Expect(err).Should(gomega.BeNil())
subnetEVMRPCEps = make([]string, 0)
blockchainID, logsDir := "", ""
// wait up to 5-minute for custom VM installation
outf("\n{{magenta}}waiting for all custom VMs to report healthy...{{/}}\n")
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Minute)
done:
for ctx.Err() == nil {
select {
case <-ctx.Done():
break done
case <-time.After(5 * time.Second):
}
outf("{{magenta}}checking custom VM status{{/}}\n")
cctx, ccancel := context.WithTimeout(context.Background(), 2*time.Minute)
resp, err := runnerCli.Status(cctx)
ccancel()
gomega.Expect(err).Should(gomega.BeNil())
// all logs are stored under root data dir
logsDir = resp.GetClusterInfo().GetRootDataDir()
for blkChainID, vmInfo := range resp.ClusterInfo.CustomChains {
if vmInfo.VmId == vmID.String() {
blockchainID = blkChainID
outf("{{blue}}subnet-evm is ready:{{/}} %+v\n", vmInfo)
break done
}
}
}
gomega.Expect(ctx.Err()).Should(gomega.BeNil())
cancel()
gomega.Expect(blockchainID).Should(gomega.Not(gomega.BeEmpty()))
gomega.Expect(logsDir).Should(gomega.Not(gomega.BeEmpty()))
cctx, ccancel := context.WithTimeout(context.Background(), 2*time.Minute)
uris, err := runnerCli.URIs(cctx)
ccancel()
gomega.Expect(err).Should(gomega.BeNil())
outf("{{blue}}avalanche HTTP RPCs URIs:{{/}} %q\n", uris)
for _, u := range uris {
rpcEP := fmt.Sprintf("%s/ext/bc/%s/rpc", u, blockchainID)
subnetEVMRPCEps = append(subnetEVMRPCEps, rpcEP)
outf("{{blue}}avalanche subnet-evm RPC:{{/}} %q\n", rpcEP)
}
pid := os.Getpid()
outf("{{blue}}{{bold}}writing output %q with PID %d{{/}}\n", utils.GetOutputPath(), pid)
ci := clusterInfo{
URIs: uris,
Endpoint: fmt.Sprintf("/ext/bc/%s", blockchainID),
PID: pid,
LogsDir: logsDir,
}
gomega.Expect(ci.Save(utils.GetOutputPath())).Should(gomega.BeNil())
b, err := os.ReadFile(utils.GetOutputPath())
gomega.Expect(err).Should(gomega.BeNil())
outf("\n{{blue}}$ cat %s:{{/}}\n%s\n", utils.GetOutputPath(), string(b))
})
var _ = ginkgo.AfterSuite(func() {
if utils.GetSkipNetworkRunnerShutdown() {
return
}
// if cluster is running, shut it down
running := runner.IsRunnerUp()
if running {
@@ -126,3 +251,35 @@ var _ = ginkgo.AfterSuite(func() {
err := runner.ShutdownClient()
gomega.Expect(err).Should(gomega.BeNil())
})
// Outputs to stdout.
//
// e.g.,
// Out("{{green}}{{bold}}hi there %q{{/}}", "aa")
// Out("{{magenta}}{{bold}}hi therea{{/}} {{cyan}}{{underline}}b{{/}}")
//
// ref.
// https://github.com/onsi/ginkgo/blob/v2.0.0/formatter/formatter.go#L52-L73
//
func outf(format string, args ...interface{}) {
s := formatter.F(format, args...)
fmt.Fprint(formatter.ColorableStdOut, s)
}
// clusterInfo represents the local cluster information.
type clusterInfo struct {
URIs []string `json:"uris"`
Endpoint string `json:"endpoint"`
PID int `json:"pid"`
LogsDir string `json:"logsDir"`
}
const fsModeWrite = 0o600
func (ci clusterInfo) Save(p string) error {
ob, err := yaml.Marshal(ci)
if err != nil {
return err
}
return os.WriteFile(p, ob, fsModeWrite)
}
+3 -3
View File
@@ -8,11 +8,11 @@ import (
"context"
"time"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/ava-labs/subnet-evm/tests/e2e/runner"
"github.com/ava-labs/subnet-evm/tests/e2e/utils"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)
var _ = utils.DescribeLocal("[Ping]", func() {
+4 -5
View File
@@ -1,20 +1,19 @@
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Implements ping tests, requires network-runner cluster.
// Implements solidity tests.
package solidity
import (
"fmt"
"os/exec"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/ava-labs/subnet-evm/plugin/evm"
"github.com/ava-labs/subnet-evm/tests/e2e/runner"
"github.com/ava-labs/subnet-evm/tests/e2e/utils"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
)
const vmName = "subnetevm"
+78 -2
View File
@@ -1,22 +1,98 @@
package utils
import "sync"
var (
mu sync.RWMutex
outputFile string
pluginDir string
// executable path for "avalanchego"
execPath string
vmGenesisPath string
skipNetworkRunnerStart bool
skipNetworkRunnerShutdown bool
)
func SetOutputFile(filepath string) {
mu.Lock()
outputFile = filepath
mu.Unlock()
}
func GetOutputPath() string {
return outputFile
mu.RLock()
e := outputFile
mu.RUnlock()
return e
}
// Sets the executable path for "avalanchego".
func SetExecPath(p string) {
mu.Lock()
execPath = p
mu.Unlock()
}
// Loads the executable path for "avalanchego".
func GetExecPath() string {
mu.RLock()
e := execPath
mu.RUnlock()
return e
}
func SetPluginDir(dir string) {
mu.Lock()
pluginDir = dir
mu.Unlock()
}
func GetPluginDir() string {
return pluginDir
mu.RLock()
p := pluginDir
mu.RUnlock()
return p
}
func SetVmGenesisPath(p string) {
mu.Lock()
vmGenesisPath = p
mu.Unlock()
}
func GetVmGenesisPath() string {
mu.RLock()
p := vmGenesisPath
mu.RUnlock()
return p
}
func SetSkipNetworkRunnerStart(b bool) {
mu.Lock()
skipNetworkRunnerStart = b
mu.Unlock()
}
func GetSkipNetworkRunnerStart() bool {
mu.RLock()
b := skipNetworkRunnerStart
mu.RUnlock()
return b
}
func SetSkipNetworkRunnerShutdown(b bool) {
mu.Lock()
skipNetworkRunnerShutdown = b
mu.Unlock()
}
func GetSkipNetworkRunnerShutdown() bool {
mu.RLock()
b := skipNetworkRunnerShutdown
mu.RUnlock()
return b
}