-
Notifications
You must be signed in to change notification settings - Fork 0
Use requests builder #2
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
base: main
Are you sure you want to change the base?
Conversation
@coderabbitai full review |
✅ Actions performedFull review triggered. |
WalkthroughThis set of changes refactors how JSON-RPC method definitions are managed and used for benchmarking. Static JavaScript method definitions were removed and replaced by a generated JSON file created via a new build script. Test scripts were updated to load method data dynamically from this JSON. Documentation, environment variables, and configuration files were updated accordingly, including renaming environment variables and adding instructions for generating method definitions. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant build_requests.js
participant filecoin-requests-builder
participant methods/requests.json
User->>build_requests.js: Run build-requests script
build_requests.js->>filecoin-requests-builder: fetchRpcContext(RPC_URL)
filecoin-requests-builder-->>build_requests.js: RPC context
build_requests.js->>filecoin-requests-builder: buildRequests(context)
filecoin-requests-builder-->>build_requests.js: Requests object
build_requests.js->>methods/requests.json: Write requests as JSON
sequenceDiagram
participant K6 Test Script
participant methods/requests.json
participant RPC Endpoint
K6 Test Script->>methods/requests.json: Load method definitions
loop For each method
K6 Test Script->>RPC Endpoint: Send request (method, params)
RPC Endpoint-->>K6 Test Script: Response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~45 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (2)
tests/all.js (2)
7-7
: Remove unnecessary await for synchronous JSON parsing.The
open()
function is synchronous in k6, soawait
is unnecessary here.-const requests = await JSON.parse(open('../methods/requests.json')); +const requests = JSON.parse(open('../methods/requests.json'));
11-12
: Add error handling for malformed JSON or missing file.Consider adding error handling for cases where the JSON file is missing or malformed.
- for (const [method, { params }] of Object.entries(requests)) { - const response = sendRpcRequest(url, method, params); + try { + for (const [method, { params }] of Object.entries(requests)) { + const response = sendRpcRequest(url, method, params); + assertSuccess(response); + } + } catch (error) { + console.error('Error processing requests:', error.message); + throw error; + }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (2)
package-lock.json
is excluded by!**/package-lock.json
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (11)
.gitignore
(1 hunks)Makefile
(1 hunks)README.md
(2 hunks)methods/index.js
(0 hunks)package.json
(1 hunks)scripts/build_requests.js
(1 hunks)tests/all.js
(1 hunks)tests/gas_price.js
(0 hunks)tests/single_method.js
(1 hunks)tests/top5.js
(0 hunks)utils/rpc.js
(2 hunks)
🧬 Code Graph Analysis (4)
tests/all.js (4)
scripts/build_requests.js (2)
url
(4-4)requests
(7-7)tests/single_method.js (4)
url
(4-4)requests
(8-8)method
(5-5)response
(16-16)utils/benchmark_params.js (2)
regularBenchmarkParams
(2-8)regularBenchmarkParams
(2-8)utils/rpc.js (2)
response
(16-19)sendRpcRequest
(4-26)
scripts/build_requests.js (2)
tests/single_method.js (2)
url
(4-4)requests
(8-8)tests/all.js (2)
url
(4-4)requests
(7-7)
tests/single_method.js (3)
scripts/build_requests.js (2)
url
(4-4)requests
(7-7)tests/all.js (5)
url
(4-4)options
(6-6)options
(6-6)requests
(7-7)response
(12-12)utils/rpc.js (3)
response
(16-19)sendRpcRequest
(4-26)assertSuccess
(28-36)
utils/rpc.js (3)
scripts/build_requests.js (1)
url
(4-4)tests/single_method.js (3)
url
(4-4)method
(5-5)response
(16-16)tests/all.js (2)
url
(4-4)response
(12-12)
🪛 LanguageTool
README.md
[style] ~17-~17: Consider using a less common alternative to make your writing sound more unique and professional.
Context: ...em in the methods/requests.json
file. Feel free to adjust parameters manually. ## Local b...
(FEEL_FREE_TO_STYLE_ME)
💤 Files with no reviewable changes (3)
- tests/top5.js
- tests/gas_price.js
- methods/index.js
🧰 Additional context used
🧬 Code Graph Analysis (4)
tests/all.js (4)
scripts/build_requests.js (2)
url
(4-4)requests
(7-7)tests/single_method.js (4)
url
(4-4)requests
(8-8)method
(5-5)response
(16-16)utils/benchmark_params.js (2)
regularBenchmarkParams
(2-8)regularBenchmarkParams
(2-8)utils/rpc.js (2)
response
(16-19)sendRpcRequest
(4-26)
scripts/build_requests.js (2)
tests/single_method.js (2)
url
(4-4)requests
(8-8)tests/all.js (2)
url
(4-4)requests
(7-7)
tests/single_method.js (3)
scripts/build_requests.js (2)
url
(4-4)requests
(7-7)tests/all.js (5)
url
(4-4)options
(6-6)options
(6-6)requests
(7-7)response
(12-12)utils/rpc.js (3)
response
(16-19)sendRpcRequest
(4-26)assertSuccess
(28-36)
utils/rpc.js (3)
scripts/build_requests.js (1)
url
(4-4)tests/single_method.js (3)
url
(4-4)method
(5-5)response
(16-16)tests/all.js (2)
url
(4-4)response
(12-12)
🪛 LanguageTool
README.md
[style] ~17-~17: Consider using a less common alternative to make your writing sound more unique and professional.
Context: ...em in the methods/requests.json
file. Feel free to adjust parameters manually. ## Local b...
(FEEL_FREE_TO_STYLE_ME)
🔇 Additional comments (13)
.gitignore (1)
1-11
: LGTM! Proper exclusion patterns for Yarn and generated files.The refined Yarn exclusions follow best practices by preserving necessary Yarn subdirectories while excluding cache and PnP files. Adding
methods/requests.json
to gitignore is correct since this file is generated by the build script.package.json (2)
11-11
: LGTM! ES module configuration enables import syntax.Adding
"type": "module"
correctly enables ES module syntax used in the new build script.
8-8
: LGTM! New build script aligns with the refactoring.The
build-requests
script properly integrates the new dynamic request generation workflow.Makefile (1)
2-2
: LGTM! Consistent environment variable naming.Renaming
K6_TEST_URL
toK6_RPC_URL
across all targets improves clarity and aligns with the standardization across the codebase.Also applies to: 5-5, 8-8, 11-11
tests/all.js (1)
4-4
: LGTM! Consistent environment variable usage.The environment variable change to
K6_RPC_URL
aligns with the standardization across the codebase.utils/rpc.js (3)
4-8
: LGTM! Clean refactor of function signature.The change from accepting a method object to separate
method
andparams
arguments is a good improvement that:
- Makes the function signature more intuitive and explicit
- Aligns well with the new dynamic JSON-based approach for loading method definitions
- Eliminates the need for method objects with
name
andparams
properties
18-18
: Tagging correctly updated for new signature.The HTTP request tagging now uses the method string directly, which is consistent with the updated function signature.
22-22
: Debug logging properly updated.The debug logging now uses the method string directly, maintaining the same debugging functionality with the new signature.
README.md (2)
9-19
: Excellent documentation of the new workflow.The new "Methods Definitions" section clearly explains:
- How to generate method definitions using the requests builder
- The purpose and location of the generated
methods/requests.json
file- That users can manually adjust parameters for customization
This provides users with the essential information needed to work with the new dynamic approach.
24-34
: Well-executed environment variable standardization.The updates consistently replace
K6_TEST_URL
with the more descriptiveK6_RPC_URL
throughout all examples, and properly document the newK6_METHOD
variable for single-method benchmarking. This improves clarity and supports the new flexible testing approach.Also applies to: 41-41, 50-54
tests/single_method.js (3)
1-2
: Proper imports for the test functionality.The imports correctly bring in the RPC utilities and benchmark parameters needed for the single-method testing.
4-8
: Well-structured configuration with appropriate defaults.The configuration properly:
- Uses the standardized
K6_RPC_URL
environment variable- Defaults to
eth_gasPrice
which is ideal for single-method testing- Loads the generated
methods/requests.json
file using the correct async pattern- Exports the benchmark options for k6
11-18
: Robust implementation of single-method benchmarking.The test function includes:
- Proper validation that the requested method exists in the loaded definitions
- Clear error messaging for unsupported methods
- Correct usage of the updated
sendRpcRequest
function with separate method and params arguments- Appropriate success assertion
This provides a flexible foundation for benchmarking any supported RPC method.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
filecoin-requests-builder is used to generate method definitions, k6 just goes through them.
Single method
andall
benchmarks supported.First of all, a user is required to generate requests definitions, they will be stored to the methods/requests.json file, which then could be manually adjusted if needed and used to reproduce the same scenario on another server
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores
.gitignore
for Yarn and build artifacts.Refactor
Revert