Poke endpoint on ICRC Index Canisters

Context

Problem

I’d like to be able to ensure that an SNS token index canister can be as responsive as needed while also avoiding unnecessary polling expense. The incremental polling wait time increase change introduced recently is a good change (see context), but it introduces the potential for a laggy user experience.

Proposal

I’d like to propose a very simple ‘Poke()’ endpoint on the ICRC Index canister implementation, along with an optional allowed caller list.

In cases where ledger activity has been slow, but then a user performs an action involving a token transfer, they should not need to wait for 10 seconds when the dapp could instead just poke the index canister to eagerly inform it of the activity it now needs to index.

Follow up opportunities

As a separate follow up concern, with this in place I think that an SNS should also be able to increase the 10 seconds to a more relaxed 1 minute (as a configuration option, but they could keep it at 10 or even reduce it). This would help reduce SNS costs, while also increasing the feasibility of people launching more SNSs (I certainly plan to do this), ones which are perpetually funded and self-sustaining.


I’m happy to do the dev work, rigorous test cases, mainnet acceptance testing, and then raise the PR for DFINITY review. First I’d like to get feedback on the general idea.

@daniel-wong, @mathiasb, @bjoern, @Snassy-icp, @borovan4000 your thoughts would be especially helpful.

Thank you for the feedback. Sounds very reasonable. Mathias would be the one who would work on it though, so I don’t want to volunteer him for anything. I’m just saying, “this is reasonable”.

fyi: Mathias is on vacation until the 19th.

Thanks @daniel-wong

Given that the proposed endpoint is rather simple and self-contained, I’d be interested in implementing this and raising a pull request.

Ideally I think DFINITY should be looking for opportunities to share workload out to the community (while maintaining oversight and at least review involvement).

Unless there are any objections I can take a look at raising a PR within the next week or so.

feat(ICRC_Index): Add one-way poke endpoint by aodl · Pull Request #11882 · dfinity/ic

Bumping this very reasonable request just because I am not sure you tagged the right Mathias.

Thanks for the initiative, @Lorimer! We discussed this internally, and it looks like a reasonable approach. Some high-level comments on the design and roll-out:

  • Currently, it is not possible to provide any upgrade arguments for canisters of an SNS, so enabling poke() would have to be the default. The default would probably have to be allowing all principals to call the new endpoint.
  • If an SNS would like to have a different configuration, something similar to ManageLedgerParameters would be needed (@daniel-wong would probably be the best to comment on what adding that would involve).
  • Related to this, if we’d want to bump the timer interval from 10s to e.g., 1min, this would currently also need to be done by changing the default, and it would apply to all SNSs (unless they opt-out of automated upgrades for all SNS canisters, not only for upgrades of the index canister).

Hey @mathiasb, thanks for taking a look.

I’d push back on enabling the poke endpoint as the default. It’s not a major blocker that SNSs don’t currently have a route for updating the config. I think this needs addressing anyway and I was planning to raise a separate PR for it after this one (I realise now that I wasn’t clear about what I meant in the follow up work mentioned above). While I’m there I was also planning to address some technical debt.

I think the current default polling schedule is good. Whenever a project enables poke they can set a different schedule then (depending on who poke is intended to be called by and any other context).

Hey @mathiasb, please confirm if there’s anything you need from me to push forward with the PR