fix(wallet): await on-chain confirmation before returning from deploy-program#375
Open
jimmy-claw wants to merge 2 commits intologos-blockchain:mainfrom
Open
Conversation
…-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.
Collaborator
|
please, could you follow the PR template when opening PRs? |
Author
Arjentix
requested changes
Mar 10, 2026
| 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." |
Collaborator
There was a problem hiding this comment.
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( |
Collaborator
There was a problem hiding this comment.
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( |
Collaborator
There was a problem hiding this comment.
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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Purpose
Fixes a bug where
wallet deploy-programexits 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
🧪 How to Test
🔗 Dependencies
None.
🔜 Future Work
get_programRPC method instead of polling nonces as a proxy for confirmation📋 PR Completion Checklist