Skip to content
Draft
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
32 changes: 24 additions & 8 deletions tooling/reorgs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async fn main() {
// run_test(&cmd_path, test_one_block_reorg_and_back).await;
// run_test(&cmd_path, test_reorg_back_to_base_with_common_ancestor).await;
// run_test(&cmd_path, test_storage_slots_reorg).await;
run_test(&cmd_path, test_storage_tree_with_branches).await;

// run_test(&cmd_path, test_many_blocks_reorg).await;
}
Expand Down Expand Up @@ -343,15 +344,18 @@ async fn test_storage_slots_reorg(simulator: Arc<Mutex<Simulator>>) {
.send_contract_deploy(&signer, contract_deploy_bytecode)
.await;

for _ in 0..10 {
let extended_base_chain = node0.build_payload(base_chain).await;
node0.notify_new_payload(&extended_base_chain).await;
node0.update_forkchoice(&extended_base_chain).await;
base_chain = node0.extend_chain(base_chain, 10).await;
// for _ in 0..10 {
// let extended_base_chain = node0.build_payload(base_chain).await;
// node0.notify_new_payload(&extended_base_chain).await;
// node0.update_forkchoice(&extended_base_chain).await;

node1.notify_new_payload(&extended_base_chain).await;
node1.update_forkchoice(&extended_base_chain).await;
base_chain = extended_base_chain;
}
// node1.notify_new_payload(&extended_base_chain).await;
// node1.update_forkchoice(&extended_base_chain).await;
// base_chain = extended_base_chain;
// }

node1.update_forkchoice(&base_chain).await;

// Sanity check: storage slots are initially empty
let initial_value = node0.get_storage_at(contract_address, slot_key0).await;
Expand Down Expand Up @@ -419,3 +423,15 @@ async fn test_storage_slots_reorg(simulator: Arc<Mutex<Simulator>>) {
let value_slot1 = node0.get_storage_at(contract_address, slot_key1).await;
assert_eq!(value_slot1, slot_value1);
}

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

// These hash to the same 0x2b prefix, causing a branch in the storage trie
let slot0A = 15865164872778812924_u64;
let slot0B = 11566337052255443646_u64;

// These hash to the same 0x83 prefix, causing a branch in the storage trie
let slot1A = 5800641681667202032_u64;
let slot1B = 8343558256908705664_u64;
}
Loading