Repeat steps:
- in terminal1, run “dfx start --clean”
- in terminal2, run “dfx deploy basic_bitcoin”
- in terminal2, remove all owner of basic_bitcoin by “dfx canister update-settings xxx --remove-controler yyy”
- in terminal1, stop local env by “control +c”
- in terminal1, run “dfx start --clean” again
- in terminal2, run “dfx deploy basic_bitcoin” again, reoport the followin errors
and I find a workaround method:
at step6, run “dfx deploy hello”,then run “dfx deploy basic_bitcoin”. logs is attached below.
xxx-MacBook-Pro basic_bitcoin %dfx deploy basic_bitcoin
Deploying: basic_bitcoin
All canisters have already been created.
Building canisters...
Executing 'src/basic_bitcoin/build.sh'
~/Code/github.com/dfinity/examples/rust/basic_bitcoin/src/basic_bitcoin ~/Code/github.com/dfinity/examples/rust/basic_bitcoin
Finished release [optimized] target(s) in 0.03s
~/Code/github.com/dfinity/examples/rust/basic_bitcoin
Installing canisters...
Installing code for canister basic_bitcoin, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
This canister requires an initialization argument.
Enter a value for network : variant { mainnet; regtest; testnet }
✔ Select a variant · regtest
Sending the following argument:
(variant { regtest })
Do you want to initialize the canister with this argument? [y/N]
y
Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to install all canisters.
Caused by: Failed to install wasm module to canister 'basic_bitcoin'.
Caused by: Failed during wasm installation call
Caused by: The replica returned a rejection error: reject code DestinationInvalid, reject message Canister bkyz2-fmaaa-aaaaa-qaaaq-cai not found, error code Some("IC0301")
xxx-MacBook-Pro basic_bitcoin %dfx deploy ../hello/basic_bitcoin
Error: Failed while trying to deploy canisters.
Caused by: Failed to collect canisters and their dependencies.
Caused by: Failed to add dependencies for canister '../hello/basic_bitcoin'
Caused by: Canister '../hello/basic_bitcoin' not found in dfx.json.
xxx-MacBook-Pro basic_bitcoin %cd ..
xxx-MacBook-Pro rust %cd hello
xxx-MacBook-Pro hello %dfx deploy hello
Deploying: hello
Creating canisters...
Creating canister hello...
Creating a wallet canister on the local network.
The wallet canister on the "local" network for user "identity1" is "bnz7o-iuaaa-aaaaa-qaaaa-cai"
hello canister created with canister id: bkyz2-fmaaa-aaaaa-qaaaq-cai
Building canisters...
Checking for vulnerabilities in rust canisters.
Fetching advisory database from `https://github.com/RustSec/advisory-db.git`
brenda
Loaded 651 security advisories (from /Users/xxxx/.cargo/advisory-db)
Updating crates.io index
Scanning Cargo.lock for vulnerabilities (54 crate dependencies)
Crate: ic-cdk
Version: 0.12.0
Warning: yanked
Dependency tree:
ic-cdk 0.12.0
└── hello 1.1.0
warning: 1 allowed warning found
Audit found no vulnerabilities.
Executing: cargo build --target wasm32-unknown-unknown --release -p hello --locked
Finished release [optimized] target(s) in 0.03s
Installing canisters...
Creating UI canister on the local network.
The UI canister on the "local" network is "bd3sg-teaaa-aaaaa-qaaba-cai"
Installing code for canister hello, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
This canister requires an initialization argument.
✔ Enter a text (type :e to use editor) · :e
Sending the following argument:
("brenda")
Do you want to initialize the canister with this argument? [y/N]
y
Deployed canisters.
URLs:
Backend canister via Candid interface:
hello: http://127.0.0.1:4943/?canisterId=bd3sg-teaaa-aaaaa-qaaba-cai&id=bkyz2-fmaaa-aaaaa-qaaaq-cai
xxx -MacBook-Pro hello %cd ../basic_bitcoin
xxx-MacBook-Pro basic_bitcoin %dfx deploy basic_bitcoin
Deploying: basic_bitcoin
All canisters have already been created.
Building canisters...
Executing 'src/basic_bitcoin/build.sh'
~/Code/github.com/dfinity/examples/rust/basic_bitcoin/src/basic_bitcoin ~/Code/github.com/dfinity/examples/rust/basic_bitcoin
Finished release [optimized] target(s) in 0.04s
~/Code/github.com/dfinity/examples/rust/basic_bitcoin
Installing canisters...
Upgrading code for canister basic_bitcoin, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
WARNING!
Candid interface compatibility check failed for canister 'basic_bitcoin'.
You are making a BREAKING change. Other canisters or frontend clients relying on your canister may stop working.
Method greet is only in the expected type
Do you want to proceed? yes/No
yes
This canister requires an initialization argument.
Enter a value for network : variant { mainnet; regtest; testnet }
✔ Select a variant · regtest
Sending the following argument:
(variant { regtest })
Do you want to initialize the canister with this argument? [y/N]
y
Deployed canisters.
URLs:
Backend canister via Candid interface:
basic_bitcoin: http://127.0.0.1:4943/?canisterId=bd3sg-teaaa-aaaaa-qaaba-cai&id=bkyz2-fmaaa-aaaaa-qaaaq-cai
the hello.rs code is shown bellow
use std::cell::RefCell;
use ic_cdk::post_upgrade;
thread_local! {
static MY_NAME: RefCell<String> = RefCell::new("".to_string());
}
#[ic_cdk_macros::init]
fn init(my_name: String) {
MY_NAME.with(|name| {
*name.borrow_mut() = my_name;
});
}
#[ic_cdk_macros::query]
fn greet(name: String) -> String {
let my_name = MY_NAME.with(|name| name.borrow().to_string());
format!("Hello, {}, my name is {}!", name, my_name)
}
#[post_upgrade]
fn post_upgrade(my_name:String) {
init(my_name);
}