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

Mevboost relay implementation #5757

Open
idatsy opened this issue Dec 14, 2023 · 2 comments
Open

Mevboost relay implementation #5757

idatsy opened this issue Dec 14, 2023 · 2 comments
Labels
C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity

Comments

@idatsy
Copy link
Contributor

idatsy commented Dec 14, 2023

Describe the feature

Submitting mev-boost relays requires a signed BidTrace, a struct already defined in

pub struct BidTrace {

as

pub struct SignedBidTrace {

What is actually sent:

pub struct SignedBidSubmission {

AFAIK there is no signing functionality etc which means block builders have to implement their own. Would be convenient to have a signing implementation on the BidTrace struct that take a BLS signing key and produce a SignedMessage.

Might as well include request-response pattern for the 5 relay endpoints (types are already defined in relay.rs so should be ez)

Happy to put together a PR for this if you'd like, as long as you are happy with the shape/approach.

sauce: I am running a reth builder and have currently rolled my own.

Would be a continuation on @mattsse #5568 as well

Additional context

Thinking something like this:

pub trait MevBoostRelayClient {
    type Error;

    /// Get a list of validator registrations for validators scheduled to propose in the current and next epoch.
    /// Used by builders to know when to submit bids for an upcoming proposal.
    /// Returns an array of validator registrations for the current and next epoch.
    /// Each entry includes a slot and the validator with assigned duty.
    /// Slots without a registered validator are omitted.
    fn get_validators(&self) -> Result<Vec<Validator>, Self::Error> {
        Err("Not implemented".into())
    }

    /// Submit a new block to the relay.
    /// Blocks can be submitted as JSON or SSZ, and optionally GZIP encoded.
    /// The relay will simulate the block to verify properties and proposer payment.
    /// For accountability, builder signature is over the SSZ encoded message.
    /// Any new submission by a builder will overwrite a previous one by the same builder_pubkey.
    fn submit_block(&self, block: SignedBidSubmission) -> Result<(), Self::Error> {
        Err("Not implemented".into())
    }

    /// Get payloads that were delivered to proposers.
    /// Payloads become available after the relay responds to a getPayload request from the proposer.
    fn get_payloads_delivered(&self) -> Result<Vec<ProposerPayloadsDeliveredQuery>, Self::Error> {
        Err("Not implemented".into())
    }

    /// Get builder bid submissions.
    /// Returns a list of builder bids without execution payloads.
    /// Only submissions that were successfully verified.
    fn get_builder_bids(&self) -> Result<Vec<BuilderBlocksReceivedQuery>, Self::Error> {
        Err("Not implemented".into())
    }

    /// Check that a validator is registered with the relay.
    /// Returns the latest validator registration for a given pubkey.
    fn check_validator_registration(&self, pubkey: PublicKey) -> Result<todo!("add missing struct"), Self::Error> {
        Err("Not implemented".into())
    }
}

Which I guess could be made more generic for consumers along the lines of:

pub trait MevBoostRelayClient {
    type Error;

    // Get a list of validator registrations for validators scheduled to propose in the current and next epoch.
    fn get_validators(&self) -> Result<Vec<Validator>, Self::Error>;

    // Submit a new block to the relay.
    fn submit_block(&self, block: SignedBidSubmission) -> Result<(), Self::Error>;

    // Get payloads that were delivered to proposers.
    fn get_payloads_delivered(&self) -> Result<Vec<ProposerPayloadsDeliveredQuery>, Self::Error>;

    // Get builder bid submissions.
    fn get_builder_bids(&self) -> Result<Vec<BuilderBlocksReceivedQuery>, Self::Error>;

    // Check that a validator is registered with the relay.
    fn check_validator_registration(&self, pubkey: PublicKey) -> Result<ValidatorRegistration, Self::Error>;
}

and then

pub struct ExampleMevBoostRelayClient {
    base_url: String,
}

impl ExampleMevBoostRelayClient {
    pub fn new(base_url: String) -> Self {
        ExampleMevBoostRelayClient { base_url }
    }
}

impl MevBoostRelayClient for ExampleMevBoostRelayClient {
    type Error = MyErrorType;

    fn get_validators(&self) -> Result<Vec<Validator>, Self::Error> {
        todo!("Implement get_validators")
    }

    fn submit_block(&self, block: SignedBidSubmission) -> Result<(), Self::Error> {
        todo!("Implement submit_block")
    }

    fn get_payloads_delivered(&self) -> Result<Vec<ProposerPayloadsDeliveredQuery>, Self::Error> {
        todo!("Implement get_payloads_delivered")
    }

    fn get_builder_bids(&self) -> Result<Vec<BuilderBlocksReceivedQuery>, Self::Error> {
        todo!("Implement get_builder_bids")
    }

    fn check_validator_registration(&self, pubkey: PublicKey) -> Result<ValidatorRegistration, Self::Error> {
        todo!("Implement check_validator_registration")
    }
}

or

impl<T: FullMevBoostRelayClient> MevBoostRelayClient for T {
    type Error = T::Error;

    fn get_validators(&self) -> Result<Vec<Validator>, Self::Error> {
        <Self as FullMevBoostRelayClient>::get_validators(self)
    }

    fn submit_block(&self, block: SignedBidSubmission) -> Result<(), Self::Error> {
        <Self as FullMevBoostRelayClient>::submit_block(self, block)
    }

    fn get_payloads_delivered(&self) -> Result<Vec<ProposerPayloadsDeliveredQuery>, Self::Error> {
        <Self as FullMevBoostRelayClient>::get_payloads_delivered(self)
    }

    fn get_builder_bids(&self) -> Result<Vec<BuilderBlocksReceivedQuery>, Self::Error> {
        <Self as FullMevBoostRelayClient>::get_builder_bids(self)
    }

    fn check_validator_registration(&self, pubkey: PublicKey) -> Result<ValidatorRegistration, Self::Error> {
        <Self as FullMevBoostRelayClient>::check_validator_registration(self, pubkey)
    }
}
@idatsy idatsy added C-enhancement New feature or request S-needs-triage This issue needs to be labelled labels Dec 14, 2023
@yash-atreya
Copy link
Contributor

@mattsse If this is to be implemented, I can take this.

@idatsy
Copy link
Contributor Author

idatsy commented Dec 14, 2023

@mattsse If this is to be implemented, I can take this.

I have already implemented this x) but happy to share/help you out

@DaniPopes DaniPopes added M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity and removed S-needs-triage This issue needs to be labelled labels Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement New feature or request M-prevent-stale Prevents old inactive issues/PRs from being closed due to inactivity
Projects
Status: Todo
Development

No branches or pull requests

3 participants