Skip to content

Commit

Permalink
chore: add error struct for checking builder submissions (paradigmxyz…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Dec 18, 2023
1 parent 453f699 commit 342ee4a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
40 changes: 40 additions & 0 deletions crates/rpc/rpc-types/src/relay/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! Error types for the relay.
use alloy_primitives::B256;

/// Error thrown by the `validateBuilderSubmission` endpoints if the message differs from payload.
#[derive(Debug, thiserror::Error)]
pub enum ValidateBuilderSubmissionEqualityError {
/// Thrown if parent hash mismatches
#[error("incorrect ParentHash {actual}, expected {expected}")]
IncorrectParentHash {
/// The expected parent hash
expected: B256,
/// The actual parent hash
actual: B256,
},
/// Thrown if block hash mismatches
#[error("incorrect BlockHash {actual}, expected {expected}")]
IncorrectBlockHash {
/// The expected block hash
expected: B256,
/// The actual block hash
actual: B256,
},
/// Thrown if block hash mismatches
#[error("incorrect GasLimit {actual}, expected {expected}")]
IncorrectGasLimit {
/// The expected gas limit
expected: u64,
/// The actual gas limit
actual: B256,
},
/// Thrown if block hash mismatches
#[error("incorrect GasUsed {actual}, expected {expected}")]
IncorrectGasUsed {
/// The expected gas used
expected: u64,
/// The actual gas used
actual: B256,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use alloy_primitives::{Address, B256, U256};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};

pub mod error;

/// Represents an entry of the `/relay/v1/builder/validators` endpoint
#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down Expand Up @@ -324,7 +326,7 @@ mod tests {
#[test]
fn test_can_parse_validation_request_body() {
const VALIDATION_REQUEST_BODY: &str =
include_str!("../test_data/relay/single_payload.json");
include_str!("../../test_data/relay/single_payload.json");

let _validation_request_body: BuilderBlockValidationRequest =
serde_json::from_str(VALIDATION_REQUEST_BODY).unwrap();
Expand Down

0 comments on commit 342ee4a

Please sign in to comment.