mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use B160, B256 and U256 coming from revm and ruint (#676)
* use B256, B160 and U256 from revm * fix U256 from_str * use U256::ZERO * use temporary commit for revm and interpreter * more U256::ZERO * more changes for revm/ruint types * clippy * change revm and revm-interpreter repo * remove H160 wrap * minor cleanup * remove unused * fix MIN_PROTOCOL_BASE_FEE
This commit is contained in:
@ -77,16 +77,16 @@ impl From<Header> for SealedHeader {
|
||||
fn from(value: Header) -> Self {
|
||||
SealedHeader::new(
|
||||
RethHeader {
|
||||
base_fee_per_gas: value.base_fee_per_gas.map(|v| v.0.as_u64()),
|
||||
base_fee_per_gas: value.base_fee_per_gas.map(|v| v.0.to::<u64>()),
|
||||
beneficiary: value.coinbase,
|
||||
difficulty: value.difficulty.0,
|
||||
extra_data: value.extra_data.0,
|
||||
gas_limit: value.gas_limit.0.as_u64(),
|
||||
gas_used: value.gas_used.0.as_u64(),
|
||||
gas_limit: value.gas_limit.0.to::<u64>(),
|
||||
gas_used: value.gas_used.0.to::<u64>(),
|
||||
mix_hash: value.mix_hash,
|
||||
nonce: value.nonce.into_uint().as_u64(),
|
||||
number: value.number.0.as_u64(),
|
||||
timestamp: value.timestamp.0.as_u64(),
|
||||
number: value.number.0.to::<u64>(),
|
||||
timestamp: value.timestamp.0.to::<u64>(),
|
||||
transactions_root: value.transactions_trie,
|
||||
receipts_root: value.receipt_trie,
|
||||
ommers_hash: value.uncle_hash,
|
||||
|
||||
@ -128,7 +128,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
address,
|
||||
RethAccount {
|
||||
balance: account.balance.0,
|
||||
nonce: account.nonce.0.as_u64(),
|
||||
nonce: account.nonce.0.to::<u64>(),
|
||||
bytecode_hash: code_hash,
|
||||
},
|
||||
)?;
|
||||
@ -137,9 +137,10 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
}
|
||||
account.storage.iter().try_for_each(|(k, v)| {
|
||||
tracing::trace!("Update storage: {address} key:{:?} val:{:?}", k.0, v.0);
|
||||
let mut key = H256::zero();
|
||||
k.0.to_big_endian(&mut key.0);
|
||||
tx.put::<tables::PlainStorageState>(address, StorageEntry { key, value: v.0 })
|
||||
tx.put::<tables::PlainStorageState>(
|
||||
address,
|
||||
StorageEntry { key: H256::from_slice(&k.0.to_be_bytes::<32>()), value: v.0 },
|
||||
)
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
@ -154,7 +155,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
Ok(walker.map(|mut walker| {
|
||||
let mut map: HashMap<Address, HashMap<U256, U256>> = HashMap::new();
|
||||
while let Some(Ok((address, slot))) = walker.next() {
|
||||
let key = U256::from_big_endian(&slot.key.0);
|
||||
let key = U256::from_be_bytes(slot.key.0);
|
||||
map.entry(address).or_default().insert(key, slot.value);
|
||||
}
|
||||
map
|
||||
@ -165,7 +166,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
// Initialize the execution stage
|
||||
// Hardcode the chain_id to Ethereum 1.
|
||||
let mut stage =
|
||||
ExecutionStage::new(reth_executor::Config { chain_id: 1.into(), spec_upgrades });
|
||||
ExecutionStage::new(reth_executor::Config { chain_id: U256::from(1), spec_upgrades });
|
||||
|
||||
// Call execution stage
|
||||
let input = ExecInput::default();
|
||||
@ -188,7 +189,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
let storage = walker.map(|mut walker| {
|
||||
let mut map: HashMap<Address, HashMap<U256, U256>> = HashMap::new();
|
||||
while let Some(Ok((address, slot))) = walker.next() {
|
||||
let key = U256::from_big_endian(&slot.key.0);
|
||||
let key = U256::from_be_bytes(slot.key.0);
|
||||
map.entry(address).or_default().insert(key, slot.value);
|
||||
}
|
||||
map
|
||||
@ -206,7 +207,7 @@ pub async fn run_test(path: PathBuf) -> eyre::Result<()> {
|
||||
our_account.balance
|
||||
))
|
||||
}
|
||||
if test_account.nonce.0.as_u64() != our_account.nonce {
|
||||
if test_account.nonce.0.to::<u64>() != our_account.nonce {
|
||||
return Err(eyre!(
|
||||
"Account {address} nonce diff, expected {} got {}",
|
||||
test_account.nonce.0,
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
use reth_primitives::{
|
||||
utils::serde_helpers::{deserialize_number, deserialize_stringified_u64},
|
||||
Address, Bytes, Header, H256, U256,
|
||||
utils::serde_helpers::deserialize_stringified_u64, Address, Bytes, Header, H256, U256,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
@ -32,7 +31,6 @@ pub struct Genesis {
|
||||
#[serde(deserialize_with = "deserialize_stringified_u64")]
|
||||
pub gas_limit: u64,
|
||||
/// The genesis header difficulty.
|
||||
#[serde(deserialize_with = "deserialize_number")]
|
||||
pub difficulty: U256,
|
||||
/// The genesis header mix hash.
|
||||
pub mix_hash: H256,
|
||||
|
||||
Reference in New Issue
Block a user