Skip to content

Comments

feat(Ledger_Index): DEFI-2676: Set index timer minimum interval#8974

Open
mbjorkqvist wants to merge 3 commits intomasterfrom
mathias/DEFI-2676-index-timer-interval
Open

feat(Ledger_Index): DEFI-2676: Set index timer minimum interval#8974
mbjorkqvist wants to merge 3 commits intomasterfrom
mathias/DEFI-2676-index-timer-interval

Conversation

@mbjorkqvist
Copy link
Contributor

Set a minimum timer interval for the ICP and ICRC index canister.

@github-actions github-actions bot added the feat label Feb 20, 2026
@mbjorkqvist mbjorkqvist marked this pull request as ready for review February 24, 2026 08:58
@mbjorkqvist mbjorkqvist requested a review from a team as a code owner February 24, 2026 08:58
@github-actions github-actions bot added the @defi label Feb 24, 2026
state.retrieve_blocks_from_ledger_interval = retrieve_blocks_from_ledger_interval_seconds
.map(|interval| {
Duration::from_secs(interval).max(MIN_RETRIEVE_BLOCKS_FROM_LEDGER_INTERVAL)
});
Copy link
Contributor

Choose a reason for hiding this comment

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

understanding: why clamping to MIN_RETRIEVE_BLOCKS_FROM_LEDGER_INTERVAL and not returning an error in case the interval is smaller than this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Returning an error is definitely an option. I'd be fine with going this route, although it does come with the drawback outlined in the other discussion.

@@ -45,6 +45,10 @@ const ACCOUNTIDENTIFIER_BLOCK_IDS_MEMORY_ID: MemoryId = MemoryId::new(3);
const ACCOUNTIDENTIFIER_DATA_MEMORY_ID: MemoryId = MemoryId::new(4);
Copy link
Contributor

Choose a reason for hiding this comment

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

here for a lack of better place: shouldn't the corresponding retrieve_block_from_ledger tests be updated to not have a value of 0 for the interval (for clarity)? And shouldn't we test setting an interval with value less than 1 sec?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the init and upgrade arguments, we take as input the interval in seconds (as u64), so without changing the init and upgrade arguments, an interval of less than 1 second cannot be specified. There are certainly some options we could consider:

  • Add a new upgrade argument, e.g., retrieve_blocks_from_ledger_interval_millis, which would allow for finer-grained configuring of the interval.
  • Disallow intervals of 0 seconds. There probably aren't any index canisters out there with this configuration, but for ones that may exist, we'd need to decide what to do, either fail the upgrade if the interval is set to 0 seconds, or forcefully change it to 1 second (which may not be so easy for a user to discover).

There is a potential use case (although not necessarily a reasonable one) for less than 1 second - if you want the index to poll the ledger every round, then 1 second is not enough if the subnet finalization rate is more than 1 block/s.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants