Skip to content

perf: cut governance and epoch interval waits on Leios - #3740

Merged
mkoura merged 2 commits into
masterfrom
gov_waits_speedup
Oct 6, 2026
Merged

mkoura merged 2 commits into
masterfrom
gov_waits_speedup

Conversation

@mkoura

@mkoura mkoura commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

On the Leios testnet (leios_fast: 800 s epochs, a block every 20 s on average), a lot of test time goes to waiting for blocks and epoch windows that don't need to be waited for.

Guardrails: don't wait for epoch interval

test_guardrails waited for the epoch interval before each of its ~120 pparam proposals. That meant waiting for a new block every time, and also waiting out the last 240 s of each epoch whenever a proposal fell into it. The proposals are never voted on, and the committee and DReps are locked, so nothing can be enacted to change the previous action ID used in a proposal. Crossing an epoch boundary is harmless.

In the last Leios run this was ~75 of the test's 140 minutes (35 min of end-of-epoch waits, ~40 min of per-proposal block waits).

wait_for_epoch_interval: use wall clock

wait_for_epoch_interval waited for a new block before measuring the time, only to get an up-to-date slot number from the tip. On Leios that is ~20 s per call, and the function is used in ~90 places.

  • The current slot now comes from the wall clock (cardano-cli query slot-number).
  • It falls back to the tip, with a block wait, if the query fails (e.g. past the forecast horizon).
  • With check_slot, the slot of the last forged block must be in the interval, so the tip is still used there.
  • Callers often query the current epoch right after the wait. The first block of an epoch can come a while after the epoch started, so the function waits until the tip is in the current epoch before checking the interval. If that block comes after stop, it moves on to the next epoch as before.

Testing

  • New unit tests in framework_tests/test_clusterlib_utils.py, using a simulated chain clock: in-interval without a block wait, sleep until start, tip still in the previous epoch, first block of the epoch after stop, past the interval, force_epoch, check_slot, the slot query failing at the start or mid-wait, and the tip never reaching the epoch.
  • On a local dev cluster: test_stake_snapshot, test_delegate_using_pool_id, test_update_stake_pool_metadata, test_pool_blocks.

mkoura added 2 commits October 6, 2026 09:25
The guardrails proposals are never voted on, and the committee and
DReps are locked, so no pparam update can be enacted and change the
previous action ID used in a proposal. Crossing an epoch boundary
between building and submitting a proposal is therefore harmless.

Waiting for the epoch interval cost a new block before each of ~120
proposals, plus waiting out the end of epoch whenever a proposal fell
into it. On the Leios testnet (20 s blocks, 240 s end of epoch buffer
in 800 s epochs) that was ~75 of the test's 140 minutes.
`wait_for_epoch_interval` waited for a new block before every check,
only to get an up-to-date slot number from the tip. On the Leios
testnet, with a block every 20 s on average, that cost ~20 s per call,
and the function is used in ~90 places.

Derive the current slot from wall clock (`query slot-number`) instead.
Fall back to the tip if the query fails, e.g. past the forecast
horizon. With `check_slot`, the slot of the last forged block must
match the interval, so the tip is still used there.

Callers often query the current epoch right after the wait. As the
first block of an epoch can come a while after the epoch started, wait
until the tip is in the current epoch, and only then check that the
time is in the interval, as the block can come late in the epoch.
@mkoura
mkoura requested a review from saratomaz as a code owner October 6, 2026 10:59
@mkoura
mkoura requested a balanced review from Copilot and removed request for saratomaz October 6, 2026 10:59

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

🔵 Needs a closer look

The timing helper has broad E2E impact and relies on race-sensitive node and wall-clock behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Optimizes Leios test execution by avoiding unnecessary block and epoch waits.

Changes:

  • Uses wall-clock slot queries with tip fallback.
  • Adds simulated-chain unit coverage.
  • Removes redundant guardrail proposal waits.
File Description
framework_tests/​test_clusterlib_utils.py Tests interval-wait scenarios.
cardano_node_tests/​utils/​clusterlib_utils.py Implements wall-clock timing.
cardano_node_tests/​tests/​tests_conway/​test_guardrails.py Removes proposal wait.

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

@mkoura
mkoura merged commit 19a44bd into master Oct 6, 2026
4 checks passed
@mkoura
mkoura deleted the gov_waits_speedup branch October 6, 2026 11:19
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