Skip to content

Commit

Permalink
Merge pull request #289 from vegaprotocol/288-add-check-for-price-lev…
Browse files Browse the repository at this point in the history
…el-overflow

Check for overflowing price levels
  • Loading branch information
peterbarrow authored Jul 17, 2023
2 parents 1c7d905 + fcd9cdc commit f46bacb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
- [268](https://github.com/vegaprotocol/vegatools/issues/268) - Streamlatency tool to measure latency difference between two different event streams
- [270](https://github.com/vegaprotocol/vegatools/issues/270) - signingrate tool to benchmark a server to see at what rate they can sign transactions
- [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


### 🐛 Fixes
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
code.vegaprotocol.io/shared v0.0.0-20221010085458-55c50711135f
code.vegaprotocol.io/vega v0.70.1-0.20230419150238-cdfb016b9196
code.vegaprotocol.io/vega v0.71.6
github.com/cosmos/iavl v0.19.4
github.com/ethereum/go-ethereum v1.11.2
github.com/gdamore/tcell/v2 v2.5.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
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.70.1-0.20230419150238-cdfb016b9196 h1:HMY/9+XUr8hvq4YI/HkVxuv3ohEbNW6GwEAc22fk13A=
code.vegaprotocol.io/vega v0.70.1-0.20230419150238-cdfb016b9196/go.mod h1:2/tnFImHhnoel/PeX0n5uiNSqdXyHLcLKXRhLENzPSw=
code.vegaprotocol.io/vega v0.71.6 h1:d5+ZOPAq5hpuih+E/XsBTLDoKb1h9ECp0Gsx5vCPdBc=
code.vegaprotocol.io/vega v0.71.6/go.mod h1:2/tnFImHhnoel/PeX0n5uiNSqdXyHLcLKXRhLENzPSw=
contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/Antonboom/errname v0.1.7/go.mod h1:g0ONh16msHIPgJSGsecu1G/dcF2hlYR/0SddnIAGavU=
Expand Down
15 changes: 15 additions & 0 deletions perftest/perftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ func (p *perfLoadTesting) checkNetworkLimits(opts Opts) error {
if opts.BatchSize > int(maxBatchSize) {
return fmt.Errorf("supplied order batch size is greater than network param (%d>%d)", opts.BatchSize, maxBatchSize)
}

// 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) {
return fmt.Errorf("unable to fill price levels because the starting mid price is too low (%d<%d)", opts.StartingMidPrice, opts.PriceLevels)
}
}
return nil
}

Expand Down Expand Up @@ -629,6 +636,7 @@ func (p *perfLoadTesting) sendBatchTradingLoad(marketIDs []string, opts Opts) er
// Run is the main function of `perftest` package
func Run(opts Opts) error {

fmt.Println(opts)
f, err := os.OpenFile("perftest.log", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o666)
if err != nil {
log.Fatalf("error opening file: %v", err)
Expand Down Expand Up @@ -715,6 +723,13 @@ func Run(opts Opts) error {

// If we are only initialising, stop now and return
if opts.InitialiseOnly {
// Make one more check that assets are topped up
err = plt.depositTokens(assets, opts)
if err != nil {
fmt.Println("FAILED")
return err
}

fmt.Println("Initialisation complete")
return nil
}
Expand Down

0 comments on commit f46bacb

Please sign in to comment.