Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add eip4844 tx type id #3928

Merged
merged 3 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 5 additions & 4 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 @@ -268,7 +267,9 @@ pub struct TxEip4844 {
pub blob_hashes: Vec<H256>,

/// Max fee per data gas
pub max_fee_per_blob: u128,
///
/// aka BlobFeeCap
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good comment

Copy link
Collaborator

@joshieDo joshieDo Jul 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not maintain blob instead of data? (which is in accordance to the eip)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good point, renamed so it matches eip

pub max_fee_per_data_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 @@ -292,7 +293,7 @@ impl TxEip4844 {
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
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