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: remove block range limit in eth_getLogs when filtering with a single address #2236

Merged
merged 11 commits into from
Mar 28, 2024

Conversation

acuarica
Copy link
Contributor

@acuarica acuarica commented Mar 21, 2024

Description:

This PR removes the block range limit, e.g., 1000, when the filter in the eth_getLogs contains a single address (the optional address param might be either a string or an addresses array).

This change allows consumers to query all the log entries of the given address. For now, we permit only a single address, but in the future we might relax this constraint as well.

The block range validation is also used in eth_newFilter, but it should not be affected by this change.

Related issue(s):

Fixes #2175

Notes for reviewer:

It also fixes function type signatures, _i.e., use string[] instead of [string].

Checklist

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

@acuarica acuarica linked an issue Mar 21, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Mar 21, 2024

Tests

    1 files    35 suites   3s ⏱️
194 tests 193 ✔️ 1 💤 0
197 runs  196 ✔️ 1 💤 0

Results for commit f341324.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.15%. Comparing base (adfe759) to head (f87da1b).
Report is 13 commits behind head on main.

❗ Current head f87da1b differs from pull request most recent head f341324. Consider uploading reports for the commit f341324 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2236   +/-   ##
=======================================
  Coverage   75.15%   75.15%           
=======================================
  Files          13       13           
  Lines         644      644           
  Branches      118      118           
=======================================
  Hits          484      484           
  Misses        115      115           
  Partials       45       45           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Mar 21, 2024

Acceptance Tests

  13 files  153 suites   15m 13s ⏱️
398 tests 393 ✔️ 4 💤 1
418 runs  413 ✔️ 4 💤 1

Results for commit f341324.

♻️ This comment has been updated with latest results.

@acuarica acuarica marked this pull request as ready for review March 22, 2024 17:31
Nana-EC
Nana-EC previously approved these changes Mar 25, 2024
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.

LG
1 nit

packages/relay/tests/lib/eth/eth_getLogs.spec.ts Outdated Show resolved Hide resolved
Signed-off-by: Luis Mastrangelo <[email protected]>
Nana-EC
Nana-EC previously approved these changes Mar 26, 2024
@Nana-EC Nana-EC added this to the 0.45.0 milestone Mar 26, 2024
@Nana-EC Nana-EC added enhancement New feature or request P1 labels Mar 26, 2024
@acuarica
Copy link
Contributor Author

@ebadiere @AlfredoG87 I would appreciate your input here if you have some time, thanks!

Copy link
Collaborator

@AlfredoG87 AlfredoG87 left a comment

Choose a reason for hiding this comment

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

Overall looks good, leaved some comments around testing and a question on process.env.TEST that I don't understand, if is a new feature flag it should be documented and use a constant at the top of the class as other feature flags do, and should have a more descriptive name than TEST

2 other questions:

  1. should we really allow for unlimited amount of blocks? could it become too much too handle, maybe having a different limit altogether? like maybe, 100,000 blocks or something. let me know your rationale here.
    Have we tested limits on the mirror node for timestamp of query? (`contracts/${MirrorNodeClient.ADDRESS_PLACEHOLDER}/results/logs)

  2. On the tests, what happens if we increase the default limit of 1000 to lets say 2000, it would fail?

packages/relay/tests/lib/eth/eth_getLogs.spec.ts Outdated Show resolved Hide resolved
packages/relay/tests/lib/eth/eth_getLogs.spec.ts Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Mar 27, 2024

Quality Gate Passed Quality Gate passed

Issues
2 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@acuarica
Copy link
Contributor Author

  1. should we really allow for unlimited amount of blocks? could it become too much too handle, maybe having a different limit altogether? like maybe, 100,000 blocks or something. let me know your rationale here.
    Have we tested limits on the mirror node for timestamp of query? (`contracts/${MirrorNodeClient.ADDRESS_PLACEHOLDER}/results/logs)

The mirror node supports the query without timestamp. The openrpc.json was updated to reflect pagination limits in f341324.

