Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
d1ae4c4
anvil-polkadot: add snapshot manager & evm snapshot RPC
iulianbarbu Oct 3, 2025
22d3d36
cargo: format toml & lock
iulianbarbu Oct 6, 2025
afcadaa
Revert "cargo: format toml & lock"
iulianbarbu Oct 6, 2025
2725161
evm_revert: wip debug test failure
iulianbarbu Oct 7, 2025
486d13d
anvil-polkadot: seal best blocks only
iulianbarbu Oct 7, 2025
6707ca8
anvil-polkadot: test snapshot and revert
iulianbarbu Oct 7, 2025
f3376ab
tomls: update formatting and polkadot-sdk dep
iulianbarbu Oct 8, 2025
6728dc5
anvil-polkadot: revert uneeded changes
iulianbarbu Oct 8, 2025
22050bf
Merge branch 'master' of github.com:paritytech/foundry-polkadot into …
iulianbarbu Oct 8, 2025
877fff8
Update crates/revive-env/Cargo.toml
iulianbarbu Oct 8, 2025
aaba52f
Update crates/revive-strategy/Cargo.toml
iulianbarbu Oct 8, 2025
bbc1731
anvil-polkadot: update block provider best block after revert
iulianbarbu Oct 8, 2025
43b980f
anvil-polkadot: set db pruning to archive
iulianbarbu Oct 9, 2025
9b1deca
anvil-polkadot: impl rollback & add tests
iulianbarbu Oct 10, 2025
d8098d1
anvil-polkadot(tests): add todos for block provider testing
iulianbarbu Oct 14, 2025
5b32dc1
anvil-polkadot(tests): finalize existing tests
iulianbarbu Oct 14, 2025
c93d1ae
anvil-polkadot: update evm_revert & anvil-rollback return type
iulianbarbu Oct 14, 2025
3d46f1e
anvil-polkadot(tests): add revert and txs in mempool test
iulianbarbu Oct 14, 2025
a3b01e2
anvil-polkadot: code polish
iulianbarbu Oct 14, 2025
0f720de
Merge branch 'master' of github.com:paritytech/foundry-polkadot into …
iulianbarbu Oct 14, 2025
63a25f9
anvil-polkadot(tests): fix timestmap with evm revert test
iulianbarbu Oct 14, 2025
e6173bd
anvil-polkadot(tests): final polish
iulianbarbu Oct 15, 2025
37debaa
anvil-polkadot: remove leftovers
iulianbarbu Oct 15, 2025
b5b641b
Merge branch 'master' of github.com:paritytech/foundry-polkadot into …
iulianbarbu Oct 15, 2025
dcacce6
anvil-polkadot: fix merge issues
iulianbarbu Oct 15, 2025
b9ad0f0
anvil-polkadot: simplify time updating after revert
iulianbarbu Oct 15, 2025
75599db
anvil-polkadot: remove extra timestamp setting in storage
iulianbarbu Oct 17, 2025
9801c35
Merge branch 'master' of github.com:paritytech/foundry-polkadot into …
iulianbarbu Oct 20, 2025
dbb8204
anvil-polkadot: address leftovers after merge
iulianbarbu Oct 20, 2025
4b5e922
Apply suggestion from @iulianbarbu
iulianbarbu Oct 20, 2025
cd2dbd8
Apply suggestion from @iulianbarbu
iulianbarbu Oct 20, 2025
0b99c7d
anvil-polkadot: revert new backend error variants
iulianbarbu Oct 20, 2025
4e7b0cc
Update crates/anvil-polkadot/src/substrate_node/service/backend.rs
iulianbarbu Oct 20, 2025
22984b0
anvil-polkadot: address feedback
iulianbarbu Oct 20, 2025
6f56dc4
Update crates/anvil-polkadot/src/substrate_node/snapshot.rs
iulianbarbu Oct 20, 2025
04b5f0b
Update crates/anvil-polkadot/src/substrate_node/snapshot.rs
iulianbarbu Oct 20, 2025
4f0aa31
anvil-polkadot(tests): address feedback
iulianbarbu Oct 20, 2025
aab7fa5
Merge branch 'master' into ib-add-chain-reversion
iulianbarbu Oct 21, 2025
fb484e0
anvil-polkadot(tests): fix merge issue
iulianbarbu Oct 21, 2025
6e56070
anvil-polkadot: address feedback
iulianbarbu Oct 21, 2025
2b6fc22
anvil-polkadot(tests): simplify evm_snapshot result assert
iulianbarbu Oct 21, 2025
b57c04f
doc: fix clippy
iulianbarbu Oct 22, 2025
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
608 changes: 311 additions & 297 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/anvil-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ path = "bin/main.rs"
# foundry internal
codec = { version = "3.7.5", default-features = true, package = "parity-scale-codec" }
substrate-runtime = { path = "substrate-runtime" }
pallet-revive-eth-rpc = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" }
secp256k1 = { version = "0.28.0", default-features = false }
libsecp256k1 = { version = "0.7.0", default-features = false }
sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master", default-features = false }
Expand Down Expand Up @@ -64,7 +65,6 @@ polkadot-sdk = { git = "https://github.com/paritytech/polkadot-sdk.git", branch
"substrate-frame-rpc-system",
"substrate-rpc-client",
"substrate-wasm-builder",
"pallet-revive-eth-rpc"
] }
anvil.workspace = true
anvil-core.workspace = true
Expand Down
23 changes: 13 additions & 10 deletions crates/anvil-polkadot/src/api_server/error.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use crate::substrate_node::{mining_engine::MiningError, service::BackendError};
use anvil_rpc::{error::RpcError, response::ResponseResult};
use polkadot_sdk::{
pallet_revive_eth_rpc::{EthRpcError, client::ClientError},
sp_api,
};
use pallet_revive_eth_rpc::{EthRpcError, client::ClientError};
use polkadot_sdk::sp_api;
use serde::Serialize;

