Skip to content

Conversation

dknopik
Copy link
Member

@dknopik dknopik commented Dec 16, 2024

This is a PR that modularises the validator store so that we can reuse the validator services in Anchor.

Proposed Changes

  • Create trait ValidatorStore with all functions used by the validator_services
  • Make validator_services generic on S: ValidatorStore
  • Introduce LighthouseValidatorStore, which has identical functionality to the old ValidatorStore
  • Remove dependencies (especially environment) from validator_services and beacon_node_fallback in order to be able to cleanly use them in Anchor

Additional Info

This also includes some changes from @jxs's closed PR #6727 to remove E from some structs and make functions generic instead (where possible).

@chong-he chong-he added the work-in-progress PR is a work-in-progress label Dec 18, 2024
@dknopik dknopik force-pushed the modularize-validator-store branch 3 times, most recently from 3c253b4 to 838eed6 Compare December 19, 2024 16:50
@dknopik dknopik mentioned this pull request Jan 3, 2025
Copy link

mergify bot commented Jan 9, 2025

⚠️ The sha of the head commit of this PR conflicts with #6771. Mergify cannot evaluate rules on this PR. ⚠️

1 similar comment
Copy link

mergify bot commented Jan 9, 2025

⚠️ The sha of the head commit of this PR conflicts with #6771. Mergify cannot evaluate rules on this PR. ⚠️

@dknopik
Copy link
Member Author

dknopik commented Jan 16, 2025

Will rebase this to clean up the messy history after

are merged. Still, feel free to start reviewing already.

@dknopik dknopik marked this pull request as ready for review January 16, 2025 07:14
@dknopik dknopik requested a review from jxs as a code owner January 16, 2025 07:14
Copy link

mergify bot commented Jan 27, 2025

This pull request has merge conflicts. Could you please resolve them @dknopik? 🙏

@dknopik dknopik force-pushed the modularize-validator-store branch from 394ef61 to 36f2916 Compare March 13, 2025 08:35
@dknopik dknopik force-pushed the modularize-validator-store branch from 36f2916 to 29b4ce5 Compare March 13, 2025 11:27
@dknopik dknopik force-pushed the modularize-validator-store branch from 29b4ce5 to 0ab9c9a Compare March 13, 2025 12:07
@jxs jxs requested review from michaelsproul and macladson March 14, 2025 17:06
Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

This is fantastic, very clean!

I'm highly motivated to get this merged soon, not just because of Anchor, but also because I want to solve this FIXME building on your branch:

// FIXME: ignore this clippy lint until the validator store is refactored to use async locks

It will require changing a few of the ValidatorStore methods to return impl Future, but I think we should merge this first, and then adapt Anchor to that change once it's also ready and merged.

object,
Web3SignerObject::Deposit { .. } | Web3SignerObject::ValidatorRegistration(_)
) && fork_info.is_some()
if matches!(message_type, MessageType::ValidatorRegistration) && fork_info.is_some()
Copy link
Member

Choose a reason for hiding this comment

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

Is this a bugfix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch. Checking the git blame, this seems to originate from @jxs's #6727. @jxs, do you remember this? There is a non-zero chance that I messed this up when rebasing, though I do not remember ever touching this.

@michaelsproul michaelsproul added waiting-on-author The reviewer has suggested changes and awaits thier implementation. and removed work-in-progress PR is a work-in-progress labels May 5, 2025
Co-authored-by: Michael Sproul <[email protected]>
@dknopik
Copy link
Member Author

dknopik commented May 5, 2025

There is one more change that would be nice: currently, sign_validator_exit is part of the new ValidatorStore trait, as I wanted to keep the interface (mostly) the same. However, in the meantime I realized that sign_validator_exit is not actually used in the validator_services crate, but in the VC HTTP API, where the actual type "LighthouseValidatorStore" is available. So we could move it back to be a method of that type. This would make the Anchor code a bit nicer as the function signature is not sufficient for our needs, so we only return an error in there anyway (as it will never be called by the validator_services) and have a custom function for Anchor internal use.

Does that sound fine by you?

@michaelsproul
Copy link
Member

Does that sound fine by you?

Yeah that sounds totally fine, happy for it to move to LighthouseValidatorStore!

Copy link
Member

@michaelsproul michaelsproul left a comment

Choose a reason for hiding this comment

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

Let's goooo

@michaelsproul michaelsproul added val-client Relates to the validator client binary ready-for-merge This PR is ready to merge. and removed waiting-on-author The reviewer has suggested changes and awaits thier implementation. labels May 7, 2025
mergify bot added a commit that referenced this pull request May 7, 2025
@mergify mergify bot merged commit 3d92e36 into sigp:unstable May 7, 2025
31 checks passed
mergify bot pushed a commit that referenced this pull request May 21, 2025
While the Lighthouse implementation of the `ValidatorStore` does not really care about blobs, Anchor needs to be able to return different blobs from `sign_blocks` than what was passed into it, in case it decides to sign another Anchor node's block. Only passing the unsigned block into `sign_block` and only returning a signed block from it (without any blobs and proofs) was an oversight in #6705.


  - Replace `validator_store::{Uns,S}ignedBlock` with `validator_store::block_service::{Uns,S}ignedBlock`, as we need all data in there.
- In `lighthouse_validator_store`, just add the received blobs back to the signed block after signing it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge This PR is ready to merge. val-client Relates to the validator client binary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants