Skip to content

Commit

Permalink
fix: relay types (#1577)
Browse files Browse the repository at this point in the history
* fix: relay types

* fix docs

* fix docs

* fix

* BuilderBlockValidationRequestV4
  • Loading branch information
klkvr authored Oct 28, 2024
1 parent 2fbadbf commit c4f3543
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions crates/rpc-types-beacon/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use crate::{BlsPublicKey, BlsSignature};
use alloy_primitives::{Address, Bytes, B256, U256};
use alloy_rpc_types_engine::{
BlobsBundleV1, ExecutionPayload, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3,
BlobsBundleV1, ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3,
};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
Expand Down Expand Up @@ -96,6 +96,8 @@ pub struct SignedBidTrace {
}

/// Submission for the `/relay/v1/builder/blocks` endpoint (Bellatrix).
///
/// <https://github.com/attestantio/go-builder-client/blob/e54c7fffd418d88414fad808dde3ed2ac863a7f8/api/deneb/submitblockrequest.go#L13>
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Decode, ssz_derive::Encode))]
Expand All @@ -110,6 +112,8 @@ pub struct SignedBidSubmissionV1 {
}

/// Submission for the `/relay/v1/builder/blocks` endpoint (Capella).
///
/// <https://github.com/attestantio/go-builder-client/blob/e54c7fffd418d88414fad808dde3ed2ac863a7f8/api/capella/submitblockrequest.go#L13>
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Decode, ssz_derive::Encode))]
Expand All @@ -124,6 +128,8 @@ pub struct SignedBidSubmissionV2 {
}

/// Submission for the `/relay/v1/builder/blocks` endpoint (Deneb).
///
/// <https://github.com/attestantio/go-builder-client/blob/e54c7fffd418d88414fad808dde3ed2ac863a7f8/api/deneb/submitblockrequest.go#L13>
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
#[cfg_attr(feature = "ssz", derive(ssz_derive::Decode, ssz_derive::Encode))]
Expand Down Expand Up @@ -157,18 +163,6 @@ pub struct SignedBidSubmissionV4 {
pub signature: BlsSignature,
}

/// SubmitBlockRequest is the request from the builder to submit a block.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct SubmitBlockRequest {
/// The BidTrace message associated with the block submission.
pub message: BidTrace,
/// The execution payload for the block submission.
#[serde(with = "crate::payload::beacon_payload")]
pub execution_payload: ExecutionPayload,
/// The signature associated with the block submission.
pub signature: BlsSignature,
}

/// Query for the `/relay/v1/builder/blocks` endpoint
#[serde_as]
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand All @@ -186,48 +180,63 @@ impl SubmitBlockRequestQuery {
}
}

/// A Request to validate a [SubmitBlockRequest] <https://github.com/flashbots/builder/blob/03ee71cf0a344397204f65ff6d3a917ee8e06724/eth/block-validation/api.go#L132-L136>
/// A Request to validate a [`SignedBidSubmissionV1`]
///
/// <https://github.com/flashbots/builder/blob/03ee71cf0a344397204f65ff6d3a917ee8e06724/eth/block-validation/api.go#L132-L136>
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BuilderBlockValidationRequest {
/// The [SubmitBlockRequest] data to be validated.
/// The request to be validated.
#[serde(flatten)]
pub request: SubmitBlockRequest,
pub request: SignedBidSubmissionV1,
/// The registered gas limit for the validation request.
#[serde_as(as = "DisplayFromStr")]
pub registered_gas_limit: u64,
}

/// A Request to validate a [SubmitBlockRequest] <https://github.com/flashbots/builder/blob/03ee71cf0a344397204f65ff6d3a917ee8e06724/eth/block-validation/api.go#L204-L204>
/// A Request to validate a [`SignedBidSubmissionV2`]
///
/// <https://github.com/flashbots/builder/blob/03ee71cf0a344397204f65ff6d3a917ee8e06724/eth/block-validation/api.go#L204-L208>
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BuilderBlockValidationRequestV2 {
/// The [SubmitBlockRequest] data to be validated.
/// The request to be validated.
#[serde(flatten)]
pub request: SubmitBlockRequest,
pub request: SignedBidSubmissionV2,
/// The registered gas limit for the validation request.
#[serde_as(as = "DisplayFromStr")]
pub registered_gas_limit: u64,
/// The withdrawals root for the validation request.
pub withdrawals_root: B256,
}

/// A Request to validate a [SubmitBlockRequest] <https://github.com/flashbots/builder/blob/7577ac81da21e760ec6693637ce2a81fe58ac9f8/eth/block-validation/api.go#L198-L202>
/// A Request to validate a [`SignedBidSubmissionV3`]
///
/// <https://github.com/flashbots/builder/blob/7577ac81da21e760ec6693637ce2a81fe58ac9f8/eth/block-validation/api.go#L198-L202>
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BuilderBlockValidationRequestV3 {
/// The [SubmitBlockRequest] data to be validated.
/// The request to be validated.
#[serde(flatten)]
pub request: SubmitBlockRequest,
pub request: SignedBidSubmissionV3,
/// The registered gas limit for the validation request.
#[serde_as(as = "DisplayFromStr")]
pub registered_gas_limit: u64,
/// The parent beacon block root for the validation request.
pub parent_beacon_block_root: B256,
}

/// A Request to validate a [SubmitBlockRequest] <https://github.com/flashbots/builder/blob/7577ac81da21e760ec6693637ce2a81fe58ac9f8/eth/block-validation/api.go#L198-L202>
pub type BuilderBlockValidationRequestV4 = BuilderBlockValidationRequestV3;
/// A Request to validate a [`SignedBidSubmissionV4`]
#[serde_as]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct BuilderBlockValidationRequestV4 {
/// The request to be validated.
#[serde(flatten)]
pub request: SignedBidSubmissionV4,
/// The registered gas limit for the validation request.
#[serde_as(as = "DisplayFromStr")]
pub registered_gas_limit: u64,
/// The parent beacon block root for the validation request.
pub parent_beacon_block_root: B256,
}

/// Query for the GET `/relay/v1/data/bidtraces/proposer_payload_delivered`
///
Expand Down

0 comments on commit c4f3543

Please sign in to comment.