Skip to content

ir/timers: never stop epoch ticking - #4274

Open
carpawell wants to merge 1 commit into
masterfrom
fix/ir-do-not-try-epoch-tick-after-stuck
Open

carpawell wants to merge 1 commit into
masterfrom
fix/ir-do-not-try-epoch-tick-after-stuck

Conversation

@carpawell

Copy link
Copy Markdown
Member

If anything blocks epoch tick, do not simply try it once and wait for the next chain "NewEpoch" notification, instead, try to predict the next tick time and never stop trying. An epoch stuck is a critical error in the system, IRs must try their best.

@carpawell carpawell self-assigned this Nov 5, 2026
@carpawell
carpawell force-pushed the fix/ir-do-not-try-epoch-tick-after-stuck branch 4 times, most recently from bd9565d to eed742b Compare November 5, 2026 15:24
@codecov

codecov Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.83%. Comparing base (b9c6b05) to head (b3ceaa5).

Files with missing lines Patch % Lines
pkg/innerring/innerring.go 0.00% 9 Missing ⚠️
pkg/timers/timer.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4274      +/-   ##
==========================================
- Coverage   32.83%   32.83%   -0.01%     
==========================================
  Files         673      673              
  Lines       41706    41713       +7     
==========================================
+ Hits        13694    13696       +2     
- Misses      28012    28017       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roman-khimov roman-khimov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not resetting in error handler? This seems dangerous by default (some other timers can have problems with this).

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.

🟡 Changes recommended

The timer can submit the epoch transaction on every block when no valid duration is available, so the active moderate-severity issue must be fixed.

1 open issue
What changed in this PR

Updates epoch timers to keep retrying epoch ticks using the configured epoch duration when NewEpoch notifications are delayed or unavailable.

Changes:

  • Replaces one-shot completion state with persistent epoch-duration scheduling.
  • Reschedules the next epoch tick after each attempted handler execution.
  • Stores the epoch duration during timer resets.
  • A moderate issue remains when epochDur is zero: handlers may be invoked once per block instead of preserving one-shot behavior until a valid duration is available.
File Description
pkg/​timers/​timer.go Implements recurring epoch-tick scheduling and reset duration tracking.

Review effort: Lite

Comment thread pkg/timers/timer.go
Comment on lines +65 to +67
if et.epochDur != 0 {
et.nextTickAt = curr + et.epochDur
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it does not differ much from the previous behaviour: Reset is called from the beginning of IR's journey

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed with providing initial epoch duration for IR app

@End-rey

End-rey commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

This looks like the timer commit from #4272, with both issues I pointed out there fixed.

@carpawell

Copy link
Copy Markdown
Member Author

Why not resetting in error handler?

What is "error handler"? Current IR does not wait for new epoch tx inclusion, it just sends notary request, do you want it to wait for NewEpoch notification (or vub expiration)?

This seems dangerous by default (some other timers can have problems with this).

There are no other timers, only the new epoch will have this exclusive opportunity. If everything is ok, it will be reset likely almost immediately by the NewEpoch event. But if smth is wrong, the next tick will, at least, happen.

@roman-khimov

If anything blocks epoch tick, do not simply try it once and wait for the next
chain "NewEpoch" notification, instead, try to predict the next tick time and
never stop trying. An epoch stuck is a critical error in the system, IRs must
try their best.

Signed-off-by: Pavel Karpy <carpawell@nspcc.io>
@carpawell
carpawell force-pushed the fix/ir-do-not-try-epoch-tick-after-stuck branch from eed742b to b3ceaa5 Compare November 11, 2026 15:16
@carpawell

Copy link
Copy Markdown
Member Author

@roman-khimov, treat this PR like time.Timer -> time.Ticker evolution. Reset will always be called after a real NewEpoch event is handled. What exactly bothers you?

This branch has not been deployed

No deployments
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