diff --git a/cmd/perftest.go b/cmd/perftest.go index 6365d91..5a8ca06 100644 --- a/cmd/perftest.go +++ b/cmd/perftest.go @@ -42,6 +42,7 @@ func init() { perfTestCmd.Flags().BoolVarP(&opts.UseLPsForOrders, "uselpsfororders", "U", true, "allow lp users to place orders during setup") perfTestCmd.Flags().BoolVarP(&opts.BatchOnly, "batchonly", "B", false, "all transactions are sent in batches") perfTestCmd.Flags().BoolVarP(&opts.SpotMarkets, "spotmarkets", "P", false, "use spot markets") + perfTestCmd.Flags().BoolVarP(&opts.AMMs, "amms", "A", false, "send AMMs") perfTestCmd.MarkFlagRequired("address") perfTestCmd.MarkFlagRequired("wallet") perfTestCmd.MarkFlagRequired("faucet") diff --git a/go.mod b/go.mod index efe70d5..0d0efda 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.5 require ( code.vegaprotocol.io/shared v0.0.0-20230119125558-bda6563e1c7a - code.vegaprotocol.io/vega v0.76.0 + code.vegaprotocol.io/vega v0.76.2-0.20240520130421-ff0404a4a6cc github.com/cometbft/cometbft-db v0.7.0 github.com/cosmos/iavl v0.20.0 github.com/ethereum/go-ethereum v1.11.6 @@ -66,7 +66,7 @@ require ( go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.25.0 // indirect golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/sync v0.6.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/term v0.18.0 // indirect diff --git a/go.sum b/go.sum index 7751275..5150a37 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,7 @@ 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.76.0 h1:Xl+OnHhnEpZ7N1Y4EqbQSsRca2iwFyBTnCBGMqa5muQ= -code.vegaprotocol.io/vega v0.76.0/go.mod h1:oTKpFh+pTLJaDcjkdkSS0BhTm5miMRkduNxaabuY0cE= +code.vegaprotocol.io/vega v0.76.2-0.20240520130421-ff0404a4a6cc h1:6SBDA1BDWWGPBv4Pmie7YS8MGkAgF+KBFRZTkpka1m8= +code.vegaprotocol.io/vega v0.76.2-0.20240520130421-ff0404a4a6cc/go.mod h1:8BBcogM5b/HtC6gz0TCnhQ1ks7uPMDgQVs1NXmBS6MU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -331,8 +331,8 @@ golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/perftest/perftest.go b/perftest/perftest.go index 3dfb9d4..00c4795 100644 --- a/perftest/perftest.go +++ b/perftest/perftest.go @@ -46,6 +46,7 @@ type Opts struct { UseLPsForOrders bool BatchOnly bool SpotMarkets bool + AMMs bool } type perfLoadTesting struct { @@ -521,8 +522,46 @@ func (p *perfLoadTesting) seedStopOrders(marketIDs []string, opts Opts) error { return nil } +func (p *perfLoadTesting) sendAMMs(marketIDs []string, opts Opts) error { + if opts.DoNotInitialise { + return nil + } + + upperBound := fmt.Sprint(opts.StartingMidPrice + int64(opts.PriceLevels)) + lowerBound := fmt.Sprint(max(1, opts.StartingMidPrice-int64(opts.PriceLevels))) + base := fmt.Sprint(opts.StartingMidPrice) + upperLeverage := "0.1" + lowerLeverage := "0.1" + + // We need to go through all markets and all users + for _, marketID := range marketIDs { + for l := 0; l < opts.LpUserCount; l++ { + user := p.users[l] + amm := &commandspb.SubmitAMM{ + MarketId: marketID, + CommitmentAmount: "2000", + SlippageTolerance: "0.1", + ProposedFee: "0.01", + ConcentratedLiquidityParameters: &commandspb.SubmitAMM_ConcentratedLiquidityParameters{ + UpperBound: &upperBound, + LowerBound: &lowerBound, + Base: base, + LeverageAtUpperBound: &upperLeverage, + LeverageAtLowerBound: &lowerLeverage, + }, + } + err := p.wallet.SendAMM(user, amm) + if err != nil { + return err + } + time.Sleep(time.Millisecond * 250) + } + } + return nil +} + func (p *perfLoadTesting) sendSLAOrders(marketID string, deleteFirst bool, opts Opts) error { - for l := 0; l < opts.LpUserCount; l++ { + /* for l := 0; l < opts.LpUserCount; l++ { batch := &BatchOrders{} if deleteFirst { @@ -573,7 +612,7 @@ func (p *perfLoadTesting) sendSLAOrders(marketID string, deleteFirst bool, opts return err } } - } + }*/ return nil } @@ -895,7 +934,7 @@ func (p *perfLoadTesting) sendBatchOnlyLoad(marketIDs []string, opts Opts) error // Run is the main function of `perftest` package func Run(opts Opts) error { - fmt.Println(opts) + fmt.Printf("%+v\n", 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) @@ -1005,6 +1044,16 @@ func Run(opts Opts) error { return nil } + if opts.AMMs { + fmt.Print("Sending AMM submissions...") + err = plt.sendAMMs(marketIDs, opts) + if err != nil { + fmt.Println("FAILED") + return err + } + fmt.Println("Complete") + } + // Send off a controlled amount of orders and cancels if opts.BatchOnly { fmt.Print("Sending batched load transactions...") diff --git a/perftest/wallet.go b/perftest/wallet.go index 5955421..9077373 100644 --- a/perftest/wallet.go +++ b/perftest/wallet.go @@ -378,3 +378,8 @@ func (w walletWrapper) SendVote(user UserDetails, propID string) error { _, err := w.sendTransaction(user, "voteSubmission", &vote) return err } + +func (w *walletWrapper) SendAMM(user UserDetails, amm *commandspb.SubmitAMM) error { + _, err := w.sendTransaction(user, "submitAmm", amm) + return err +}