Add loadtest script
tl;dr
- Adds a crude script to loadtest the chain
Notes
Having a single payer for the load test limits the pace that we can write messages because of blockchain limitations around nonces. We can only have 64 pending transactions in the mempool. The turnaround time to mark a message as "sent" is slow, which leaves a lot of time waiting for the semaphore.
I don't really see a way around this other than sending from multiple Payers.
Summary by CodeRabbit
- New Features
- Added a new CLI load testing command that enables users to simulate load scenarios with configurable options such as messages per second, duration, message size, and connection details.
- Introduced a new package for load testing functionality on the blockchain, allowing users to conduct load tests with detailed metrics and logging.
- Improvements
- Increased the blockchain transaction receipt waiting period to better accommodate longer processing times and improve overall reliability.
- Removals
- Removed the custom nonce management implementation from tests, transitioning to a SQL-backed nonce manager.
Walkthrough
The changes introduce a new load test feature into the CLI, including the addition of a load testing command, configuration options, and implementation in a dedicated package. The CLI now registers a "loadtest" command that executes a new function invoking load test functionality. Additionally, the blockchain publisher’s waiting period for transaction receipts is increased, and updates to nonce management have been made, including refactoring tests and altering concurrency limit initialization. A new test nonce manager implementation is added in the test utilities package.
Changes
| File(s) | Change Summary |
|---|---|
cmd/cli/main.go, pkg/config/cliOptions.go, pkg/loadtest/loadtest.go |
Added load test functionality: new CLI command (loadtest), new configuration type (LoadTestOptions), and load testing implementation including functions for execution and helper methods. |
pkg/blockchain/blockchainPublisher.go |
Increased transaction receipt timeout from 2s to 10s. |
pkg/blockchain/blockchainPublisher_test.go |
Updated nonce manager instantiation to use nonceManagerUtils.NewTestNonceManager(logger). |
pkg/blockchain/nonceManager.go, pkg/blockchain/nonceManager_test.go |
Reorganized import statements; removed custom nonce manager testing types and methods. |
pkg/testutils/noncemanager/nonceManager.go |
Introduced a new test nonce manager with an Int64Heap and TestNonceManager struct, implementing heap operations and nonce management methods. |
Sequence Diagram(s)
sequenceDiagram
participant CLI
participant Parser
participant LoadTestCmd
participant LoadTestPkg
participant BlockchainPublisher
participant Database
participant Logger
CLI->>Parser: Parse command-line options
Parser->>CLI: Identify "loadtest" command with options
CLI->>LoadTestCmd: Invoke loadTest() for "loadtest"
LoadTestCmd->>LoadTestPkg: Call LoadTest(logger, options, contractsOptions)
LoadTestPkg->>BlockchainPublisher: Initialize publisher & establish DB connection
BlockchainPublisher->>Database: Open namespaced DB for nonce management
BlockchainPublisher-->>LoadTestPkg: Return publisher instance
LoadTestPkg->>LoadTestPkg: Setup ticker and wait group for sending messages
LoadTestPkg->>BlockchainPublisher: Publish messages at configured rate
BlockchainPublisher->>Logger: Log message publication status and errors
Possibly related PRs
- xmtp/xmtpd#303: The changes in the main PR introduce a new load testing command and related options in the CLI, while the retrieved PR modifies the CLI structure and command options, indicating a direct relationship in their modifications to the
cmd/cli/main.gofile.
Suggested reviewers
- mkysel
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
- #658
👈 (View in Graphite) main
How to use the Graphite Merge Queue
Add either label to this PR to merge it via the merge queue:
- Queue - adds this PR to the back of the merge queue
- Hotfix - for urgent hot fixes, skip the queue and merge this PR next
You must have a Graphite account in order to use the merge queue. Sign up using this link.
An organization admin has enabled the Graphite Merge Queue in this repository.
Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.
This stack of pull requests is managed by Graphite. Learn more about stacking.
do you already have results from localhost? I wonder how different anvil is from say staging
I've only tested against testnet staging.
I don't think it's hitting staging at its full capacity though. When I look in the block explorer I don't see fees increasing, which would be a clear indicator that the blocks are full.
Add blockchain load testing functionality
Added new loadtest CLI command and package for executing configurable load tests against blockchain contracts. Includes concurrent message publishing with rate limiting, configurable message sizes and durations. Moved TestNonceManager to dedicated test utils package and increased blockchain transaction timeout to 10 seconds.
📍Where to Start
The main CLI entry point in main.go followed by the core load testing implementation in loadtest.go
Macroscope summarized e31a9ea.
Closing this as abandoned. If we ever need it, we can make sure it can be rebased on current main