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
[FUN-1332] Allowlist optimisation #12588
base: develop
Are you sure you want to change the base?
Conversation
I see you updated files related to
|
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.
The general approach seems valid to me. Justs add some tests and I think we can give this another review.
42994fc
to
7a96c97
Compare
7a96c97
to
a234f13
Compare
5f1edc5
to
c2cbd78
Compare
fda542a
to
7170ee0
Compare
f440ada
to
d2d6bd1
Compare
d2d6bd1
to
476651c
Compare
Quality Gate passedIssues Measures |
Description
this pr introduces an optimization for allowlist by updating it in batches giving priority to latest allowed addresses and adding an extra step on the batching process in which we check for the length of the allowlist and if it changed (new addresses were added) we fetch these before continuing the loop
What changed
We are adding an extra step that will fetch the latest addresses added IF the length of the allowlist was increased.
We were already fetching the allowlist from the contract in batches, but we were updating the node representation only when the full list was fetched. This represented a delay for users when a new address was added, which would grow proportional to the increase of the allowlist length.
In order to mitigate this, we are updating the nodes representation with every batch we fetch.
Because the nodes representation uses a
atomic.Pointer[map[common.Address]struct{}]
we only have aStore
method to replace completely the current list.So we what we are doing is:
a.allowlist.Load()
by doing this the user should be able to see the new added addresses faster than waiting until the full list is fetched.
miro diagram here
How is this tested
This is tested with white box unit tests that mock the onchain part and allows to validate the correct fetching order