Skip to content

Commit

Permalink
Merge branch 'master' into SDK-1290-add-upgrade-arg-to-asset-canister…
Browse files Browse the repository at this point in the history
…-to-overwrite-permissions
  • Loading branch information
sesi200 authored Nov 16, 2023
2 parents 026fa3f + e91c27c commit ba29ce8
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 34 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/bitcoin-canister-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Check Bitcoin Canister Release Update

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *' # Runs at UTC midnight every day

jobs:
check-update:
runs-on: ubuntu-latest

steps:
- name: Checkout dfx repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch Bitcoin Canister latest release tag
env:
GH_TOKEN: "${{ secrets.NIV_UPDATER_TOKEN }}"
run: |
LATEST_TAG=$(gh release view --repo dfinity/bitcoin-canister --json tagName -q .tagName)
echo "Latest tag is $LATEST_TAG"
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
- name: Check if the latest release tag has been updated
run: |
URL_ENCODED_CURRENT_TAG=$(jq -r '.["ic-btc-canister"].version' nix/sources.json)
CURRENT_TAG=$(python -c "import sys, urllib.parse as ul; print(ul.unquote_plus(sys.argv[1]))" "$URL_ENCODED_CURRENT_TAG")
echo "Current tag is $CURRENT_TAG"
if [[ "$CURRENT_TAG" == "$LATEST_TAG" ]]; then
echo "No update is required."
exit 1
else
echo "An update is required."
fi
- name: install Nix
uses: cachix/install-nix-action@v21
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: install niv (dependency manager for Nix projects)
run: nix-env -i niv -f '<nixpkgs>'

- name: install packages from nix/sources.json
run: niv update

- name: update sources
run: |
URL_ENCODED_LATEST_TAG=$(echo -n "$LATEST_TAG" | python -c 'import sys, urllib.parse; print(urllib.parse.quote(sys.stdin.read().strip(), safe=""))')
niv update ic-btc-canister -a version=$URL_ENCODED_LATEST_TAG
./scripts/write-dfx-asset-sources.sh
- name: Update dfx to use the latest Bitcoin Canister version
env:
GH_TOKEN: "${{ secrets.NIV_UPDATER_TOKEN }}"
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout -b bot/update-bitcoin-canister/$LATEST_TAG
git add .
git commit -m "Update Bitcoin Canister to $LATEST_TAG"
git push --set-upstream origin bot/update-bitcoin-canister/$LATEST_TAG
PR_TITLE="chore: Update Bitcoin Canister Version to $LATEST_TAG"
PR_BODY="This PR updates the Bitcoin Canister version to the latest tag: $LATEST_TAG"
gh pr create --title "$PR_TITLE" --body "$PR_BODY" --base master --head $(git branch --show-current)
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

# UNRELEASED

=== 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

Running `dfx cache delete && dfx extension install nns` would previously
Expand Down Expand Up @@ -43,7 +49,7 @@ Added the following subcommands:

### Motoko

