Skip to content

Commit

Permalink
benchmarks: removing the need to get sequencer IP from aws.
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolay Nedkov <[email protected]>
  • Loading branch information
Psykepro committed Sep 1, 2023
1 parent 3b6e7b6 commit 9c52fa5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
3 changes: 3 additions & 0 deletions test/benchmarks/sequencer/scripts/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ POOLDB_EP=
POOLDB_PASS=
POOLDB_USER=

# IP/DNS for PUBLIC TESTNET: sequencer.zkevm-public.aws, INTERNAL TESTNET: sequencer.zkevm-internal.aws, DEV TESTNET: sequencer.zkevm-dev.aws
SEQUENCER_IP=

# Access to databases (Section from Deployment Docs)
POOLDB_LOCALPORT=

Expand Down
15 changes: 3 additions & 12 deletions test/benchmarks/sequencer/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This repository contains scripts to benchmark a sequencer. The main script is wr
- `POOLDB_PASS`: Password for the pool database. (From `Deployments.doc` under `BASH VARIABLES` section for the specific `Environment`)
- `POOLDB_USER`: User for the pool database. (From `Deployments.doc` under `BASH VARIABLES` section for the specific `Environment`)
- `POOLDB_LOCALPORT`: Local port for accessing the pool database. (From `Deployments.doc` under `Access to databases` section for the specific `Environment`)
#SEQUENCER_IP= # PUBLIC TESTNET: sequencer.zkevm-public.aws, INTERNAL TESTNET: sequencer.zkevm-internal.aws, DEV TESTNET: sequencer.zkevm-dev.aws
- `SEQUENCER_IP`: The IP address of the sequencer. (`sequencer.zkevm-public.aws` for `public testnet`, `sequencer.zkevm-internal.aws` for `internal testnet`, `sequencer.zkevm-dev.aws` for `dev testnet`)
- `RPC_URL`: The URL for the Remote Procedure Call (RPC) server. (From `Deployments.doc` under `Public URLs` section as a bullet point to `RPC` for the specific `Environment`)
- `CHAIN_ID`: The ID of the blockchain network. (From `Deployments.doc` under `Public URLs` section as a bullet point to `RPC` for the specific `Environment`)
- `PRIVATE_KEY`: Your private key.
Expand All @@ -28,20 +30,9 @@ This repository contains scripts to benchmark a sequencer. The main script is wr
cp .env.example .env
nano .env
```

3. **Get the Sequencer IP Address**:
The value for the `sequencer-ip` argument needs to be obtained from the `Amazon Elastic Container Service`:
- Go to https://polygon-technology.awsapps.com/start#/
- Select the `account`/`environment` (`zkEVM-dev` for `dev` or `zkEVM-staging` for `internal` or `public` testnets).
- Go to the `Amazon Elastic Container Service`.
- Navigate to the `Service` section and select `sequencer`.
- In the `Task` section, select the only `task` definition.
- Find the `Private IP` field and use it as the value for the `sequencer-ip` argument.

4. **Run the Benchmark Script**:
3. **Run the Benchmark Script**:
Run the `main.go` script with the following command-line flags:
- `--type`: The type of transactions to test. Accepted values are `eth`, `erc20` or `uniswap`.
- `--sequencer-ip`: The IP address of the sequencer (**obtained in step 3**).
- `--num-ops` (optional): The number of operations to run. Default is 200.
- `--help` (optional): Display the help message.

Expand Down
14 changes: 4 additions & 10 deletions test/benchmarks/sequencer/scripts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func main() {

// Command line flags
tType := flag.String("type", "", "The type of transactions to test: erc20, uniswap, or eth.")
sequencerIP := flag.String("sequencer-ip", "", "The IP address of the sequencer.")
numOps := flag.Int("num-ops", 200, "The number of operations to run. Default is 200.")
help := flag.Bool("help", false, "Display help message")
flag.Parse()
Expand Down Expand Up @@ -52,13 +51,6 @@ func main() {
panic(fmt.Sprintf("Error: Invalid TYPE argument. Accepted values are 'erc20', 'uniswap', or 'eth'."))
}

fmt.Println("Validating SEQUENCER_IP...")
fmt.Println("---------------------------")
// Validate SEQUENCER_IP
if *sequencerIP == "" {
panic(fmt.Sprintf("Error: SEQUENCER_IP argument is missing. Please provide it as the second argument."))
}

fmt.Println("Checking environment variables...")
fmt.Println("---------------------------------")
// Check environment variables
Expand All @@ -68,6 +60,7 @@ func main() {
checkEnvVar("RPC_URL")
checkEnvVar("CHAIN_ID")
checkEnvVar("PRIVATE_KEY")
checkEnvVar("SEQUENCER_IP")

// Forward BASTION Ports
fmt.Println("Forwarding BASTION ports...")
Expand All @@ -82,9 +75,10 @@ func main() {
defer killSSHProcess(err)

// Execute wget to get metrics from the BASTION HOST
sequencerIP := os.Getenv("SEQUENCER_IP")
fmt.Println("Fetching start metrics...")
fmt.Println("--------------------------")
output, err := runCmd("ssh", "ubuntu@"+os.Getenv("BASTION_HOST"), "wget", "-qO-", "http://"+*sequencerIP+":9091/metrics")
output, err := runCmd("ssh", "ubuntu@"+os.Getenv("BASTION_HOST"), "wget", "-qO-", "http://"+sequencerIP+":9091/metrics")
if err != nil {
panic(fmt.Sprintf("Failed to collect start metrics from BASTION HOST: %v", err))
}
Expand Down Expand Up @@ -127,7 +121,7 @@ func main() {
// Execute wget to get metrics from the BASTION HOST
fmt.Println("Fetching end metrics...")
fmt.Println("------------------------")
output, err = runCmd("ssh", "ubuntu@"+os.Getenv("BASTION_HOST"), "wget", "-qO-", "http://"+*sequencerIP+":9091/metrics")
output, err = runCmd("ssh", "ubuntu@"+os.Getenv("BASTION_HOST"), "wget", "-qO-", "http://"+sequencerIP+":9091/metrics")
if err != nil {
panic(fmt.Sprintf("Failed to collect end metrics from BASTION HOST: %v", err))
}
Expand Down

0 comments on commit 9c52fa5

Please sign in to comment.