-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: checkpoint kurtosis devnet deployment + test cases
- Loading branch information
Showing
15 changed files
with
925 additions
and
986 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[package] | ||
name = "tests" | ||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
|
||
[dependencies] | ||
# world | ||
world-chain-builder-pool = { workspace = true, features = ["test"] } | ||
world-chain-builder-node = {workspace = true, features = ["test"] } | ||
|
||
# alloy | ||
alloy-primitives.workspace = true | ||
alloy-provider.workspace = true | ||
alloy-transport.workspace = true | ||
alloy-network.workspace = true | ||
alloy-rpc-types-eth.workspace = true | ||
|
||
# async | ||
tokio = { workspace = true, features = ["full"] } | ||
futures.workspace = true | ||
|
||
# third-party | ||
serde_json.workspace = true | ||
serde.workspace = true | ||
eyre.workspace = true | ||
tracing-subscriber = { workspace = true, features = ["env-filter"]} | ||
tracing.workspace = true | ||
|
||
[lints] | ||
workspace = true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::fixtures::PBHFixture; | ||
use alloy_primitives::Bytes; | ||
use alloy_provider::Provider; | ||
use alloy_transport::Transport; | ||
use eyre::eyre::Result; | ||
use futures::stream; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
const PBH_FIXTURE: &str = include_str!("../../../../devnet/fixtures/fixture.json"); | ||
|
||
const CONCURRENCY_LIMIT: usize = 50; | ||
|
||
/// Asserts that the world-chain-builder payload is built correctly with a set of PBH transactions. | ||
pub async fn assert_build<T, P>(builder_provider: Arc<P>) -> Result<()> | ||
where | ||
T: Transport + Clone, | ||
P: Provider<T>, | ||
{ | ||
let fixture = serde_json::from_str::<PBHFixture>(PBH_FIXTURE)?; | ||
let num_transactions = fixture.fixture.len(); | ||
let half = num_transactions / 2; | ||
let builder_provider_clone = builder_provider.clone(); | ||
stream::iter(fixture.fixture.iter().enumerate()) | ||
.map(Ok) | ||
.try_for_each_concurrent(CONCURRENCY_LIMIT, move |(index, transaction)| { | ||
let builder_provider = builder_provider_clone.clone(); | ||
async move { | ||
let tx = if index < half { | ||
// First half, use eth_sendRawTransaction | ||
builder_provider.send_raw_transaction(transaction).await? | ||
} else { | ||
// Second half, use eth_sendRawTransactionConditional | ||
let rlp_hex = hex::encode_prefixed(transaction); | ||
let tx_hash = builder_provider | ||
.client() | ||
.request( | ||
"eth_sendRawTransactionConditional", | ||
(rlp_hex, ConditionalOptions::default()), | ||
) | ||
.await?; | ||
PendingTransactionBuilder::new(builder_provider.root().clone(), tx_hash) | ||
}; | ||
let hash = *tx.tx_hash(); | ||
let receipt = tx.get_receipt().await; | ||
assert!(receipt.is_ok()); | ||
debug!( | ||
receipt = ?receipt.unwrap(), | ||
hash = ?hash, | ||
index = index, | ||
"Transaction Receipt Received" | ||
); | ||
Ok::<(), eyre::Report>(()) | ||
} | ||
}) | ||
.await?; | ||
Ok(()) | ||
} | ||
|
||
/// Asserts that the chain continues to advance in the case when the world-chain-builder service is MIA. | ||
pub async fn assert_fallback<T, P>(sequencer_provider: P) -> Result<()> | ||
where | ||
T: Transport + Clone, | ||
P: Provider<T>, | ||
{ | ||
run_command( | ||
"kurtosis", | ||
&[ | ||
"service", | ||
"stop", | ||
"world-chain", | ||
"wc-admin-world-chain-builder", | ||
], | ||
)?; | ||
sleep(Duration::from_secs(5)).await; | ||
|
||
// Grab the latest block number | ||
let block_number = sequencer_provider.get_block_number().await?; | ||
let retries = 3; | ||
let mut tries = 0; | ||
loop { | ||
// Assert the chain has progressed | ||
let new_block_number = sequencer_provider.get_block_number().await?; | ||
if new_block_number > block_number { | ||
break; | ||
} | ||
|
||
if tries >= retries { | ||
panic!("Chain did not progress after {} retries", retries); | ||
} | ||
|
||
sleep(Duration::from_secs(2)).await; | ||
tries += 1; | ||
} | ||
Ok(()) | ||
} |
Oops, something went wrong.