Skip to content
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

no_std support for reth-revm and fixed tests #9634

Merged
merged 5 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/revm/src/batch.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Helper for handling execution of multiple blocks.

use crate::{precompile::Address, primitives::alloy_primitives::BlockNumber};
use crate::{
precompile::{Address, HashSet},
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::collections::HashSet;
use tracing::debug;

#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -216,7 +218,12 @@ mod tests {
use super::*;
use reth_primitives::{Address, Log, Receipt};
use reth_prune_types::{PruneMode, ReceiptsLogPruneConfig};
#[cfg(feature = "std")]
use std::collections::BTreeMap;
#[cfg(not(feature = "std"))]
extern crate alloc;
#[cfg(not(feature = "std"))]
use alloc::collections::BTreeMap;

#[test]
fn test_save_receipts_empty() {
Expand Down
10 changes: 1 addition & 9 deletions crates/revm/src/state_change.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::precompile::HashMap;
use alloy_eips::eip2935::{HISTORY_STORAGE_ADDRESS, HISTORY_STORAGE_CODE};
use reth_chainspec::{ChainSpec, EthereumHardforks};
use reth_consensus_common::calc;
Expand All @@ -9,15 +10,6 @@ use revm::{
Database, DatabaseCommit,
};

// 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.
///
/// Balance changes might include the block reward, uncle rewards, withdrawals, or irregular
Expand Down
5 changes: 4 additions & 1 deletion crates/revm/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::precompile::HashMap;
use reth_primitives::{
keccak256, Account, Address, BlockNumber, Bytecode, Bytes, StorageKey, B256, U256,
};
Expand All @@ -6,7 +7,9 @@ use reth_storage_api::{
};
use reth_storage_errors::provider::ProviderResult;
use reth_trie::{updates::TrieUpdates, AccountProof, HashedPostState};
use std::collections::HashMap;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;

/// Mock state for testing
#[derive(Debug, Default, Clone, Eq, PartialEq)]
Expand Down
Loading