Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions crates/rpc/rpc-types/src/eth/transaction/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

use alloy_rlp::{BufMut, Decodable, Encodable, Error as RlpError, RlpDecodable, RlpEncodable};
use reth_primitives::{
AccessList, Address, Bytes, Transaction, TxEip1559, TxEip2930, TxLegacy, U128, U256, U64,
kzg::{Blob, Bytes48},
AccessList, Address, Bytes, Transaction, TxEip1559, TxEip2930, TxEip4844, TxLegacy, B256, U128,
U256, U64,
};
use serde::{Deserialize, Serialize};

/// Container type for various Ethereum transaction requests
///
/// Its variants correspond to specific allowed transactions:
Expand All @@ -20,6 +21,7 @@ pub enum TypedTransactionRequest {
Legacy(LegacyTransactionRequest),
EIP2930(EIP2930TransactionRequest),
EIP1559(EIP1559TransactionRequest),
EIP4844(Eip4844TransactionRequest),
}

impl TypedTransactionRequest {
Expand Down Expand Up @@ -61,6 +63,19 @@ impl TypedTransactionRequest {
access_list: tx.access_list,
max_priority_fee_per_gas: tx.max_priority_fee_per_gas.to(),
}),
TypedTransactionRequest::EIP4844(tx) => Transaction::Eip4844(TxEip4844 {
chain_id: tx.chain_id,
nonce: tx.nonce.to(),
gas_limit: tx.gas_limit.to(),
max_fee_per_gas: tx.max_fee_per_gas.to(),
max_priority_fee_per_gas: tx.max_priority_fee_per_gas.to(),
to: tx.kind.into(),
value: tx.value.into(),
access_list: tx.access_list,
blob_versioned_hashes: tx.blob_versioned_hashes,
max_fee_per_blob_gas: tx.max_fee_per_blob_gas,
input: tx.input,
}),
})
}
}
Expand Down Expand Up @@ -104,6 +119,24 @@ pub struct EIP1559TransactionRequest {
pub access_list: AccessList,
}

/// Represents an EIP-4844 transaction request
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Eip4844TransactionRequest {
pub chain_id: u64,
pub nonce: U64,
pub max_priority_fee_per_gas: U128,
pub max_fee_per_gas: U128,
pub gas_limit: U256,
pub kind: TransactionKind,
pub value: U256,
pub input: Bytes,
pub access_list: AccessList,
pub max_fee_per_blob_gas: u128,
pub blob_versioned_hashes: Vec<B256>,
pub gas_price: U128,
pub sidecar: BlobTransactionSidecar,
}

/// Represents the `to` field of a transaction request
///
/// This determines what kind of transaction this is
Expand Down Expand Up @@ -166,3 +199,14 @@ impl From<TransactionKind> for reth_primitives::TransactionKind {
}
}
}

/// This represents a set of blobs, and its corresponding commitments and proofs.
#[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)]
pub struct BlobTransactionSidecar {
/// The blob data.
pub blobs: Vec<Blob>,
/// The blob commitments.
pub commitments: Vec<Bytes48>,
/// The blob proofs.
pub proofs: Vec<Bytes48>,
}
7 changes: 7 additions & 0 deletions crates/rpc/rpc/src/eth/api/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ where

TypedTransactionRequest::EIP1559(m)
}
Some(TypedTransactionRequest::EIP4844(mut m)) => {
m.chain_id = chain_id.to();
m.gas_limit = gas_limit;
m.gas_price = gas_price;

TypedTransactionRequest::EIP4844(m)
}
None => return Err(EthApiError::ConflictingFeeFieldsInRequest),
};

Expand Down