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

Sync committee duty calculation for an epoch is too long (4 seconds) #1299

Open
Arkenan opened this issue Sep 19, 2024 · 0 comments
Open

Sync committee duty calculation for an epoch is too long (4 seconds) #1299

Arkenan opened this issue Sep 19, 2024 · 0 comments

Comments

@Arkenan
Copy link
Collaborator

Arkenan commented Sep 19, 2024

This is a tl;dr on Rodrigo's notes on PR #1297.

On the one hand, this may not be an issue on mainnet, as it's mainly originating from all the validators being part everywhere. This is the core problem:

for 60 validators (the test I was seeing the 4 seconds delay) we have to calculate proofs for every subcommitte (4) for every slot (32). The proof calculation cost approximately 0.5 ms. so:
60 * 32 * 4 * 0.5 = 3840ms (aprox. 4 seconds)

On the other hand, we have very obvious optimizations at hand: As the core of the problem is calculating a proof via a BLS signature based on slot + subcommittee index (Validator.Utils.get_sync_committee_selection_proof/4), the calculation is completely independent for each set of validator_index, slot, subcommittee_index. Given that, it's a low hanging fruit to use something like Task.async_stream to:

  1. Parallelize computation per validator.
  2. Inside of a validator, parallelize computation per slot/subcommittee.

As a followup question, is the all of the computation consumed in BLS.sign or is Misc.compute_signing_root a relevant portion of it? If it's BLS.sign, then there's no significant further change we can do. If it's compute_signing_root, however, that doesn't require the privkey, so we could do that once per subcommittee+slot instead of doing it once per {validator, slot subcommittee_index} tuple, although it's a bit of a bothersome refactor, so it's important to see if it's valuable at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant