-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Optimize balance-related queries with a cache #2383
Conversation
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.
Overall LGTM.
A side question, right now indexation is enabled by default on nodes that did not process genesis. Do we want to also make this configurable? E.g. do some nodes like the block producer not want to perform any indexation on balances, regardless of whether they start at genesis or not?
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.
PR looks good=) I think some parts can be simplified and we can connect all places related to the same code together via same functions.
Created a PR with suggestions=) #2465
Nice one, thanks. In particular I like how you got rid of the |
@xgreenx |
…#2472) ## Description This PR partially reverts the changes introduced in the [balances indexation PR](#2383). In particular: * reverts the type of `amount` in the `Balance` GraphQL type back to `U64` * introduces a new field `amountU128` in the `Balance` GraphQL type * reverts the `FuelClient::balance()` function to return `u64`. There is no `balance_u128()` function added to the `FuelClient` for now. ![image](https://github.com/user-attachments/assets/621db3b9-54f8-46c9-8bdd-c29f65b01c7c) This is done to maintain the full backward compatibility on the GraphQL level, internally the total balance is still processed using `u128`. ### Before requesting review - [X] I have reviewed the code myself
We have an issue with adding a flag that allows you to not support off-chain database. We could consider to allows customization on what stuff we want from the off-chain database. But I think we don't need to worry about it, until someone will ask for this kind of feature=) |
Linked Issues/PRs
Closes #1965
Description
worker_service: 607: Balances cache available: false
query::balance: 100: Querying balances without balances cache owner=53a9c6a...
V2
if genesis is missingworker_service: 607: Balances cache available: true
query::balance: 151: Querying balances using balances cache owner=53a9c6a...
Technical considerations:
V2
which now containsindexation_availability
. This is a set that holds the available indexations (currently onlyBalances
)CoinBalances
andMessageBalances
that keep the coin and message balances respectivelyCoinBalances
stores the balances perowner
andasset_id
MessageBalances
stores balances perowner
, separately for retryable and non-retryable messagesMessageImported
,MessageConsumed
,CoinCreated
,CoinConsumed
balance()
andbalances()
queries use these databases to satisfy the queryChecklist
Before requesting review