@acuarica acuarica merged commit 9bcd305 into main Mar 28, 2024
27 of 28 checks passed
@acuarica acuarica deleted the 2175-issues-with-eth_getlogs-api branch March 28, 2024 13:04
@AlfredoG87 AlfredoG87 modified the milestones: 0.45.0, 0.44.2 Mar 28, 2024
AlfredoG87 pushed a commit that referenced this pull request Mar 28, 2024
… single address (#2236)

* Fix address type

Signed-off-by: Luis Mastrangelo <[email protected]>

* Remove block range limit when filtering with a single address

Signed-off-by: Luis Mastrangelo <[email protected]>

* Fix single address condition

Signed-off-by: Luis Mastrangelo <[email protected]>

* Add unit tests

Signed-off-by: Luis Mastrangelo <[email protected]>

* Add acceptance test for large block range with a single address

Signed-off-by: Luis Mastrangelo <[email protected]>

* Fix acceptance test

Signed-off-by: Luis Mastrangelo <[email protected]>

* Update `eth_getLogs`'s openrpc docs summary and restrictions

Signed-off-by: Luis Mastrangelo <[email protected]>

* Remove unneeded `console.log`

Signed-off-by: Luis Mastrangelo <[email protected]>

* Remove `env.TEST` usage as suggested by Fredy

Signed-off-by: Luis Mastrangelo <[email protected]>

* Improve test titles to use `it should` format as suggested by Fredy

Signed-off-by: Luis Mastrangelo <[email protected]>

* Include more details in the openrpc `eth_getLogs` description

Signed-off-by: Luis Mastrangelo <[email protected]>

---------

Signed-off-by: Luis Mastrangelo <[email protected]>
AlfredoG87 pushed a commit that referenced this pull request Mar 28, 2024
… single address (#2236)

* Fix address type

Signed-off-by: Luis Mastrangelo <[email protected]>

* Remove block range limit when filtering with a single address

Signed-off-by: Luis Mastrangelo <[email protected]>

* Fix single address condition

Signed-off-by: Luis Mastrangelo <[email protected]>

* Add unit tests

Signed-off-by: Luis Mastrangelo <[email protected]>

* Add acceptance test for large block range with a single address

Signed-off-by: Luis Mastrangelo <[email protected]>

* Fix acceptance test

Signed-off-by: Luis Mastrangelo <[email protected]>

* Update `eth_getLogs`'s openrpc docs summary and restrictions

Signed-off-by: Luis Mastrangelo <[email protected]>

* Remove unneeded `console.log`

Signed-off-by: Luis Mastrangelo <[email protected]>

* Remove `env.TEST` usage as suggested by Fredy

Signed-off-by: Luis Mastrangelo <[email protected]>

* Improve test titles to use `it should` format as suggested by Fredy

Signed-off-by: Luis Mastrangelo <[email protected]>

* Include more details in the openrpc `eth_getLogs` description

Signed-off-by: Luis Mastrangelo <[email protected]>

---------

Signed-off-by: Luis Mastrangelo <[email protected]>
Signed-off-by: Alfredo Gutierrez <[email protected]>
AlfredoG87 added a commit that referenced this pull request Mar 28, 2024
feat: remove block range limit in `eth_getLogs` when filtering with a single address (#2236)

* Fix address type



* Remove block range limit when filtering with a single address



* Fix single address condition



* Add unit tests



* Add acceptance test for large block range with a single address



* Fix acceptance test



* Update `eth_getLogs`'s openrpc docs summary and restrictions



* Remove unneeded `console.log`



* Remove `env.TEST` usage as suggested by Fredy



* Improve test titles to use `it should` format as suggested by Fredy



* Include more details in the openrpc `eth_getLogs` description



---------

Signed-off-by: Luis Mastrangelo <[email protected]>
Signed-off-by: Alfredo Gutierrez <[email protected]>
Co-authored-by: Luis Mastrangelo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with eth_getlogs API
4 participants