Skip to content

Commit

Permalink
Merge branch 'main' into feat/revert-msg-conformance
Browse files Browse the repository at this point in the history
  • Loading branch information
IdrisHanafi authored Nov 15, 2023
2 parents dfaf108 + 4f69f6e commit e1ed883
Show file tree
Hide file tree
Showing 8 changed files with 337 additions and 258 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ You can then generate some load to make sure that blocks with transactions are b
$ polycli loadtest --verbosity 700 --chain-id 1337 --concurrency 1 --requests 1000 --rate-limit 5 --mode c --rpc-url http://127.0.0.1:8545
```

## Monitor Debug
`polycli monitor --rpc-url http://34.117.145.249:80 -v 700 &> log.txt`

# Contributing

- If you add a new loadtest mode, don't forget to update the loadtest mode string by running the following command: `cd cmd/loadtest && stringer -type=loadTestMode`. You can install [stringer](https://pkg.go.dev/golang.org/x/tools/cmd/stringer) with `go install golang.org/x/tools/cmd/stringer@latest`.
Expand Down
20 changes: 17 additions & 3 deletions cmd/monitor/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ var (
usage string

// flags
rpcUrl string
batchSizeValue string
intervalStr string
rpcUrl string
batchSizeValue string
blockCacheLimit int
intervalStr string
)

// MonitorCmd represents the monitor command
Expand All @@ -26,6 +27,13 @@ var MonitorCmd = &cobra.Command{
Short: "Monitor blocks using a JSON-RPC endpoint.",
Long: usage,
Args: cobra.NoArgs,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
// By default, hide logs from `polycli monitor`.
verbosityFlag := cmd.Flag("verbosity")
if verbosityFlag != nil && !verbosityFlag.Changed {
util.SetLogLevel(int(util.Silent))
}
},
PreRunE: func(cmd *cobra.Command, args []string) error {
return checkFlags()
},
Expand All @@ -37,6 +45,7 @@ var MonitorCmd = &cobra.Command{
func init() {
MonitorCmd.PersistentFlags().StringVarP(&rpcUrl, "rpc-url", "r", "http://localhost:8545", "The RPC endpoint url")
MonitorCmd.PersistentFlags().StringVarP(&batchSizeValue, "batch-size", "b", "auto", "Number of requests per batch")
MonitorCmd.PersistentFlags().IntVarP(&blockCacheLimit, "cache-limit", "c", 100, "Number of cached blocks for the LRU block data structure (Min 100)")
MonitorCmd.PersistentFlags().StringVarP(&intervalStr, "interval", "i", "5s", "Amount of time between batch block rpc calls")
}

Expand Down Expand Up @@ -66,5 +75,10 @@ func checkFlags() (err error) {
}
}

// Check batch-size flag.
if blockCacheLimit < 100 {
return fmt.Errorf("block-cache can't be less than 100")
}

return nil
}
Loading

0 comments on commit e1ed883

Please sign in to comment.