Commit-Boost / commit-boost-client

Commit-Boost allows Ethereum validators to safely run MEV-Boost and community-built commitment protocols
https://commit-boost.github.io/commit-boost-client/
Apache License 2.0
54 stars 20 forks source link

Make `get_header` generic over response & bid evaluation function #105

Open mempirate opened 1 week ago

mempirate commented 1 week ago

Context

In the get_header_with_proofs endpoint of the constraints-API, we reuse practically all the same functionality of the get_header call defined in commit-boost PBS. The only differences are:

It would be great if we could reuse the same get_header implementation with all of the existing configuration, without having to copy over all of that functionality. For that, we'd need to make mev_boost::get_header generic over the response type and provide an optional generic eval_bid closure. Something like the following function signature should make it clear:

/// Implements https://ethereum.github.io/builder-specs/#/Builder/getHeader
/// Returns 200 if at least one relay returns 200, else 204
pub async fn get_header<S, R, F>(
    params: GetHeaderParams,
    req_headers: HeaderMap,
    state: PbsState<S>,
    eval_bid: Option<F>,
) -> eyre::Result<Option<R>>
where
    S: BuilderApiState,
    R: Serialize + Deserialize<'static>,
    F: Fn(&PbsState<S>, &R) -> bool,

Would this be something we could implement? Happy to open a PR if so.

ltitanb commented 1 week ago

Yep sounds good, can you clarify what would your use case for eval_bid is it just whether to accept or reject a given block?

mempirate commented 1 week ago

Yes exactly, it will be applied to each incoming block from each relay before selecting the best bid