Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simulator improvements #619

Merged
merged 16 commits into from
Apr 22, 2023
Merged

Simulator improvements #619

merged 16 commits into from
Apr 22, 2023

Conversation

aaronbuchwald
Copy link
Collaborator

Why this should be merged

This PR is intended to improve the load simulator. The original code included a lot of unnecessary error handling that complicated the logic. This code should simply:

  • fund keys
  • generate sequences of transactions
  • issue sequence of transactions
  • await tx acceptance to mark time to finality from perspective of a client
  • confirm all of the transactions

How this works

This PR breaks the load simulator into:

  • insecure key management (intended only for testing)
  • tx sequence generation
  • worker to handle issuance, await acceptance, confirmation via eth_getTransactionByHash

How this was tested

CI and local testing. To verify, create a local network with the avalanche-network-runner and try running the simulator with the following commands to test different scenarios (note: if you run a large amount of volume through the network, then it may increase the base fee, such that previously issued transactions may be underpriced)

How is this documented

This PR updates ./cmd/simulator/README.md with up to date documentation including flag options in the command output.

To see the simulator options run (from the root of the repo):

go run cmd/simulator/main/*.go --help

Output:

# command-line-arguments
ld: warning: could not create compact unwind for _blst_sha256_block_data_order: does not use RBP or RSP based frame
Usage of simulator:
      --config-file string    Specify the config path to use to load a YAML config for the simulator
      --endpoints strings     Specify a comma separated list of RPC Websocket Endpoints (default [ws://127.0.0.1:9650/ext/bc/C/ws])
      --key-dir string        Specify the directory to save private keys in (INSECURE: only use for testing) (default ".simulator/keys")
      --log-level string      Specify the log level to use in the simulator. (default "info")
      --max-fee-cap int       Specify the maximum fee cap to use for transactions denominated in GWei (default 50)
      --max-tip-cap int       Specify the max tip cap for transactions denominated in GWei (default 1)
      --timeout duration      Specify the timeout for the simulator to complete. (default 5m0s)
      --txs-per-worker uint   Specify the number of transactions to create per worker. (default 100)
      --version               Print the version and exit.
      --workers int           Specify the number of workers to create for the simulator. (default 1)

Copy link
Contributor

@richardpringle richardpringle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My review is a little overly critical; this is how I learn. Feel free to enlighten me on some of my comments, or you can even say, "I agree with your comment, but it's not worth the effort to make the change".

I also may have made comments on files that you moved and didn't change any of the logic... if that's the case, whoops...

cmd/simulator/load/funder.go Outdated Show resolved Hide resolved
cmd/simulator/load/loader.go Outdated Show resolved Hide resolved
cmd/simulator/load/loader.go Outdated Show resolved Hide resolved
cmd/simulator/load/loader.go Outdated Show resolved Hide resolved
cmd/simulator/load/tx_generator.go Outdated Show resolved Hide resolved
cmd/simulator/load/tx_generator.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, some nits. Can approve after they are addressed.

cmd/simulator/config/flags.go Outdated Show resolved Hide resolved
cmd/simulator/config/flags.go Outdated Show resolved Hide resolved
cmd/simulator/config/flags.go Show resolved Hide resolved
scripts/run_simulator.sh Show resolved Hide resolved
cmd/simulator/load/funder.go Outdated Show resolved Hide resolved
cmd/simulator/load/workers.go Show resolved Hide resolved
)

type WorkerGroup struct {
Workers []*Worker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should we use workers instead?

cmd/simulator/load/funder.go Outdated Show resolved Hide resolved
// Ensure there are at least [config.Workers] config.Endpoints by creating
// duplicates as needed.
for i := 0; len(config.Endpoints) < config.Workers; i++ {
config.Endpoints = append(config.Endpoints, config.Endpoints[i])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we avoid modifying the config object so it always corresponds to the command line arguments as provided?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

aaronbuchwald and others added 5 commits April 20, 2023 20:23
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
@aaronbuchwald aaronbuchwald self-assigned this Apr 21, 2023
Copy link
Collaborator

@darioush darioush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aaronbuchwald aaronbuchwald merged commit 9895149 into master Apr 22, 2023
@aaronbuchwald aaronbuchwald deleted the simulator-improvements branch April 22, 2023 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants