Skip to content

Conversation

@peterpeterparker
Copy link
Member

@peterpeterparker peterpeterparker commented Nov 26, 2024

Motivation

Using the IC mgmt function install_chunked_code currently fails when executed against mainnet.

e: Server returned an error:
  Code: 400 (Bad Request)
  Body: error: canister_not_found
details: The specified canister does not exist.

The feature works locally but, fails on mainnet or the call is being rejected by the BN because it does not comply with the specification.

The <effective_canister_id> in the URL paths of requests is the effective destination of the request. It must be contained in the canister ranges of a subnet, otherwise the corresponding HTTP request is rejected.
If the request is an update call to the Management Canister (aaaaa-aa), then:

If the call is to the install_chunked_code method and the arg is a Candid-encoded record with a target_canister field of type principal, then the effective canister id must be that principal.

Source: https://internetcomputer.org/docs/current/references/ic-interface-spec/#http-effective-canister-id

Changes

  • If the tranform function is called for method install_chunked_code with target_canister, then effectiveCanisterId is the target_canister else same as before.

peterpeterparker added a commit that referenced this pull request Nov 27, 2024
# Motivation

It’s literally impossible to test the internal `transform` function used
within the static `create` function of the `ic-mgmt` class. However, as
we need to address an issue to support WASM installation with chunks
(#773), we must extend it. That’s why this PR extracts the function into
a module, allowing us to provide tests for the mapping.

# Notes

We delegate the responsibility of calling the `transform` function to
`agent-js`, as it is used internally there and as we are "just"
implementing the interface exposed by agent-js. While it is not
thoroughly covered at the moment in the agent, I submitted a PR
[#954](dfinity/icp-js-core#954) today that adds at
least one assertion.

No particular entry in CHANGELOG. This is an internal refactoring.

# Changes

- Extract internal `transform` function to a utility.
- JSdocs and tests.
- Improve types of the function (expected interface and return type)

---------

Signed-off-by: David Dal Busco <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Signed-off-by: David Dal Busco <[email protected]>
Signed-off-by: David Dal Busco <[email protected]>
@github-actions
Copy link
Contributor

github-actions bot commented Nov 27, 2024

size-limit report 📦

Path Size
@dfinity/ckbtc 8.03 KB (0%)
@dfinity/cketh 3.68 KB (0%)
@dfinity/cmc 1.4 KB (0%)
@dfinity/ledger-icrc 4.17 KB (0%)
@dfinity/ledger-icp 15.43 KB (0%)
@dfinity/nns 36.68 KB (0%)
@dfinity/nns-proto 140.98 KB (0%)
@dfinity/sns 16.95 KB (0%)
@dfinity/utils 4.66 KB (0%)
@dfinity/ic-management 3.19 KB (+0.75% 🔺)

Signed-off-by: David Dal Busco <[email protected]>
@peterpeterparker peterpeterparker marked this pull request as ready for review November 27, 2024 10:29
@peterpeterparker peterpeterparker requested review from a team as code owners November 27, 2024 10:29
Copy link
Collaborator

@AntonioVentilii AntonioVentilii left a comment

Choose a reason for hiding this comment

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

LGTM tks!

@peterpeterparker peterpeterparker merged commit 98d0d33 into main Nov 27, 2024
11 checks passed
@peterpeterparker peterpeterparker deleted the fix/effective-target-canister-id branch November 27, 2024 11:45
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