Skip to content

Commit

Permalink
feat: Stress test final (#681)
Browse files Browse the repository at this point in the history
* Add stress test functionality

* added some extra wait time to run more consistently locally

* manually increment nonce on zevm withdraw, reduced deposit amount from goerli

* added tx rate calculation to stress test metrics

* aggressive outbound tx scheduling parameters

* paramters tuning

* paramters tuning

* paramters tuning

* manually clear p2p streams when stuck

* add logs to contrast StreamMgr & libp2p view of all streams

* add goroutine logs to debug leak

* changed endpoints of stress test to be configurable, cleaned up rate calculation. Separated smoke test and stress test into different commands

* pass chainID as part of query for pending cctx's

* update stress test

* revert changes to zetacore

* reverting tss signers to nil - only used for leaderless signing.

---------

Co-authored-by: brewmaster012 <>
  • Loading branch information
kevinssgh authored Jun 8, 2023
1 parent 85968c3 commit af92db4
Show file tree
Hide file tree
Showing 15 changed files with 339 additions and 58 deletions.
32 changes: 12 additions & 20 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM golang:1.19-alpine AS builder
FROM golang:1.19-alpine

ENV GOPATH /go
ENV GOOS=linux
ENV CGO_ENABLED=1

RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers
RUN apk --no-cache add git make build-base jq openssh libusb-dev linux-headers bash curl tmux
RUN ssh-keygen -b 2048 -t rsa -f /root/.ssh/localtest.pem -q -N ""

WORKDIR /go/delivery/zeta-node
Expand All @@ -18,34 +18,26 @@ RUN --mount=type=cache,target=/root/.cache/go-build \
make install
RUN --mount=type=cache,target=/root/.cache/go-build \
make install-smoketest
#
#FROM golang:1.19-alpine

FROM golang:1.19-alpine

RUN apk --no-cache add openssh jq tmux vim curl bash
#RUN apk --no-cache add openssh jq tmux vim curl bash
RUN ssh-keygen -A
WORKDIR /root

RUN cp /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys

COPY --from=builder /root/.ssh/localtest.pem.pub /root/.ssh/authorized_keys
COPY --from=builder /root/.ssh/localtest.pem.pub /root/.ssh/localtest.pem.pub
COPY --from=builder /root/.ssh/localtest.pem /root/.ssh/localtest.pem
COPY --from=builder /go/bin/zetaclientd /usr/local/bin
COPY --from=builder /go/bin/zetacored /usr/local/bin
COPY --from=builder /go/bin/smoketest /usr/local/bin
RUN cp /go/bin/zetaclientd /usr/local/bin
RUN cp /go/bin/zetacored /usr/local/bin
RUN cp /go/bin/smoketest /usr/local/bin

COPY contrib/localnet/scripts /root
COPY contrib/localnet/preparams /root/preparams
COPY contrib/localnet/ssh_config /root/.ssh/config
COPY contrib/localnet/zetacored /root/zetacored
COPY contrib/localnet/tss /root/tss

RUN chmod 755 /root/reset-testnet.sh
RUN chmod 755 /root/start-zetacored.sh
RUN chmod 755 /root/start-zetaclientd.sh
RUN chmod 755 /root/start-zetaclientd-genesis.sh
RUN chmod 755 /root/genesis.sh
RUN chmod 755 /root/seed.sh
RUN chmod 755 /root/keygen.sh
RUN chmod 755 /root/os-info.sh
RUN chmod 755 /root/start-zetaclientd-p2p-diag.sh
RUN chmod 755 /root/*.sh

WORKDIR /usr/local/bin
ENV SHELL /bin/sh
Expand Down
1 change: 1 addition & 0 deletions cmd/zetaclientd/keygen_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func keygenTss(cfg *config.Config, tss *mc.TSS, logger zerolog.Logger) error {
return err
}
tss.CurrentPubkey = res.PubKey
tss.Signers = cfg.KeyGenPubKeys

// Keygen succeed! Report TSS address
keygenLogger.Debug().Msgf("Keygen success! keygen response: %v", res)
Expand Down
5 changes: 4 additions & 1 deletion contrib/localnet/docker-compose-stresstest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.21
ports:
- "8123:8123"

entrypoint: /root/start-zetaclientd-genesis.sh
environment:
- ETHDEV_ENDPOINT=http://eth:8545
Expand Down Expand Up @@ -158,4 +161,4 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.2
entrypoint: /work/start.sh
entrypoint: ["/work/start.sh", "stress"]
2 changes: 1 addition & 1 deletion contrib/localnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,5 @@ services:
networks:
mynetwork:
ipv4_address: 172.20.0.2
entrypoint: /work/start.sh
entrypoint: ["/work/start.sh", "local"]

68 changes: 41 additions & 27 deletions contrib/localnet/orchestrator/smoketest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ package main
import (
"context"
"fmt"
"github.com/btcsuite/btcutil"
"github.com/spf13/cobra"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/zevmswap"
"github.com/zeta-chain/zetacore/zetaclient/config"
"math/big"
"os"
"sync"
"time"

"github.com/btcsuite/btcutil"
flag "github.com/spf13/pflag"
"github.com/zeta-chain/zetacore/contrib/localnet/orchestrator/smoketest/contracts/zevmswap"
"github.com/zeta-chain/zetacore/zetaclient/config"

"github.com/btcsuite/btcd/rpcclient"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
ethcommon "github.com/ethereum/go-ethereum/common"
Expand All @@ -39,9 +38,9 @@ var (
DeployerPrivateKey = "d87baf7bf6dc560a252596678c12e41f7d1682837f05b29d411bc3f78ae2c263"
TSSAddress = ethcommon.HexToAddress("0x0Da38EA1B43758F55eB97590D41e244913A00b26")
BTCTSSAddress, _ = btcutil.DecodeAddress("bcrt1q78nlhm7mr7t6z8a93z3y93k75ftppcukt5ayay", config.BitconNetParams)
BLOCK = 5 * time.Second // should be 2x block time
BLOCK = 2 * time.Second // should be 2x block time
BigZero = big.NewInt(0)
SmokeTestTimeout = 35 * time.Minute // smoke test fails if timeout is reached
SmokeTestTimeout = 24 * time.Hour // smoke test fails if timeout is reached
USDTZRC20Addr = "0x48f80608B672DC30DC7e3dbBd0343c5F02C738Eb"
USDTERC20Addr = "0xff3135df4F2775f4091b81f4c7B6359CfA07862a"
ERC20CustodyAddr = "0xD28D6A0b8189305551a0A8bd247a6ECa9CE781Ca"
Expand Down Expand Up @@ -88,6 +87,21 @@ type SmokeTest struct {
SystemContractAddr ethcommon.Address
}

var RootCmd = &cobra.Command{
Use: "smoketest",
Short: "Smoke Test CLI",
}

var LocalCmd = &cobra.Command{
Use: "local",
Short: "Run Local Smoketest",
Run: LocalSmokeTest,
}

func init() {
RootCmd.AddCommand(LocalCmd)
}

func NewSmokeTest(goerliClient *ethclient.Client, zevmClient *ethclient.Client,
cctxClient types.QueryClient, fungibleClient fungibletypes.QueryClient,
goerliAuth *bind.TransactOpts, zevmAuth *bind.TransactOpts,
Expand Down Expand Up @@ -135,11 +149,7 @@ func NewSmokeTest(goerliClient *ethclient.Client, zevmClient *ethclient.Client,
}
}

func main() {
var enableGenesis bool
flag.BoolVar(&enableGenesis, "genesis", false, "Wait for genesis initialization.")
flag.Parse()

func LocalSmokeTest(_ *cobra.Command, _ []string) {
testStartTime := time.Now()
defer func() {
fmt.Println("Smoke test took", time.Since(testStartTime))
Expand Down Expand Up @@ -195,22 +205,19 @@ func main() {
cctxClient := types.NewQueryClient(grpcConn)
fungibleClient := fungibletypes.NewQueryClient(grpcConn)

// Wait for Genesis and keygen to be completed. ~ height 10
fmt.Println("ENABLE GENESIS VALUE: ", enableGenesis)
if !enableGenesis {
// time.Sleep(time.Second * 20)
for {
time.Sleep(5 * time.Second)
response, err := cctxClient.LastZetaHeight(context.Background(), &types.QueryLastZetaHeightRequest{})
if err != nil {
fmt.Printf("cctxClient.LastZetaHeight error: %s", err)
continue
}
if response.Height >= 30 {
break
}
fmt.Printf("Last ZetaHeight: %d\n", response.Height)
// Wait for Genesis and keygen to be completed. ~ height 30
time.Sleep(20 * time.Second)
for {
time.Sleep(5 * time.Second)
response, err := cctxClient.LastZetaHeight(context.Background(), &types.QueryLastZetaHeightRequest{})
if err != nil {
fmt.Printf("cctxClient.LastZetaHeight error: %s", err)
continue
}
if response.Height >= 30 {
break
}
fmt.Printf("Last ZetaHeight: %d\n", response.Height)
}

// get the clients for tests
Expand Down Expand Up @@ -279,3 +286,10 @@ func main() {

smokeTest.wg.Wait()
}

func main() {
if err := RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
}
}
Loading

0 comments on commit af92db4

Please sign in to comment.