Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: revert header error message change #10866

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions crates/rpc/rpc-eth-types/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,18 @@ impl From<EthApiError> for jsonrpsee_types::error::ErrorObject<'static> {
EthApiError::UnknownBlockOrTxIndex => {
rpc_error_with_code(EthRpcErrorCode::ResourceNotFound.code(), error.to_string())
}
EthApiError::HeaderNotFound(id) | EthApiError::ReceiptsNotFound(id) => {
rpc_error_with_code(
EthRpcErrorCode::ResourceNotFound.code(),
format!("{error}: {}", block_id_to_str(id)),
)
}
// TODO(onbjerg): We rewrite the error message here because op-node does string matching
// on the error message.
//
// Until https://github.com/ethereum-optimism/optimism/pull/11759 is released, this must be kept around.
EthApiError::HeaderNotFound(id) => rpc_error_with_code(
EthRpcErrorCode::ResourceNotFound.code(),
format!("block not found: {}", block_id_to_str(id)),
),
EthApiError::ReceiptsNotFound(id) => rpc_error_with_code(
EthRpcErrorCode::ResourceNotFound.code(),
format!("{error}: {}", block_id_to_str(id)),
),
EthApiError::HeaderRangeNotFound(start_id, end_id) => rpc_error_with_code(
EthRpcErrorCode::ResourceNotFound.code(),
format!(
Expand Down Expand Up @@ -738,24 +744,24 @@ mod tests {
"1a15e3c30cf094a99826869517b16d185d45831d3a494f01030b0001a9d3ebb9"
)))
.into();
assert_eq!(err.message(), "header not found: hash 0x1a15e3c30cf094a99826869517b16d185d45831d3a494f01030b0001a9d3ebb9");
assert_eq!(err.message(), "block not found: hash 0x1a15e3c30cf094a99826869517b16d185d45831d3a494f01030b0001a9d3ebb9");
let err: jsonrpsee_types::error::ErrorObject<'static> =
EthApiError::HeaderNotFound(BlockId::hash_canonical(b256!(
"1a15e3c30cf094a99826869517b16d185d45831d3a494f01030b0001a9d3ebb9"
)))
.into();
assert_eq!(err.message(), "header not found: canonical hash 0x1a15e3c30cf094a99826869517b16d185d45831d3a494f01030b0001a9d3ebb9");
assert_eq!(err.message(), "block not found: canonical hash 0x1a15e3c30cf094a99826869517b16d185d45831d3a494f01030b0001a9d3ebb9");
let err: jsonrpsee_types::error::ErrorObject<'static> =
EthApiError::HeaderNotFound(BlockId::number(100000)).into();
assert_eq!(err.message(), "header not found: number 0x186a0");
assert_eq!(err.message(), "block not found: number 0x186a0");
let err: jsonrpsee_types::error::ErrorObject<'static> =
EthApiError::HeaderNotFound(BlockId::latest()).into();
assert_eq!(err.message(), "header not found: latest");
assert_eq!(err.message(), "block not found: latest");
let err: jsonrpsee_types::error::ErrorObject<'static> =
EthApiError::HeaderNotFound(BlockId::safe()).into();
assert_eq!(err.message(), "header not found: safe");
assert_eq!(err.message(), "block not found: safe");
let err: jsonrpsee_types::error::ErrorObject<'static> =
EthApiError::HeaderNotFound(BlockId::finalized()).into();
assert_eq!(err.message(), "header not found: finalized");
assert_eq!(err.message(), "block not found: finalized");
}
}
Loading