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

Updated all pagination queries to work with the Stream instead of Iterator #2341

Merged
merged 19 commits into from
Oct 14, 2024

Conversation

xgreenx
Copy link
Collaborator

@xgreenx xgreenx commented Oct 14, 2024

Accidentally merged #2337. Reopen it again in this PR

This change updates all pagination queries to work with the async stream instead of the sync iterator.

It is preparation for the next PR to move the fetching of transactions, coins, and messages into a separate thread and await the return of the result from this thread.

Also, this PR limits the maximum number of requested coins from the coins_to_spend query to max_inputs.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog

Before requesting review

  • I have reviewed the code myself

@xgreenx xgreenx self-assigned this Oct 14, 2024
@xgreenx xgreenx requested a review from a team October 14, 2024 06:50
@xgreenx xgreenx changed the title Feature/async pagination queries Updated all pagination queries to work with the Stream instead of Iterator Oct 14, 2024
CHANGELOG.md Outdated
Comment on lines 12 to 15
- [2337](https://github.com/FuelLabs/fuel-core/pull/2337): Updated all pagination queries to work with the async stream instead of the sync iterator.

#### Breaking
- [2337](https://github.com/FuelLabs/fuel-core/pull/2337): The maximum number of processed coins from the `coins_to_spend` query is limited to `max_inputs`.
Copy link
Member

Choose a reason for hiding this comment

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

this needs to be changed, pr number

Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

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

The PR number needs to be changed as @rymnc pointed out, and there are some introduced TODO comments that doesn't reference any issues that I would ideally see either removed or have issues created for them.

Otherwise nice stuff!

Comment on lines +161 to +166
// TODO: Reimplement this algorithm to be simpler and faster:
// Instead of selecting random coins first, we can sort them.
// After that, we can split the coins into the part that covers the
// target and the part that does not(by choosing the most expensive coins).
// When the target is satisfied, we can select random coins from the remaining
// coins not used in the target.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have an issue for this that we can link?

crates/fuel-core/src/query/balance/asset_query.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/query/coin.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/query/message.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/query/tx.rs Outdated Show resolved Hide resolved
crates/fuel-core/src/schema.rs Show resolved Hide resolved
crates/fuel-core/src/schema/coins.rs Show resolved Hide resolved
crates/fuel-core/src/schema/coins.rs Show resolved Hide resolved
@xgreenx xgreenx requested review from netrome and rymnc October 14, 2024 08:09
netrome
netrome previously approved these changes Oct 14, 2024
Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Nice stuff, thanks for updating 🙏

Base automatically changed from feature/prepare-graphql-for-async to master October 14, 2024 09:24
@xgreenx xgreenx dismissed netrome’s stale review October 14, 2024 09:24

The base branch was changed.

# Conflicts:
#	CHANGELOG.md
#	crates/fuel-core/src/coins_query.rs
#	crates/fuel-core/src/graphql_api/database.rs
#	crates/fuel-core/src/query/balance.rs
#	crates/fuel-core/src/query/balance/asset_query.rs
#	crates/fuel-core/src/query/block.rs
#	crates/fuel-core/src/query/coin.rs
#	crates/fuel-core/src/query/message.rs
#	crates/fuel-core/src/query/tx.rs
@xgreenx xgreenx requested review from netrome and a team October 14, 2024 10:10
netrome
netrome previously approved these changes Oct 14, 2024
Copy link
Contributor

@netrome netrome left a comment

Choose a reason for hiding this comment

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

Thanks for updating!

@xgreenx xgreenx requested a review from a team October 14, 2024 15:20
@xgreenx xgreenx requested a review from netrome October 14, 2024 17:49
AurelienFT
AurelienFT previously approved these changes Oct 14, 2024
Copy link
Contributor

@AurelienFT AurelienFT left a comment

Choose a reason for hiding this comment

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

I'm not very familiar with the API and the DB but the changes seems ok from an external POV.

@xgreenx xgreenx enabled auto-merge (squash) October 14, 2024 19:05
@xgreenx xgreenx merged commit 0a378bf into master Oct 14, 2024
32 of 38 checks passed
@xgreenx xgreenx deleted the feature/async-pagination-queries branch October 14, 2024 19:53
@xgreenx xgreenx restored the feature/async-pagination-queries branch October 14, 2024 20:02
@xgreenx xgreenx mentioned this pull request Oct 14, 2024
xgreenx added a commit that referenced this pull request Oct 14, 2024
## Version v0.40.0

### Added
- [2347](#2347): Add GraphQL
complexity histogram to metrics.
- [2350](#2350): Added a new
CLI flag `graphql-number-of-threads` to limit the number of threads used
by the GraphQL service. The default value is `2`, `0` enables the old
behavior.
- [2335](#2335): Added CLI
arguments for configuring GraphQL query costs.

### Fixed
- [2345](#2345): In PoA
increase priority of block creation timer trigger compare to txpool
event management

### Changed
- [2334](#2334): Prepare the
GraphQL service for the switching to `async` methods.
- [2310](#2310): New metrics:
"The gas prices used in a block" (`importer_gas_price_for_block`), "The
total gas used in a block" (`importer_gas_per_block`), "The total fee
(gwei) paid by transactions in a block" (`importer_fee_per_block_gwei`),
"The total number of transactions in a block"
(`importer_transactions_per_block`), P2P metrics for swarm and protocol.
- [2340](#2340): Avoid long
heavy tasks in the GraphQL service by splitting work into batches.
- [2341](#2341): Updated all
pagination queries to work with the async stream instead of the sync
iterator.
- [2350](#2350): Limited the
number of threads used by the GraphQL service.

#### Breaking
- [2310](#2310): The `metrics`
command-line parameter has been replaced with `disable-metrics`. Metrics
are now enabled by default, with the option to disable them entirely or
on a per-module basis.
- [2341](#2341): The maximum
number of processed coins from the `coins_to_spend` query is limited to
`max_inputs`.

## What's Changed
* fix(gas_price_service): service name and unused trait impl by @rymnc
in #2317
* Do not require build of docker images to pass CI by @xgreenx in
#2342
* Prepare the GraphQL service for the switching to `async` methods by
@xgreenx in #2334
* Limited the number of threads used by the GraphQL service by @xgreenx
in #2350
* Increase priority of timer over txpool event by @xgreenx in
#2345
* Disable flaky `test_poa_multiple_producers` test by @rafal-ch in
#2353
* feat: CLI arguments for configuring GraphQL query costs. by @netrome
in #2335
* Add graphql query complexity histogram metric by @AurelienFT in
#2349
* Updated all pagination queries to work with the `Stream` instead of
`Iterator` by @xgreenx in
#2341
* Avoid long heavy tasks in the GraphQL service by @xgreenx in
#2340
* Add more metrics by @rafal-ch in
#2310


**Full Changelog**:
v0.39.0...v0.40.0

---------

Co-authored-by: Rafał Chabowski <[email protected]>
Co-authored-by: acerone85 <[email protected]>
Co-authored-by: rymnc <[email protected]>
Co-authored-by: Rafał Chabowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants