Skip to content
This repository was archived by the owner on Feb 18, 2025. It is now read-only.

Commit 1e70f26

Browse files
authored
Merge pull request #134 from anton-rs/rf/engine-error
chore(engine): Rename EngineApiError
2 parents 8d27cec + c4f4df7 commit 1e70f26

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

crates/engine/src/client.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use url::Url;
2727

2828
use hilo_providers_alloy::AlloyL2ChainProvider;
2929

30-
use crate::{Engine, EngineApiError};
30+
use crate::{Engine, EngineError};
3131

3232
/// A Hyper HTTP client with a JWT authentication layer.
3333
type HyperAuthClient<B = Full<Bytes>> = HyperClient<B, AuthService<Client<HttpConnector, B>>>;
@@ -62,24 +62,21 @@ impl EngineClient {
6262

6363
#[async_trait]
6464
impl Engine for EngineClient {
65-
type Error = EngineApiError;
65+
type Error = EngineError;
6666

6767
async fn get_payload(
6868
&self,
6969
payload_id: PayloadId,
7070
) -> Result<OpExecutionPayloadEnvelopeV3, Self::Error> {
71-
self.engine.get_payload_v3(payload_id).await.map_err(|_| EngineApiError::PayloadError)
71+
self.engine.get_payload_v3(payload_id).await.map_err(|_| EngineError::PayloadError)
7272
}
7373

7474
async fn forkchoice_update(
7575
&self,
7676
state: ForkchoiceState,
7777
attr: Option<OpPayloadAttributes>,
7878
) -> Result<ForkchoiceUpdated, Self::Error> {
79-
self.engine
80-
.fork_choice_updated_v2(state, attr)
81-
.await
82-
.map_err(|_| EngineApiError::PayloadError)
79+
self.engine.fork_choice_updated_v2(state, attr).await.map_err(|_| EngineError::PayloadError)
8380
}
8481

8582
async fn new_payload(
@@ -90,7 +87,7 @@ impl Engine for EngineClient {
9087
self.engine
9188
.new_payload_v3(payload, parent_beacon_block_root)
9289
.await
93-
.map_err(|_| EngineApiError::PayloadError)
90+
.map_err(|_| EngineError::PayloadError)
9491
}
9592

9693
async fn l2_block_ref_by_label(
@@ -100,11 +97,11 @@ impl Engine for EngineClient {
10097
let number = match numtag {
10198
BlockNumberOrTag::Number(n) => n,
10299
BlockNumberOrTag::Latest => {
103-
self.rpc.latest_block_number().await.map_err(|_| EngineApiError::PayloadError)?
100+
self.rpc.latest_block_number().await.map_err(|_| EngineError::LatestBlockNumber)?
104101
}
105-
_ => return Err(EngineApiError::PayloadError),
102+
_ => return Err(EngineError::InvalidBlockTag),
106103
};
107-
self.rpc.l2_block_info_by_number(number).await.map_err(|_| EngineApiError::PayloadError)
104+
self.rpc.l2_block_info_by_number(number).await.map_err(|_| EngineError::L2BlockInfoFetch)
108105
}
109106
}
110107

crates/engine/src/controller.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::{sync::Arc, time::Duration};
1414
use tokio::time::sleep;
1515
use url::Url;
1616

17-
use crate::{Engine, EngineApiError, EngineClient};
17+
use crate::{Engine, EngineClient, EngineError};
1818

1919
/// L1 epoch block
2020
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
@@ -94,7 +94,7 @@ impl EngineController {
9494

9595
#[async_trait]
9696
impl Executor for EngineController {
97-
type Error = EngineApiError;
97+
type Error = EngineError;
9898

9999
/// Waits for the engine to be ready.
100100
async fn wait_until_ready(&mut self) {

crates/engine/src/errors.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@
22
33
/// An error that originated from the engine api.
44
#[derive(Debug, thiserror::Error)]
5-
pub enum EngineApiError {
5+
pub enum EngineError {
66
/// An error occurred while executing the payload.
77
#[error("An error occurred while executing the payload")]
88
PayloadError,
99
/// An error occurred while computing the output root.
1010
#[error("An error occurred while computing the output root")]
1111
OutputRootError,
12+
/// Invalid block tag used to fetch the L2 block ref.
13+
#[error("Invalid block tag. Use `latest` or a block number.")]
14+
InvalidBlockTag,
15+
/// Failed to fetch the latest block number from the l2 rpc provider.
16+
#[error("Failed to fetch the latest block number from the l2 rpc provider")]
17+
LatestBlockNumber,
18+
/// Failed to get the `L2BlockInfo` for the given block number.
19+
#[error("Failed to get the `L2BlockInfo` for the given block number")]
20+
L2BlockInfoFetch,
1221
}

crates/engine/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod traits;
1010
pub use traits::Engine;
1111

1212
mod errors;
13-
pub use errors::EngineApiError;
13+
pub use errors::EngineError;
1414

1515
mod controller;
1616
pub use controller::EngineController;

0 commit comments

Comments
 (0)