Skip to content

feat(tests): wait for fork resolution in tx checks - #3715

Merged
mkoura merged 1 commit into
masterfrom
missing_utxos_fork_wait
Sep 29, 2026
Merged

mkoura merged 1 commit into
masterfrom
missing_utxos_fork_wait

Conversation

@mkoura

@mkoura mkoura commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Temporary forks are more frequent on loaded Leios testnets. A tx lost in a fork makes tests, especially long ones, fail much later with a confusing error.

Replace check_missing_utxos with check_tx_on_all_nodes, which checks the first output of the tx on all nodes. Outputs of a tx are either all on the chain or none, so checking one output is enough.

When the tx is missing on some nodes, retry quietly once, as a node can be just a bit behind with block propagation. Then wait for the nodes to reach the same chain tip and for 3 more blocks, as the tx can still get into a block from a mempool of a node on the winning chain. The block counting starts again when the nodes fork again. Fail when the tx is still missing after that, or when the nodes don't converge within the timeout (by default 20 average block times, at least 60 seconds).

Also call the check after state changing txs in shared delegation and governance helpers, and in long running staking, pool, BLS and governance tests. In tests that need the tx in the same epoch, check the epoch after the tx check, as the tx can get into a block after the epoch boundary when there was a fork.

The assert tx_raw_dereg in test_redelegation narrows the type for mypy. The stake address is registered at that point, so None would mean a bug.

Temporary forks are more frequent on loaded Leios testnets. A tx lost
in a fork makes tests, especially long ones, fail much later with a
confusing error.

Replace `check_missing_utxos` with `check_tx_on_all_nodes`, which
checks the first output of the tx on all nodes. Outputs of a tx are
either all on the chain or none, so checking one output is enough.

When the tx is missing on some nodes, retry quietly once, as a node
can be just a bit behind with block propagation. Then wait for the
nodes to reach the same chain tip and for 3 more blocks, as the tx can
still get into a block from a mempool of a node on the winning chain.
The block counting starts again when the nodes fork again. Fail when
the tx is still missing after that, or when the nodes don't converge
within the timeout (by default 20 average block times, at least 60
seconds).

Also call the check after state changing txs in shared delegation and
governance helpers, and in long running staking, pool, BLS and
governance tests. In tests that need the tx in the same epoch, check
the epoch after the tx check, as the tx can get into a block after
the epoch boundary when there was a fork.

The `assert tx_raw_dereg` in `test_redelegation` narrows the type for
mypy. The stake address is registered at that point, so `None` would
mean a bug.
@mkoura
mkoura requested a review from saratomaz as a code owner September 25, 2026 15:57
@mkoura
mkoura requested a lite review from Copilot and removed request for saratomaz September 25, 2026 15:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Address the convergence reset, timeout enforcement, and cleanup-finalizer issues before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

This pull request adds fork-aware transaction consistency checks across the Cardano node test suite, waiting for convergence before reporting missing transactions.

Changes:

  • Replaces UTxO-only checks with check_tx_on_all_nodes.
  • Adds retry, convergence, and post-convergence block waiting.
  • Applies checks across governance, delegation, staking, pool, BLS, Plutus, and transaction tests.
  • Reorders epoch checks and narrows optional deregistration transaction types.
File Reviewed changes
cardano_node_tests/​utils/​node_consistency.py Implements fork-aware transaction polling.
cardano_node_tests/​utils/​governance_utils.py Checks DRep registration transactions.
cardano_node_tests/​utils/​governance_setup.py Checks governance setup transactions.
cardano_node_tests/​tests/​tests_plutus/​test_spend_datum_raw.py Updates Plutus transaction checks.
cardano_node_tests/​tests/​tests_plutus/​test_spend_datum_build.py Updates datum transaction checks.
cardano_node_tests/​tests/​tests_plutus/​test_spend_build.py Updates spending consistency checks.
cardano_node_tests/​tests/​tests_plutus/​test_mint_raw.py Updates minting consistency checks.
cardano_node_tests/​tests/​tests_plutus/​test_mint_build.py Updates mint build checks.
cardano_node_tests/​tests/​tests_plutus/​test_delegation.py Adds delegation transaction checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_secp256k1_build.py Updates spending checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_ref_inputs_raw.py Updates reference-input checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_spend_ref_inputs_build.py Updates reference-input build checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_secp256k1_raw.py Updates minting checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_secp256k1_build.py Updates mint build checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_raw.py Updates raw mint checks.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_negative_build.py Checks successful negative-mint transactions.
cardano_node_tests/​tests/​tests_plutus_v2/​test_mint_build.py Updates mint build checks.
cardano_node_tests/​tests/​tests_plutus_v2/​mint_raw.py Updates shared mint helper checks.
cardano_node_tests/​tests/​tests_conway/​test_treasury_withdrawals.py Adds treasury transaction checks.
cardano_node_tests/​tests/​tests_conway/​test_treasury_donation.py Updates donation checks.
cardano_node_tests/​tests/​tests_conway/​test_offchain_voting_anchor.py Adds proposal transaction checks.
cardano_node_tests/​tests/​tests_conway/​test_no_confidence.py Adds governance transaction checks.
cardano_node_tests/​tests/​tests_conway/​test_info.py Adds governance transaction checks.
cardano_node_tests/​tests/​tests_conway/​test_hardfork.py Adds hardfork transaction checks.
cardano_node_tests/​tests/​tests_conway/​test_drep.py Adds delegation transaction checks.
cardano_node_tests/​tests/​tests_conway/​test_committee.py Adds committee transaction checks.
cardano_node_tests/​tests/​tests_conway/​conway_common.py Adds shared governance transaction checks.
cardano_node_tests/​tests/​test_tx_basic.py Updates basic transaction checks.
cardano_node_tests/​tests/​test_staking_rewards.py Adds checks to long-running staking flows.
cardano_node_tests/​tests/​test_staking_no_rewards.py Adds staking and pool transaction checks.
cardano_node_tests/​tests/​test_scripts.py Updates script transaction checks.
cardano_node_tests/​tests/​test_pools.py Adds pool transaction checks.
cardano_node_tests/​tests/​test_native_tokens.py Updates token transaction checks.
cardano_node_tests/​tests/​test_delegation.py Adds delegation transaction checks.
cardano_node_tests/​tests/​test_bls_rotation.py Adds BLS transaction checks.
cardano_node_tests/​tests/​test_bls_keys.py Adds pool registration checks.
cardano_node_tests/​tests/​delegation.py Adds shared delegation checks.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cardano_node_tests/utils/node_consistency.py
Comment thread cardano_node_tests/utils/node_consistency.py
@mkoura
mkoura merged commit b7db7ee into master Sep 29, 2026
4 checks passed
@mkoura
mkoura deleted the missing_utxos_fork_wait branch September 29, 2026 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants