From 58e2e60356bfaaa9d541186b1d7eba7f4ac6e00c Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Thu, 28 Sep 2023 20:42:24 +0100 Subject: [PATCH 1/8] feat: Adding stop order support in perftool --- CHANGELOG.md | 1 + cmd/perftest.go | 1 + go.mod | 9 +++---- go.sum | 23 +++++++--------- perftest/perftest.go | 62 ++++++++++++++++++++++++++++++++++++++++++++ perftest/wallet.go | 23 ++++++++++++++++ 6 files changed, 100 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a3ba869..7e5cfc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,6 +75,7 @@ - [281](https://github.com/vegaprotocol/vegatools/issues/281) - add a toggle to perftest to enable/disable lp users from creating initial orders - [288](https://github.com/vegaprotocol/vegatools/issues/288) - stop processing per testing if the number of price levels is greater than the mid price - [297](https://github.com/vegaprotocol/vegatools/issues/297) - update perftool to use the new SLA liquidity system +- [304](https://github.com/vegaprotocol/vegatools/issues/304) - update perftool to support stop orders ### 🐛 Fixes diff --git a/cmd/perftest.go b/cmd/perftest.go index 1e4a7f93..93729fe3 100644 --- a/cmd/perftest.go +++ b/cmd/perftest.go @@ -33,6 +33,7 @@ func init() { perfTestCmd.Flags().IntVarP(&opts.PriceLevels, "pricelevels", "L", 100, "number of price levels per side") perfTestCmd.Flags().IntVarP(&opts.SLAUpdateSeconds, "slaupdate", "S", 10, "number of seconds between SLA updates") perfTestCmd.Flags().IntVarP(&opts.SLAPriceLevels, "slapricelevels", "l", 3, "number of price levels for SLA orders") + perfTestCmd.Flags().IntVarP(&opts.StopOrders, "stoporders", "d", 0, "number of stop orders per user") perfTestCmd.Flags().Int64VarP(&opts.StartingMidPrice, "startingmidprice", "s", 10000, "mid price to use at the start") perfTestCmd.Flags().BoolVarP(&opts.MoveMid, "movemidprice", "M", false, "allow the mid price we place orders around to move randomly") perfTestCmd.Flags().BoolVarP(&opts.FillPriceLevels, "fillpricelevel", "F", false, "place an order at every available price level") diff --git a/go.mod b/go.mod index d688b820..bdecb313 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module code.vegaprotocol.io/vegatools go 1.19 require ( - code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f - code.vegaprotocol.io/vega v0.72.8 + code.vegaprotocol.io/shared v0.0.0-20230119125558-bda6563e1c7a + code.vegaprotocol.io/vega v0.73.0-preview.8 + github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/iavl v0.20.0 github.com/ethereum/go-ethereum v1.11.6 github.com/gdamore/tcell/v2 v2.5.2 @@ -21,12 +22,9 @@ require ( require ( github.com/StackExchange/wmi v1.2.1 // indirect - github.com/btcsuite/btcd v0.22.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect - github.com/cometbft/cometbft-db v0.7.0 // indirect github.com/confio/ics23/go v0.9.0 // indirect - github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/deckarep/golang-set/v2 v2.1.0 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect @@ -35,6 +33,7 @@ require ( github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect github.com/didip/tollbooth/v7 v7.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/fatih/structs v1.1.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gdamore/encoding v1.0.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect diff --git a/go.sum b/go.sum index cb011e53..c610f672 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ -code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f h1:ivaWSXN7XKESShqYw/QFuT6b2mvThWPQLO7lW5sadHs= -code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f/go.mod h1:XzX67GsyOHzvytMr0QOHX4CCTdCZDYKUUi88rx40Nt0= -code.vegaprotocol.io/vega v0.72.8 h1:WLIrubFNF/rpDHqmdS2HGWv/jUphjuBk7pS5AWgm6Eo= -code.vegaprotocol.io/vega v0.72.8/go.mod h1:4jz+8jy99maf7bop6JkxeyQplI+d+mmdf8Zgk+REyBg= +code.vegaprotocol.io/shared v0.0.0-20230119125558-bda6563e1c7a h1:sgniM6sgxPKAStJo2rNoYJR3NMlS/t55H12lvynkw5c= +code.vegaprotocol.io/shared v0.0.0-20230119125558-bda6563e1c7a/go.mod h1:XzX67GsyOHzvytMr0QOHX4CCTdCZDYKUUi88rx40Nt0= +code.vegaprotocol.io/vega v0.73.0-preview.8 h1:JhV92aCVUwBu+byA9Jy7Cxdf9j4IIJyj8Oiy8seE1OU= +code.vegaprotocol.io/vega v0.73.0-preview.8/go.mod h1:GVK9Ex2zdERQGOMsre49eVrlAPprkHe8M2l8O2MnBRM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= @@ -10,11 +10,10 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= -github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E= github.com/btcsuite/btcd/btcec/v2 v2.2.1/go.mod h1:9/CSmJxmuvqzX9Wh2fXMWToLOHhPd11lSPuIupwTkI8= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= @@ -36,8 +35,6 @@ github.com/confio/ics23/go v0.9.0/go.mod h1:4LPZ2NYqnYIVRklaozjNR1FScgDJ2s5Xrp+e github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= -github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.20.0 h1:fTVznVlepH0KK8NyKq8w+U7c2L6jofa27aFX6YGlm38= github.com/cosmos/iavl v0.20.0/go.mod h1:WO7FyvaZJoH65+HFOsDir7xU9FWk2w9cHXNW1XHcl7A= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= @@ -50,6 +47,7 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -69,6 +67,8 @@ github.com/ethereum/go-ethereum v1.11.6/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSo github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -169,7 +169,6 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLA github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= -github.com/oasisprotocol/curve25519-voi v0.0.0-20220317090546-adb2f9614b17 h1:pxR+aWfo+famermIZvD+SiDQ3qmF7Iy2VPZuEsKTMtA= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -183,7 +182,6 @@ github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAl github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -197,13 +195,13 @@ github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= @@ -238,9 +236,6 @@ github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a h1:1ur3QoCqvE5f github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a/go.mod h1:RRCYJbIwD5jmqPI9XoAFR0OcDxqUctll6zUj/+B4S48= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= -github.com/tendermint/tendermint v0.35.9 h1:yUEgfkcNHWSidsU8wHjRDbYPVijV4cHxCclKVITGRAQ= -github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= -github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0 h1:E53Dm1HjH1/R2/aoCtXtPgzmElmn51aOkhCFSuZq//o= diff --git a/perftest/perftest.go b/perftest/perftest.go index d31e7341..a75bda23 100644 --- a/perftest/perftest.go +++ b/perftest/perftest.go @@ -38,6 +38,7 @@ type Opts struct { PriceLevels int SLAUpdateSeconds int SLAPriceLevels int + StopOrders int StartingMidPrice int64 FillPriceLevels bool InitialiseOnly bool @@ -396,6 +397,57 @@ func (p *perfLoadTesting) seedPriceLevels(marketIDs []string, opts Opts) error { return nil } +func (p *perfLoadTesting) seedStopOrders(marketIDs []string, opts Opts) error { + // We need to go through all markets and all users + for _, marketID := range marketIDs { + order := &commandspb.OrderSubmission{ + MarketId: marketID, + Size: 1, + Side: proto.Side_SIDE_SELL, + Type: proto.Order_TYPE_MARKET, + Reference: "StopLossOrder", + ReduceOnly: true, + TimeInForce: proto.Order_TIME_IN_FORCE_IOC} + for userOffset := opts.LpUserCount; userOffset < (opts.LpUserCount + opts.NormalUserCount); userOffset++ { + user := p.users[userOffset] + + // We need a position before we can place a stop order + err := p.wallet.SendOrder(user, &commandspb.OrderSubmission{ + MarketId: marketID, + Size: 1, + Side: proto.Side_SIDE_BUY, + Type: proto.Order_TYPE_MARKET, + TimeInForce: proto.Order_TIME_IN_FORCE_IOC, + }) + if err != nil { + return err + } + + time.Sleep(1 * time.Second) + + sos := &commandspb.StopOrdersSubmission{ + RisesAbove: &commandspb.StopOrderSetup{ + OrderSubmission: order, + Trigger: &commandspb.StopOrderSetup_Price{ + Price: fmt.Sprint(opts.StartingMidPrice + 1000), + }, + }, + FallsBelow: &commandspb.StopOrderSetup{ + OrderSubmission: order, + Trigger: &commandspb.StopOrderSetup_Price{ + Price: fmt.Sprint(opts.StartingMidPrice - 1000), + }, + }, + } + err = p.wallet.SendStopOrder(user, sos) + if err != nil { + return err + } + } + } + return nil +} + func (p *perfLoadTesting) sendSLAOrders(marketID string, deleteFirst bool, opts Opts) error { for l := 0; l < opts.LpUserCount; l++ { batch := &BatchOrders{} @@ -780,6 +832,16 @@ func Run(opts Opts) error { fmt.Println("Complete") } + // Do we need to place stop orders for all users + if opts.StopOrders > 0 { + err = plt.seedStopOrders(marketIDs, opts) + if err != nil { + fmt.Println("FAILED") + return err + } + fmt.Println("Complete") + } + // If we are only initialising, stop now and return if opts.InitialiseOnly { // Make one more check that assets are topped up diff --git a/perftest/wallet.go b/perftest/wallet.go index 0a50c45f..ce4ab9eb 100644 --- a/perftest/wallet.go +++ b/perftest/wallet.go @@ -10,6 +10,7 @@ import ( proto "code.vegaprotocol.io/vega/protos/vega" commandspb "code.vegaprotocol.io/vega/protos/vega/commands/v1" + "google.golang.org/protobuf/encoding/protojson" ) // WalletWrapper holds details about the wallet @@ -42,6 +43,22 @@ type listKeysResult struct { ID string } +func (w walletWrapper) sendTransactionString(user UserDetails, subType string, subData string) ([]byte, error) { + transactionStr := `{ + "jsonrpc": "2.0", + "method": "client.send_transaction", + "id": "1", + "params": { + "publicKey":"` + user.pubKey + `", + "sendingMode": "TYPE_SYNC", + "transaction":{"` + subType + `":` + subData + ` + } + } + }` + + return w.sendRequest([]byte(transactionStr), user.token) +} + func (w walletWrapper) sendTransaction(user UserDetails, subType string, subData interface{}) ([]byte, error) { transaction, _ := json.Marshal(map[string]interface{}{ "jsonrpc": "2.0", @@ -213,6 +230,12 @@ func (w walletWrapper) GetFirstKey(longLivedToken string) (string, error) { return "", nil } +func (w *walletWrapper) SendStopOrder(user UserDetails, sos *commandspb.StopOrdersSubmission) error { + sosString, _ := protojson.Marshal(sos) + _, err := w.sendTransactionString(user, "stopOrdersSubmission", string(sosString)) + return err +} + // SendBatchOrders sends a set of new order commands to the wallet func (w *walletWrapper) SendBatchOrders(user UserDetails, cancels []*commandspb.OrderCancellation, From 199621f22c028b76bb475cef6b70e8bb389da13e Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Fri, 29 Sep 2023 10:31:19 +0100 Subject: [PATCH 2/8] fix: Added stop order limit check --- perftest/perftest.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/perftest/perftest.go b/perftest/perftest.go index a75bda23..345a2048 100644 --- a/perftest/perftest.go +++ b/perftest/perftest.go @@ -217,6 +217,18 @@ func (p *perfLoadTesting) checkNetworkLimits(opts Opts) error { return fmt.Errorf("supplied order batch size is greater than network param (%d>%d)", opts.BatchSize, maxBatchSize) } + // Check the maximum number of stop orders per market per user + networkParam, err = p.dataNode.getNetworkParam("spam.protection.max.stopOrdersPerMarket") + if err != nil { + fmt.Println("Failed to get maximum order batch size") + return err + } + maxStopOrders, _ := strconv.ParseInt(networkParam, 0, 32) + + if opts.StopOrders > int(maxStopOrders) { + return fmt.Errorf("supplied stop orders size is greater than network param (%d>%d)", opts.StopOrders, maxStopOrders) + } + // Make sure if we are adding price levels that we have enough space to put them all in given the mid price if opts.FillPriceLevels { if opts.PriceLevels > int(opts.StartingMidPrice) { From a8b1d00de15a6967e104017855d0b18e98e9d1cc Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Mon, 2 Oct 2023 12:35:16 +0100 Subject: [PATCH 3/8] fix: Added correct logging --- perftest/perftest.go | 1 + 1 file changed, 1 insertion(+) diff --git a/perftest/perftest.go b/perftest/perftest.go index 345a2048..8e30590b 100644 --- a/perftest/perftest.go +++ b/perftest/perftest.go @@ -846,6 +846,7 @@ func Run(opts Opts) error { // Do we need to place stop orders for all users if opts.StopOrders > 0 { + fmt.Print("Adding stop orders for every user and market...") err = plt.seedStopOrders(marketIDs, opts) if err != nil { fmt.Println("FAILED") From cf3a5edf19299f060b43a57ed25fd1f0ee3dc8cc Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Mon, 2 Oct 2023 14:57:16 +0100 Subject: [PATCH 4/8] fix: Added new liquidity monitoring params to market proposal --- perftest/wallet.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/perftest/wallet.go b/perftest/wallet.go index ce4ab9eb..23e55aa2 100644 --- a/perftest/wallet.go +++ b/perftest/wallet.go @@ -200,6 +200,14 @@ func (w walletWrapper) NewMarket(offset int, user UserDetails) error { "performanceHysteresisEpochs": 60, "slaCompetitionFactor": "1.0", }, + "liquidityMonitoringParameters": map[string]interface{}{ + "targetStakeParameters": map[string]interface{}{ + "timeWindow": "100", + "scalingFactor": "1.0", + }, + "triggeringRatio": "1.0", + "auctionExtension": "10", + }, }, }, }, From f52a6f15f45ac31aa43254709fa4c085867aa32d Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Mon, 2 Oct 2023 16:12:36 +0100 Subject: [PATCH 5/8] fix: Updated golang to version 1.20 --- .github/workflows/go-coverage.yml | 2 +- .github/workflows/go.yml | 2 +- go.mod | 3 +-- go.sum | 5 ----- networkhistorydivergencetool/go.mod | 2 +- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.github/workflows/go-coverage.yml b/.github/workflows/go-coverage.yml index aa21b27d..5dc97c2a 100644 --- a/.github/workflows/go-coverage.yml +++ b/.github/workflows/go-coverage.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.19 + go-version: 1.20 id: go - name: Check out code diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a6a900c5..f5b74d45 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - go: ['1.19'] + go: ['1.20'] steps: - name: Set up Go ${{ matrix.go }} uses: actions/setup-go@v2 diff --git a/go.mod b/go.mod index bdecb313..21d4c7f6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module code.vegaprotocol.io/vegatools -go 1.19 +go 1.20 require ( code.vegaprotocol.io/shared v0.0.0-20230119125558-bda6563e1c7a @@ -33,7 +33,6 @@ require ( github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect github.com/didip/tollbooth/v7 v7.0.1 // indirect github.com/dustin/go-humanize v1.0.1 // indirect - github.com/fatih/structs v1.1.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/gdamore/encoding v1.0.0 // indirect github.com/go-ole/go-ole v1.2.6 // indirect diff --git a/go.sum b/go.sum index c610f672..a58a0945 100644 --- a/go.sum +++ b/go.sum @@ -10,7 +10,6 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -47,7 +46,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= -github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= @@ -67,8 +65,6 @@ github.com/ethereum/go-ethereum v1.11.6/go.mod h1:+a8pUj1tOyJ2RinsNQD4326YS+leSo github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= -github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= -github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= @@ -195,7 +191,6 @@ github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= diff --git a/networkhistorydivergencetool/go.mod b/networkhistorydivergencetool/go.mod index 0d4fbd63..69a017e8 100644 --- a/networkhistorydivergencetool/go.mod +++ b/networkhistorydivergencetool/go.mod @@ -1,6 +1,6 @@ module networkhistorydivergencetool -go 1.19 +go 1.20 require ( github.com/benbjohnson/clock v1.3.0 // indirect From f8354589a65013d2758cf8f3dace35c344626c3d Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Mon, 2 Oct 2023 16:17:46 +0100 Subject: [PATCH 6/8] fix: Updated golang to version 1.20 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a4ede3c9..309fea3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.19-alpine AS builder +FROM golang:1.20-alpine AS builder # Install git: required for fetching the Go dependencies. RUN apk update && apk add --no-cache git ENV GOPROXY=direct GOSUMDB=off From 26633275ac63fa32a4ba8989d20273b3152e6a30 Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Mon, 2 Oct 2023 16:33:34 +0100 Subject: [PATCH 7/8] fix: Updated golang to version 1.20.8 --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index f5b74d45..c4153377 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - go: ['1.20'] + go: ['1.20.8'] steps: - name: Set up Go ${{ matrix.go }} uses: actions/setup-go@v2 From be71de2e68c9aeb2340095505cff68a22e5c7c9d Mon Sep 17 00:00:00 2001 From: Peter Barrow Date: Mon, 2 Oct 2023 16:38:50 +0100 Subject: [PATCH 8/8] fix: Updated golang to version 1.20 --- .github/workflows/go-coverage.yml | 2 +- .github/workflows/go.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go-coverage.yml b/.github/workflows/go-coverage.yml index 5dc97c2a..51cc1f57 100644 --- a/.github/workflows/go-coverage.yml +++ b/.github/workflows/go-coverage.yml @@ -16,7 +16,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.20 + go-version: '1.20' id: go - name: Check out code diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index c4153377..f5b74d45 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - go: ['1.20.8'] + go: ['1.20'] steps: - name: Set up Go ${{ matrix.go }} uses: actions/setup-go@v2