Skip to content

Commit

Permalink
fix: remove optimism-related types (#1203)
Browse files Browse the repository at this point in the history
* fix: remove optimism-related types

* rm serde helper
  • Loading branch information
klkvr authored Aug 27, 2024
1 parent 61c91bc commit d663b1c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 336 deletions.
62 changes: 0 additions & 62 deletions crates/rpc-types-beacon/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,68 +129,6 @@ struct BeaconOptimismPayloadAttributes {
gas_limit: Option<u64>,
}

/// A helper module for serializing and deserializing optimism payload attributes for the beacon
/// API.
///
/// See docs for [beacon_api_payload_attributes].
pub mod beacon_api_payload_attributes_optimism {
use super::*;
use alloy_rpc_types_engine::{OptimismPayloadAttributes, PayloadAttributes};

/// Serialize the payload attributes for the beacon API.
pub fn serialize<S>(
payload_attributes: &OptimismPayloadAttributes,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let beacon_api_payload_attributes = BeaconPayloadAttributes {
timestamp: payload_attributes.payload_attributes.timestamp,
prev_randao: payload_attributes.payload_attributes.prev_randao,
suggested_fee_recipient: payload_attributes.payload_attributes.suggested_fee_recipient,
withdrawals: payload_attributes.payload_attributes.withdrawals.clone(),
parent_beacon_block_root: payload_attributes
.payload_attributes
.parent_beacon_block_root,
};

let op_beacon_api_payload_attributes = BeaconOptimismPayloadAttributes {
payload_attributes: beacon_api_payload_attributes,
transactions: payload_attributes.transactions.clone(),
no_tx_pool: payload_attributes.no_tx_pool,
gas_limit: payload_attributes.gas_limit,
};

op_beacon_api_payload_attributes.serialize(serializer)
}

/// Deserialize the payload attributes for the beacon API.
pub fn deserialize<'de, D>(deserializer: D) -> Result<OptimismPayloadAttributes, D::Error>
where
D: Deserializer<'de>,
{
let beacon_api_payload_attributes =
BeaconOptimismPayloadAttributes::deserialize(deserializer)?;
Ok(OptimismPayloadAttributes {
payload_attributes: PayloadAttributes {
timestamp: beacon_api_payload_attributes.payload_attributes.timestamp,
prev_randao: beacon_api_payload_attributes.payload_attributes.prev_randao,
suggested_fee_recipient: beacon_api_payload_attributes
.payload_attributes
.suggested_fee_recipient,
withdrawals: beacon_api_payload_attributes.payload_attributes.withdrawals,
parent_beacon_block_root: beacon_api_payload_attributes
.payload_attributes
.parent_beacon_block_root,
},
transactions: beacon_api_payload_attributes.transactions,
no_tx_pool: beacon_api_payload_attributes.no_tx_pool,
gas_limit: beacon_api_payload_attributes.gas_limit,
})
}
}

/// A helper module for serializing and deserializing the payload attributes for the beacon API.
///
/// The beacon API encoded object has equivalent fields to the
Expand Down
5 changes: 1 addition & 4 deletions crates/rpc-types-engine/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ mod forkchoice;
mod identification;
#[cfg(feature = "jwt")]
mod jwt;
mod optimism;
pub mod payload;
mod transition;

pub use self::{
cancun::*, forkchoice::*, identification::*, optimism::*, payload::*, transition::*,
};
pub use self::{cancun::*, forkchoice::*, identification::*, payload::*, transition::*};

#[cfg(feature = "jwt")]
pub use self::jwt::*;
Expand Down
86 changes: 0 additions & 86 deletions crates/rpc-types-engine/src/optimism.rs

This file was deleted.

7 changes: 7 additions & 0 deletions crates/rpc-types-engine/src/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1380,4 +1380,11 @@ mod tests {
serde_json::from_str(input);
assert!(payload_res.is_err());
}

// <https://github.com/paradigmxyz/reth/issues/6036>
#[test]
fn deserialize_op_base_payload() {
let payload = r#"{"parentHash":"0x24e8df372a61cdcdb1a163b52aaa1785e0c869d28c3b742ac09e826bbb524723","feeRecipient":"0x4200000000000000000000000000000000000011","stateRoot":"0x9a5db45897f1ff1e620a6c14b0a6f1b3bcdbed59f2adc516a34c9a9d6baafa71","receiptsRoot":"0x8af6f74835d47835deb5628ca941d00e0c9fd75585f26dabdcb280ec7122e6af","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","prevRandao":"0xf37b24eeff594848072a05f74c8600001706c83e489a9132e55bf43a236e42ec","blockNumber":"0xe3d5d8","gasLimit":"0x17d7840","gasUsed":"0xb705","timestamp":"0x65a118c0","extraData":"0x","baseFeePerGas":"0x7a0ff32","blockHash":"0xf5c147b2d60a519b72434f0a8e082e18599021294dd9085d7597b0ffa638f1c0","withdrawals":[],"transactions":["0x7ef90159a05ba0034ffdcb246703298224564720b66964a6a69d0d7e9ffd970c546f7c048094deaddeaddeaddeaddeaddeaddeaddeaddead00019442000000000000000000000000000000000000158080830f424080b90104015d8eb900000000000000000000000000000000000000000000000000000000009e1c4a0000000000000000000000000000000000000000000000000000000065a11748000000000000000000000000000000000000000000000000000000000000000a4b479e5fa8d52dd20a8a66e468b56e993bdbffcccf729223aabff06299ab36db000000000000000000000000000000000000000000000000000000000000000400000000000000000000000073b4168cc87f35cc239200a20eb841cded23493b000000000000000000000000000000000000000000000000000000000000083400000000000000000000000000000000000000000000000000000000000f4240"]}"#;
let _payload = serde_json::from_str::<ExecutionPayloadInputV2>(payload).unwrap();
}
}
3 changes: 0 additions & 3 deletions crates/rpc-types-eth/src/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ pub use common::TransactionInfo;
mod error;
pub use error::ConversionError;

pub mod optimism;
pub use optimism::OptimismTransactionReceiptFields;

mod receipt;
pub use receipt::{AnyTransactionReceipt, TransactionReceipt};

Expand Down
Loading

0 comments on commit d663b1c

Please sign in to comment.