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

[FUN-1332] Allowlist optimisation #12588

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

agparadiso
Copy link
Contributor

@agparadiso agparadiso commented Mar 26, 2024

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 a Store method to replace completely the current list.

So we what we are doing is:

  • get the current allowlist node's state by using the a.allowlist.Load()
  • fetch the allowlist in batches from the contract (starting by latest addresses added)
  • append the batch to a copy of the node's current state and replace the list
  • clean the blocked list at the db layer

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

Copy link
Contributor

github-actions bot commented Mar 26, 2024

I see you updated files related to core. Please run pnpm changeset in the root directory to add a changeset as well as in the text include at least one of the following tags:

  • #added For any new functionality added.
  • #breaking_change For any functionality that requires manual action for the node to boot.
  • #bugfix For bug fixes.
  • #changed For any change to the existing functionality.
  • #db_update For any feature that introduces updates to database schema.
  • #deprecation_notice For any upcoming deprecation functionality.
  • #internal For changesets that need to be excluded from the final changelog.
  • #nops For any feature that is NOP facing and needs to be in the official Release Notes for the release.
  • #removed For any functionality/config that is removed.
  • #updated For any functionality that is updated.
  • #wip For any change that is not ready yet and external communication about it should be held off till it is feature complete.

@agparadiso agparadiso changed the title [FUN-1332] Allowlist optimization [FUN-1332] Allowlist optimisation Mar 26, 2024
Copy link
Collaborator

@KuphJr KuphJr left a 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.

@agparadiso agparadiso force-pushed the feat/FUN-1332_allowlist_optimization branch from 42994fc to 7a96c97 Compare March 28, 2024 13:48
@agparadiso agparadiso force-pushed the feat/FUN-1332_allowlist_optimization branch from 7a96c97 to a234f13 Compare April 2, 2024 09:25
@agparadiso agparadiso force-pushed the feat/FUN-1332_allowlist_optimization branch from 5f1edc5 to c2cbd78 Compare April 3, 2024 16:00
@agparadiso agparadiso marked this pull request as ready for review April 8, 2024 14:56
@agparadiso agparadiso requested a review from a team as a code owner April 8, 2024 14:56
@agparadiso agparadiso requested a review from KuphJr April 8, 2024 14:57
@agparadiso agparadiso force-pushed the feat/FUN-1332_allowlist_optimization branch from fda542a to 7170ee0 Compare May 3, 2024 13:39
@agparadiso agparadiso force-pushed the feat/FUN-1332_allowlist_optimization branch from f440ada to d2d6bd1 Compare May 6, 2024 15:01
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.

None yet

2 participants