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

feat: enhanced eth_getLogs with timestamp range validation and new error handling #3431

Conversation

quiet-node
Copy link
Member

Description:
This pull request improves the eth_getLogs functionality by:

Tests and comments have been added to support and clarify these changes.

Related issue(s):

Fixes #3428

Notes for reviewer:

Checklist

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

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
… and toBlock is valid

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
@quiet-node quiet-node added the bug Something isn't working label Jan 28, 2025
@quiet-node quiet-node added this to the 0.65.0 milestone Jan 28, 2025
@quiet-node quiet-node self-assigned this Jan 28, 2025
@quiet-node quiet-node requested review from Nana-EC and a team as code owners January 28, 2025 01:10
@quiet-node quiet-node modified the milestones: 0.65.0, 0.64.3 Jan 28, 2025
Copy link

github-actions bot commented Jan 28, 2025

Test Results

 18 files   -   4  236 suites   - 35   33m 5s ⏱️ - 32m 38s
613 tests +  4  609 ✅ + 17  4 💤 +1  0 ❌  - 14 
629 runs   - 217  625 ✅  - 199  4 💤 ±0  0 ❌  - 18 

Results for commit 6b90c41. ± Comparison against base commit 373f1dc.

This pull request removes 4 and adds 8 tests. Note that renamed tests count towards both.
"after all" hook in "RPC Server Acceptance Tests" ‑ RPC Server Acceptance Tests "after all" hook in "RPC Server Acceptance Tests"
"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 each" hook for "from/to Addresses when transferring HTS tokens to the tokenAddress are in evm and long-zero format" ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests "before each" hook for "from/to Addresses when transferring HTS tokens to the tokenAddress are in evm and long-zero format"
@release should execute "eth_getCode" for contract evm_address ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode @release should execute "eth_getCode" for contract evm_address
@release should execute "eth_getCode" for contract with id converted to evm_address ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode @release should execute "eth_getCode" for contract with id converted to evm_address
should execute "eth_getCode" for hts token ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should execute "eth_getCode" for hts token
should not return contract bytecode after sefldestruct ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should not return contract bytecode after sefldestruct
should return 0x0 for account alias on eth_getCode ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should return 0x0 for account alias on eth_getCode
should return 0x0 for account evm_address on eth_getCode ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should return 0x0 for account evm_address on eth_getCode
should return 0x0 for non-existing contract on eth_getCode ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-2 RPC Server Acceptance Tests eth_getCode should return 0x0 for non-existing contract on eth_getCode
should return empty logs if `toBlock` is not found ‑ RPC Server Acceptance Tests Acceptance tests @api-batch-1 RPC Server Acceptance Tests RPC Server Acceptance Tests eth_getLogs should return empty logs if `toBlock` is not found

♻️ This comment has been updated with latest results.

Copy link
Collaborator

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

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

Looking good some questions

packages/relay/src/lib/errors/JsonRpcError.ts Outdated Show resolved Hide resolved
packages/relay/src/lib/errors/JsonRpcError.ts Show resolved Hide resolved
natanasow
natanasow previously approved these changes Jan 28, 2025
Copy link
Collaborator

@natanasow natanasow left a comment

Choose a reason for hiding this comment

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

LG, some nits that can be addressed in a follow-up PR due to the urgency of this one.

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
natanasow
natanasow previously approved these changes Jan 28, 2025
konstantinabl
konstantinabl previously approved these changes Jan 28, 2025
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
…kNum

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
@quiet-node quiet-node force-pushed the 3429-eth_getlogs-failure-eth_getlogs-requests-fail-for-outdated-fromblock-range branch from d8743aa to 6b90c41 Compare January 28, 2025 22:29
Copy link
Collaborator

@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, we just have to discuss if we will limit users to 7 days or we somehow handle this limiti from the MN side

@quiet-node quiet-node merged commit 0179a87 into main Jan 29, 2025
47 checks passed
@quiet-node quiet-node deleted the 3429-eth_getlogs-failure-eth_getlogs-requests-fail-for-outdated-fromblock-range branch January 29, 2025 15:28
Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 91.66667% with 3 lines in your changes missing coverage. Please review.

Project coverage is 85.35%. Comparing base (373f1dc) to head (6b90c41).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../lib/services/ethService/ethCommonService/index.ts 94.11% 0 Missing and 2 partials ⚠️
.../lib/services/ethService/ethFilterService/index.ts 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3431      +/-   ##
==========================================
+ Coverage   84.18%   85.35%   +1.16%     
==========================================
  Files          69       69              
  Lines        4711     4738      +27     
  Branches     1048     1056       +8     
==========================================
+ Hits         3966     4044      +78     
+ Misses        428      394      -34     
+ Partials      317      300      -17     
Flag Coverage Δ
config-service 98.14% <ø> (ø)
relay 79.26% <91.66%> (+0.04%) ⬆️
server 83.30% <ø> (ø)
ws-server 36.66% <ø> (ø)

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

Files with missing lines Coverage Δ
packages/relay/src/lib/errors/JsonRpcError.ts 75.00% <100.00%> (+0.49%) ⬆️
packages/relay/src/lib/eth.ts 86.11% <ø> (+4.84%) ⬆️
.../lib/services/ethService/ethFilterService/index.ts 80.43% <0.00%> (-2.18%) ⬇️
.../lib/services/ethService/ethCommonService/index.ts 91.46% <94.11%> (+0.15%) ⬆️

... and 4 files with indirect coverage changes

quiet-node added a commit that referenced this pull request Jan 29, 2025
…ror handling (#3431)

* fix: returned empty array for eth_getLogs if toBlock is not found

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* feat: added new predefined error TIMESTAMP_RANGE_TOO_LARGE

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* fix: added validation to ensure the timestamp range between fromBlock and toBlock is valid

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* chore: added comments to clarify the logic

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* test: added unit test

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* test: added acceptance test

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* chore: updated a unique JsonRPC error code for TIMESTAMP_RANGE_TOO_LARGE

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* chore: updated 7 timestamp validation

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* chore: explained the logic behind MISSING_FROM_BLOCK_PARAM error

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* feat: added a dedicated validateBlockRange for eth_newFilter

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

* fix: threw INVALID_BLOCK_RANGE if fromBlockNum is greater than toBlockNum

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>

---------

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
quiet-node added a commit that referenced this pull request Jan 29, 2025
…lidation and new error handling (#3431) to release/0.64 (#3434)

feat: enhanced eth_getLogs with timestamp range validation and new error handling (#3431)

* fix: returned empty array for eth_getLogs if toBlock is not found



* feat: added new predefined error TIMESTAMP_RANGE_TOO_LARGE



* fix: added validation to ensure the timestamp range between fromBlock and toBlock is valid



* chore: added comments to clarify the logic



* test: added unit test



* test: added acceptance test



* chore: updated a unique JsonRPC error code for TIMESTAMP_RANGE_TOO_LARGE



* chore: updated 7 timestamp validation



* chore: explained the logic behind MISSING_FROM_BLOCK_PARAM error



* feat: added a dedicated validateBlockRange for eth_newFilter



* fix: threw INVALID_BLOCK_RANGE if fromBlockNum is greater than toBlockNum



---------

Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants