Skip to content

cardano-testnet | Fix flaky height check in rpc test#6550

Open
carbolymer wants to merge 1 commit intomasterfrom
mgalazyn/fix/fix-stale-height-check
Open

cardano-testnet | Fix flaky height check in rpc test#6550
carbolymer wants to merge 1 commit intomasterfrom
mgalazyn/fix/fix-stale-height-check

Conversation

@carbolymer
Copy link
Copy Markdown
Contributor

Description

The chain height check was relying on an assumption that transaction goes into the next block, and sometimes the block nr check was returning stale info.

This changes the implementation to use retry untilM, to reliably check for the height.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. These may include:
    • golden tests
    • property tests
    • roundtrip tests
    • integration tests
      See Running tests for more details
  • Any changes are noted in the CHANGELOG.md for affected package
  • The version bounds in .cabal files are updated
  • CI passes. See note on CI. The following CI checks are required:
    • Code is linted with hlint. See .github/workflows/check-hlint.yml to get the hlint version
    • Code is formatted with stylish-haskell. See .github/workflows/stylish-haskell.yml to get the stylish-haskell version
    • Code builds on Linux, MacOS and Windows for ghc-9.6 and ghc-9.12
  • Self-reviewed the diff

Note on CI

If your PR is from a fork, the necessary CI jobs won't trigger automatically for security reasons.
You will need to get someone with write privileges. Please contact IOG node developers to do this
for you.

@carbolymer carbolymer requested a review from a team as a code owner April 24, 2026 08:09
@carbolymer carbolymer requested review from nc6 and removed request for a team April 24, 2026 08:09
@carbolymer carbolymer self-assigned this Apr 24, 2026
@carbolymer carbolymer changed the base branch from master to mgalazyn/refactor/remove-epoch-state-polling April 24, 2026 08:13
@carbolymer carbolymer force-pushed the mgalazyn/fix/fix-stale-height-check branch from 98eace4 to d3b60ad Compare April 24, 2026 08:15
@carbolymer carbolymer requested review from Jimbo4350 and palas and removed request for nc6 April 24, 2026 08:30
Base automatically changed from mgalazyn/refactor/remove-epoch-state-polling to master April 24, 2026 09:33
@Jimbo4350 Jimbo4350 requested a review from Copilot April 24, 2026 12:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses flakiness in the Cardano testnet RPC transaction integration test by replacing a brittle “wait for next block height” approach with a retry-based check that waits until the expected UTxOs are observable after submission.

Changes:

  • Replace the previous block-height polling loop with retryUntilM to wait until the destination address shows the expected UTxO state.
  • Introduce an EpochStateView in the test to drive block-based retry timing.
  • Add a changelog fragment documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cardano-testnet/test/cardano-testnet-test/Cardano/Testnet/Test/Rpc/Transaction.hs Reworks the post-submit waiting logic to retry querying UTxOs until the expected results appear, avoiding stale height assumptions.
cardano-testnet/changelog.d/20260424_081135_mgalazyn_fix_rpc_transaction_test.md Documents the flakiness fix in the changelog fragments.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

when (previousBlockNo + 1 >= currentBlockNo) $ do
threadDelay 500_000
loop
H.note_ "Ensure that submitted transaction ID is in the submitted transactions list"
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

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

The note text says this checks that the submitted tx id is "in the submitted transactions list", but the assertion only compares the locally computed tx id to the id returned by submitTx. Consider updating the message to reflect what’s actually being verified (or add an RPC query to check presence in a list if that’s the intent).

Suggested change
H.note_ "Ensure that submitted transaction ID is in the submitted transactions list"
H.note_ "Ensure that submitTx returns the same transaction ID as the locally computed signed transaction ID"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

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

Nice 👍

utxoAddress <- deserialiseAddressBs addrInEra $ utxo ^. U5c.cardano . U5c.address
pure $ addr1 == utxoAddress
)
(\xs -> length xs == 2)
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.

This assumes the testnet generated address has a single UTxO, and it seems that is indeed the case. But I think it would be more robust to either use a freshly generated address or check the assumption. Also the last assertion ends up being elem instead of a ===.

Also, now I realise this is really not from this PR, it was in the code already

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.

4 participants