Skip to content

Commit

Permalink
Merge branch 'master' into SDK-1308-dfx-calls-cycles-faucet-endpoint-…
Browse files Browse the repository at this point in the history
…if-no-wallet-exists
  • Loading branch information
Marcin Nowak-Liebiediew authored Jan 23, 2024
2 parents 5266cfd + 023d127 commit 97e9e33
Show file tree
Hide file tree
Showing 43 changed files with 494 additions and 242 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ jobs:
runs-on: ${{ matrix.os }}
needs: [build_dfx]
strategy:
fail-fast: false
matrix:
os: [macos-12, ubuntu-20.04, ubuntu-22.04]
steps:
Expand Down Expand Up @@ -191,6 +192,12 @@ jobs:
--frontend_url "$FRONTEND_URL" \
--candid_url "$CANDID_URL" \
--browser chromium firefox webkit
export FRONTEND_URL_LOCALHOST="${FRONTEND_URL/127\.0\.0\.1/localhost}"
export CANDID_URL_LOCALHOST="${CANDID_URL/127\.0\.0\.1/localhost}"
python scripts/test-uis.py \
--frontend_url "$FRONTEND_URL_LOCALHOST" \
--candid_url "$CANDID_URL_LOCALHOST" \
--browser chromium firefox webkit
aggregate:
name: e2e:required
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ target/

# Backup files
*.bak

# DB repo for cargo-audit
advisory-db/
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

# UNRELEASED

### fix!: always fetch did file from canister when making canister calls

`dfx canister call` will always fetch did file from the canister metadata. This is especially helpful for calling remote canisters. It's a breaking change in the sense that if the canister doesn't have the `candid:service` metadata, we will not read the local did file from build artifact, and dfx will issue a warning in this case to encourage canister developers to put the did file into canister metadata.

### fix: support `import` for local did file

If the local did file contains `import` or init args, dfx will rewrite the did file when storing in canister metadata.
Due to current limitations of the Candid parser, comments will be dropped during rewriting.
If the local did file doesn't contain `import` or init args, we will not perform the rewriting, thus preserving the comments.

### fix: subtyping check reports the special opt rule as error

# 0.16.0

### feat: large canister modules now supported

When using `dfx deploy` or `dfx canister install`, previously WASM modules larger than 2MiB would be rejected.
They are now automatically submitted via the chunking API if they are large enough.
From a user perspective the limitation will simply have been lifted.

### feat: dfx deps: wasm_hash_url and loose the hash check

Providers can provide the hash through `wasm_hash_url` instead of hard coding the hash directly.
Expand All @@ -27,6 +47,10 @@ Updated to candid 0.10, ic-cdk 0.12, and ic-cdk-timers 0.6
They've always been stored with nanosecond precisions on Linux and Macos.
Now they are stored with nanosecond precision on Windows too.

### fix: dfx canister delete, when using an HSM identity, no longer fails by trying to open two sessions to the HSM

Previously, this would fail with a PKCS#11: CKR_CRYPTOKI_ALREADY_INITIALIZED error.

## Dependencies