#[derive(Debug, thiserror::Error)]
Expand All @@ -16,6 +14,10 @@ pub enum Error {
InvalidParams(String),
#[error("Revive call failed: {0}")]
ReviveRpc(#[from] EthRpcError),
#[error("Snapshot error: {0}")]
SnapshotRpc(String),
#[error("Subxt error: {0}")]
Subxt(#[from] subxt::error::Error),
#[error(transparent)]
Backend(#[from] BackendError),
#[error("Nonce overflowing the substrate nonce type")]
Expand All @@ -28,12 +30,6 @@ pub enum Error {
InternalError(String),
}

impl From<subxt::Error> for Error {
fn from(err: subxt::Error) -> Self {
Self::ReviveRpc(EthRpcError::ClientError(err.into()))
}
}
Comment on lines 31 to 35
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this back since I also removed the Subxt variant. No need to use it, since as you mentioned, we can rely on the catch all internal error variant.


impl From<ClientError> for Error {
fn from(err: ClientError) -> Self {
Self::ReviveRpc(EthRpcError::ClientError(err))
Expand Down Expand Up @@ -83,6 +79,13 @@ impl<T: Serialize> ToRpcResponseResult for Result<T> {
Error::InvalidParams(error_message) => {
RpcError::invalid_params(error_message).into()
}
Error::SnapshotRpc(err) => RpcError::internal_error_with(err).into(),
Error::ReviveRpc(client_error) => {
RpcError::internal_error_with(format!("{client_error}")).into()
}
Error::Subxt(subxt_err) => {
RpcError::internal_error_with(format!("{subxt_err}")).into()
}
err => RpcError::internal_error_with(format!("{err}")).into(),
},
}
Expand Down
19 changes: 14 additions & 5 deletions crates/anvil-polkadot/src/api_server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{
AnvilNodeConfig,
logging::LoggingManager,
substrate_node::{impersonation::ImpersonationManager, service::Service},
substrate_node::{
impersonation::ImpersonationManager, service::Service, snapshot::SnapshotManager,
},
};
use anvil_core::eth::EthRequest;
use anvil_rpc::response::ResponseResult;
Expand All @@ -20,19 +22,26 @@ pub struct ApiRequest {
}

pub fn spawn(
config: &AnvilNodeConfig,
substrate_service: &Service,
logging_manager: LoggingManager,
config: &AnvilNodeConfig,
snapshot_manager: SnapshotManager,
) -> ApiHandle {
let (api_handle, receiver) = mpsc::channel(100);

let service = substrate_service.clone();
let mut impersonation_manager = ImpersonationManager::default();
impersonation_manager.set_auto_impersonate_account(config.enable_auto_impersonate);
substrate_service.spawn_handle.spawn("anvil-api-server", "anvil", async move {
let api_server = ApiServer::new(service, receiver, logging_manager, impersonation_manager)
.await
.unwrap_or_else(|err| panic!("Failed to spawn the API server: {err}"));
let api_server = ApiServer::new(
service,
receiver,
logging_manager,
snapshot_manager,
impersonation_manager,
)
.await
.unwrap_or_else(|err| panic!("Failed to spawn the API server: {err}"));
api_server.run().await;
});

Expand Down
Loading
Loading