Skip to content

cardano-testnet | Remove redundant watchEpochStateUpdate#6535

Merged
carbolymer merged 1 commit intomasterfrom
mgalazyn/refactor/remove-watch-epoch-state-update
Apr 24, 2026
Merged

cardano-testnet | Remove redundant watchEpochStateUpdate#6535
carbolymer merged 1 commit intomasterfrom
mgalazyn/refactor/remove-watch-epoch-state-update

Conversation

@carbolymer
Copy link
Copy Markdown
Contributor

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 force-pushed the mgalazyn/refactor/remove-watch-epoch-state-update branch 7 times, most recently from c076427 to 6bd49c2 Compare April 16, 2026 12:49
@carbolymer carbolymer self-assigned this Apr 16, 2026
@carbolymer carbolymer marked this pull request as ready for review April 16, 2026 12:50
@carbolymer carbolymer requested a review from a team as a code owner April 16, 2026 12:50
Base automatically changed from mgalazyn/fix/testnet-make-conditions-wait-longer to master April 16, 2026 14:45
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.

Very nice simplification 👍

There is a lot of small nuance in some changes, and probably most of it doesn't really make a difference in practice, so I think we can ignore it.

I pointed out a couple of small things that may be worth changing or double-checking


-- | Core retry loop. Repeats the action every 300ms until it returns 'Right'
-- or the timeout is reached, in which case the last 'Left' is returned.
retryByTimeout
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.

I think the name is misleading. To me, retryByTimeout suggests that it will retry once when the timeout hits. Maybe retryUntilTimeout instead?

retryUntil is better but there is already retryUntilM and they are both monadic... If what we want is making them easier to differentiate, I would focus on naming the difference, maybe simpleRetryUntilM or eitherRetryUntilM or something like that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think I'll go with retryUntilRightM

-> m (Either e a)
retryByTimeout esv timeout act = withFrozenCallStack $ do
startingValue <- getCurrentValue
go $ startingValue + timeoutW64
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.

Nice, I was thinking about this recalculation before but I didn't want to mention it

Comment on lines +140 to +142
retryUntilM epochStateView (WaitForBlocks numberOfBlocks)
(getBlockNumber epochStateView)
(\(BlockNo bn) -> bn >= startingBlockNumber + numberOfBlocks)
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.

I think it is not very nice to have both the timeout and the action counting blocks, they may get out of sync too. I think it would be better to use retryByTimeout and rely on the timeout only, making the action always Left =<< getBlockNumber epochStateView, or Left () and then getting the block number afterwards.

Same as in waitForEpochs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point.

mGovernanceActionTxIx H.=== Nothing
void $ retryUntilM epochStateView (WaitForEpochs $ EpochInterval 2)
(maybeExtractGovernanceActionIndex governanceActionTxId <$> getEpochState epochStateView)
isNothing
Copy link
Copy Markdown
Contributor

@palas palas Apr 16, 2026

Choose a reason for hiding this comment

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

Apparently, this is weakening the test, because it was originally testing that:

  • The action is not available at the beginning of the call to watchEpochStateUpdate
  • The action remained unavailable during two epochs

But I am not sure the later was intentional.

On the other hand, line 136 was clearly waiting for the proposal to expire. And the new usage of retryUntilM is allowing for that to happen 2 epochs later potentially, so that is not good.

We could either merge this with the line 136 and reduce the timeout to adjust it to the original expectation. Or if we think that verifying that "the action does not reappear for two extra epochs" is important, we would need to invert this retrying and make the timeout the success

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch.

it was originally testing that (...) The action remained unavailable during two epochs

Looks like a double-check to me to deal with rollbacks. I don't expect rollbacks in one SPO testnets, but we can add a one epoch wait for a good measure, in case rollback happens on epoch boundary.

@carbolymer carbolymer force-pushed the mgalazyn/refactor/remove-watch-epoch-state-update branch 2 times, most recently from 82f0f20 to 75aece7 Compare April 21, 2026 07:47
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.

Just one comment for clarification and one thing that I think is weird in the test gov action test. Otherwise, looking good 👍

| ti1 == L.extractHash ti2 = Just gai
compareWithTxId _ x _ _ = x

-- | Look up the @gasExpiresAfter@ epoch for the governance action submitted
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.

I was super confused until I found out that gas meant GovActionState. Maybe it would be good to say that, for example say "look up the expiration epoch in the governance action state, through the gasExpiresAfter lens", or something like that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've renamed the function parameter

@carbolymer carbolymer force-pushed the mgalazyn/refactor/remove-watch-epoch-state-update branch from 75aece7 to 47aa730 Compare April 22, 2026 12:06
@Jimbo4350 Jimbo4350 self-requested a review April 23, 2026 15:00
Copy link
Copy Markdown
Contributor

@Jimbo4350 Jimbo4350 left a comment

Choose a reason for hiding this comment

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

Approved based on the work in: github.com//pull/6538

@carbolymer carbolymer force-pushed the mgalazyn/refactor/remove-watch-epoch-state-update branch from 47aa730 to 344c313 Compare April 24, 2026 06:57
@carbolymer carbolymer enabled auto-merge April 24, 2026 06:58
@carbolymer carbolymer added this pull request to the merge queue Apr 24, 2026
@carbolymer carbolymer removed this pull request from the merge queue due to a manual request Apr 24, 2026
@carbolymer carbolymer merged commit 3a12571 into master Apr 24, 2026
29 checks passed
@carbolymer carbolymer deleted the mgalazyn/refactor/remove-watch-epoch-state-update branch April 24, 2026 08:16
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.

3 participants