mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 19:51:47 +00:00
Kiln mev boost (#3062)
## Issue Addressed MEV boost compatibility ## Proposed Changes See #2987 ## Additional Info This is blocked on the stabilization of a couple specs, [here](https://github.com/ethereum/beacon-APIs/pull/194) and [here](https://github.com/flashbots/mev-boost/pull/20). Additional TODO's and outstanding questions - [ ] MEV boost JWT Auth - [ ] Will `builder_proposeBlindedBlock` return the revealed payload for the BN to propogate - [ ] Should we remove `private-tx-proposals` flag and communicate BN <> VC with blinded blocks by default once these endpoints enter the beacon-API's repo? This simplifies merge transition logic. Co-authored-by: realbigsean <seananderson33@gmail.com> Co-authored-by: realbigsean <sean@sigmaprime.io>
This commit is contained in:
@@ -1,18 +1,21 @@
|
||||
use crate::engines::ForkChoiceState;
|
||||
use async_trait::async_trait;
|
||||
use eth1::http::RpcError;
|
||||
pub use json_structures::TransitionConfigurationV1;
|
||||
use reqwest::StatusCode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const LATEST_TAG: &str = "latest";
|
||||
|
||||
use crate::engines::ForkChoiceState;
|
||||
pub use json_structures::TransitionConfigurationV1;
|
||||
pub use types::{Address, EthSpec, ExecutionBlockHash, ExecutionPayload, Hash256, Uint256};
|
||||
use slog::Logger;
|
||||
pub use types::{
|
||||
Address, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader, Hash256,
|
||||
Uint256,
|
||||
};
|
||||
|
||||
pub mod auth;
|
||||
pub mod http;
|
||||
pub mod json_structures;
|
||||
|
||||
pub const LATEST_TAG: &str = "latest";
|
||||
|
||||
pub type PayloadId = [u8; 8];
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -24,7 +27,10 @@ pub enum Error {
|
||||
InvalidExecutePayloadResponse(&'static str),
|
||||
JsonRpc(RpcError),
|
||||
Json(serde_json::Error),
|
||||
ServerMessage { code: i64, message: String },
|
||||
ServerMessage {
|
||||
code: i64,
|
||||
message: String,
|
||||
},
|
||||
Eip155Failure,
|
||||
IsSyncing,
|
||||
ExecutionBlockNotFound(ExecutionBlockHash),
|
||||
@@ -32,6 +38,14 @@ pub enum Error {
|
||||
ParentHashEqualsBlockHash(ExecutionBlockHash),
|
||||
PayloadIdUnavailable,
|
||||
TransitionConfigurationMismatch,
|
||||
PayloadConversionLogicFlaw,
|
||||
InvalidBuilderQuery,
|
||||
MissingPayloadId {
|
||||
parent_hash: ExecutionBlockHash,
|
||||
timestamp: u64,
|
||||
prev_randao: Hash256,
|
||||
suggested_fee_recipient: Address,
|
||||
},
|
||||
}
|
||||
|
||||
impl From<reqwest::Error> for Error {
|
||||
@@ -59,41 +73,17 @@ impl From<auth::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic interface for an execution engine API.
|
||||
pub struct EngineApi;
|
||||
pub struct BuilderApi;
|
||||
|
||||
#[async_trait]
|
||||
pub trait EngineApi {
|
||||
async fn upcheck(&self) -> Result<(), Error>;
|
||||
|
||||
async fn get_block_by_number<'a>(
|
||||
&self,
|
||||
block_by_number: BlockByNumberQuery<'a>,
|
||||
) -> Result<Option<ExecutionBlock>, Error>;
|
||||
|
||||
async fn get_block_by_hash<'a>(
|
||||
&self,
|
||||
block_hash: ExecutionBlockHash,
|
||||
) -> Result<Option<ExecutionBlock>, Error>;
|
||||
|
||||
async fn new_payload_v1<T: EthSpec>(
|
||||
&self,
|
||||
execution_payload: ExecutionPayload<T>,
|
||||
) -> Result<PayloadStatusV1, Error>;
|
||||
|
||||
async fn get_payload_v1<T: EthSpec>(
|
||||
&self,
|
||||
payload_id: PayloadId,
|
||||
) -> Result<ExecutionPayload<T>, Error>;
|
||||
|
||||
async fn forkchoice_updated_v1(
|
||||
pub trait Builder {
|
||||
async fn notify_forkchoice_updated(
|
||||
&self,
|
||||
forkchoice_state: ForkChoiceState,
|
||||
payload_attributes: Option<PayloadAttributes>,
|
||||
log: &Logger,
|
||||
) -> Result<ForkchoiceUpdatedResponse, Error>;
|
||||
|
||||
async fn exchange_transition_configuration_v1(
|
||||
&self,
|
||||
transition_configuration: TransitionConfigurationV1,
|
||||
) -> Result<TransitionConfigurationV1, Error>;
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
@@ -142,3 +132,17 @@ pub struct ForkchoiceUpdatedResponse {
|
||||
pub payload_status: PayloadStatusV1,
|
||||
pub payload_id: Option<PayloadId>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum ProposeBlindedBlockResponseStatus {
|
||||
Valid,
|
||||
Invalid,
|
||||
Syncing,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ProposeBlindedBlockResponse {
|
||||
pub status: ProposeBlindedBlockResponseStatus,
|
||||
pub latest_valid_hash: Option<Hash256>,
|
||||
pub validation_error: Option<String>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user