mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: relax some op pool validator internals (#13358)
This commit is contained in:
@ -33,14 +33,21 @@ const L1_BLOCK_ECOTONE_SELECTOR: [u8; 4] = hex!("440a5e20");
|
||||
///
|
||||
/// Returns an error if the L1 info transaction is not found, if the block is empty.
|
||||
pub fn extract_l1_info<B: BlockBody>(body: &B) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
let l1_info_tx_data = body
|
||||
.transactions()
|
||||
.first()
|
||||
.ok_or_else(|| OpBlockExecutionError::L1BlockInfoError {
|
||||
let l1_info_tx =
|
||||
body.transactions().first().ok_or_else(|| OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "could not find l1 block info tx in the L2 block".to_string(),
|
||||
})
|
||||
.map(|tx| tx.input())?;
|
||||
})?;
|
||||
extract_l1_info_from_tx(l1_info_tx)
|
||||
}
|
||||
|
||||
/// Extracts the [`L1BlockInfo`] from the the L1 info transaction (first transaction) in the L2
|
||||
/// block.
|
||||
///
|
||||
/// Returns an error if the calldata is shorter than 4 bytes.
|
||||
pub fn extract_l1_info_from_tx<T: Transaction>(
|
||||
tx: &T,
|
||||
) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
let l1_info_tx_data = tx.input();
|
||||
if l1_info_tx_data.len() < 4 {
|
||||
return Err(OpBlockExecutionError::L1BlockInfoError {
|
||||
message: "invalid l1 block info transaction calldata in the L2 block".to_string(),
|
||||
@ -53,6 +60,12 @@ pub fn extract_l1_info<B: BlockBody>(body: &B) -> Result<L1BlockInfo, OpBlockExe
|
||||
/// Parses the input of the first transaction in the L2 block, into [`L1BlockInfo`].
|
||||
///
|
||||
/// Returns an error if data is incorrect length.
|
||||
///
|
||||
/// Caution this expects that the input is the calldata of the [`L1BlockInfo`] transaction (first
|
||||
/// transaction) in the L2 block.
|
||||
///
|
||||
/// # Panics
|
||||
/// If the input is shorter than 4 bytes.
|
||||
pub fn parse_l1_info(input: &[u8]) -> Result<L1BlockInfo, OpBlockExecutionError> {
|
||||
// If the first 4 bytes of the calldata are the L1BlockInfoEcotone selector, then we parse the
|
||||
// calldata as an Ecotone hardfork L1BlockInfo transaction. Otherwise, we parse it as a
|
||||
|
||||
Reference in New Issue
Block a user