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

chore: apply same member order #1408

Merged
merged 1 commit into from
Oct 1, 2024
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
8 changes: 4 additions & 4 deletions crates/consensus/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ mod block_rlp {
}

impl<T: Encodable> Encodable for Block<T> {
fn length(&self) -> usize {
fn encode(&self, out: &mut dyn alloy_rlp::bytes::BufMut) {
let helper: HelperRef<'_, T> = self.into();
helper.length()
helper.encode(out)
}

fn encode(&self, out: &mut dyn alloy_rlp::bytes::BufMut) {
fn length(&self) -> usize {
let helper: HelperRef<'_, T> = self.into();
helper.encode(out)
helper.length()
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,14 @@ impl Transaction for TxEip1559 {
Some(self.max_priority_fee_per_gas)
}

fn priority_fee_or_price(&self) -> u128 {
self.max_priority_fee_per_gas
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
None
}

fn priority_fee_or_price(&self) -> u128 {
self.max_priority_fee_per_gas
}

fn to(&self) -> TxKind {
self.to
}
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,14 @@ impl Transaction for TxEip2930 {
None
}

fn priority_fee_or_price(&self) -> u128 {
self.gas_price
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
None
}

fn priority_fee_or_price(&self) -> u128 {
self.gas_price
}

fn to(&self) -> TxKind {
self.to
}
Expand Down
28 changes: 14 additions & 14 deletions crates/consensus/src/transaction/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,17 @@ impl Transaction for TxEip4844Variant {
}
}

fn priority_fee_or_price(&self) -> u128 {
fn max_fee_per_blob_gas(&self) -> Option<u128> {
match self {
Self::TxEip4844(tx) => tx.priority_fee_or_price(),
Self::TxEip4844WithSidecar(tx) => tx.priority_fee_or_price(),
Self::TxEip4844(tx) => tx.max_fee_per_blob_gas(),
Self::TxEip4844WithSidecar(tx) => tx.max_fee_per_blob_gas(),
}
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
fn priority_fee_or_price(&self) -> u128 {
match self {
Self::TxEip4844(tx) => tx.max_fee_per_blob_gas(),
Self::TxEip4844WithSidecar(tx) => tx.max_fee_per_blob_gas(),
Self::TxEip4844(tx) => tx.priority_fee_or_price(),
Self::TxEip4844WithSidecar(tx) => tx.priority_fee_or_price(),
}
}

Expand Down Expand Up @@ -709,14 +709,14 @@ impl Transaction for TxEip4844 {
Some(self.max_priority_fee_per_gas)
}

fn priority_fee_or_price(&self) -> u128 {
self.max_priority_fee_per_gas
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
Some(self.max_fee_per_blob_gas)
}

fn priority_fee_or_price(&self) -> u128 {
self.max_priority_fee_per_gas
}

fn to(&self) -> TxKind {
self.to.into()
}
Expand Down Expand Up @@ -982,14 +982,14 @@ impl Transaction for TxEip4844WithSidecar {
self.tx.max_priority_fee_per_gas()
}

fn priority_fee_or_price(&self) -> u128 {
self.tx.priority_fee_or_price()
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
self.tx.max_fee_per_blob_gas()
}

fn priority_fee_or_price(&self) -> u128 {
self.tx.priority_fee_or_price()
}

fn to(&self) -> TxKind {
self.tx.to()
}
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/src/transaction/eip7702.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,14 @@ impl Transaction for TxEip7702 {
Some(self.max_priority_fee_per_gas)
}

fn priority_fee_or_price(&self) -> u128 {
self.max_priority_fee_per_gas
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
None
}

fn priority_fee_or_price(&self) -> u128 {
self.max_priority_fee_per_gas
}

fn to(&self) -> TxKind {
self.to.into()
}
Expand Down
52 changes: 26 additions & 26 deletions crates/consensus/src/transaction/envelope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,16 @@ impl Transaction for TxEnvelope {
}
}

fn nonce(&self) -> u64 {
match self {
Self::Legacy(tx) => tx.tx().nonce(),
Self::Eip2930(tx) => tx.tx().nonce(),
Self::Eip1559(tx) => tx.tx().nonce(),
Self::Eip4844(tx) => tx.tx().nonce(),
Self::Eip7702(tx) => tx.tx().nonce(),
}
}

fn gas_limit(&self) -> u64 {
match self {
Self::Legacy(tx) => tx.tx().gas_limit(),
Expand Down Expand Up @@ -422,16 +432,6 @@ impl Transaction for TxEnvelope {
}
}

fn priority_fee_or_price(&self) -> u128 {
match self {
Self::Legacy(tx) => tx.tx().priority_fee_or_price(),
Self::Eip2930(tx) => tx.tx().priority_fee_or_price(),
Self::Eip1559(tx) => tx.tx().priority_fee_or_price(),
Self::Eip4844(tx) => tx.tx().priority_fee_or_price(),
Self::Eip7702(tx) => tx.tx().priority_fee_or_price(),
}
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
match self {
Self::Legacy(tx) => tx.tx().max_fee_per_blob_gas(),
Expand All @@ -442,23 +442,13 @@ impl Transaction for TxEnvelope {
}
}

fn input(&self) -> &[u8] {
match self {
Self::Legacy(tx) => tx.tx().input(),
Self::Eip2930(tx) => tx.tx().input(),
Self::Eip1559(tx) => tx.tx().input(),
Self::Eip4844(tx) => tx.tx().input(),
Self::Eip7702(tx) => tx.tx().input(),
}
}

fn nonce(&self) -> u64 {
fn priority_fee_or_price(&self) -> u128 {
match self {
Self::Legacy(tx) => tx.tx().nonce(),
Self::Eip2930(tx) => tx.tx().nonce(),
Self::Eip1559(tx) => tx.tx().nonce(),
Self::Eip4844(tx) => tx.tx().nonce(),
Self::Eip7702(tx) => tx.tx().nonce(),
Self::Legacy(tx) => tx.tx().priority_fee_or_price(),
Self::Eip2930(tx) => tx.tx().priority_fee_or_price(),
Self::Eip1559(tx) => tx.tx().priority_fee_or_price(),
Self::Eip4844(tx) => tx.tx().priority_fee_or_price(),
Self::Eip7702(tx) => tx.tx().priority_fee_or_price(),
}
}

Expand All @@ -482,6 +472,16 @@ impl Transaction for TxEnvelope {
}
}

fn input(&self) -> &[u8] {
match self {
Self::Legacy(tx) => tx.tx().input(),
Self::Eip2930(tx) => tx.tx().input(),
Self::Eip1559(tx) => tx.tx().input(),
Self::Eip4844(tx) => tx.tx().input(),
Self::Eip7702(tx) => tx.tx().input(),
}
}

fn ty(&self) -> u8 {
match self {
Self::Legacy(tx) => tx.tx().ty(),
Expand Down
8 changes: 4 additions & 4 deletions crates/consensus/src/transaction/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ impl Transaction for TxLegacy {
None
}

fn priority_fee_or_price(&self) -> u128 {
self.gas_price
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
None
}

fn priority_fee_or_price(&self) -> u128 {
self.gas_price
}

fn to(&self) -> TxKind {
self.to
}
Expand Down
20 changes: 10 additions & 10 deletions crates/consensus/src/transaction/typed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,6 @@ impl Transaction for TypedTransaction {
}
}

fn priority_fee_or_price(&self) -> u128 {
match self {
Self::Legacy(tx) => tx.priority_fee_or_price(),
Self::Eip2930(tx) => tx.priority_fee_or_price(),
Self::Eip1559(tx) => tx.priority_fee_or_price(),
Self::Eip4844(tx) => tx.priority_fee_or_price(),
Self::Eip7702(tx) => tx.priority_fee_or_price(),
}
}

fn max_fee_per_blob_gas(&self) -> Option<u128> {
match self {
Self::Legacy(tx) => tx.max_fee_per_blob_gas(),
Expand All @@ -216,6 +206,16 @@ impl Transaction for TypedTransaction {
}
}

fn priority_fee_or_price(&self) -> u128 {
match self {
Self::Legacy(tx) => tx.priority_fee_or_price(),
Self::Eip2930(tx) => tx.priority_fee_or_price(),
Self::Eip1559(tx) => tx.priority_fee_or_price(),
Self::Eip4844(tx) => tx.priority_fee_or_price(),
Self::Eip7702(tx) => tx.priority_fee_or_price(),
}
}

fn to(&self) -> TxKind {
match self {
Self::Legacy(tx) => tx.to(),
Expand Down
2 changes: 1 addition & 1 deletion crates/rpc-types-eth/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,8 @@ pub struct BlockOverrides {
}

impl<T: TransactionResponse, H: HeaderResponse> BlockResponse for Block<T, H> {
type Transaction = T;
type Header = H;
type Transaction = T;

fn header(&self) -> &Self::Header {
&self.header
Expand Down