Skip to content
Draft
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
15 changes: 15 additions & 0 deletions tooling/reorgs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ async fn main() {
info!("Starting test run");
info!("");

run_test(&cmd_path, no_reorgs_full_sync_smoke_test).await;
run_test(&cmd_path, test_one_block_reorg_and_back).await;
run_test(&cmd_path, test_storage_slots_reorg).await;

Expand Down Expand Up @@ -81,6 +82,20 @@ where
info!("");
}

async fn no_reorgs_full_sync_smoke_test(simulator: Arc<Mutex<Simulator>>) {
let mut simulator = simulator.lock().await;

// Start two ethrex nodes
let node0 = simulator.start_node().await;
let node1 = simulator.start_node().await;

// Create a chain and extend it with a few empty blocks
let base_chain = node0.extend_chain(simulator.get_base_chain(), 10).await;

// Try to fully sync node1 (which is a peer of node0)
node1.update_forkchoice(&base_chain).await;
}

async fn test_one_block_reorg_and_back(simulator: Arc<Mutex<Simulator>>) {
let mut simulator = simulator.lock().await;
let signer: Signer = LocalSigner::new(
Expand Down
9 changes: 9 additions & 0 deletions tooling/reorgs/src/simulator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ impl Node {
chain
}

pub async fn extend_chain(&self, mut chain: Chain, num_blocks: usize) -> Chain {
for _ in 0..num_blocks {
chain = self.build_payload(chain).await;
self.notify_new_payload(&chain).await;
}
self.update_forkchoice(&chain).await;
chain
}

pub async fn notify_new_payload(&self, chain: &Chain) {
let head = chain.blocks.last().unwrap();
let execution_payload = ExecutionPayload::from_block(head.clone());
Expand Down
Loading