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(primitives): remove TxValue wrapper #6874

Merged
merged 3 commits into from
Feb 29, 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
2 changes: 1 addition & 1 deletion bin/reth/src/commands/db/static_files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl Command {
fn generate_static_file<DB: Database>(
&self,
factory: Arc<ProviderFactory<DB>>,
segment: impl Segment<DB> + Send + Sync,
segment: impl Segment<DB>,
config: SegmentConfig,
) -> eyre::Result<()> {
let dir = PathBuf::default();
Expand Down
4 changes: 2 additions & 2 deletions crates/consensus/common/src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ mod tests {
gas_price: 0x28f000fff,
gas_limit: 10,
to: TransactionKind::Call(Address::default()),
value: 3_u64.into(),
value: U256::from(3_u64),
input: Bytes::from(vec![1, 2]),
access_list: Default::default(),
});
Expand All @@ -461,7 +461,7 @@ mod tests {
max_fee_per_blob_gas: 0x7,
gas_limit: 10,
to: TransactionKind::Call(Address::default()),
value: 3_u64.into(),
value: U256::from(3_u64),
input: Bytes::from(vec![1, 2]),
access_list: Default::default(),
blob_versioned_hashes: std::iter::repeat_with(|| rng.gen()).take(num_blobs).collect(),
Expand Down
6 changes: 3 additions & 3 deletions crates/interfaces/src/test_utils/generators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn random_tx<R: Rng>(rng: &mut R) -> Transaction {
gas_price: rng.gen::<u16>().into(),
gas_limit: rng.gen::<u16>().into(),
to: TransactionKind::Call(rng.gen()),
value: U256::from(rng.gen::<u16>()).into(),
value: U256::from(rng.gen::<u16>()),
input: Bytes::default(),
})
}
Expand Down Expand Up @@ -396,7 +396,7 @@ mod tests {
nonce: 0x42,
gas_limit: 44386,
to: TransactionKind::Call(hex!("6069a6c32cf691f5982febae4faf8a6f3ab2f0f6").into()),
value: 0_u64.into(),
value: U256::from(0_u64),
input: hex!("a22cb4650000000000000000000000005eee75727d804a2b13038928d36f8b188945a57a0000000000000000000000000000000000000000000000000000000000000000").into(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down Expand Up @@ -428,7 +428,7 @@ mod tests {
gas_price: 20 * 10_u128.pow(9),
gas_limit: 21000,
to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()),
value: 10_u128.pow(18).into(),
value: U256::from(10_u128.pow(18)),
input: Bytes::default(),
});

