Skip to content
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
20 changes: 12 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions dapp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@ proptest = "1.0.0"
[dev-dependencies]
evm-adapters = { path = "./../evm-adapters", features = ["sputnik", "sputnik-helpers", "evmodin", "evmodin-helpers"] }
evmodin = { git = "https://github.com/vorot93/evmodin", features = ["util"] }
# evm = { version = "0.30.1" }
evm = { git = "https://github.com/rust-blockchain/evm" }
evm = { version = "0.31" }
ethers = { git = "https://github.com/gakonst/ethers-rs", features = ["solc-full", "solc-tests"] }
2 changes: 1 addition & 1 deletion dapptools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ tracing = "0.1.26"

## EVM Implementations
# evm = { version = "0.30.1" }
sputnik = { package = "evm", git = "https://github.com/rust-blockchain/evm", optional = true }
sputnik = { package = "evm", version = "0.31", optional = true }
evmodin = { git = "https://github.com/vorot93/evmodin", optional = true }
proptest = "1.0.0"
git2 = "0.13.22"
Expand Down
3 changes: 1 addition & 2 deletions evm-adapters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ edition = "2018"
[dependencies]
dapp-utils = { path = "./../utils" }

# evm = { version = "0.30.1" }
sputnik = { package = "evm", git = "https://github.com/rust-blockchain/evm", optional = true, features = ["tracing"] }
sputnik = { package = "evm", version = "0.31", optional = true, features = ["tracing"] }

evmodin = { git = "https://github.com/vorot93/evmodin", optional = true }

Expand Down
17 changes: 12 additions & 5 deletions evm-adapters/src/blocking_provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ use ethers::{
providers::Middleware,
types::{Address, Block, BlockId, Bytes, TxHash, H256, U256, U64},
};
use tokio::runtime::Runtime;
use tokio::runtime::{Handle, Runtime};

#[derive(Debug)]
/// Blocking wrapper around an Ethers middleware, for use in synchronous contexts
/// (powered by a tokio runtime)
pub struct BlockingProvider<M> {
provider: M,
runtime: Runtime,
runtime: Option<Runtime>,
}

impl<M: Clone> Clone for BlockingProvider<M> {
fn clone(&self) -> Self {
Self { provider: self.provider.clone(), runtime: Runtime::new().unwrap() }
Self {
provider: self.provider.clone(),
runtime: self.runtime.as_ref().map(|_| Runtime::new().unwrap()),
}
}
}

Expand All @@ -24,11 +27,15 @@ where
M::Error: 'static,
{
pub fn new(provider: M) -> Self {
Self { provider, runtime: Runtime::new().unwrap() }
let runtime = Handle::try_current().is_err().then(|| Runtime::new().unwrap());
Self { provider, runtime }
}

fn block_on<F: std::future::Future>(&self, f: F) -> F::Output {
self.runtime.block_on(f)
match &self.runtime {
Some(runtime) => runtime.block_on(f),
None => futures::executor::block_on(f),
}
}

pub fn block_and_chainid(
Expand Down
2 changes: 1 addition & 1 deletion evm-adapters/src/sputnik/cheatcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::collections::HashMap;

pub use cheatcode_handler::CheatcodeHandler;

mod backend;
pub mod backend;

use ethers::types::{Address, H256, U256};
use sputnik::backend::{Backend, MemoryAccount, MemoryBackend};
Expand Down
2 changes: 2 additions & 0 deletions evm-adapters/src/sputnik/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use sputnik::{
Config, CreateScheme, ExitError, ExitReason, ExitSucceed,
};

pub use sputnik as sputnik_evm;

pub async fn vicinity<M: Middleware>(
provider: &M,
pin_block: Option<u64>,
Expand Down