Skip to content

Commit

Permalink
builder: gracefully handle unsupported forks
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes committed May 7, 2024
1 parent 4501234 commit 95b532f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion mev-build-rs/src/auctioneer/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fn prepare_submission(
signature,
})
}
other => unreachable!("fork {other} is not reachable from this type"),
fork => return Err(Error::UnsupportedFork(fork)),
};
Ok(submission)
}
Expand Down
4 changes: 2 additions & 2 deletions mev-build-rs/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ethereum_consensus::{
crypto::{KzgCommitment, KzgProof},
primitives::{Bytes32, ExecutionAddress},
ssz::prelude::{ByteList, ByteVector, SimpleSerializeError, U256},
Error as ConsensusError, Fork,
Fork,
};
use mev_rs::types::{BlobsBundle, ExecutionPayload};
use reth::primitives::{Address, BlobTransactionSidecar, Bloom, SealedBlock, B256};
Expand Down Expand Up @@ -106,7 +106,7 @@ pub fn to_execution_payload(value: &SealedBlock, fork: Fork) -> Result<Execution
};
Ok(ExecutionPayload::Electra(payload))
}
fork => Err(Error::Consensus(ConsensusError::UnsupportedFork(fork))),
fork => Err(Error::UnsupportedFork(fork)),
}
}

Expand Down
4 changes: 3 additions & 1 deletion mev-build-rs/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use alloy_signer_wallet::WalletError;
use ethereum_consensus::Error as ConsensusError;
use ethereum_consensus::{Error as ConsensusError, Fork};
use reth::payload::error::PayloadBuilderError;
use thiserror::Error;

#[derive(Error, Debug)]
pub enum Error {
#[error("fork {0} is not supported for this operation")]
UnsupportedFork(Fork),
#[error(transparent)]
Consensus(#[from] ConsensusError),
#[error(transparent)]
Expand Down

0 comments on commit 95b532f

Please sign in to comment.