Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Stage/stage-proofs upgrade info + better finalization scripts #3529

Merged
merged 20 commits into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
better scripts
  • Loading branch information
StanislavBreadless committed Jan 16, 2025
commit 06dbd202ae7e9f25bd54e71629f4b2d6a5973767
29 changes: 27 additions & 2 deletions zkstack_cli/crates/zkstack/src/commands/dev/commands/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,17 @@ pub async fn check_chain_readiness(
.build();
let l2_client = Box::new(l2_client) as Box<DynClient<L2>>;

let inflight_txs_count: usize = l2_client.get_unconfirmed_txs_count().await?;
let diamond_proxy_addr = l2_client.get_main_contract().await?;
let inflight_txs_count = match l2_client
.get_unconfirmed_txs_count()
.await {
Ok(x) => x,
Err(e) => {
anyhow::bail!("Failed to call `unstable_unconfirmedTxsCount`. Reason: `{}`.\nEnsure that `unstable` namespace is enabled on your server and it runs the latest version", e)
}
};

let diamond_proxy_addr = l2_client.get_main_contract().await?;

if inflight_txs_count != 0 {
anyhow::bail!("Chain not ready since there are inflight txs!");
}
Expand Down Expand Up @@ -714,6 +722,8 @@ pub struct GatewayUpgradeCalldataArgs {
da_mode: DAMode,
#[clap(long, default_missing_value = "false")]
dangerous_no_cross_check: Option<bool>,
#[clap(long, default_missing_value = "false")]
force_display_finalization_params: Option<bool>
}

pub struct GatewayUpgradeArgsInner {
Expand Down Expand Up @@ -800,6 +810,21 @@ pub(crate) async fn run(shell: &Shell, args: GatewayUpgradeCalldataArgs) -> anyh
hex::encode(&schedule_calldata)
);

if !args.force_display_finalization_params.unwrap_or_default() {
let chain_readiness = check_chain_readiness(
args.l1_rpc_url.clone(),
args.l2_rpc_url.clone(),
args.chain_id
).await;

if let Err(err) = chain_readiness {
println!("Chain is not ready to finalize the upgrade due to the reason:\n{:#?}", err);
println!("Once the chain is ready, you can re-run this command to obtain the calls to finalize the upgrade");
println!("If you want to display finalization params anyway, pass `--force-display-finalization-params=true`.");
return Ok(());
};
}

let admin_calls_finalize = get_admin_call_builder(&upgrade_info, &chain_info, args.into());

admin_calls_finalize.display();
Expand Down