fix(e2e): guard alice's back-to-back gov txs against sequence-mismatc…#2268
Merged
Conversation
ⓘ You are approaching your monthly quota for Qodo. Upgrade your plan Review Summary by QodoFix account sequence mismatch in E2E back-to-back governance transactions
WalkthroughsDescription• Add lavad_tx_and_wait helper to ensure tx block inclusion before next same-signer tx • Wrap alice's back-to-back proposal submit-vote patterns with new helper • Eliminate race condition where vote queries pre-submit sequence from mempool • Fix "account sequence mismatch" flake in E2E initialization script Diagramflowchart LR
A["lavad tx --broadcast-mode sync"] -->|returns after CheckTx| B["mempool"]
B -->|not guaranteed included| C["wait_next_block"]
C -->|queries sequence| D["pre-submit value"]
D -->|signs vote| E["antehandler rejects"]
F["lavad_tx_and_wait wrapper"] -->|polls tx inclusion| G["block confirmed"]
G -->|sequence advanced| H["next tx safe"]
File Changes1. scripts/useful_commands.sh
|
Code Review by Qodo
|
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…h flake The Lava Protocol E2E job (CI run 24386640804) failed at init_e2e.sh line 20 with "account sequence mismatch, expected 2, got 1" on `lavad tx gov vote 1 yes --from alice`. Three identical patterns in init_e2e.sh have alice submit a legacy proposal, then vote on it; and every vote is followed by another alice submit (or, for vote 3, the end of alice's sequence). Both the submit→vote pair AND the vote→next-submit pair can race. Root cause: `lavad tx ... --broadcast-mode sync` (the default) returns after CheckTx accepts the tx into the mempool — not after the tx lands in a block. A subsequent `wait_next_block` only waits for block height to tick; it does not guarantee the prior tx was included in that block. The follow-up alice tx then queries alice's on-chain sequence, gets the pre-prior-tx value, signs with that sequence, and broadcasts. If the prior tx lands between query and broadcast, the antehandler (cosmos-sdk@v0.47.13/x/auth/ante/sigverify.go:269) rejects the new tx. The `sleep 6` after each vote is a timing assumption, not a guarantee — under CI load a single slow block makes vote 1 → submit 2 just as racy as submit 1 → vote 1. Add `lavad_tx_and_wait` in scripts/useful_commands.sh — a thin wrapper around `lavad <subcommand>` that captures the txhash from the CLI output and polls `lavad q tx $hash` via the existing `wait_for_tx` helper until the tx is actually included. Wrap every alice gov tx in init_e2e.sh (three submit-legacy-proposal and three vote calls) so every same-signer transition is guaranteed sequence-consistent. The intermediate `wait_next_block` calls are now redundant (inclusion is explicit) and are dropped; the `sleep 6` calls remain for their original purpose of letting plan policies become active after voting. Other same-account back-to-back patterns in the script (user1, user3) are separated by `sleep_until_next_epoch` or `sleep 6`, which already close the race in practice; leaving those unchanged for minimum churn. They can adopt the helper if a similar flake surfaces. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e57d558 to
43ad824
Compare
avitenzer
approved these changes
Apr 14, 2026
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.
…h flake
The Lava Protocol E2E job (CI run 24386640804) failed at init_e2e.sh line 20 with "account sequence mismatch, expected 2, got 1" on
lavad tx gov vote 1 yes --from alice. The fail repeats across three identical patterns in init_e2e.sh where alice submits a legacy proposal and immediately votes on it.Root cause:
lavad tx ... --broadcast-mode sync(the default) returns after CheckTx accepts the tx into the mempool — not after the tx lands in a block. A subsequentwait_next_blockonly waits for block height to tick; it does not guarantee the prior tx was included in that block. The follow-up vote then queries alice's on-chain sequence, gets the pre-submit value, signs the vote with that sequence, and broadcasts. If the submit lands between query and broadcast, the antehandler (cosmos-sdk@v0.47.13/x/auth/ante/sigverify.go:269) rejects the vote.Add
lavad_tx_and_waitin scripts/useful_commands.sh — a thin wrapper aroundlavad <subcommand>that captures the txhash from the CLI output and pollslavad q tx $hashvia the existingwait_for_txhelper until the tx is actually included. Wrap the three same-signer submit-then-vote patterns in init_e2e.sh (proposals 1, 2, and 3) so alice's sequence has definitely advanced on chain before the vote queries it. The redundantwait_next_blockbetween each submit and vote is dropped: inclusion is now explicit.Other same-account back-to-back patterns in the script (user1, user3) are separated by
wait_next_block+sleep_until_next_epochorsleep 6, which already provide enough wall-clock gap for the CheckTx → block-inclusion race to close. Leaving those unchanged for minimum churn; they can adopt the helper if a similar flake surfaces.Description
Closes: #XXXX
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!in the type prefix if API or client breaking changemainbranchReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...