mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make reth-revm compile with no-std (#8931)
This commit is contained in:
@ -36,4 +36,6 @@ tracing.workspace = true
|
||||
reth-trie.workspace = true
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = []
|
||||
test-utils = ["dep:reth-trie"]
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
//! Helper for handling execution of multiple blocks.
|
||||
|
||||
use crate::{precompile::Address, primitives::alloy_primitives::BlockNumber};
|
||||
use core::time::Duration;
|
||||
use reth_execution_errors::BlockExecutionError;
|
||||
use reth_primitives::{Receipt, Receipts, Request, Requests};
|
||||
use reth_prune_types::{PruneMode, PruneModes, PruneSegmentError, MINIMUM_PRUNING_DISTANCE};
|
||||
use revm::db::states::bundle_state::BundleRetention;
|
||||
use std::time::Duration;
|
||||
use tracing::debug;
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::vec::Vec;
|
||||
|
||||
/// Takes care of:
|
||||
/// - recording receipts during execution of multiple blocks.
|
||||
/// - pruning receipts according to the pruning configuration.
|
||||
@ -78,7 +81,7 @@ impl BlockBatchRecord {
|
||||
|
||||
/// Returns all recorded receipts.
|
||||
pub fn take_receipts(&mut self) -> Receipts {
|
||||
std::mem::take(&mut self.receipts)
|
||||
core::mem::take(&mut self.receipts)
|
||||
}
|
||||
|
||||
/// Returns the recorded requests.
|
||||
@ -88,7 +91,7 @@ impl BlockBatchRecord {
|
||||
|
||||
/// Returns all recorded requests.
|
||||
pub fn take_requests(&mut self) -> Vec<Requests> {
|
||||
std::mem::take(&mut self.requests)
|
||||
core::mem::take(&mut self.requests)
|
||||
}
|
||||
|
||||
/// Returns the [`BundleRetention`] for the given block based on the configured prune modes.
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use crate::primitives::alloy_primitives::{BlockNumber, StorageKey, StorageValue};
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use reth_primitives::{Account, Address, B256, KECCAK_EMPTY, U256};
|
||||
use reth_storage_errors::provider::{ProviderError, ProviderResult};
|
||||
use revm::{
|
||||
@ -6,7 +7,6 @@ use revm::{
|
||||
primitives::{AccountInfo, Bytecode},
|
||||
Database,
|
||||
};
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// A helper trait responsible for providing that necessary state for the EVM execution.
|
||||
///
|
||||
|
||||
@ -7,6 +7,10 @@
|
||||
)]
|
||||
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate alloc;
|
||||
|
||||
/// Contains glue code for integrating reth database into revm's [Database].
|
||||
pub mod database;
|
||||
|
||||
@ -22,6 +22,14 @@ use revm::{
|
||||
},
|
||||
Database, DatabaseCommit, Evm,
|
||||
};
|
||||
|
||||
// reuse revm's hashbrown implementation for no-std
|
||||
#[cfg(not(feature = "std"))]
|
||||
use crate::precompile::HashMap;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::{boxed::Box, format, string::ToString, vec::Vec};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Collect all balance changes at the end of the block.
|
||||
@ -86,7 +94,7 @@ pub fn apply_blockhashes_update<DB: Database<Error = ProviderError> + DatabaseCo
|
||||
parent_block_hash: B256,
|
||||
) -> Result<(), BlockExecutionError>
|
||||
where
|
||||
DB::Error: std::fmt::Display,
|
||||
DB::Error: core::fmt::Display,
|
||||
{
|
||||
// If Prague is not activated or this is the genesis block, no hashes are added.
|
||||
if !chain_spec.is_prague_active_at_timestamp(block_timestamp) || block_number == 0 {
|
||||
@ -153,7 +161,7 @@ pub fn apply_beacon_root_contract_call<EXT, DB: Database + DatabaseCommit>(
|
||||
evm: &mut Evm<'_, EXT, DB>,
|
||||
) -> Result<(), BlockExecutionError>
|
||||
where
|
||||
DB::Error: std::fmt::Display,
|
||||
DB::Error: core::fmt::Display,
|
||||
{
|
||||
if !chain_spec.is_cancun_active_at_timestamp(block_timestamp) {
|
||||
return Ok(())
|
||||
@ -256,7 +264,7 @@ pub fn apply_withdrawal_requests_contract_call<EXT, DB: Database + DatabaseCommi
|
||||
evm: &mut Evm<'_, EXT, DB>,
|
||||
) -> Result<Vec<Request>, BlockExecutionError>
|
||||
where
|
||||
DB::Error: std::fmt::Display,
|
||||
DB::Error: core::fmt::Display,
|
||||
{
|
||||
// get previous env
|
||||
let previous_env = Box::new(evm.context.env().clone());
|
||||
|
||||
Reference in New Issue
Block a user