Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOLLOW-244: Add notifyTopUpIfNeeded to canisters service #5857

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

dskloetd
Copy link
Contributor

Motivation

Topping up a canister is a 2-step process:

  1. Transfer ICP to a subaccount of the CMC
  2. Notify the CMC of the transfer
    Because the process might be interrupted between the 2 steps, the nns-dapp canister listens for all transactions to see if any might be a canister top-up transaction by an NNS dapp user.

We want the NNS dapp to stop listening for all transactions so we want to move this fallback mechanism to the frontend.

In this PR we add a service function that will be used to check if the CMC needs to be notified and to do so if needed.

It only checks the most recent transaction to see if it is a funding transaction. It's theoretically possible to have a funding transaction that is followed by another transaction that's not the corresponding burn transaction. This was discussed with the PM and decided that it's unlikely enough that it's not worth the extra complexity to take into account. If we decide later that we do want to take this into account we can still recover from those cases that were missed before.

Changes

  1. Add notifyTopUpIfNeeded. It checks the latest transaction on the CMC subaccount for a specific canister and notifies the CMC if the latest transaction is a top-up transaction.

Tests

  1. Added unit tests.
  2. Tested manually in a branch with end-to-end changes.

Todos

  • Add entry to changelog (if necessary).
    not yet

@dskloetd dskloetd marked this pull request as ready for review November 26, 2024 07:00
@dskloetd dskloetd requested a review from a team as a code owner November 26, 2024 07:00
Copy link
Contributor

@mstrasinskis mstrasinskis left a comment

Choose a reason for hiding this comment

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

Thank you!

@dskloetd dskloetd added this pull request to the merge queue Nov 26, 2024
Merged via the queue into main with commit 95b7d3e Nov 26, 2024
30 checks passed
@dskloetd dskloetd deleted the kloet/topup-service branch November 26, 2024 10:11
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2024
…5859)

# Motivation

# Motivation

Topping up a canister is a 2-step process:

1. Transfer ICP to a subaccount of the CMC
2. Notify the CMC of the transfer
Because the process might be interrupted between the 2 steps, the
nns-dapp canister listens for all transactions to see if any might be a
canister top-up transaction by an NNS dapp user.

We want the NNS dapp to stop listening for all transactions so we want
to move this fallback mechanism to the frontend.

# Changes

1. Call the service function that was added in
#5857 from `CanisterDetails` to
actually do the notifying if needed.

# Tests

1. Unit tests added.
2. Tested manually by removing the top-up functionality from the backend
canister and reloading the page in the middle of the top-up process.

# Todos

- [x] Add entry to changelog (if necessary).
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