Skip to content

Commit

Permalink
Fix panic
Browse files Browse the repository at this point in the history
  • Loading branch information
wtdcode committed Feb 29, 2024
1 parent 228ee70 commit 897e2ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/revm/src/db/ethersdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ impl<M: Middleware> EthersDB<M> {
/// internal utility function to call tokio feature and wait for output
fn block_on<F: core::future::Future>(&self, f: F) -> F::Output {
match Handle::try_current() {
Ok(handle) => handle.block_on(f),
Ok(handle) => {
tokio::task::block_in_place(move || {
handle.block_on(f)
})
}
Err(_) => Builder::new_current_thread()
.enable_all()
.build()
Expand Down Expand Up @@ -74,13 +78,15 @@ impl<M: Middleware> DatabaseRef for EthersDB<M> {
let add = eH160::from(address.0 .0);
let index = H256::from(index.to_be_bytes());
let f = async {
println!("async");
let storage = self
.client
.get_storage_at(add, index, self.block_number)
.await
.unwrap();
U256::from_be_bytes(storage.to_fixed_bytes())
};
println!("??");
Ok(self.block_on(f))
}

Expand Down

0 comments on commit 897e2ae

Please sign in to comment.