Expand Down
8 changes: 4 additions & 4 deletions crates/net/eth-wire/src/types/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ mod tests {
gas_price: 0x4a817c808,
gas_limit: 0x2e248u64,
to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()),
value: 0x200u64.into(),
value: U256::from(0x200u64),
input: Default::default(),
}),
Signature {
Expand All @@ -401,7 +401,7 @@ mod tests {
gas_price: 0x4a817c809,
gas_limit: 0x33450u64,
to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()),
value: 0x2d9u64.into(),
value: U256::from(0x2d9u64),
input: Default::default(),
}), Signature {
odd_y_parity: false,
Expand Down Expand Up @@ -458,7 +458,7 @@ mod tests {
gas_price: 0x4a817c808,
gas_limit: 0x2e248u64,
to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()),
value: 0x200u64.into(),
value: U256::from(0x200u64),
input: Default::default(),
}),
Signature {
Expand All @@ -474,7 +474,7 @@ mod tests {
gas_price: 0x4a817c809,
gas_limit: 0x33450u64,
to: TransactionKind::Call(hex!("3535353535353535353535353535353535353535").into()),
value: 0x2d9u64.into(),
value: U256::from(0x2d9u64),
input: Default::default(),
}),
Signature {
Expand Down
28 changes: 14 additions & 14 deletions crates/net/eth-wire/src/types/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ mod tests {
to: TransactionKind::Call(
hex!("3535353535353535353535353535353535353535").into(),
),
value: 0x200u64.into(),
value: U256::from(0x200u64),
input: Default::default(),
}),
Signature {
Expand All @@ -154,7 +154,7 @@ mod tests {
to: TransactionKind::Call(
hex!("3535353535353535353535353535353535353535").into(),
),
value: 0x2d9u64.into(),
value: U256::from(0x2d9u64),
input: Default::default(),
}),
Signature {
Expand Down Expand Up @@ -192,7 +192,7 @@ mod tests {
to: TransactionKind::Call(
hex!("3535353535353535353535353535353535353535").into(),
),
value: 0x200u64.into(),
value: U256::from(0x200u64),
input: Default::default(),
}),
Signature {
Expand All @@ -216,7 +216,7 @@ mod tests {
to: TransactionKind::Call(
hex!("3535353535353535353535353535353535353535").into(),
),
value: 0x2d9u64.into(),
value: U256::from(0x2d9u64),
input: Default::default(),
}),
Signature {
Expand Down Expand Up @@ -257,7 +257,7 @@ mod tests {
to: TransactionKind::Call(
hex!("cf7f9e66af820a19257a2108375b180b0ec49167").into(),
),
value: 1234u64.into(),
value: U256::from(1234u64),
input: Default::default(),
}),
Signature {
Expand All @@ -282,7 +282,7 @@ mod tests {
to: TransactionKind::Call(
hex!("61815774383099e24810ab832a5b2a5425c154d5").into(),
),
value: 3000000000000000000u64.into(),
value: U256::from(3000000000000000000u64),
input: Default::default(),
access_list: Default::default(),
}),
Expand All @@ -307,7 +307,7 @@ mod tests {
to: TransactionKind::Call(
hex!("d3e8763675e4c425df46cc3b5c0f6cbdac396046").into(),
),
value: 1000000000000000u64.into(),
value: U256::from(1000000000000000u64),
input: Default::default(),
}),
Signature {
Expand All @@ -331,7 +331,7 @@ mod tests {
to: TransactionKind::Call(
hex!("d3e8763675e4c425df46cc3b5c0f6cbdac396046").into(),
),
value: 693361000000000u64.into(),
value: U256::from(693361000000000u64),
input: Default::default(),
}),
Signature {
Expand All @@ -355,7 +355,7 @@ mod tests {
to: TransactionKind::Call(
hex!("d3e8763675e4c425df46cc3b5c0f6cbdac396046").into(),
),
value: 1000000000000000u64.into(),
value: U256::from(1000000000000000u64),
input: Default::default(),
}),
Signature {
Expand Down Expand Up @@ -400,7 +400,7 @@ mod tests {
to: TransactionKind::Call(
hex!("cf7f9e66af820a19257a2108375b180b0ec49167").into(),
),
value: 1234u64.into(),
value: U256::from(1234u64),
input: Default::default(),
}),
Signature {
Expand All @@ -425,7 +425,7 @@ mod tests {
to: TransactionKind::Call(
hex!("61815774383099e24810ab832a5b2a5425c154d5").into(),
),
value: 3000000000000000000u64.into(),
value: U256::from(3000000000000000000u64),
input: Default::default(),
access_list: Default::default(),
}),
Expand All @@ -450,7 +450,7 @@ mod tests {
to: TransactionKind::Call(
hex!("d3e8763675e4c425df46cc3b5c0f6cbdac396046").into(),
),
value: 1000000000000000u64.into(),
value: U256::from(1000000000000000u64),
input: Default::default(),
}),
Signature {
Expand All @@ -474,7 +474,7 @@ mod tests {
to: TransactionKind::Call(
hex!("d3e8763675e4c425df46cc3b5c0f6cbdac396046").into(),
),
value: 693361000000000u64.into(),
value: U256::from(693361000000000u64),
input: Default::default(),
}),
Signature {
Expand All @@ -498,7 +498,7 @@ mod tests {
to: TransactionKind::Call(
hex!("d3e8763675e4c425df46cc3b5c0f6cbdac396046").into(),
),
value: 1000000000000000u64.into(),
value: U256::from(1000000000000000u64),
input: Default::default(),
}),
Signature {
Expand Down
2 changes: 1 addition & 1 deletion crates/net/network/tests/it/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn rng_transaction(rng: &mut impl rand::RngCore) -> TransactionSigned {
gas_price: rng.gen(),
gas_limit: rng.gen(),
to: TransactionKind::Create,
value: rng.gen::<u128>().into(),
value: U256::from(rng.gen::<u128>()),
input: Bytes::from(vec![1, 2]),
access_list: Default::default(),
});
Expand Down
2 changes: 1 addition & 1 deletion crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub use transaction::{
AccessList, AccessListItem, FromRecoveredTransaction, IntoRecoveredTransaction,
InvalidTransactionError, Signature, Transaction, TransactionKind, TransactionMeta,
TransactionSigned, TransactionSignedEcRecovered, TransactionSignedNoHash, TxEip1559, TxEip2930,
TxEip4844, TxHashOrNumber, TxLegacy, TxType, TxValue, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
TxEip4844, TxHashOrNumber, TxLegacy, TxType, EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID,
EIP4844_TX_TYPE_ID, LEGACY_TX_TYPE_ID,
};
pub use withdrawal::{Withdrawal, Withdrawals};
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives/src/proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ use crate::{
keccak256,
trie::{HashBuilder, Nibbles, TrieAccount},
Address, Header, Receipt, ReceiptWithBloom, ReceiptWithBloomRef, TransactionSigned, Withdrawal,
B256,
B256, U256,
};
use alloy_primitives::U256;
use alloy_rlp::Encodable;
use bytes::{BufMut, BytesMut};
use itertools::Itertools;
Expand Down
10 changes: 5 additions & 5 deletions crates/primitives/src/revm/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
TransactionKind::Call(to) => TransactTo::Call(to),
TransactionKind::Create => TransactTo::create(),
};
tx_env.value = tx.value.into();
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = tx.chain_id;
tx_env.nonce = Some(tx.nonce);
Expand All @@ -216,7 +216,7 @@ where
TransactionKind::Call(to) => TransactTo::Call(to),
TransactionKind::Create => TransactTo::create(),
};
tx_env.value = tx.value.into();
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
Expand All @@ -239,7 +239,7 @@ where
TransactionKind::Call(to) => TransactTo::Call(to),
TransactionKind::Create => TransactTo::create(),
};
tx_env.value = tx.value.into();
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
Expand All @@ -262,7 +262,7 @@ where
TransactionKind::Call(to) => TransactTo::Call(to),
TransactionKind::Create => TransactTo::create(),
};
tx_env.value = tx.value.into();
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = Some(tx.chain_id);
tx_env.nonce = Some(tx.nonce);
Expand All @@ -287,7 +287,7 @@ where
TransactionKind::Call(to) => tx_env.transact_to = TransactTo::Call(to),
TransactionKind::Create => tx_env.transact_to = TransactTo::create(),
}
tx_env.value = tx.value.into();
tx_env.value = tx.value;
tx_env.data = tx.input.clone();
tx_env.chain_id = None;
tx_env.nonce = None;
Expand Down
3 changes: 1 addition & 2 deletions crates/primitives/src/transaction/access_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{Address, B256};
use alloy_primitives::U256;
use crate::{Address, B256, U256};
use alloy_rlp::{RlpDecodable, RlpDecodableWrapper, RlpEncodable, RlpEncodableWrapper};
use reth_codecs::{main_codec, Compact};
use std::{
Expand Down
8 changes: 4 additions & 4 deletions crates/primitives/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::access_list::AccessList;
use crate::{keccak256, Bytes, ChainId, Signature, TransactionKind, TxType, TxValue, B256};
use crate::{keccak256, Bytes, ChainId, Signature, TransactionKind, TxType, B256, U256};
use alloy_rlp::{length_of_length, Decodable, Encodable, Header};
use bytes::BytesMut;
use reth_codecs::{main_codec, Compact};
Expand Down Expand Up @@ -46,7 +46,7 @@ pub struct TxEip1559 {
/// be transferred to the message call’s recipient or,
/// in the case of contract creation, as an endowment
/// to the newly created account; formally Tv.
pub value: TxValue,
pub value: U256,
/// The accessList specifies a list of addresses and storage keys;
/// these addresses and storage keys are added into the `accessed_addresses`
/// and `accessed_storage_keys` global sets (introduced in EIP-2929).
Expand Down Expand Up @@ -188,7 +188,7 @@ impl TxEip1559 {
mem::size_of::<u128>() + // max_fee_per_gas
mem::size_of::<u128>() + // max_priority_fee_per_gas
self.to.size() + // to
mem::size_of::<TxValue>() + // value
mem::size_of::<U256>() + // value
self.access_list.size() + // access_list
self.input.len() // input
}
Expand Down Expand Up @@ -244,7 +244,7 @@ mod tests {
nonce: 0x42,
gas_limit: 44386,
to: TransactionKind::Call( hex!("6069a6c32cf691f5982febae4faf8a6f3ab2f0f6").into()),
value: 0_u64.into(),
value: U256::ZERO,
input: hex!("a22cb4650000000000000000000000005eee75727d804a2b13038928d36f8b188945a57a0000000000000000000000000000000000000000000000000000000000000000").into(),
max_fee_per_gas: 0x4a817c800,
max_priority_fee_per_gas: 0x3b9aca00,
Expand Down
10 changes: 5 additions & 5 deletions crates/primitives/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::access_list::AccessList;
use crate::{keccak256, Bytes, ChainId, Signature, TransactionKind, TxType, TxValue, B256};
use crate::{keccak256, Bytes, ChainId, Signature, TransactionKind, TxType, B256, U256};
use alloy_rlp::{length_of_length, Decodable, Encodable, Header};
use bytes::BytesMut;
use reth_codecs::{main_codec, Compact};
Expand Down Expand Up @@ -34,7 +34,7 @@ pub struct TxEip2930 {
/// be transferred to the message call’s recipient or,
/// in the case of contract creation, as an endowment
/// to the newly created account; formally Tv.
pub value: TxValue,
pub value: U256,
/// The accessList specifies a list of addresses and storage keys;
/// these addresses and storage keys are added into the `accessed_addresses`
/// and `accessed_storage_keys` global sets (introduced in EIP-2929).
Expand All @@ -58,7 +58,7 @@ impl TxEip2930 {
mem::size_of::<u128>() + // gas_price
mem::size_of::<u64>() + // gas_limit
self.to.size() + // to
mem::size_of::<TxValue>() + // value
mem::size_of::<U256>() + // value
self.access_list.size() + // access_list
self.input.len() // input
}
Expand Down Expand Up @@ -204,7 +204,7 @@ mod tests {
gas_price: 1,
gas_limit: 2,
to: TransactionKind::Create,
value: 3_u64.into(),
value: U256::from(3),
input: Bytes::from(vec![1, 2]),
access_list: Default::default(),
});
Expand All @@ -227,7 +227,7 @@ mod tests {
gas_price: 1,
gas_limit: 2,
to: TransactionKind::Call(Address::default()),
value: 3_u64.into(),
value: U256::from(3),
input: Bytes::from(vec![1, 2]),
access_list: Default::default(),
});
Expand Down
Loading