mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-26 23:58:46 -05:00
chore(sdk): impl Receipt for reth_primitives::Receipt (#12446)
This commit is contained in:
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -91,9 +91,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.20"
|
||||
version = "0.2.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
|
||||
checksum = "611cc2ae7d2e242c457e4be7f97036b8ad9ca152b499f53faf99b1ed8fc2553f"
|
||||
|
||||
[[package]]
|
||||
name = "alloy-chains"
|
||||
@@ -9645,9 +9645,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.40"
|
||||
version = "0.38.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
|
||||
checksum = "375116bee2be9ed569afe2154ea6a99dfdffd257f533f187498c2a8f5feaf4ee"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"errno",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use core::fmt;
|
||||
|
||||
use alloy_consensus::TxReceipt;
|
||||
use alloy_primitives::B256;
|
||||
use reth_codecs::Compact;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -27,4 +28,7 @@ pub trait Receipt:
|
||||
{
|
||||
/// Returns transaction type.
|
||||
fn tx_type(&self) -> u8;
|
||||
|
||||
/// Calculates the receipts root of all receipts in a block.
|
||||
fn receipts_root(receipts: &[&Self]) -> B256;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
#[cfg(feature = "reth-codec")]
|
||||
use crate::compression::{RECEIPT_COMPRESSOR, RECEIPT_DECOMPRESSOR};
|
||||
use crate::TxType;
|
||||
use alloc::{vec, vec::Vec};
|
||||
use alloy_consensus::constants::{
|
||||
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
|
||||
use core::{cmp::Ordering, ops::Deref};
|
||||
|
||||
use alloy_consensus::{
|
||||
constants::{EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID},
|
||||
Eip658Value, TxReceipt,
|
||||
};
|
||||
use alloy_eips::eip2718::Encodable2718;
|
||||
use alloy_primitives::{Bloom, Log, B256};
|
||||
use alloy_rlp::{length_of_length, Decodable, Encodable, RlpDecodable, RlpEncodable};
|
||||
use bytes::{Buf, BufMut};
|
||||
use core::{cmp::Ordering, ops::Deref};
|
||||
use derive_more::{DerefMut, From, IntoIterator};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[cfg(feature = "reth-codec")]
|
||||
use crate::compression::{RECEIPT_COMPRESSOR, RECEIPT_DECOMPRESSOR};
|
||||
use crate::TxType;
|
||||
|
||||
/// Receipt containing result of transaction execution.
|
||||
#[derive(
|
||||
Clone, Debug, PartialEq, Eq, Default, RlpEncodable, RlpDecodable, Serialize, Deserialize,
|
||||
@@ -64,6 +67,42 @@ impl Receipt {
|
||||
}
|
||||
}
|
||||
|
||||
// todo: replace with alloy receipt
|
||||
impl TxReceipt for Receipt {
|
||||
fn status_or_post_state(&self) -> Eip658Value {
|
||||
self.success.into()
|
||||
}
|
||||
|
||||
fn status(&self) -> bool {
|
||||
self.success
|
||||
}
|
||||
|
||||
fn bloom(&self) -> Bloom {
|
||||
alloy_primitives::logs_bloom(self.logs.iter())
|
||||
}
|
||||
|
||||
fn cumulative_gas_used(&self) -> u128 {
|
||||
self.cumulative_gas_used as u128
|
||||
}
|
||||
|
||||
fn logs(&self) -> &[Log] {
|
||||
&self.logs
|
||||
}
|
||||
}
|
||||
|
||||
impl reth_primitives_traits::Receipt for Receipt {
|
||||
fn tx_type(&self) -> u8 {
|
||||
self.tx_type as u8
|
||||
}
|
||||
|
||||
fn receipts_root(_receipts: &[&Self]) -> B256 {
|
||||
#[cfg(feature = "optimism")]
|
||||
panic!("This should not be called in optimism mode. Use `optimism_receipts_root_slow` instead.");
|
||||
#[cfg(not(feature = "optimism"))]
|
||||
crate::proofs::calculate_receipt_root_no_memo(_receipts)
|
||||
}
|
||||
}
|
||||
|
||||
/// A collection of receipts organized as a two-dimensional vector.
|
||||
#[derive(
|
||||
Clone,
|
||||
|
||||
Reference in New Issue
Block a user