Skip to content

Commit

Permalink
fix(rpc): remove invalid block hash variant
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Jun 2, 2023
1 parent 43f421d commit 78983f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
1 change: 0 additions & 1 deletion crates/consensus/beacon/src/engine/forkchoice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ impl ForkchoiceStatus {
// This is only returned on `newPayload` accepted would be a valid state here.
ForkchoiceStatus::Valid
}
PayloadStatusEnum::InvalidBlockHash { .. } => ForkchoiceStatus::Invalid,
}
}
}
Expand Down
23 changes: 1 addition & 22 deletions crates/rpc/rpc-types/src/eth/engine/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,7 @@ impl Serialize for PayloadStatus {

impl From<PayloadError> for PayloadStatusEnum {
fn from(error: PayloadError) -> Self {
match error {
error @ PayloadError::BlockHash { .. } => {
PayloadStatusEnum::InvalidBlockHash { validation_error: error.to_string() }
}
_ => PayloadStatusEnum::Invalid { validation_error: error.to_string() },
}
PayloadStatusEnum::Invalid { validation_error: error.to_string() }
}
}

Expand Down Expand Up @@ -356,10 +351,6 @@ pub enum PayloadStatusEnum {
/// ACCEPTED is returned by the engine API in the following calls:
/// - newPayloadV1: if the payload was accepted, but not processed (side chain)
Accepted,
InvalidBlockHash {
#[serde(rename = "validationError")]
validation_error: String,
},
}

impl PayloadStatusEnum {
Expand All @@ -370,14 +361,12 @@ impl PayloadStatusEnum {
PayloadStatusEnum::Invalid { .. } => "INVALID",
PayloadStatusEnum::Syncing => "SYNCING",
PayloadStatusEnum::Accepted => "ACCEPTED",
PayloadStatusEnum::InvalidBlockHash { .. } => "INVALID_BLOCK_HASH",
}
}

/// Returns the validation error if the payload status is invalid.
pub fn validation_error(&self) -> Option<&str> {
match self {
PayloadStatusEnum::InvalidBlockHash { validation_error } |
PayloadStatusEnum::Invalid { validation_error } => Some(validation_error),
_ => None,
}
Expand All @@ -397,11 +386,6 @@ impl PayloadStatusEnum {
pub fn is_invalid(&self) -> bool {
matches!(self, PayloadStatusEnum::Invalid { .. })
}

/// Returns true if the payload status is invalid block hash.
pub fn is_invalid_block_hash(&self) -> bool {
matches!(self, PayloadStatusEnum::InvalidBlockHash { .. })
}
}

impl std::fmt::Display for PayloadStatusEnum {
Expand All @@ -412,11 +396,6 @@ impl std::fmt::Display for PayloadStatusEnum {
f.write_str(": ")?;
f.write_str(validation_error.as_str())
}
PayloadStatusEnum::InvalidBlockHash { validation_error } => {
f.write_str(self.as_str())?;
f.write_str(": ")?;
f.write_str(validation_error.as_str())
}
_ => f.write_str(self.as_str()),
}
}
Expand Down

0 comments on commit 78983f4

Please sign in to comment.