diff --git a/Cargo.toml b/Cargo.toml index a6d3152..092fec6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,17 +25,18 @@ all-features = true rustdoc-args = ["--cfg", "docsrs"] [dependencies] -alloy-primitives = { version = "1.0", features = ["map"] } -alloy-provider = { version = "1.0.3", default-features = false } -alloy-rpc-types = { version = "1.0.3", features = ["eth"] } -alloy-consensus = { version = "1.0.3", default-features = false } +alloy-consensus = { version = "1.0.16", default-features = false } +alloy-hardforks = { version = "0.2.11", default-features = false } +alloy-primitives = { version = "1.2", features = ["map"] } +alloy-provider = { version = "1.0.16", default-features = false } +alloy-rpc-types = { version = "1.0.16", features = ["eth"] } eyre = "0.6" futures = "0.3" parking_lot = "0.12" -revm = { version = "24.0.0", features = ["std", "serde"] } +revm = { version = "27.0.1", features = ["std", "serde"] } serde = "1.0" serde_json = "1.0" @@ -47,7 +48,7 @@ tracing = "0.1" url = "2" [dev-dependencies] -alloy-rpc-client = "1.0.3" +alloy-rpc-client = "1.0.16" tiny_http = "0.12" # [patch.crates-io] diff --git a/src/backend.rs b/src/backend.rs index 5306320..03dbecf 100644 --- a/src/backend.rs +++ b/src/backend.rs @@ -1017,7 +1017,7 @@ mod tests { let provider = get_http_provider(endpoint); let any_rpc_block = provider.get_block(BlockId::latest()).hashes().await.unwrap().unwrap(); - let _meta = BlockchainDbMeta::default().with_block(&any_rpc_block.inner); + let _meta = BlockchainDbMeta::default().with_block(1, &any_rpc_block.inner); } #[tokio::test(flavor = "multi_thread")] diff --git a/src/cache.rs b/src/cache.rs index 2c7779c..2fe24dd 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -1,5 +1,7 @@ //! Cache related abstraction + use alloy_consensus::BlockHeader; +use alloy_hardforks::EthereumHardfork; use alloy_primitives::{Address, B256, U256}; use alloy_provider::network::TransactionResponse; use parking_lot::RwLock; @@ -7,6 +9,7 @@ use revm::{ context::BlockEnv, context_interface::block::BlobExcessGasAndPrice, primitives::{ + eip4844::{BLOB_BASE_FEE_UPDATE_FRACTION_CANCUN, BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE}, map::{AddressHashMap, HashMap}, KECCAK_EMPTY, }, @@ -145,19 +148,27 @@ impl BlockchainDbMeta { /// Sets the [BlockEnv] of this instance using the provided [alloy_rpc_types::Block] pub fn with_block( mut self, + chain_id: u64, block: &alloy_rpc_types::Block, ) -> Self { + let blob_base_fee_update_fraction = + match EthereumHardfork::from_chain_id_and_timestamp(chain_id, block.header.timestamp()) + { + Some(EthereumHardfork::Cancun) => BLOB_BASE_FEE_UPDATE_FRACTION_CANCUN, + _ => BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, + }; + self.block_env = BlockEnv { - number: block.header.number(), + number: U256::from(block.header.number()), beneficiary: block.header.beneficiary(), - timestamp: block.header.timestamp(), + timestamp: U256::from(block.header.timestamp()), difficulty: U256::from(block.header.difficulty()), basefee: block.header.base_fee_per_gas().unwrap_or_default(), gas_limit: block.header.gas_limit(), prevrandao: block.header.mix_hash(), blob_excess_gas_and_price: Some(BlobExcessGasAndPrice::new( block.header.excess_blob_gas().unwrap_or_default(), - false, + blob_base_fee_update_fraction, )), };