Updated Motoko to [0.10.1](https://github.com/dfinity/motoko/releases/tag/0.10.1)
Updated Motoko to [0.10.2](https://github.com/dfinity/motoko/releases/tag/0.10.2)

### Frontend canister

Expand Down Expand Up @@ -73,6 +79,10 @@ This incorporates the following executed proposals:
- [124858](https://dashboard.internetcomputer.org/proposal/124858)
- [124857](https://dashboard.internetcomputer.org/proposal/124857)

### Bitcoin canister

Updated Bitcoin canister to [release/2023-10-13](https://github.com/dfinity/bitcoin-canister/releases/tag/release%2F2023-10-13)

# 0.15.1

### feat: Added support for reserved_cycles and reserved_cycles_limit
Expand Down
13 changes: 13 additions & 0 deletions e2e/tests-dfx/delete.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ teardown() {
standard_teardown
}

@test "delete by canister id cleans up canister id store" {
dfx_start
dfx deploy e2e_project_backend
id=$(dfx canister id e2e_project_backend)
dfx canister stop e2e_project_backend
assert_command dfx canister delete "$id"
assert_command_fail dfx canister info e2e_project_backend
assert_contains "Cannot find canister id. Please issue 'dfx canister create e2e_project_backend'."
assert_command_fail dfx canister status "$id"
assert_contains "Canister $id not found"
assert_command dfx deploy
}

@test "delete can be used to delete a canister" {
dfx_start
dfx deploy e2e_project_backend
Expand Down
30 changes: 15 additions & 15 deletions nix/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"homepage": "https://rustsec.org",
"owner": "RustSec",
"repo": "advisory-db",
"rev": "0c251c3c9a1b08e08ef5946d4c2d133fe1bc213e",
"sha256": "1nqzy1ky570zdkkdc9q7cpi5ys9cxnkyjhzvic1fzfcrrlz92kzd",
"rev": "3338fcfb59cea5fcd7d2a4e7fe24cbc7cb778003",
"sha256": "0fw5xrzafv061jj3lzrnqarbjcm1irzvl338yhkzw1k8firmki7d",
"type": "tarball",
"url": "https://github.com/RustSec/advisory-db/archive/0c251c3c9a1b08e08ef5946d4c2d133fe1bc213e.tar.gz",
"url": "https://github.com/RustSec/advisory-db/archive/3338fcfb59cea5fcd7d2a4e7fe24cbc7cb778003.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"canister_sandbox-x86_64-darwin": {
Expand Down Expand Up @@ -66,11 +66,11 @@
},
"ic-btc-canister": {
"owner": "dfinity",
"sha256": "0izvazr0cpdwjga12zim2cwp3rgm5n3w7ag5yplfl8rxrhwk65f4",
"sha256": "1b34jpxkk72h07ls0fspwrgmndmj7xhlivdhn82msvgz8mx69x89",
"type": "file",
"url": "https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-03-31/ic-btc-canister.wasm.gz",
"url": "https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-10-13/ic-btc-canister.wasm.gz",
"url_template": "https://github.com/dfinity/bitcoin-canister/releases/download/<version>/ic-btc-canister.wasm.gz",
"version": "release%2F2023-03-31"
"version": "release%2F2023-10-13"
},
"ic-https-outcalls-adapter-x86_64-darwin": {
"builtin": false,
Expand Down Expand Up @@ -160,27 +160,27 @@
"builtin": false,
"description": "The Motoko base library",
"owner": "dfinity",
"sha256": "0b8lsxb3j7qj6kzb32fbkf0a018jkisapcb8szwl8ad023lv3xv3",
"sha256": "12z4mr3r63nnncjqxrsxjhr1z2p8adg7zp48wbacb42jhs0mkfvl",
"type": "tarball",
"url": "https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-base-library.tar.gz",
"url": "https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-base-library.tar.gz",
"url_template": "https://github.com/dfinity/motoko/releases/download/<version>/motoko-base-library.tar.gz",
"version": "0.10.1"
"version": "0.10.2"
},
"motoko-x86_64-darwin": {
"builtin": false,
"sha256": "1inc2x9misqazgswfz7irvsjp4dkvab87j66yklnvy51w6pi3r7b",
"sha256": "1x49qwzrxc6dj5gik2hpi8l3xdnggqj2v9yvb6sfb7ff6gx3avc6",
"type": "file",
"url": "https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-Darwin-x86_64-0.10.1.tar.gz",
"url": "https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-Darwin-x86_64-0.10.2.tar.gz",
"url_template": "https://github.com/dfinity/motoko/releases/download/<version>/motoko-Darwin-x86_64-<version>.tar.gz",
"version": "0.10.1"
"version": "0.10.2"
},
"motoko-x86_64-linux": {
"builtin": false,
"sha256": "11jx3r0lw41x7xqajqqc7s9wvkr9kfpg5h38vr9bcvwfndg49flc",
"sha256": "1a1yv2awrd053qk3h9a34y887j2vfhb0ckrk25kjjx4ifdygp8ys",
"type": "file",
"url": "https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-Linux-x86_64-0.10.1.tar.gz",
"url": "https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-Linux-x86_64-0.10.2.tar.gz",
"url_template": "https://github.com/dfinity/motoko/releases/download/<version>/motoko-Linux-x86_64-<version>.tar.gz",
"version": "0.10.1"
"version": "0.10.2"
},
"replica-x86_64-darwin": {
"builtin": false,
Expand Down
3 changes: 2 additions & 1 deletion scripts/workflows/provision-darwin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ if [ "$E2E_TEST" = "tests-dfx/certificate.bash" ]; then
brew install mitmproxy
fi
if [ "$E2E_TEST" = "tests-dfx/deps.bash" ]; then
cargo install ic-wasm
cargo install cargo-binstall
cargo binstall -y ic-wasm
fi

# Exit temporary directory.
Expand Down
3 changes: 2 additions & 1 deletion scripts/workflows/provision-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ if [ "$E2E_TEST" = "tests-dfx/identity_encryption.bash" ] || [ "$E2E_TEST" = "te
sudo apt-get install --yes expect
fi
if [ "$E2E_TEST" = "tests-dfx/deps.bash" ]; then
cargo install ic-wasm
cargo install cargo-binstall
cargo binstall -y ic-wasm
fi

# Set environment variables.
Expand Down
6 changes: 5 additions & 1 deletion src/dfx-core/src/config/model/canister_id_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,14 @@ impl CanisterIdStore {
self.remote_ids
.as_ref()
.and_then(|remote_ids| self.get_name_in(canister_id, remote_ids))
.or_else(|| self.get_name_in(canister_id, &self.ids))
.or_else(|| self.get_name_in_project(canister_id))
.or_else(|| self.get_name_in_pull_ids(canister_id))
}

pub fn get_name_in_project(&self, canister_id: &str) -> Option<&String> {
self.get_name_in(canister_id, &self.ids)
}

pub fn get_name_in<'a>(
&'a self,
canister_id: &str,
Expand Down
24 changes: 12 additions & 12 deletions src/dfx/assets/dfx-asset-sources.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ url = 'https://download.dfinity.systems/ic/80a6745673a28ee53d257b3fe19dcd6b7efa9
sha256 = 'd42213aea42f1ae55623e7e437ef683e99c0a3a98c1bae7dc24db7c1577005e9'

[x86_64-darwin.motoko]
url = 'https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-Darwin-x86_64-0.10.1.tar.gz'
sha256 = 'ebe411afe1a1f86de9f4c6c88396dab3912bf5cef17cc7f5fb0aeb585317ccc6'
url = 'https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-Darwin-x86_64-0.10.2.tar.gz'
sha256 = '866d35fa33ce9de5b459dba72d247ecfb63e288a178a195f91cdb09e3fc789f4'
# The replica and canister_sandbox binaries must have the same revision.

[x86_64-darwin.replica]
Expand All @@ -52,12 +52,12 @@ url = 'https://download.dfinity.systems/ic/80a6745673a28ee53d257b3fe19dcd6b7efa9
sha256 = '73a6d72d82025abb58c28d6ada411ac40ed5b482017f409133f7ac5562899990'

[x86_64-darwin.motoko-base]
url = 'https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-base-library.tar.gz'
sha256 = '27563ee89ad2b6c24642ccd9b569836cef2a0316d33bc3d2b4cc61ed7ec1017e'
url = 'https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-base-library.tar.gz'
sha256 = 'cfa7950a3f452b0d8f42320061be09176a7aecee5a7851d913a1517a8116fd46'

[x86_64-darwin.ic-btc-canister]
url = 'https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-03-31/ic-btc-canister.wasm.gz'
sha256 = 'c4153339cc3d23eae8f5e5a9c3872df5e5713913357e11d493bc5d06f257fb47'
url = 'https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-10-13/ic-btc-canister.wasm.gz'
sha256 = '09f5647a45ff6d5d05b2b0ed48613fb2365b5fe6573ba0e901509c39fb9564ac'

[x86_64-linux.ic-ref]
url = 'https://download.dfinity.systems/ic-ref/ic-ref-0.0.1-a9f73dba-x86_64-linux.tar.gz'
Expand Down Expand Up @@ -88,8 +88,8 @@ url = 'https://download.dfinity.systems/ic/80a6745673a28ee53d257b3fe19dcd6b7efa9
sha256 = 'eb5ea6cd768fda12d00f370665db132d66c262b35f1a513c2807f78881c1cb7a'

[x86_64-linux.motoko]
url = 'https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-Linux-x86_64-0.10.1.tar.gz'
sha256 = '8cba445eb38e6fb652de68c0f2ae9b29cfcd933e0c63a9703f3d104e411e5d86'
url = 'https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-Linux-x86_64-0.10.2.tar.gz'
sha256 = 'daa3fb7c739174296711334f0616745bc8839027432538261e05b4cc95d83ea8'
# The replica and canister_sandbox binaries must have the same revision.

[x86_64-linux.replica]
Expand All @@ -110,9 +110,9 @@ url = 'https://download.dfinity.systems/ic/80a6745673a28ee53d257b3fe19dcd6b7efa9
sha256 = 'a9e30c500fb108ab5247db0827868fb74914939a04519d08943440f12b020db8'

[x86_64-linux.motoko-base]
url = 'https://github.com/dfinity/motoko/releases/download/0.10.1/motoko-base-library.tar.gz'
sha256 = '27563ee89ad2b6c24642ccd9b569836cef2a0316d33bc3d2b4cc61ed7ec1017e'
url = 'https://github.com/dfinity/motoko/releases/download/0.10.2/motoko-base-library.tar.gz'
sha256 = 'cfa7950a3f452b0d8f42320061be09176a7aecee5a7851d913a1517a8116fd46'

[x86_64-linux.ic-btc-canister]
url = 'https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-03-31/ic-btc-canister.wasm.gz'
sha256 = 'c4153339cc3d23eae8f5e5a9c3872df5e5713913357e11d493bc5d06f257fb47'
url = 'https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-10-13/ic-btc-canister.wasm.gz'
sha256 = '09f5647a45ff6d5d05b2b0ed48613fb2365b5fe6573ba0e901509c39fb9564ac'
14 changes: 11 additions & 3 deletions src/dfx/src/commands/canister/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,15 @@ async fn delete_canister(
) -> DfxResult {
let log = env.get_logger();
let mut canister_id_store = env.get_canister_id_store()?;
let (canister_id, canister_name_to_delete) = match Principal::from_text(canister) {
Ok(canister_id) => (
canister_id,
canister_id_store.get_name_in_project(canister).cloned(),
),
Err(_) => (canister_id_store.get(canister)?, Some(canister.to_string())),
};

if !env.get_network_descriptor().is_playground() {
let canister_id =
Principal::from_text(canister).or_else(|_| canister_id_store.get(canister))?;
let mut call_sender = call_sender;
let to_dank = withdraw_cycles_to_dank || withdraw_cycles_to_dank_principal.is_some();

Expand Down Expand Up @@ -268,7 +273,10 @@ async fn delete_canister(

canister::delete_canister(env, canister_id, call_sender).await?;
}
canister_id_store.remove(canister)?;

if let Some(canister_name) = canister_name_to_delete {
canister_id_store.remove(&canister_name)?;
}

Ok(())
}
Expand Down

0 comments on commit ba29ce8

Please sign in to comment.