Skip to content

Commit

Permalink
add case
Browse files Browse the repository at this point in the history
  • Loading branch information
publicqi committed Feb 21, 2024
1 parent fdd26df commit 2b736a7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 37 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ edition = "2021"

[[bin]]
name = "revm_hang"
path = "src/lib.rs"
path = "src/main.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ethers-providers = "2.0.13"
revm = { version = "3.5.0", features = ["ethersdb"] }
revm = { version = "6.0.0", features = ["ethersdb"] }
tokio = "1.36.0"
35 changes: 0 additions & 35 deletions src/lib.rs

This file was deleted.

52 changes: 52 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
use std::sync::Arc;

use ethers_providers::{Http, Provider};
use revm::{
db::EthersDB,
primitives::{Address, U256},
Database,
};

#[tokio::main]
async fn main() {
let args = std::env::args().collect::<Vec<String>>();
if args.len() != 2 {
println!("Usage: cargo run <hang|nohang>");
return;
}

// setup
let url = "http://localhost:8124/eth";
let client = Provider::<Http>::try_from(url).unwrap();

if args[1] == "nohang" {
let _ = EthersDB::new(Arc::new(client), None).unwrap();
panic!("this panic is expected");
} else {
let mut ethers_db = EthersDB::new(Arc::new(client), None).unwrap();

let addr = Address::ZERO;
let slot = U256::ZERO;
for _ in 0..1000 {
ethers_db.storage(addr, slot).unwrap();
}
panic!("we want to panic but it hangs");
}
}

#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn test_hang() {
let url = "http://localhost:8124/eth";
let client = Provider::<Http>::try_from(url).unwrap();

let block_number = client.get_block_number().await.unwrap();
println!("block_number: {:?}", block_number);

let _ = EthersDB::new(Arc::new(client), None).unwrap();

panic!("we want to panic but it hangs");
}
}

0 comments on commit 2b736a7

Please sign in to comment.