Skip to content

Commit

Permalink
feat: enable chunked wasm upgrade (#213)
Browse files Browse the repository at this point in the history
* feat: enable chunked wasm upgrade

* feat: ic-mgmt

* feat: ic-mgmt next

* build: redo peer next

* build: bump ic-mgmt
  • Loading branch information
peterpeterparker authored Nov 27, 2024
1 parent 30c341b commit 37ee938
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
22 changes: 11 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"homepage": "https://juno.build",
"peerDependencies": {
"@dfinity/agent": "^2.1.3",
"@dfinity/ic-management": "^6.0.0",
"@dfinity/ic-management": "^6.0.0-next-2024-11-27.1",
"@dfinity/identity": "^2.1.3",
"@dfinity/principal": "^2.1.3",
"@junobuild/config": "*",
Expand Down
13 changes: 2 additions & 11 deletions packages/admin/src/handlers/upgrade.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {UpgradeCodeUnchangedError} from '../errors/upgrade.errors';
import {UpgradeCodeParams, UpgradeCodeProgressStep} from '../types/upgrade.types';
import {uint8ArrayToHexString} from '../utils/array.utils';
import {uint8ArraySha256} from '../utils/crypto.utils';
import {upgradeChunkedCode} from './upgrade.chunks.handlers';
import {upgradeSingleChunkCode} from './upgrade.single.handlers';

export const upgrade = async ({
Expand Down Expand Up @@ -102,21 +103,11 @@ const upgradeCode = async ({
actor,
...rest
}: Omit<UpgradeCodeParams, 'onProgress'>) => {
// We install the new code, effectively performing an upgrade.
// TODO: remove eslint ignore
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const upgradeType = (): 'simple' | 'chunked' => {
const blob = new Blob([wasmModule]);
return blob.size > SIMPLE_INSTALL_MAX_WASM_SIZE ? 'chunked' : 'simple';
};

// TODO: upgradeChunkedCode does not work on mainnet. Either an IC or agent-js issue.
// e: Server returned an error:
// Code: 400 (Bad Request)
// Body: error: canister_not_found
// details: The specified canister does not exist.
// const fn = upgradeType() === 'chunked' ? upgradeChunkedCode : upgradeSingleChunkCode;
const fn = upgradeSingleChunkCode;

const fn = upgradeType() === 'chunked' ? upgradeChunkedCode : upgradeSingleChunkCode;
await fn({wasmModule, canisterId, actor, ...rest});
};

0 comments on commit 37ee938

Please sign in to comment.