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

Signature caching in the VC #3216

Closed
paulhauner opened this issue May 25, 2022 · 3 comments
Closed

Signature caching in the VC #3216

paulhauner opened this issue May 25, 2022 · 3 comments

Comments

@paulhauner
Copy link
Member

paulhauner commented May 25, 2022

Description

@jmcruz1983 (Juan) has pointed out that Lighthouse is doing orders of magnitude more signing requests to Web3Signer than Teku. At scale (e.g., thousands of validators), this can overload infrastructure and cause real problems.

Based on some data from Juan, I suspect this is caused by duplicate signing of selection proofs (I'm not sure if it's for attestations or sync messages).

I have a proposed solution that should be simple to implement and will:

  • Definitely be useful for Juan to test on his infra to see if it resolves the issue.
  • Probably be a tenable long-term solution.

Proposed Solution

In the validator_store, create a signature_cache: SignatureCache<T>(HashMap<(T, SigningContext), Signature>) struct.

  1. Attached to the ValidatorStore is one signature_cache (probably wrapped in an RwLock) for produce_selection_proof and one for produce_sync_selection_proof.
  2. When a selection proof is requested, we check the cache to see if it already exists. If so, we return early with that signature.
  3. After we create a signature (because it wasn't in the cache), we add it to the cache.
    • If, during the cache add, we discover that the cache is over a certain size (64?) then we prune the entry with the lowest slot.

Whenever the signature cache reaches a certain size (4?) it will prune the entry

@paulhauner
Copy link
Member Author

Oh wait, I just realised that those signature_caches need to be per validator. Perhaps attaching them to the SigningMethod would be more appropriate.

@michaelsproul
Copy link
Member

We already pre-compute all the sync selection proof signatures. It could be that this burst of signing is what shows up on web3signer's end.

Or, alternatively if we do adopt a cache we can probably drop the signature pre-compute, as I think a cache would obsolete the pre-compute.

@paulhauner
Copy link
Member Author

Closing since #3223 implemented this feature and saw little to no benefit.

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

No branches or pull requests

2 participants