-
Notifications
You must be signed in to change notification settings - Fork 17
chore(deps): bump revm 27.0.2 #53
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
Changes from all commits
621d528
91b76a3
b742f13
2cc5629
d1d62a2
8e1e69f
d366fbd
c4f6bf0
4ed9afb
3ec870f
e819e0a
2212816
da31b84
7c57782
b4f7b03
515a153
18c4ceb
221098e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
//! Cache related abstraction | ||
|
||
use alloy_chains::Chain; | ||
use alloy_consensus::BlockHeader; | ||
use alloy_hardforks::EthereumHardfork; | ||
use alloy_primitives::{Address, B256, U256}; | ||
use alloy_provider::network::TransactionResponse; | ||
use parking_lot::RwLock; | ||
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, | ||
}, | ||
|
@@ -123,8 +127,11 @@ impl BlockchainDb { | |
} | ||
|
||
/// relevant identifying markers in the context of [BlockchainDb] | ||
#[derive(Clone, Debug, Eq, Serialize, Default)] | ||
#[derive(Clone, Debug, Default, Eq, Serialize)] | ||
pub struct BlockchainDbMeta { | ||
/// The chain of the blockchain of the block environment | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub chain: Option<Chain>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we mark this default and skip if none There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 221098e |
||
/// The block environment | ||
pub block_env: BlockEnv, | ||
/// All the hosts used to connect to | ||
|
@@ -139,25 +146,33 @@ impl BlockchainDbMeta { | |
.and_then(|url| url.host().map(|host| host.to_string())) | ||
.unwrap_or(url); | ||
|
||
Self { block_env, hosts: BTreeSet::from([host]) } | ||
Self { chain: None, block_env, hosts: BTreeSet::from([host]) } | ||
} | ||
|
||
/// Sets the [BlockEnv] of this instance using the provided [alloy_rpc_types::Block] | ||
/// Sets the [BlockEnv] of this instance using the provided [Chain] and [alloy_rpc_types::Block] | ||
pub fn with_block<T: TransactionResponse, H: BlockHeader>( | ||
mut self, | ||
block: &alloy_rpc_types::Block<T, H>, | ||
) -> Self { | ||
let blob_base_fee_update_fraction = | ||
self.chain.map_or(BLOB_BASE_FEE_UPDATE_FRACTION_PRAGUE, |chain| { | ||
match EthereumHardfork::from_chain_and_timestamp(chain, 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need this, this previously also just defaulted to pre-prague and I believe we only use this to tag the metadata? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated, now we have a builder method |
||
)), | ||
}; | ||
|
||
|
@@ -174,9 +189,16 @@ impl BlockchainDbMeta { | |
self | ||
} | ||
|
||
/// Sets the [Chain] of this instance | ||
pub fn set_chain(mut self, chain: Chain) -> Self { | ||
self.chain = Some(chain); | ||
self | ||
} | ||
|
||
/// Sets the [BlockEnv] of this instance | ||
pub fn set_block_env(mut self, block_env: revm::context::BlockEnv) { | ||
pub fn set_block_env(mut self, block_env: revm::context::BlockEnv) -> Self { | ||
self.block_env = block_env; | ||
self | ||
} | ||
} | ||
|
||
|
@@ -229,6 +251,7 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { | |
// custom deserialize impl to not break existing cache files | ||
#[derive(Deserialize)] | ||
struct Meta { | ||
chain: Option<Chain>, | ||
block_env: BlockEnvBackwardsCompat, | ||
/// all the hosts used to connect to | ||
#[serde(alias = "host")] | ||
|
@@ -242,8 +265,9 @@ impl<'de> Deserialize<'de> for BlockchainDbMeta { | |
Single(String), | ||
} | ||
|
||
let Meta { block_env, hosts } = Meta::deserialize(deserializer)?; | ||
let Meta { chain, block_env, hosts } = Meta::deserialize(deserializer)?; | ||
Ok(Self { | ||
chain, | ||
block_env: block_env.inner, | ||
hosts: match hosts { | ||
Hosts::Multi(hosts) => hosts, | ||
|
Uh oh!
There was an error while loading. Please reload this page.