Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Feb 21, 2025
1 parent 68e5688 commit 5069f72
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 51 deletions.
42 changes: 0 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/protocol/protocol/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ pub enum OpBlockConversionError {
#[error("Empty transactions in payload. Block hash: {0}")]
EmptyTransactions(B256),
/// EIP-1559 parameter decoding error.
#[error("Failed to decode EIP-1559 parameters from header's `nonce` field.")]
#[error("Failed to decode EIP-1559 parameters from header's `extraData` field.")]
Eip1559DecodeError,
}
24 changes: 16 additions & 8 deletions crates/protocol/protocol/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,22 @@ pub fn to_system_config(

// After holocene's activation, the EIP-1559 parameters are stored in the block header's nonce.
if rollup_config.is_holocene_active(block.header.timestamp) {
let eip1559_params = block.header.nonce;
let eip1559_params = &block.header.extra_data;

if eip1559_params.len() != 9 {
return Err(OpBlockConversionError::Eip1559DecodeError);

Check warning on line 98 in crates/protocol/protocol/src/utils.rs

View check run for this annotation

Codecov / codecov/patch

crates/protocol/protocol/src/utils.rs#L98

Added line #L98 was not covered by tests
}
if eip1559_params[0] != 0 {
return Err(OpBlockConversionError::Eip1559DecodeError);

Check warning on line 101 in crates/protocol/protocol/src/utils.rs

View check run for this annotation

Codecov / codecov/patch

crates/protocol/protocol/src/utils.rs#L101

Added line #L101 was not covered by tests
}

cfg.eip1559_denominator = Some(u32::from_be_bytes(
eip1559_params[0..4]
eip1559_params[1..5]
.try_into()
.map_err(|_| OpBlockConversionError::Eip1559DecodeError)?,
));
cfg.eip1559_elasticity = Some(u32::from_be_bytes(
eip1559_params[4..8]
eip1559_params[5..9]
.try_into()
.map_err(|_| OpBlockConversionError::Eip1559DecodeError)?,
));
Expand Down Expand Up @@ -156,7 +164,7 @@ mod tests {
use crate::test_utils::{RAW_BEDROCK_INFO_TX, RAW_ECOTONE_INFO_TX, RAW_ISTHMUS_INFO_TX};
use alloc::vec;
use alloy_eips::eip1898::BlockNumHash;
use alloy_primitives::{address, hex, uint, U256};
use alloy_primitives::{address, bytes, uint, U256};
use kona_genesis::ChainGenesis;

#[test]
Expand Down Expand Up @@ -300,8 +308,8 @@ mod tests {
let block = OpBlock {
header: alloy_consensus::Header {
number: 1,
// Holocene EIP1559 parameters stored in the nonce.
nonce: hex!("0000beef0000babe").into(),
// Holocene EIP1559 parameters stored in the extra data.
extra_data: bytes!("000000beef0000babe"),
..Default::default()
},
body: alloy_consensus::BlockBody {
Expand Down Expand Up @@ -347,8 +355,8 @@ mod tests {
let block = OpBlock {
header: alloy_consensus::Header {
number: 1,
// Holocene EIP1559 parameters stored in the nonce.
nonce: hex!("0000beef0000babe").into(),
// Holocene EIP1559 parameters stored in the extra data.
extra_data: bytes!("000000beef0000babe"),
..Default::default()
},
body: alloy_consensus::BlockBody {
Expand Down

0 comments on commit 5069f72

Please sign in to comment.