mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: persist contract analysis in db (#1640)
This commit is contained in:
@ -39,7 +39,7 @@ pub fn fill_cfg_env(
|
||||
cfg_env.chain_id = U256::from(chain_spec.chain().id());
|
||||
cfg_env.spec_id = spec_id;
|
||||
cfg_env.perf_all_precompiles_have_balance = false;
|
||||
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Raw;
|
||||
cfg_env.perf_analyse_created_bytecodes = AnalysisKind::Analyse;
|
||||
}
|
||||
/// Fill block environment from Block.
|
||||
pub fn fill_block_env(block_env: &mut BlockEnv, header: &Header, after_merge: bool) {
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
))]
|
||||
|
||||
//! revm utils and implementations specific to reth.
|
||||
|
||||
pub mod config;
|
||||
|
||||
/// Helpers for configuring revm [Env](revm::primitives::Env)
|
||||
|
||||
@ -49,19 +49,9 @@ impl<DB: StateProvider> DatabaseRef for State<DB> {
|
||||
fn code_by_hash(&self, code_hash: H256) -> Result<Bytecode, Self::Error> {
|
||||
let bytecode = self.0.bytecode_by_hash(code_hash)?;
|
||||
|
||||
// SAFETY: We are requesting the code by its hash, so it is almost tautological why this
|
||||
// would be safe. If the bytecode is not found, we return an empty bytecode with the
|
||||
// appropriate hash.
|
||||
//
|
||||
// In an ideal world we would return analysed bytecode here, but analysed bytecode in revm
|
||||
// depends on the current active hard fork, since it calculates gas blocks...
|
||||
if let Some(bytecode) = bytecode {
|
||||
Ok(unsafe { Bytecode::new_raw_with_hash(bytecode.0, code_hash) })
|
||||
Ok(bytecode.with_code_hash(code_hash).0)
|
||||
} else {
|
||||
// NOTE(onbjerg): This corresponds to an empty analysed bytecode with a hash of
|
||||
// `KECCAK_EMPTY`. In the case where the bytecode is not found, we would
|
||||
// return empty bytes anyway: this simply skips the hashing and analysis steps, which
|
||||
// would otherwise be present if we simply did an `.unwrap_or_default()` above.
|
||||
Ok(Bytecode::new())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user