Skip to content
2 changes: 1 addition & 1 deletion crates/anvil-polkadot/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Anvil is a fast local Ethereum development node.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

use crate::{
api_server::ApiHandle,
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Core Ethereum types for Anvil.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

/// Various Ethereum types
pub mod eth;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! JSON-RPC types.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

/// JSON-RPC request bindings
pub mod request;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Bootstrap [axum] RPC servers.
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Anvil is a fast local Ethereum development node.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use crate::{
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/src/cmd/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::{
};
use alloy_primitives::Address;
use alloy_provider::Provider;
use clap::{Parser, command};
use clap::Parser;
use eyre::Result;
use foundry_cli::{
opts::{EtherscanOpts, RpcOpts},
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/src/cmd/constructor_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{
use alloy_dyn_abi::DynSolType;
use alloy_primitives::{Address, Bytes};
use alloy_provider::Provider;
use clap::{Parser, command};
use clap::Parser;
use eyre::{OptionExt, Result, eyre};
use foundry_cli::{
opts::{EtherscanOpts, RpcOpts},
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/src/cmd/creation_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_consensus::Transaction;
use alloy_primitives::{Address, Bytes};
use alloy_provider::{Provider, ext::TraceApi};
use alloy_rpc_types::trace::parity::{Action, CreateAction, CreateOutput, TraceOutput};
use clap::{Parser, command};
use clap::Parser;
use eyre::{OptionExt, Result, eyre};
use foundry_block_explorers::Client;
use foundry_cli::{
Expand Down
2 changes: 1 addition & 1 deletion crates/cast/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Cast is a Swiss Army knife for interacting with Ethereum applications from the command line.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use alloy_consensus::{Header, TxEnvelope};
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/spec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Cheatcode specification for Foundry.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

use serde::{Deserialize, Serialize};
use std::{borrow::Cow, fmt};
Expand Down
2 changes: 1 addition & 1 deletion crates/cheatcodes/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Foundry cheatcodes implementations.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![allow(elided_lifetimes_in_paths)] // Cheats context uses 3 lifetimes

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion crates/chisel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Chisel is a fast, utilitarian, and verbose Solidity REPL.

#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

#[macro_use]
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Common CLI utilities.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
2 changes: 1 addition & 1 deletion crates/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Common utilities for building and using foundry's tools.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[expect(unused_extern_crates)] // Used by `ConsoleFmt`.
extern crate self as foundry_common;
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Foundry configuration.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion crates/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Interactive Solidity TUI debugger and debugger data file dumper

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
2 changes: 1 addition & 1 deletion crates/doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! See [`DocBuilder`].

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/abi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Solidity ABI-related utilities and [`sol!`](alloy_sol_types::sol) definitions.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod console;
2 changes: 1 addition & 1 deletion crates/evm/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Core EVM abstractions.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

use crate::constants::DEFAULT_CREATE2_DEPLOYER;
use alloy_evm::eth::EthEvmContext;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/coverage/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! EVM bytecode coverage analysis.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/evm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Main Foundry EVM backend abstractions.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/fuzz/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! EVM fuzzing implementation using [`proptest`].

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion crates/evm/traces/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! EVM trace identifying and decoding.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
2 changes: 1 addition & 1 deletion crates/fmt/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate tracing;
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Forge is a fast and flexible Ethereum testing framework.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
68 changes: 68 additions & 0 deletions crates/forge/tests/cli/revive_vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,71 @@ Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)

"#]]);
});

forgetest!(vm_load, |prj, cmd| {
prj.insert_ds_test();
prj.insert_vm();
prj.insert_console();
prj.add_source(
"Counter.sol",
r#"
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Counter {
uint256 public number;

constructor (uint256 number_) {
number = number_;
}
}
"#,
)
.unwrap();
prj.add_source(
"Load.t.sol",
r#"
import "./test.sol";
import "./Vm.sol";
import {console} from "./console.sol";
import {Counter} from "./Counter.sol";

contract Load is DSTest {
Vm constant vm = Vm(HEVM_ADDRESS);

function testFuzz_Load(uint256 x) public {
vm.pvm(true);
Counter counter = new Counter(x);
bytes32 res = vm.load(address(counter), bytes32(uint256(0)));
assertEq(uint256(res), x);
}
}
"#,
)
.unwrap();

let res = cmd.args(["test", "--resolc", "-vvv"]).assert_success();
res.stderr_eq(str![""]).stdout_eq(str![[r#"
[COMPILING_FILES] with [SOLC_VERSION]
[SOLC_VERSION] [ELAPSED]
Compiler run successful!
[COMPILING_FILES] with [RESOLC_VERSION]
[RESOLC_VERSION] [ELAPSED]
Compiler run successful with warnings:
Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is
usually needed in the following cases:
1. To detect whether an address belongs to a smart contract.
2. To detect whether the deploy code execution has finished.
Polkadot comes with native account abstraction support (so smart contracts are just accounts
coverned by code), and you should avoid differentiating between contracts and non-contract
addresses.
[FILE]

Ran 1 test for src/Load.t.sol:Load
[PASS] testFuzz_Load(uint256) (runs: 256, [AVG_GAS])
Suite result: ok. 1 passed; 0 failed; 0 skipped; [ELAPSED]

Ran 1 test suite [ELAPSED]: 1 tests passed, 0 failed, 0 skipped (1 total tests)

"#]]);
});
2 changes: 1 addition & 1 deletion crates/linking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! EVM bytecode linker.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

use alloy_primitives::{Address, B256, Bytes};
use foundry_compilers::{
Expand Down
2 changes: 1 addition & 1 deletion crates/lint/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![doc = include_str!("../README.md")]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

pub mod inline_config;
pub mod linter;
Expand Down
2 changes: 1 addition & 1 deletion crates/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Internal Foundry proc-macros.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate proc_macro_error2;
Expand Down
6 changes: 1 addition & 5 deletions crates/revive-env/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

use frame_support::{runtime, traits::FindAuthor, weights::constants::WEIGHT_REF_TIME_PER_SECOND};
use pallet_revive::AccountId32Mapper;
use polkadot_sdk::{
polkadot_sdk_frame::{log, runtime::prelude::*},
sp_runtime::AccountId32,
*,
};
use polkadot_sdk::{polkadot_sdk_frame::runtime::prelude::*, sp_runtime::AccountId32, *};

pub type Balance = u128;
pub type AccountId = pallet_revive::AccountId32Mapper<Runtime>;
Expand Down
21 changes: 20 additions & 1 deletion crates/revive-strategy/src/cheatcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ use foundry_cheatcodes::{
Broadcast, BroadcastableTransactions, CheatcodeInspectorStrategy,
CheatcodeInspectorStrategyContext, CheatcodeInspectorStrategyRunner, CheatsConfig, CheatsCtxt,
CommonCreateInput, DealRecord, Ecx, EvmCheatcodeInspectorStrategyRunner, Result,
Vm::{dealCall, getNonce_0Call, pvmCall, rollCall, setNonceCall, setNonceUnsafeCall, warpCall},
Vm::{
dealCall, getNonce_0Call, loadCall, pvmCall, rollCall, setNonceCall, setNonceUnsafeCall,
warpCall,
},
};
use foundry_common::sh_err;
use foundry_compilers::resolc::dual_compiled_contracts::DualCompiledContracts;
Expand Down Expand Up @@ -246,6 +249,22 @@ impl CheatcodeInspectorStrategyRunner for PvmCheatcodeInspectorStrategyRunner {

Ok(Default::default())
}
t if using_pvm && is::<loadCall>(t) => {
tracing::info!(cheatcode = ?cheatcode.as_debug() , using_pvm = ?using_pvm);
let &loadCall { target, slot } = cheatcode.as_any().downcast_ref().unwrap();
let target_address_h160 = H160::from_slice(target.as_slice());
let storage_value = execute_with_externalities(|externalities| {
externalities.execute_with(|| {
Pallet::<Runtime>::get_storage(target_address_h160, slot.into())
})
});
let result = storage_value
.ok()
.flatten()
.map(|b| B256::from_slice(&b))
.unwrap_or(B256::ZERO);
Ok(result.abi_encode())
}
// Not custom, just invoke the default behavior
_ => cheatcode.dyn_apply(ccx, executor),
}
Expand Down
2 changes: 1 addition & 1 deletion crates/script/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Smart contract scripting.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
2 changes: 1 addition & 1 deletion crates/test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! Internal Foundry testing utilities.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
// Shouldn't use sh_* macros here, as they don't get captured by the test runner.
#![allow(clippy::disallowed_macros)]

Expand Down
2 changes: 1 addition & 1 deletion crates/verify/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Smart contract verification.

#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[macro_use]
extern crate foundry_common;
Expand Down
Loading
Loading