Skip to content

feat: filter out some methods from batch requests #3497

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

Merged
merged 6 commits into from
Feb 21, 2025

Conversation

natanasow
Copy link
Contributor

@natanasow natanasow commented Feb 19, 2025

Description:

Some methods should not be allowed to be requested as part of a batch.

Debug and Filter APIs to start with, but we might want to leave them in a configurable property that we can extend if needed.

Solution:

  • New error
    code: -32007
    message: Method <method> is not permitted as part of batch requests

  • New Configurable property with the list of the methods that are not allowed for batch.

  • Add a validation on each request, right before calling getRequestResult

Related issue(s):

Fixes #1885

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@natanasow natanasow self-assigned this Feb 19, 2025
@natanasow natanasow added this to the 0.67.0 milestone Feb 19, 2025
@natanasow natanasow added the enhancement New feature or request label Feb 19, 2025
Copy link

github-actions bot commented Feb 19, 2025

Test Results

 18 files   -   7  236 suites   - 125   33m 14s ⏱️ - 52m 42s
618 tests  -   7  614 ✅ + 10  4 💤 ±0  0 ❌  - 17 
634 runs   - 178  630 ✅  - 158  4 💤 ±0  0 ❌  - 20 

Results for commit 4e6d9ec. ± Comparison against base commit 8c0898f.

This pull request removes 8 and adds 1 tests. Note that renamed tests count towards both.
"before all" hook for "emits an approval event" ‑ RPC Server Acceptance Tests Acceptance tests @erc20 Acceptance Tests HTS token should behave like erc20 transfer from when the token owner is not the zero address when the recipient is not the zero address when the spender has enough allowance "before all" hook for "emits an approval event"
"before all" hook for "reverts" ‑ RPC Server Acceptance Tests Acceptance tests @erc20 Acceptance Tests HTS token should behave like erc20 transfer from when the token owner is not the zero address when the recipient is not the zero address when the spender does not have enough allowance when the token owner has enough balance "before all" hook for "reverts"
"before all" hook for "should execute "eth_getCode" for hts token" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode "before all" hook for "should execute "eth_getCode" for hts token"
"before all" hook in "@api-batch-2 RPC Server Acceptance Tests" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before all" hook in "@api-batch-2 RPC Server Acceptance Tests"
"before all" hook in "HBAR Rate Limit Tests" ‑ RPC Server Acceptance Tests Acceptance tests @hbarlimiter HBAR Limiter Acceptance Tests HBAR Rate Limit Tests "before all" hook in "HBAR Rate Limit Tests"
"before each" hook for "Should allow different accounts associated in the same HbarSpendingPlan to contribute to the same budget" ‑ RPC Server Acceptance Tests Acceptance tests @hbarlimiter HBAR Limiter Acceptance Tests HBAR Rate Limit Tests HBAR Rate Limit For Different Spending Plan Tiers @hbarlimiter-batch2 Preconfigured Tiers PRIVILEGED Tier "before each" hook for "Should allow different accounts associated in the same HbarSpendingPlan to contribute to the same budget"
"before each" hook for "reverts" ‑ RPC Server Acceptance Tests Acceptance tests @erc20 Acceptance Tests HTS token should behave like erc20 transfer from when the token owner is not the zero address when the recipient is not the zero address when the spender does not have enough allowance "before each" hook for "reverts"
"before each" hook for "should execute "eth_getStorageAt" request to get current state changes with passing specific block hash" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before each" hook for "should execute "eth_getStorageAt" request to get current state changes with passing specific block hash"
@release Should return errors for blacklisted methods ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-3 RPC Server Acceptance Tests Batch Request Test Suite BATCH_REQUESTS_ENABLED = true @release Should return errors for blacklisted methods

♻️ This comment has been updated with latest results.

@natanasow natanasow marked this pull request as ready for review February 19, 2025 16:25
@natanasow natanasow requested review from Nana-EC and a team as code owners February 19, 2025 16:25
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Nice work!

@natanasow natanasow requested a review from quiet-node February 20, 2025 07:20
Copy link
Contributor

@quiet-node quiet-node left a comment

Choose a reason for hiding this comment

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

Perfect! LGTM! Thanks for the great work!

Copy link
Contributor

@konstantinabl konstantinabl left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@Ferparishuertas Ferparishuertas left a comment

Choose a reason for hiding this comment

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

LGTM

@natanasow natanasow merged commit 7c4e8df into main Feb 21, 2025
47 checks passed
@natanasow natanasow deleted the 1885-batch-requests-method-not-allowed branch February 21, 2025 12:38
Copy link

codecov bot commented Feb 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.50%. Comparing base (8c0898f) to head (4e6d9ec).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3497      +/-   ##
==========================================
+ Coverage   84.36%   85.50%   +1.13%     
==========================================
  Files          69       69              
  Lines        4734     4738       +4     
  Branches      999     1000       +1     
==========================================
+ Hits         3994     4051      +57     
+ Misses        434      400      -34     
+ Partials      306      287      -19     
Flag Coverage Δ
config-service 95.16% <ø> (ø)
relay 79.52% <0.00%> (-0.03%) ⬇️
server 83.38% <81.81%> (-0.23%) ⬇️
ws-server 36.31% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ckages/config-service/src/services/globalConfig.ts 100.00% <ø> (ø)
packages/relay/src/lib/errors/JsonRpcError.ts 75.47% <100.00%> (+0.47%) ⬆️
packages/server/src/koaJsonRpc/index.ts 85.12% <100.00%> (+0.37%) ⬆️

... and 6 files with indirect coverage changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Batch Requests - Method not allowed for batch request
4 participants