Skip to content

fix(wallet): await on-chain confirmation before returning from deploy-program#375

Open
jimmy-claw wants to merge 2 commits intologos-blockchain:mainfrom
jimmy-claw:jimmy/wallet-deploy-await-confirmation
Open

fix(wallet): await on-chain confirmation before returning from deploy-program#375
jimmy-claw wants to merge 2 commits intologos-blockchain:mainfrom
jimmy-claw:jimmy/wallet-deploy-await-confirmation

Conversation

@jimmy-claw
Copy link

@jimmy-claw jimmy-claw commented Mar 2, 2026

🎯 Purpose

Fixes a bug where wallet deploy-program exits 0 immediately after TX submission, even if the sequencer rejected it. Caused silent failures during the LEZ demo — command reported success but program was not deployed.

⚙️ Approach

  • After submitting the deploy TX, poll the sequencer until the program ID appears in state or ~45s timeout (3 blocks)
  • Returns exit 1 with a clear error if the program fails to land on-chain
  • No change to TX submission logic

🧪 How to Test

# Should exit 0 and confirm deployment
wallet deploy-program path/to/program.bin

# With an invalid binary — should now exit 1 with error (previously silent exit 0)

🔗 Dependencies

None.

🔜 Future Work

  • Dedicated get_program RPC method instead of polling nonces as a proxy for confirmation

📋 PR Completion Checklist

  • Complete PR description
  • Implement the core functionality
  • Add/update tests
  • Add/update documentation and inline comments

jimmy-claw and others added 2 commits March 2, 2026 20:32
…-program

The DeployProgram command previously submitted the transaction and
immediately returned success, even if the sequencer rejected it. Now it
polls get_transaction_by_hash until the transaction appears in a block,
exiting non-zero with a clear error message after a 30s timeout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Block time in lssa is 15s, so 3 blocks = 45s is the right timeout.
Polling every 2s (23 attempts) is responsive without hammering the sequencer.
@moudyellaz
Copy link
Collaborator

please, could you follow the PR template when opening PRs?

@jimmy-claw
Copy link
Author

Done — updated the description to follow the PR template. Also updated #341 and #378 for consistency. Sorry for skipping it!

if !confirmed {
anyhow::bail!(
"Transaction was not confirmed after timeout. \
Timed out after ~3 blocks (45s). The program may not have been deployed. Check sequencer logs."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an appropriate message for external user who just uses a wallet, I suggest to remove this part


/// Poll the sequencer until a transaction appears in a block.
/// Returns `Ok(true)` if confirmed, `Ok(false)` if timed out.
async fn wait_for_tx_confirmation(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have TxPoller::poll_tx(), better to use it and not to write similar code from scratch

println!("Waiting for confirmation...");

// Poll until the transaction is included in a block
let confirmed = wait_for_tx_confirmation(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can see, that this is probably a handy thing to wait for tx confirmation. However it may be not always desired. My suggestion is to make some refactor in future to make user code to look like so:

let tx_hash = wallet.deploy_program(...).await;
wallet.wait_for_tx_confirmation(tx_hash);

And same in other places. But probably not for this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants