Skip to content

Commit

Permalink
Merge branch 'master' into release-0.15.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Nowak-Liebiediew committed Nov 27, 2023
2 parents d9f2c98 + e8da377 commit 8fe0489
Show file tree
Hide file tree
Showing 23 changed files with 406 additions and 184 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ jobs:
strategy:
fail-fast: false
matrix:
backend: ["ic-ref", "replica"]
# macos-latest is currently macos-11, ubuntu-latest is currently ubuntu-20.04
# ubuntu-18.04 not supported due to:
# /home/runner/.cache/dfinity/versions/0.8.3-34-g36e39809/ic-starter:
Expand All @@ -107,11 +106,7 @@ jobs:
time dfx cache install
time dfx new smoke
cd smoke
if [ "${{ matrix.backend}}" = "ic-ref" ]; then
time dfx start --emulator --background
else
time dfx start --background
fi
time dfx start --background
time dfx deploy
time dfx canister call smoke_backend greet '("fire")'
time curl --fail http://localhost:"$(dfx info webserver-port)"/sample-asset.txt?canisterId=$(dfx canister id smoke_frontend)
Expand Down
34 changes: 28 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

# UNRELEASED

=== fix: `dfx canister delete <canister id>` removes the related entry from the canister id store
### fix: `dfx canister delete <canister id>` removes the related entry from the canister id store

Previously, deleting a canister in the project by id rather than by name
would leave the canister id in the canister id store. This would cause
`dfx deploy` to fail.

=== fix: dfx extension install can no longer create a corrupt cache directory
### fix: dfx extension install can no longer create a corrupt cache directory

Running `dfx cache delete && dfx extension install nns` would previously
create a cache directory containing only an `extensions` subdirectory.
dfx only looks for the existence of a cache version subdirectory to
determine whether it has been installed. The end result was that later
commands would fail when the cache did not contain expected files.

=== fix: output_env_file is now considered relative to project root
### fix: output_env_file is now considered relative to project root

The .env file location, whether specified as `output_env_file` in dfx.json
or `--output-env-file <file>` on the commandline, is now considered relative
to the project root, rather than relative to the current working directory.

=== feat: Read dfx canister install argument from a file
### feat: Read dfx canister install argument from a file

Enables passing large arguments that cannot be passed directly in the command line using the `--argument-file` flag. For example `dfx canister install --argument-file ./my/argument/file.txt my_canister_name`.

Expand All @@ -36,6 +36,18 @@ call it as a query call. This resolves a potential security risk.

The message "transaction is a duplicate of another transaction in block ...", previously printed to stdout, is now logged to stderr. This means that the output of `dfx ledger transfer` to stdout will contain only "Transfer sent at block height <block height>".

### feat: accept more ways to specify cycle and e8s amounts

Underscores (`_`) can now be used to make large numbers more readable. For example: `dfx canister deposit-cycles 1_234_567 mycanister`

Certain suffixes that replace a number of zeros are now supported. The (case-insensitive) suffixes are:
- `k` for `000`, e.g. `500k`
- `m` for `000_000`, e.g. `5m`
- `b` for `000_000_000`, e.g. `50B`
- `t` for `000_000_000_000`, e.g. `0.3T`

For cycles an additional `c` or `C` is also acceptable. For example: `dfx canister deposit-cycles 3TC mycanister`

### feat: added `dfx cycles` command

This won't work on mainnet yet, but can work locally after installing the cycles ledger.
Expand All @@ -57,16 +69,26 @@ Defining a custom `etag` header no longer breaks certification.

Fixed a certification issue where under certain conditions the fallback file (`/index.html`) was served with an incomplete certificate tree, not proving sufficiently that the fallback file may be used as a replacement.

- Module hash: 965c8899f0a033593dc9b1634b2ab4e0f3fd28c1cfa06993069be2040a2f700e
Add the option to (re)set all permissions using upgrade arguments. This is especially useful for SNSes that cannot make calls as the canister's controller.

- Module hash: 657938477f1dee46db70b5a9f0bd167ec5ffcd2f930a1d96593c17dcddef61b3
- https://github.com/dfinity/sdk/pull/3443
- https://github.com/dfinity/sdk/pull/3451
- https://github.com/dfinity/sdk/pull/3429
- https://github.com/dfinity/sdk/pull/3428
- https://github.com/dfinity/sdk/pull/3421

### Replica

Updated replica to elected commit 80a6745673a28ee53d257b3fe19dcd6b7efa93d1.
Updated replica to elected commit 69e1408347723dbaa7a6cd2faa9b65c42abbe861.
This incorporates the following executed proposals:

