Skip to content

Commit

Permalink
feat: add eip4844 tx type id (#3928)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Jul 27, 2023
1 parent b5a44ae commit 72ab361
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/primitives/src/transaction/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::mem;

use crate::{
compression::{TRANSACTION_COMPRESSOR, TRANSACTION_DECOMPRESSOR},
keccak256, Address, Bytes, ChainId, TxHash, H256,
Expand All @@ -15,6 +13,7 @@ use reth_rlp::{
};
use serde::{Deserialize, Serialize};
pub use signature::Signature;
use std::mem;
pub use tx_type::{TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, LEGACY_TX_TYPE_ID};

mod access_list;
Expand Down Expand Up @@ -265,10 +264,12 @@ pub struct TxEip4844 {
pub access_list: AccessList,

/// It contains a vector of fixed size hash(32 bytes)
pub blob_hashes: Vec<H256>,
pub blob_versioned_hashes: Vec<H256>,

/// Max fee per data gas
pub max_fee_per_blob: u128,
///
/// aka BlobFeeCap
pub max_fee_per_blob_gas: u128,

/// Input has two uses depending if transaction is Create or Call (if `to` field is None or
/// Some). pub init: An unlimited size byte array specifying the
Expand All @@ -291,8 +292,8 @@ impl TxEip4844 {
mem::size_of::<u128>() + // value
self.access_list.size() + // access_list
self.input.len() + // input
self.blob_hashes.capacity() * mem::size_of::<H256>() + // blob hashes size
mem::size_of::<u128>() // blob fee cap
self.blob_versioned_hashes.capacity() * mem::size_of::<H256>() + // blob hashes size
mem::size_of::<u128>() // max_fee_per_data_gas
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/primitives/src/transaction/tx_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pub const EIP2930_TX_TYPE_ID: u8 = 1;
/// Identifier for [TxEip1559](crate::TxEip1559) transaction.
pub const EIP1559_TX_TYPE_ID: u8 = 2;

/// Identifier for [TxEip4844](crate::TxEip4844) transaction.
#[allow(unused)]
pub(crate) const EIP4844_TX_TYPE_ID: u8 = 3;

/// Transaction Type
#[derive_arbitrary(compact)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Default, Serialize, Deserialize)]
Expand Down

0 comments on commit 72ab361

Please sign in to comment.