Skip to content

Commit

Permalink
Merge pull request #267 from vegaprotocol/266-correct-governance-call
Browse files Browse the repository at this point in the history
Use correct governance call
  • Loading branch information
jeremyletang authored Feb 21, 2023
2 parents 484f7ed + ea2f6d4 commit e0f23a0
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
- [256](https://github.com/vegaprotocol/vegatools/issues/256) - Fix batch orders
- [260](https://github.com/vegaprotocol/vegatools/issues/260) - Better handling of staking assets in perftool
- [264](https://github.com/vegaprotocol/vegatools/issues/264) - Eventrate tool can now output a simple report and then exit for use in scripts
- [266](https://github.com/vegaprotocol/vegatools/issues/266) - Eventrate tool uses correct gov prop call and new option to only initialise the markets

### 🐛 Fixes
- [78](https://github.com/vegaprotocol/vegatools/pull/78) - Fix build with missing dependency
Expand Down
1 change: 1 addition & 0 deletions cmd/perftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func init() {
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")
perfTestCmd.Flags().BoolVarP(&opts.InitialiseOnly, "initialiseonly", "i", false, "initialise everything and then exit")
perfTestCmd.MarkFlagRequired("address")
perfTestCmd.MarkFlagRequired("wallet")
perfTestCmd.MarkFlagRequired("faucet")
Expand Down
13 changes: 6 additions & 7 deletions perftest/datanode.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,19 @@ func (d *dnWrapper) getPendingProposalID() (string, error) {
}

func (d *dnWrapper) waitForMarketEnactment(marketID string, maxWaitSeconds int) error {
request := &datanode.ListGovernanceDataRequest{
ProposalReference: &marketID,
request := &datanode.GetGovernanceDataRequest{
ProposalId: &marketID,
}

for i := 0; i < maxWaitSeconds; i++ {
response, err := d.dataNode.ListGovernanceData(context.Background(), request)
response, err := d.dataNode.GetGovernanceData(context.Background(), request)
if err != nil {
return err
}

for _, proposal := range response.Connection.Edges {
if proposal.Node.Proposal.State == proto.Proposal_STATE_ENACTED {
return nil
}
gd := response.GetData()
if gd.Proposal.State == proto.Proposal_STATE_ENACTED {
return nil
}
time.Sleep(time.Second)
}
Expand Down
32 changes: 19 additions & 13 deletions perftest/perftest.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Opts struct {
PriceLevels int
StartingMidPrice int64
FillPriceLevels bool
InitialiseOnly bool
}

type perfLoadTesting struct {
Expand Down Expand Up @@ -98,7 +99,7 @@ func (p *perfLoadTesting) LoadUsers(tokenFilePath string, userCount int) error {
return nil
}

func (p *perfLoadTesting) depositTokens(assets map[string]string, faucetURL, ganacheURL string, voters int) error {
func (p *perfLoadTesting) depositTokens(assets map[string]string, faucetURL, ganacheURL string, voters, markets int) error {
if len(ganacheURL) > 0 {
for index, user := range p.users {
if index >= voters {
Expand Down Expand Up @@ -128,17 +129,14 @@ func (p *perfLoadTesting) depositTokens(assets map[string]string, faucetURL, gan
}

// Add some more to the special accounts as we might need it for price level orders
for t := 0; t < 100; t++ {
err := topUpAsset(faucetURL, p.users[0].pubKey, asset, 100000000)
if err != nil {
return err
}
time.Sleep(time.Millisecond * 5)
err = topUpAsset(faucetURL, p.users[1].pubKey, asset, 100000000)
if err != nil {
return err
for t := 0; t < markets+10; t++ {
for v := 0; v < voters; v++ {
err := topUpAsset(faucetURL, p.users[v].pubKey, asset, 100000000)
if err != nil {
return err
}
time.Sleep(time.Millisecond * 5)
}
time.Sleep(time.Millisecond * 5)
}
} else {
// We just need to top everyone back up to the same amount
Expand Down Expand Up @@ -244,7 +242,8 @@ func (p *perfLoadTesting) proposeAndEnactMarket(numberOfMarkets, voters, maxLPSh
}
}
}
time.Sleep(time.Second * 6)
// We need to wait at least 5 seconds for the markets to move from enacted to pending
time.Sleep(time.Second * 10)

// Move markets out of auction
markets = p.dataNode.getMarkets()
Expand Down Expand Up @@ -282,6 +281,7 @@ func (p *perfLoadTesting) proposeAndEnactMarket(numberOfMarkets, voters, maxLPSh
Type: proto.Order_TYPE_LIMIT,
TimeInForce: proto.Order_TIME_IN_FORCE_GTC})
}
time.Sleep(time.Second * 1)
}
} else {
return nil, fmt.Errorf("failed to get open market")
Expand Down Expand Up @@ -649,7 +649,7 @@ func Run(opts Opts) error {

// Send some tokens to any newly created users
fmt.Print("Depositing tokens and assets...")
err = plt.depositTokens(assets, opts.FaucetURL, opts.GanacheURL, opts.Voters)
err = plt.depositTokens(assets, opts.FaucetURL, opts.GanacheURL, opts.Voters, opts.MarketCount)
if err != nil {
fmt.Println("FAILED")
return err
Expand Down Expand Up @@ -692,6 +692,12 @@ func Run(opts Opts) error {
fmt.Println("Complete")
}

// If we are only initialising, stop now and return
if opts.InitialiseOnly {
fmt.Println("Initialisation complete")
return nil
}

// Send off a controlled amount of orders and cancels
if opts.BatchSize > 0 {
fmt.Print("Sending batched load transactions...")
Expand Down
3 changes: 2 additions & 1 deletion perftest/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (w walletWrapper) sendRequest(request []byte, token string) ([]byte, error)
}

func (w walletWrapper) NewMarket(offset int, user UserDetails) error {
marketName := fmt.Sprintf("JUN 2023 BTV vs USD future %d", offset)
newMarket := map[string]interface{}{
"rationale": map[string]interface{}{
"description": "desc",
Expand All @@ -107,7 +108,7 @@ func (w walletWrapper) NewMarket(offset int, user UserDetails) error {
"positionDecimalPlaces": "5",
"instrument": map[string]interface{}{
"code": "CRYPTO:BTCUSD/NOV22",
"name": "NOV 2022 BTC vs USD future",
"name": marketName,
"future": map[string]interface{}{
"settlementAsset": "fUSDC",
"quoteName": "BTCUSD",
Expand Down

0 comments on commit e0f23a0

Please sign in to comment.