- [126095](https://dashboard.internetcomputer.org/proposal/126095)
- [126000](https://dashboard.internetcomputer.org/proposal/126000)
- [125592](https://dashboard.internetcomputer.org/proposal/125592)
- [125591](https://dashboard.internetcomputer.org/proposal/125591)
- [125504](https://dashboard.internetcomputer.org/proposal/125504)
- [125503](https://dashboard.internetcomputer.org/proposal/125503)
- [125343](https://dashboard.internetcomputer.org/proposal/125343)
- [125342](https://dashboard.internetcomputer.org/proposal/125342)
- [125321](https://dashboard.internetcomputer.org/proposal/125321)
Expand Down
10 changes: 5 additions & 5 deletions Cargo.lock

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

23 changes: 23 additions & 0 deletions docs/design/asset-canister-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ The size of any chunk cannot exceed the message ingress limit.

## Method Reference

### Method: `init` and `post_upgrade`

```candid
service: (asset_canister_args: variant {
Init: record {};
Upgrade: record {
set_permissions: opt record {
prepare: vec principal;
commit: vec principal;
manage_permissions: vec principal;
};
};
})
```

The methods `init` and `post_upgrade` are called automatically by the system after new code is installed in the canister.

Both methods take the same argument type by definition. Therefore, to be able to have different arguments for the two cases, an enum is used to make the distinction.
If `init` is called with the `Upgrade` variant or if `post_upgrade` is called with the `Init` variant the asset canister traps and thereby reverts the code changes.

In `Upgrade`, the field `set_permissions` can be used to (re)set the list of principals with the listed permissions.
If `set_permissions` that is not `null`, then all permissions are set to the newly provided list of principals and the previous lists of principals are discarded.

### Method: `get`

```candid
Expand Down
39 changes: 39 additions & 0 deletions e2e/tests-dfx/assetscanister.bash
Original file line number Diff line number Diff line change
Expand Up @@ -1732,3 +1732,42 @@ WARN: {
assert_command dfx canister call e2e_project_frontend configure '(record { max_chunks=opt opt 3; max_bytes = opt opt 5500 })'
assert_command dfx deploy
}

@test "set permissions through upgrade argument" {
dfx_start
dfx deploy

assert_command dfx canister call e2e_project_frontend list_permitted '(record { permission = variant { Prepare }; })'
assert_eq "(vec {})"
assert_command dfx canister call e2e_project_frontend list_permitted '(record { permission = variant { Commit }; })'
assert_match "$(dfx identity get-principal)"
assert_command dfx canister call e2e_project_frontend list_permitted '(record { permission = variant { ManagePermissions }; })'
assert_eq "(vec {})"

dfx identity new alice --storage-mode plaintext
ALICE="$(dfx --identity alice identity get-principal)"

dfx canister install e2e_project_frontend --upgrade-unchanged --mode upgrade --argument "(opt variant {
Upgrade = record {
set_permissions = opt record {
prepare = vec {
principal \"${ALICE}\";
};
commit = vec {
principal \"$(dfx identity get-principal)\";
principal \"aaaaa-aa\";
};
manage_permissions = vec {
principal \"$(dfx identity get-principal)\";
};
}
}
})"
assert_command dfx canister call e2e_project_frontend list_permitted '(record { permission = variant { Prepare }; })'
assert_match "${ALICE}"
assert_command dfx canister call e2e_project_frontend list_permitted '(record { permission = variant { Commit }; })'
assert_match "$(dfx identity get-principal)"
assert_match '"aaaaa-aa"'
assert_command dfx canister call e2e_project_frontend list_permitted '(record { permission = variant { ManagePermissions }; })'
assert_match "$(dfx identity get-principal)"
}
2 changes: 1 addition & 1 deletion e2e/tests-dfx/build_granular.bash
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ teardown() {
dfx build e2e_project_backend
# validate assets canister wasn't built and can't be installed
assert_command_fail dfx canister install e2e_project_frontend
assert_match "No such file or directory"
assert_match "The canister must be built before install. Please run \`dfx build\`."
}


Expand Down
7 changes: 7 additions & 0 deletions e2e/tests-dfx/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,10 @@ teardown() {
assert_command_fail dfx canister install --all --argument '()'
assert_contains "error: the argument '--all' cannot be used with '--argument <ARGUMENT>'"
}

@test "remind to build before install" {
dfx_start
dfx canister create --all
assert_command_fail dfx canister install e2e_project_backend
assert_contains "The canister must be built before install. Please run \`dfx build\`."
}
Loading

0 comments on commit 8fe0489

Please sign in to comment.