Skip to content

Commit

Permalink
test: checkpoint kurtosis deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
0xOsiris committed Dec 27, 2024
1 parent c63e317 commit 0d62eed
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 26 deletions.
1 change: 1 addition & 0 deletions contracts/lib/solady
Submodule solady added at 717c0a
2 changes: 1 addition & 1 deletion contracts/scripts/DeployDevnet.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ contract DeployDevnet is Script {
}

function beginBroadcast() internal {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
uint256 deployerPrivateKey = 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80;
vm.startBroadcast(deployerPrivateKey);
}
}
2 changes: 2 additions & 0 deletions devnet/src/el/world-chain/world_chain_launcher.star
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ def get_config(
"--metrics=0.0.0.0:{0}".format(METRICS_PORT_NUM),
"--discovery.port={0}".format(discovery_port),
"--port={0}".format(discovery_port),
"--builder.pbh_validator=0x7a2088a1bFc9d81c55368AE168C2C02570cB814F", # Deterministic Deployment Address on re-runs
"--builder.signature_aggregator=0x09635F643e140090A9A8Dcd712eD6285858ceBef" # Deterministic Deployment Address on re-runs
]

if len(existing_el_clients) > 0:
Expand Down
2 changes: 1 addition & 1 deletion world-chain-builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ RUN apt-get update && apt-get install -y libclang-dev gcc
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/world-chain-builder/target \
cargo install --path . --locked
cargo install --path crates/world/bin --locked

ENTRYPOINT [ "world-chain-builder" ]
2 changes: 1 addition & 1 deletion world-chain-builder/crates/tests/src/cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
"world-chain",
"wc-admin-world-chain-builder",
],
".",
env!("CARGO_MANIFEST_DIR"),
)
.await?;
sleep(Duration::from_secs(5)).await;
Expand Down
2 changes: 1 addition & 1 deletion world-chain-builder/crates/tests/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ pub async fn generate_test_fixture() -> Result<()> {

serde_json::to_writer(File::create(FIXTURES_DIR)?, &test_fixture)?;
Ok(())
}
}
49 changes: 29 additions & 20 deletions world-chain-builder/crates/tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//! NOTE: This binary assumes that the Kurtosis Devnet is not running, and the `world-chain` enclave has been cleaned.
use std::{
env,
path::Path,
sync::Arc,
time::{self, Duration, Instant},
Expand Down Expand Up @@ -34,9 +35,6 @@ async fn main() -> Result<()> {
.init();

let (builder_rpc, sequencer_rpc) = start_devnet().await?;
deploy_contracts(builder_rpc.clone()).await?;

generate_test_fixture().await?;

let sequencer_provider =
Arc::new(ProviderBuilder::default().on_http(sequencer_rpc.parse().unwrap()));
Expand All @@ -45,34 +43,36 @@ async fn main() -> Result<()> {

let timeout = std::time::Duration::from_secs(30);

info!("Waiting for the devnet to be ready");

let f = async {
let wait_0 = wait(sequencer_provider.clone(), timeout);
let wait_1 = wait(builder_provider.clone(), timeout);
tokio::join!(wait_0, wait_1);
};
f.await;

info!("Devnet is ready");
info!("Deploying contracts");
deploy_contracts(builder_rpc.clone()).await?;

info!("Generating test fixtures");
generate_test_fixture().await?;

info!("Running test cases");
cases::assert_build(builder_provider.clone()).await?;
cases::assert_fallback(sequencer_provider.clone()).await?;

Ok(())
}

async fn start_devnet() -> Result<(String, String)> {
run_command(
&"kurtosis run",
&[
".",
"--args-file",
"network_params.yaml",
"--enclave",
"world-chain",
],
"../../../../devnet/",
)
.await?;
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(3)
.unwrap()
.canonicalize()?;

run_command(&"just", &["devnet-up"], path).await?;
print!("Devnet is running");
let builder_socket = run_command(
"kurtosis",
Expand All @@ -83,7 +83,7 @@ async fn start_devnet() -> Result<(String, String)> {
"wc-admin-world-chain-builder",
"rpc",
],
"../../../../devnet/",
env!("CARGO_MANIFEST_DIR"),
)
.await?;

Expand All @@ -95,7 +95,7 @@ async fn start_devnet() -> Result<(String, String)> {
let sequencer_socket = run_command(
"kurtosis",
&["port", "print", "world-chain", "wc-admin-op-geth", "rpc"],
"../../../../devnet/",
env!("CARGO_MANIFEST_DIR"),
)
.await?;

Expand All @@ -117,6 +117,15 @@ async fn deploy_contracts(builder_rpc: String) -> Result<()> {
if std::env::var("PRIVATE_KEY").is_err() {
std::env::set_var("PRIVATE_KEY", DEPLOYER_DEV);
}
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.ancestors()
.nth(3)
.unwrap()
.join("contracts/")
.canonicalize()?;

info!("Deploying PBH 4337 contracts at {:?}", builder_rpc);

run_command(
"forge",
&[
Expand All @@ -126,7 +135,7 @@ async fn deploy_contracts(builder_rpc: String) -> Result<()> {
&builder_rpc,
"--broadcast",
],
"../../../../devnet/",
path,
)
.await?;
Ok(())
Expand Down Expand Up @@ -154,7 +163,7 @@ where
}

pub async fn run_command(cmd: &str, args: &[&str], ctx: impl AsRef<Path>) -> Result<String> {
let output = Command::new(cmd).args(args).current_dir(ctx).output()?;
let output = Command::new(cmd).current_dir(ctx).args(args).output()?;
if output.status.success() {
Ok(String::from_utf8(output.stdout)?)
} else {
Expand Down
4 changes: 2 additions & 2 deletions world-chain-builder/crates/world/pool/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ pub fn pbh_bundle(
}

pub const PBH_TEST_SIGNATURE_AGGREGATOR: Address =
address!("dEAD000000000000000042069420694206942069");
address!("09635F643e140090A9A8Dcd712eD6285858ceBef");

pub const PBH_TEST_VALIDATOR: Address = address!("deadbeefdeadbeefdeadbeefdeadbeefdeadbeef");
pub const PBH_TEST_VALIDATOR: Address = address!("7a2088a1bFc9d81c55368AE168C2C02570cB814F");

pub fn world_chain_validator(
) -> WorldChainTransactionValidator<MockEthProvider, WorldChainPooledTransaction> {
Expand Down

0 comments on commit 0d62eed

Please sign in to comment.