Skip to content

Commit

Permalink
feat(evm): support wasm32-wasip1 (paradigmxyz#10083)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin authored and martinezjorge committed Aug 7, 2024
1 parent 887b8e7 commit c365422
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/assets/check_wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ wasm_crates=(
# The following were confirmed not working in the past, but could be enabled if issues have been resolved
# reth-consensus
# reth-db
# reth-evm
# reth-evm-ethereum
# The following are confirmed working
reth-codecs
reth-errors
reth-ethereum-forks
reth-evm
reth-network-peers
reth-primitives
reth-primitives-traits
Expand Down
2 changes: 2 additions & 0 deletions crates/evm/execution-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ alloy-primitives.workspace = true
alloy-eips.workspace = true

[features]
default = ["std"]
optimism = ["dep:reth-chainspec"]
serde = ["dep:serde", "reth-trie/serde", "revm/serde"]
std = []
7 changes: 6 additions & 1 deletion crates/evm/execution-types/src/chain.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
//! Contains [Chain], a chain of blocks and their final state.

#[cfg(not(feature = "std"))]
use alloc::{borrow::Cow, collections::BTreeMap};
use core::{fmt, ops::RangeInclusive};
#[cfg(feature = "std")]
use std::{borrow::Cow, collections::BTreeMap};

use crate::ExecutionOutcome;
use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError};
use reth_primitives::{
Expand All @@ -8,7 +14,6 @@ use reth_primitives::{
};
use reth_trie::updates::TrieUpdates;
use revm::db::BundleState;
use std::{borrow::Cow, collections::BTreeMap, fmt, ops::RangeInclusive};

/// A chain of blocks and their final state.
///
Expand Down
3 changes: 3 additions & 0 deletions crates/evm/execution-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

#[cfg(not(feature = "std"))]
extern crate alloc;

mod chain;
pub use chain::*;

Expand Down
3 changes: 3 additions & 0 deletions crates/evm/src/builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
//! Builder for creating an EVM with a database and environment.

#[cfg(not(feature = "std"))]
use alloc::boxed::Box;

use revm::{inspector_handle_register, Database, Evm, EvmBuilder, GetInspector};
use revm_primitives::EnvWithHandlerCfg;

Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/either.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Helper type that represents one of two possible executor types

use std::fmt::Display;
use core::fmt::Display;

use crate::execute::{BatchExecutor, BlockExecutorProvider, Executor};
use reth_execution_errors::BlockExecutionError;
Expand Down
11 changes: 4 additions & 7 deletions crates/evm/src/execute.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
//! Traits for execution.

// Re-export execution types
pub use reth_execution_errors::{BlockExecutionError, BlockValidationError};
pub use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionOutcome};
pub use reth_storage_errors::provider::ProviderError;

use core::fmt::Display;

use reth_primitives::{BlockNumber, BlockWithSenders, Receipt};
use reth_prune_types::PruneModes;
use revm_primitives::db::Database;
use std::fmt::Display;

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

pub use reth_execution_errors::{BlockExecutionError, BlockValidationError};
pub use reth_storage_errors::provider::ProviderError;

/// A general purpose executor trait that executes an input (e.g. block) and produces an output
/// (e.g. state changes and receipts).
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/src/noop.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A no operation block executor implementation.

use std::fmt::Display;
use core::fmt::Display;

use reth_execution_errors::BlockExecutionError;
use reth_execution_types::{BlockExecutionInput, BlockExecutionOutput, ExecutionOutcome};
Expand Down
14 changes: 11 additions & 3 deletions crates/evm/src/system_calls.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
//! System contract call functions.

#[cfg(feature = "std")]
use std::fmt::Display;
#[cfg(not(feature = "std"))]
use {
alloc::{boxed::Box, format, string::ToString, vec::Vec},
core::fmt::Display,
};

use crate::ConfigureEvm;
use alloy_eips::{
eip4788::BEACON_ROOTS_ADDRESS,
Expand Down Expand Up @@ -35,7 +43,7 @@ pub fn pre_block_beacon_root_contract_call<EvmConfig, DB>(
) -> Result<(), BlockExecutionError>
where
DB: Database + DatabaseCommit,
DB::Error: std::fmt::Display,
DB::Error: Display,
EvmConfig: ConfigureEvm,
{
// apply pre-block EIP-4788 contract call
Expand Down Expand Up @@ -148,7 +156,7 @@ pub fn post_block_withdrawal_requests_contract_call<EvmConfig, DB>(
) -> Result<Vec<Request>, BlockExecutionError>
where
DB: Database + DatabaseCommit,
DB::Error: std::fmt::Display,
DB::Error: Display,
EvmConfig: ConfigureEvm,
{
// apply post-block EIP-7002 contract call
Expand Down Expand Up @@ -278,7 +286,7 @@ pub fn post_block_consolidation_requests_contract_call<EvmConfig, DB>(
) -> Result<Vec<Request>, BlockExecutionError>
where
DB: Database + DatabaseCommit,
DB::Error: std::fmt::Display,
DB::Error: Display,
EvmConfig: ConfigureEvm,
{
// apply post-block EIP-7251 contract call
Expand Down

0 comments on commit c365422

Please sign in to comment.