diff --git a/crates/primitives/src/lib.rs b/crates/primitives/src/lib.rs index 72c808071..cfa7ad364 100644 --- a/crates/primitives/src/lib.rs +++ b/crates/primitives/src/lib.rs @@ -73,7 +73,6 @@ pub use prune::{ ReceiptsLogPruneConfig, MINIMUM_PRUNING_DISTANCE, }; pub use receipt::{Receipt, ReceiptWithBloom, ReceiptWithBloomRef, Receipts}; -pub use serde_helper::JsonU256; pub use snapshot::SnapshotSegment; pub use storage::StorageEntry; diff --git a/testing/ef-tests/src/models.rs b/testing/ef-tests/src/models.rs index e213bdb5b..4578c001e 100644 --- a/testing/ef-tests/src/models.rs +++ b/testing/ef-tests/src/models.rs @@ -8,8 +8,8 @@ use reth_db::{ }; use reth_primitives::{ keccak256, Account as RethAccount, Address, Bloom, Bytecode, Bytes, ChainSpec, - ChainSpecBuilder, Header as RethHeader, JsonU256, SealedHeader, StorageEntry, Withdrawals, - B256, B64, U256, + ChainSpecBuilder, Header as RethHeader, SealedHeader, StorageEntry, Withdrawals, B256, B64, + U256, }; use serde::{self, Deserialize}; use std::{collections::BTreeMap, ops::Deref}; @@ -49,13 +49,13 @@ pub struct Header { /// Coinbase. pub coinbase: Address, /// Difficulty. - pub difficulty: JsonU256, + pub difficulty: U256, /// Extra data. pub extra_data: Bytes, /// Gas limit. - pub gas_limit: JsonU256, + pub gas_limit: U256, /// Gas used. - pub gas_used: JsonU256, + pub gas_used: U256, /// Block Hash. pub hash: B256, /// Mix hash. @@ -63,7 +63,7 @@ pub struct Header { /// Seal nonce. pub nonce: B64, /// Block number. - pub number: JsonU256, + pub number: U256, /// Parent hash. pub parent_hash: B256, /// Receipt trie. @@ -71,19 +71,19 @@ pub struct Header { /// State root. pub state_root: B256, /// Timestamp. - pub timestamp: JsonU256, + pub timestamp: U256, /// Transactions trie. pub transactions_trie: B256, /// Uncle hash. pub uncle_hash: B256, /// Base fee per gas. - pub base_fee_per_gas: Option, + pub base_fee_per_gas: Option, /// Withdrawals root. pub withdrawals_root: Option, /// Blob gas used. - pub blob_gas_used: Option, + pub blob_gas_used: Option, /// Excess blob gas. - pub excess_blob_gas: Option, + pub excess_blob_gas: Option, /// Parent beacon block root. pub parent_beacon_block_root: Option, } @@ -91,16 +91,16 @@ pub struct Header { impl From
for SealedHeader { fn from(value: Header) -> Self { let header = RethHeader { - base_fee_per_gas: value.base_fee_per_gas.map(|v| v.0.to::()), + base_fee_per_gas: value.base_fee_per_gas.map(|v| v.to::()), beneficiary: value.coinbase, - difficulty: value.difficulty.0, + difficulty: value.difficulty, extra_data: value.extra_data, - gas_limit: value.gas_limit.0.to::(), - gas_used: value.gas_used.0.to::(), + gas_limit: value.gas_limit.to::(), + gas_used: value.gas_used.to::(), mix_hash: value.mix_hash, nonce: u64::from_be_bytes(value.nonce.0), - number: value.number.0.to::(), - timestamp: value.timestamp.0.to::(), + number: value.number.to::(), + timestamp: value.timestamp.to::(), transactions_root: value.transactions_trie, receipts_root: value.receipt_trie, ommers_hash: value.uncle_hash, @@ -108,8 +108,8 @@ impl From
for SealedHeader { parent_hash: value.parent_hash, logs_bloom: value.bloom, withdrawals_root: value.withdrawals_root, - blob_gas_used: value.blob_gas_used.map(|v| v.0.to::()), - excess_blob_gas: value.excess_blob_gas.map(|v| v.0.to::()), + blob_gas_used: value.blob_gas_used.map(|v| v.to::()), + excess_blob_gas: value.excess_blob_gas.map(|v| v.to::()), parent_beacon_block_root: value.parent_beacon_block_root, }; header.seal(value.hash) @@ -156,8 +156,8 @@ impl State { let has_code = !account.code.is_empty(); let code_hash = has_code.then(|| keccak256(&account.code)); let reth_account = RethAccount { - balance: account.balance.0, - nonce: account.nonce.0.to::(), + balance: account.balance, + nonce: account.nonce.to::(), bytecode_hash: code_hash, }; tx.put::(address, reth_account)?; @@ -165,15 +165,15 @@ impl State { if let Some(code_hash) = code_hash { tx.put::(code_hash, Bytecode::new_raw(account.code.clone()))?; } - account.storage.iter().filter(|(_, v)| v.0 != U256::ZERO).try_for_each(|(k, v)| { - let storage_key = B256::from_slice(&k.0.to_be_bytes::<32>()); + account.storage.iter().filter(|(_, v)| !v.is_zero()).try_for_each(|(k, v)| { + let storage_key = B256::from_slice(&k.to_be_bytes::<32>()); tx.put::( address, - StorageEntry { key: storage_key, value: v.0 }, + StorageEntry { key: storage_key, value: *v }, )?; tx.put::( hashed_address, - StorageEntry { key: keccak256(storage_key), value: v.0 }, + StorageEntry { key: keccak256(storage_key), value: *v }, ) })?; } @@ -195,13 +195,13 @@ impl Deref for State { #[serde(deny_unknown_fields)] pub struct Account { /// Balance. - pub balance: JsonU256, + pub balance: U256, /// Code. pub code: Bytes, /// Nonce. - pub nonce: JsonU256, + pub nonce: U256, /// Storage. - pub storage: BTreeMap, + pub storage: BTreeMap, } impl Account { @@ -213,8 +213,8 @@ impl Account { Error::Assertion(format!("Expected account ({address}) is missing from DB: {self:?}")) })?; - assert_equal(self.balance.into(), account.balance, "Balance does not match")?; - assert_equal(self.nonce.0.to(), account.nonce, "Nonce does not match")?; + assert_equal(self.balance, account.balance, "Balance does not match")?; + assert_equal(self.nonce.to(), account.nonce, "Nonce does not match")?; if let Some(bytecode_hash) = account.bytecode_hash { assert_equal(keccak256(&self.code), bytecode_hash, "Bytecode does not match")?; @@ -229,11 +229,11 @@ impl Account { let mut storage_cursor = tx.cursor_dup_read::()?; for (slot, value) in self.storage.iter() { if let Some(entry) = - storage_cursor.seek_by_key_subkey(address, B256::new(slot.0.to_be_bytes()))? + storage_cursor.seek_by_key_subkey(address, B256::new(slot.to_be_bytes()))? { - if U256::from_be_bytes(entry.key.0) == slot.0 { + if U256::from_be_bytes(entry.key.0) == *slot { assert_equal( - value.0, + *value, entry.value, &format!("Storage for slot {:?} does not match", slot), )?; @@ -360,31 +360,31 @@ pub enum SealEngine { pub struct Transaction { /// Transaction type #[serde(rename = "type")] - pub transaction_type: Option, + pub transaction_type: Option, /// Data. pub data: Bytes, /// Gas limit. - pub gas_limit: JsonU256, + pub gas_limit: U256, /// Gas price. - pub gas_price: Option, + pub gas_price: Option, /// Nonce. - pub nonce: JsonU256, + pub nonce: U256, /// Signature r part. - pub r: JsonU256, + pub r: U256, /// Signature s part. - pub s: JsonU256, + pub s: U256, /// Parity bit. - pub v: JsonU256, + pub v: U256, /// Transaction value. - pub value: JsonU256, + pub value: U256, /// Chain ID. - pub chain_id: Option, + pub chain_id: Option, /// Access list. pub access_list: Option, /// Max fee per gas. - pub max_fee_per_gas: Option, + pub max_fee_per_gas: Option, /// Max priority fee per gas - pub max_priority_fee_per_gas: Option, + pub max_priority_fee_per_gas: Option, /// Transaction hash. pub hash: Option, }