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

Speed up balance fetching #2045

Merged
merged 1 commit into from
Nov 7, 2023
Merged

Speed up balance fetching #2045

merged 1 commit into from
Nov 7, 2023

Conversation

MartinquaXD
Copy link
Contributor

Description

The driver has a routine to prioritize orders and filter orders based on the balance the trader currently has.
With the introduction of pre-interactions this check became much trickier because a user might not have any sell_tokens at the moment but unstakes the needed tokens in a pre-interaction. Because of that we introduced a way to get the actual tradable balance by simulating a balance check using a helper contract.
This is very accurate but unfortunately also very slow. (~10s just for fetching the balances of all traders in an auction)
Luckily most of our orders don't have pre-interactions so we can fall back to a simpler and faster way to query the current balance.

Changes

Reimplement parts of the balance query of balances.sol using simple eth_calls and use that for any order group that does not contain any pre-interactions.
While testing locally this reduced the time to fetch all balances to ~ 1.2 - 2 seconds.

How to test

covered by e2e tests

Related Issues

#2041

@MartinquaXD MartinquaXD requested a review from a team as a code owner November 7, 2023 00:14
@MartinquaXD MartinquaXD force-pushed the speed-up-balance-fetching branch from 478f1bb to 3deaa18 Compare November 7, 2023 05:50
Copy link
Contributor

@sunce86 sunce86 left a comment

Choose a reason for hiding this comment

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

Lg

@MartinquaXD MartinquaXD merged commit 327b5eb into main Nov 7, 2023
14 checks passed
@MartinquaXD MartinquaXD deleted the speed-up-balance-fetching branch November 7, 2023 16:56
@github-actions github-actions bot locked and limited conversation to collaborators Nov 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants