diff --git a/book/cli/reth/import-receipts-op.md b/book/cli/reth/import-receipts-op.md index a5e1863ce..0b7135e1d 100644 --- a/book/cli/reth/import-receipts-op.md +++ b/book/cli/reth/import-receipts-op.md @@ -49,7 +49,7 @@ Database: [possible values: true, false] - The path to a receipts file for import. File must use `HackReceiptFileCodec` (used for + The path to a receipts file for import. File must use `OpGethReceiptFileCodec` (used for exporting OP chain segment below Bedrock block via testinprod/op-geth). diff --git a/crates/optimism/cli/src/commands/import_receipts.rs b/crates/optimism/cli/src/commands/import_receipts.rs index e564982cf..e6235de92 100644 --- a/crates/optimism/cli/src/commands/import_receipts.rs +++ b/crates/optimism/cli/src/commands/import_receipts.rs @@ -26,7 +26,7 @@ use reth_stages::{StageCheckpoint, StageId}; use reth_static_file_types::StaticFileSegment; use tracing::{debug, info, trace, warn}; -use crate::receipt_file_codec::HackReceiptFileCodec; +use crate::receipt_file_codec::OpGethReceiptFileCodec; /// Initializes the database with the genesis block. #[derive(Debug, Parser)] @@ -38,7 +38,7 @@ pub struct ImportReceiptsOpCommand { #[arg(long, value_name = "CHUNK_LEN", verbatim_doc_comment)] chunk_len: Option, - /// The path to a receipts file for import. File must use `HackReceiptFileCodec` (used for + /// The path to a receipts file for import. File must use `OpGethReceiptFileCodec` (used for /// exporting OP chain segment below Bedrock block via testinprod/op-geth). /// /// @@ -161,7 +161,7 @@ where .expect("transaction static files must exist before importing receipts"); while let Some(file_client) = - reader.next_receipts_chunk::>>().await? + reader.next_receipts_chunk::>>().await? { if highest_block_receipts == highest_block_transactions { warn!(target: "reth::cli", highest_block_receipts, highest_block_transactions, "Ignoring all other blocks in the file since we have reached the desired height"); diff --git a/crates/optimism/cli/src/lib.rs b/crates/optimism/cli/src/lib.rs index 4e1aa9469..5c3900a0e 100644 --- a/crates/optimism/cli/src/lib.rs +++ b/crates/optimism/cli/src/lib.rs @@ -16,14 +16,14 @@ pub mod chainspec; pub mod commands; /// Module with a codec for reading and encoding receipts in files. /// -/// Enables decoding and encoding `HackReceipt` type. See . +/// Enables decoding and encoding `OpGethReceipt` type. See . /// -/// Currently configured to use codec [`HackReceipt`](receipt_file_codec::HackReceipt) based on +/// Currently configured to use codec [`OpGethReceipt`](receipt_file_codec::OpGethReceipt) based on /// export of below Bedrock data using . Codec can /// be replaced with regular encoding of receipts for export. /// /// NOTE: receipts can be exported using regular op-geth encoding for `Receipt` type, to fit -/// reth's needs for importing. However, this would require patching the diff in to export the `Receipt` and not `HackReceipt` type (originally +/// reth's needs for importing. However, this would require patching the diff in to export the `Receipt` and not `OpGethReceipt` type (originally /// made for op-erigon's import needs). pub mod receipt_file_codec; diff --git a/crates/optimism/cli/src/receipt_file_codec.rs b/crates/optimism/cli/src/receipt_file_codec.rs index 96810543a..e307b10ac 100644 --- a/crates/optimism/cli/src/receipt_file_codec.rs +++ b/crates/optimism/cli/src/receipt_file_codec.rs @@ -26,17 +26,17 @@ use reth_downloaders::{file_client::FileClientError, receipt_file_client::Receip /// It's recommended to use [`with_capacity`](tokio_util::codec::FramedRead::with_capacity) to set /// the capacity of the framed reader to the size of the file. #[derive(Debug)] -pub struct HackReceiptFileCodec(core::marker::PhantomData); +pub struct OpGethReceiptFileCodec(core::marker::PhantomData); -impl Default for HackReceiptFileCodec { +impl Default for OpGethReceiptFileCodec { fn default() -> Self { Self(Default::default()) } } -impl Decoder for HackReceiptFileCodec +impl Decoder for OpGethReceiptFileCodec where - R: TryFrom>, + R: TryFrom>, { type Item = Option>; type Error = FileClientError; @@ -47,7 +47,7 @@ where } let buf_slice = &mut src.as_ref(); - let receipt = HackReceiptContainer::decode(buf_slice) + let receipt = OpGethReceiptContainer::decode(buf_slice) .map_err(|err| Self::Error::Rlp(err, src.to_vec()))? .0; src.advance(src.len() - buf_slice.len()); @@ -68,7 +68,7 @@ where /// See #[derive(Debug, PartialEq, Eq, RlpDecodable)] -pub struct HackReceipt { +pub struct OpGethReceipt { tx_type: u8, post_state: Bytes, status: u64, @@ -90,13 +90,13 @@ pub struct HackReceipt { #[derive(Debug, PartialEq, Eq, RlpDecodable)] #[rlp(trailing)] -struct HackReceiptContainer(Option); +struct OpGethReceiptContainer(Option); -impl TryFrom for Receipt { +impl TryFrom for Receipt { type Error = &'static str; - fn try_from(exported_receipt: HackReceipt) -> Result { - let HackReceipt { tx_type, status, cumulative_gas_used, logs, .. } = exported_receipt; + fn try_from(exported_receipt: OpGethReceipt) -> Result { + let OpGethReceipt { tx_type, status, cumulative_gas_used, logs, .. } = exported_receipt; #[allow(clippy::needless_update)] Ok(Self { @@ -109,10 +109,10 @@ impl TryFrom for Receipt { } } -impl TryFrom for OpReceipt { +impl TryFrom for OpReceipt { type Error = &'static str; - fn try_from(exported_receipt: HackReceipt) -> Result { + fn try_from(exported_receipt: OpGethReceipt) -> Result { let Receipt { tx_type, success, @@ -152,10 +152,10 @@ pub(crate) mod test { pub(crate) const HACK_RECEIPT_ENCODED_BLOCK_3: &[u8] = &hex!("f90271f9026e8080018301c60db9010000000000000000000000000000000000000000400000000000000000008000000000000000000000000000000000004000000000000000000000400004000000100000000000000000000000000000000000000000000000000000000000004000000000000000000000040000000000400080000400000000000000100000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000008100000000000000000000000000000000000004000000000000000000000000008000000000000000000010000000000000000000000000000400000000000000001000000000000000000000000002000f8faf89c948ce8c13d816fe6daf12d6fd9e4952e1fc88850aff884a092e98423f8adac6e64d0608e519fd1cefb861498385c6dee70d58fc926ddc68ca000000000000000000000000000000000000000000000000000000000d101e54ba00000000000000000000000000000000000000000000000000000000000014218a0000000000000000000000000fa011d8d6c26f13abe2cefed38226e401b2b8a9980f85a948ce8c13d816fe6daf12d6fd9e4952e1fc88850aff842a0fe25c73e3b9089fac37d55c4c7efcba6f04af04cebd2fc4d6d7dbb07e1e5234fa000000000000000000000000000000000000000000000007ed8842f062774800080a08fab01dcec1da547e90a77597999e9153ff788fa6451d1cc942064427bd995019400000000000000000000000000000000000000008301c60da0da4509fe0ca03202ddbe4f68692c132d689ee098433691040ece18c3a45d44c50380018212c2821c2383312e35"); - fn hack_receipt_1() -> HackReceipt { + fn hack_receipt_1() -> OpGethReceipt { let receipt = receipt_block_1(); - HackReceipt { + OpGethReceipt { tx_type: receipt.receipt.tx_type as u8, post_state: Bytes::default(), status: receipt.receipt.success as u64, @@ -354,7 +354,7 @@ pub(crate) mod test { fn decode_hack_receipt() { let receipt = hack_receipt_1(); - let decoded = HackReceiptContainer::decode(&mut &HACK_RECEIPT_ENCODED_BLOCK_1[..]) + let decoded = OpGethReceiptContainer::decode(&mut &HACK_RECEIPT_ENCODED_BLOCK_1[..]) .unwrap() .0 .unwrap(); @@ -373,7 +373,7 @@ pub(crate) mod test { let encoded = &mut BytesMut::from(&receipt_1_to_3[..]); - let mut codec = HackReceiptFileCodec::default(); + let mut codec = OpGethReceiptFileCodec::default(); // test