### Motoko
Expand All @@ -37,6 +61,31 @@ Updated Motoko to [0.10.4](https://github.com/dfinity/motoko/releases/tag/0.10.4

Module hash: 3c86d912ead6de7133b9f787df4ca9feee07bea8835d3ed594b47ee89e6cb730

### Candid UI

Module hash: b91e3dd381aedb002633352f8ebad03b6eee330b7e30c3d15a5657e6f428d815

Fix the routing error when deploying to gitpod/github workspace.
Fix that Candid UI cannot be opened using localhost URL.

### Replica

Updated replica to elected commit 324eb99eb7531369a5ef75560f1a1a652d123714.
This incorporates the following executed proposals:

- [127096](https://dashboard.internetcomputer.org/proposal/127096)
- [127094](https://dashboard.internetcomputer.org/proposal/127094)
- [127034](https://dashboard.internetcomputer.org/proposal/127034)
- [127031](https://dashboard.internetcomputer.org/proposal/127031)
- [126879](https://dashboard.internetcomputer.org/proposal/126879)
- [126878](https://dashboard.internetcomputer.org/proposal/126878)
- [126730](https://dashboard.internetcomputer.org/proposal/126730)
- [126729](https://dashboard.internetcomputer.org/proposal/126729)
- [126727](https://dashboard.internetcomputer.org/proposal/126727)
- [126366](https://dashboard.internetcomputer.org/proposal/126366)
- [126365](https://dashboard.internetcomputer.org/proposal/126365)
- [126293](https://dashboard.internetcomputer.org/proposal/126293)

# 0.15.3

### fix: allow `http://localhost:*` as `connect-src` in the asset canister's CSP
Expand Down
16 changes: 9 additions & 7 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ license = "Apache-2.0"
[workspace.dependencies]
candid = "0.10.0"
candid_parser = "0.1.2"
ic-agent = { git = "https://github.com/dfinity/agent-rs.git", rev = "a7f44ad05e77fc89b8447dd65b345e7a62fd1042" }
ic-agent = { git = "https://github.com/dfinity/agent-rs.git", rev = "6b02f649a569f354a0a1b370368ba28d31dd8702" }
ic-asset = { path = "src/canisters/frontend/ic-asset" }
ic-cdk = "0.12.0"
ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs.git", rev = "a7f44ad05e77fc89b8447dd65b345e7a62fd1042" }
ic-utils = { git = "https://github.com/dfinity/agent-rs.git", rev = "a7f44ad05e77fc89b8447dd65b345e7a62fd1042" }
ic-identity-hsm = { git = "https://github.com/dfinity/agent-rs.git", rev = "6b02f649a569f354a0a1b370368ba28d31dd8702" }
ic-utils = { git = "https://github.com/dfinity/agent-rs.git", rev = "6b02f649a569f354a0a1b370368ba28d31dd8702" }

aes-gcm = "0.10.3"
anyhow = "1.0.56"
Expand Down
20 changes: 20 additions & 0 deletions docs/cli-reference/dfx-identity.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For reference information and examples that illustrate using `dfx identity` comm
| [`get-principal`](#dfx-identity-get-principal) | Shows the textual representation of the principal associated with the current identity. |
| [`get-wallet`](#dfx-identity-get-wallet) | Shows the canister identifier for the wallet associated with your current identity principal. |
| `help` | Displays this usage message or the help of the given subcommand(s). |
| [`export`](#dfx-identity-export) | Exports the PEM definition for an identity. |
| [`import`](#dfx-identity-import) | Creates a new identity by importing a PEM file that contains the key information or security certificate for a principal. |
| [`list`](#dfx-identity-list) | Lists existing identities. |
| [`new`](#dfx-identity-new) | Creates a new identity. |
Expand Down Expand Up @@ -110,6 +111,25 @@ To display the canister identifier for the wallet canister associated with your
dfx identity get-wallet --network=https://192.168.74.4
```

## dfx identity export

Use the `dfx identity export` command to export the PEM definition of an existing identity. You can import this definition elsewhere using [`dfx identity import`](#dfx-identity-import).

### Basic usage

``` bash
dfx identity export identity-name
```

### Examples

The following will export a PEM file for an existing identity. If you transferred this file to another computer, the
example below for `dfx identity import` would import it.

``` bash
dfx identity export alice >generated-id.pem
```

## dfx identity import

Use the `dfx identity import` command to create a user identity by importing the user’s key information or security certificate from a PEM file.
Expand Down
9 changes: 9 additions & 0 deletions e2e/assets/large_canister/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "large"
version = "0.0.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[workspace]
9 changes: 9 additions & 0 deletions e2e/assets/large_canister/dfx.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"canisters": {
"large": {
"type": "rust",
"package": "large",
"candid": "large.did"
}
}
}
1 change: 1 addition & 0 deletions e2e/assets/large_canister/large.did
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service : {}
2 changes: 2 additions & 0 deletions e2e/assets/large_canister/patch.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
head -c $((1024 * 1024 * 8)) /dev/urandom >garbage.bin
3 changes: 3 additions & 0 deletions e2e/assets/large_canister/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "stable"
targets = ["wasm32-unknown-unknown"]
3 changes: 3 additions & 0 deletions e2e/assets/large_canister/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#[used]
#[no_mangle]
pub static LARGE: &[u8] = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/garbage.bin"));
9 changes: 9 additions & 0 deletions e2e/assets/prebuilt_custom_canister/dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@
"candid": "custom_with_build_step.did",
"wasm": "main.wasm",
"build": "echo just a build step"
},
"prebuilt_local_import": {
"type": "custom",
"candid": "local_import.did",
"wasm": "main.wasm",
"build": [],
"metadata": [
{ "name": "candid:service" }
]
}
},
"networks": {
Expand Down
2 changes: 2 additions & 0 deletions e2e/assets/prebuilt_custom_canister/local_import.did
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import service "prebuilt_custom_no_build.did";

3 changes: 3 additions & 0 deletions e2e/assets/upgrade/v1.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ actor {
state += 1;
return state;
};
public func f() : async ?Int {
return ?42;
};
public query func read() : async Int { return state; };
}

3 changes: 3 additions & 0 deletions e2e/assets/upgrade/v2.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ actor {
new_state += 1;
return new_state;
};
public func f() : async ?Int {
return ?42;
};
public query func read() : async Nat { return new_state; };
}

3 changes: 3 additions & 0 deletions e2e/assets/upgrade/v2_bad.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ actor {
state += 1;
return state;
};
public func f() : async ?Int {
return ?42;
};
public query func read() : async Nat { return state; };
}

3 changes: 3 additions & 0 deletions e2e/assets/upgrade/v3_bad.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ actor {
state += 1;
return state;
};
public func f() : async ?Int {
return ?42;
};
public query func read2() : async Int { return state; };
}

12 changes: 12 additions & 0 deletions e2e/assets/upgrade/v4_bad.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
actor {
stable var state : Int = 0;
public func inc() : async Int {
state += 1;
return state;
};
public func f() : async ?Text {
return ?"";
};
public query func read() : async Int { return state; };
}

17 changes: 11 additions & 6 deletions e2e/tests-dfx/assetscanister.bash
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ check_permission_failure() {
FE_CANISTER_ID="$(dfx canister id e2e_project_frontend)"
rm .dfx/local/canister_ids.json
assert_command_fail dfx canister call "$FE_CANISTER_ID" validate_revoke_permission "(record { of_principal=principal \"$PREPARE_PRINCIPAL\"; permission = variant { FlyBeFree }; })"
assert_contains "trapped"
assert_contains "FlyBeFree not found"
}

@test "access control - fine-grained" {
Expand Down Expand Up @@ -905,24 +905,29 @@ check_permission_failure() {
dfx canister install e2e_project_frontend

assert_command dfx canister call --query e2e_project_frontend retrieve '("/binary/noise.txt")' --output idl
assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")'
# shellcheck disable=SC2154
assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")' "$stdout"

assert_command dfx canister call --query e2e_project_frontend retrieve '("/text-with-newlines.txt")' --output idl
assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")'
# shellcheck disable=SC2154
assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")' "$stdout"

assert_command dfx canister call --update e2e_project_frontend store '(record{key="AA"; content_type="text/plain"; content_encoding="identity"; content=blob "hello, world!"})'
assert_eq '()'
assert_command dfx canister call --update e2e_project_frontend store '(record{key="B"; content_type="application/octet-stream"; content_encoding="identity"; content=blob"XWV"})'
assert_eq '()'

assert_command dfx canister call --query e2e_project_frontend retrieve '("B")' --output idl
assert_eq '(blob "XWV")'
# shellcheck disable=SC2154
assert_eq '(blob "XWV")' "$stdout"

assert_command dfx canister call --query e2e_project_frontend retrieve '("AA")' --output idl
assert_eq '(blob "hello, world!")'
# shellcheck disable=SC2154
assert_eq '(blob "hello, world!")' "$stdout"

assert_command dfx canister call --query e2e_project_frontend retrieve '("B")' --output idl
assert_eq '(blob "XWV")'
# shellcheck disable=SC2154
assert_eq '(blob "XWV")' "$stdout"

assert_command_fail dfx canister call --query e2e_project_frontend retrieve '("C")'
}
Expand Down
6 changes: 4 additions & 2 deletions e2e/tests-dfx/build_granular.bash
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ teardown() {
dfx canister install e2e_project_frontend

assert_command dfx canister call --query e2e_project_frontend retrieve '("/binary/noise.txt")' --output idl
assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")'
# shellcheck disable=SC2154
assert_eq '(blob "\b8\01\20\80\0a\77\31\32\20\00\78\79\0a\4b\4c\0b\0a\6a\6b")' "$stdout"

assert_command dfx canister call --query e2e_project_frontend retrieve '("/text-with-newlines.txt")' --output idl
assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")'
# shellcheck disable=SC2154
assert_eq '(blob "cherries\0ait\27s cherry season\0aCHERRIES")' "$stdout"
}

@test "cyclic dependencies are detected" {
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests-dfx/call.bash
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ teardown() {
CANISTER_ID=$(dfx canister id hello_backend)
rm .dfx/local/canister_ids.json

# if no candid file known, then no field names
# given a canister id, fetch the did file from metadata
assert_command dfx canister call "$CANISTER_ID" make_struct '("A", "B")'
assert_eq '(record { 99 = "A"; 100 = "B" })'
assert_eq '(record { c = "A"; d = "B" })'

# if passing the candid file, field names available
assert_command dfx canister call --candid .dfx/local/canisters/hello_backend/hello_backend.did "$CANISTER_ID" make_struct '("A", "B")'
Expand Down
Loading

0 comments on commit 97e9e33

Please sign in to comment.