Skip to content

Commit

Permalink
fix(workspace): Exclude Maili Shadows (#1076)
Browse files Browse the repository at this point in the history
Co-authored-by: clabby <ben@clab.by>
  • Loading branch information
refcell and clabby authored Feb 21, 2025
1 parent 42e5cb1 commit d02f6e0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ homepage = "https://github.com/op-rs/kona"
repository = "https://github.com/op-rs/kona"
keywords = ["ethereum", "optimism", "crypto"]
categories = ["cryptography", "cryptography::cryptocurrencies"]
exclude = ["**/target"]
exclude = [
"**/target",
# Maili shadow crates must be explicitly excluded for `cargo metadata` to work
"crates/external/rpc/maili",
"crates/protocol/protocol/maili",
"crates/protocol/interop/maili",
"crates/protocol/registry/maili",
"crates/protocol/genesis/maili",
"crates/utilities/serde/maili",
]

[workspace]
members = [
Expand Down
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);
}
if eip1559_params[0] != 0 {
return Err(OpBlockConversionError::Eip1559DecodeError);
}

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 d02f6e0

Please # to comment.