diff --git a/.github/workflows/bitcoin-canister-update.yml b/.github/workflows/bitcoin-canister-update.yml deleted file mode 100644 index 17c04b7dfe..0000000000 --- a/.github/workflows/bitcoin-canister-update.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Check Bitcoin Canister Release Update - -on: - workflow_dispatch: - schedule: - - cron: "0 4 * * 3" # 4:00 AM UTC every Wednesday - -env: - # When getting Rust dependencies, retry on network error: - CARGO_NET_RETRY: 10 - # Use the local .curlrc - CURL_HOME: . - # Disable DFX telemetry - DFX_TELEMETRY: 'off' - -jobs: - check-update: - runs-on: ubuntu-latest - - steps: - - name: Checkout dfx repository - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Install script dependencies - run: sudo apt-get install -y moreutils - - - name: Create GitHub App Token - uses: actions/create-github-app-token@v2 - id: app-token - with: - app-id: ${{ vars.PR_AUTOMATION_BOT_PUBLIC_APP_ID }} - private-key: ${{ secrets.PR_AUTOMATION_BOT_PUBLIC_PRIVATE_KEY }} - - - name: Fetch Bitcoin Canister latest release tag - env: - GH_TOKEN: ${{ steps.app-token.outputs.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: | - CURRENT_TAG=$(jq -r '.common."ic-btc-canister".version' src/dfx/assets/dfx-asset-sources.json) - 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: Update sources to use the latest bitcoin canister version - run: ./scripts/update-btc-canister.sh "$LATEST_TAG" - - - name: Create PR - env: - GH_TOKEN: "${{ steps.app-token.outputs.token }}" - run: | - git config user.name github-actions - git config user.email github-actions@github.com - 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) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe3657e6bf..06fe773048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ Improved the canister snapshot download/upload feature by - supporting download/upload with resuming. - supporting download/upload with concurrency, default to 3 tasks in parallel. +### fix: use `pocket-ic` to init BTC canisters + +The custom logic was prone to becoming outdated, such as not adapting to changing cycles fees. +By using `pocket-ic`, which gets updated frequently, the BTC integration is significanly less likely to break. + # 0.30.0 ### feat: `dfx start --system-canisters` for bootstrapping system canisters diff --git a/e2e/tests-dfx/bitcoin.bash b/e2e/tests-dfx/bitcoin.bash index 88bc42af4b..9ed89a3368 100644 --- a/e2e/tests-dfx/bitcoin.bash +++ b/e2e/tests-dfx/bitcoin.bash @@ -42,17 +42,9 @@ set_local_network_bitcoin_enabled() { dfx_start --enable-bitcoin assert_command dfx canister info "$BITCOIN_CANISTER_ID" - assert_contains "Controllers: 2vxsx-fae" assert_contains "Module hash: 0x" } -@test "bitcoin canister has decent amount of cycles" { - dfx_start --enable-bitcoin - # The canister is created with default amount of cycles: 100T - cycles_balance=$( dfx --identity anonymous canister status "$BITCOIN_CANISTER_ID" 2>&1 | grep 'Balance:' | sed 's/[^0-9]//g' ) - assert_command test "$cycles_balance" -gt 99000000000000 # 99T -} - @test "can call bitcoin API of the management canister" { install_asset bitcoin dfx_start --enable-bitcoin diff --git a/scripts/update-btc-canister.sh b/scripts/update-btc-canister.sh deleted file mode 100755 index 498f875236..0000000000 --- a/scripts/update-btc-canister.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# $1 not set || not running in repo root -if [ -z ${1+x} ] || [ ! "$0" -ef ./scripts/update-btc-canister.sh ]; then - echo "Usage: run ./scripts/update-btc-canister.sh in repo root" - exit 1 -fi - -for cmd in curl jq sponge; do - if ! command -v "$cmd" &>/dev/null; then - echo "'$cmd' was not found." - echo "This script requires curl, jq, and moreutils to be installed" - exit 1 - fi -done - - -urlencode() { - printf '%s' "$1" | jq -sRr @uri -} - -sources="src/dfx/assets/dfx-asset-sources.json" -version=$1 -echo "Updating sources to version $version" -btc_canister_url=$(printf 'https://github.com/dfinity/bitcoin-canister/releases/download/%s/ic-btc-canister.wasm.gz' "$(urlencode "$version")") -btc_canister_sha=$(curl --proto '=https' --tlsv1.2 -sSfL "$btc_canister_url" | sha256sum | head -c 64) -jq '.common."ic-btc-canister" = {url: $url, sha256: $sha256, version: $version}' --arg version "$version" \ - --arg url "$btc_canister_url" --arg sha256 "$btc_canister_sha" "$sources" | sponge "$sources" - -echo "Done. Don't forget to update CHANGELOG.md" diff --git a/src/dfx/assets/build.rs b/src/dfx/assets/build.rs index b4a2d0f4e6..caff8a5f1e 100644 --- a/src/dfx/assets/build.rs +++ b/src/dfx/assets/build.rs @@ -241,7 +241,6 @@ fn add_assets(sources: Sources) { add_asset_archive("assetstorage_canister", &mut f, &dfx_assets); add_asset_archive("wallet_canister", &mut f, &dfx_assets); add_asset_archive("ui_canister", &mut f, &dfx_assets); - add_asset_archive("btc_canister", &mut f, &dfx_assets); add_assets_from_directory("language_bindings", &mut f, "assets/language_bindings"); add_assets_from_directory( "new_project_motoko_files", diff --git a/src/dfx/assets/dfx-asset-sources.json b/src/dfx/assets/dfx-asset-sources.json index 26b3b9737c..c5e341f355 100644 --- a/src/dfx/assets/dfx-asset-sources.json +++ b/src/dfx/assets/dfx-asset-sources.json @@ -54,15 +54,10 @@ "sha256": "c41db448cf9fd63d285aac5415e122d1970a94e13a870a381322584f3153c2b4", "version": "0.16.2" }, - "ic-btc-canister": { - "url": "https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2025-07-02/ic-btc-canister.wasm.gz", - "sha256": "42af59ae4fd5041f30f8ac12f324e3a93533de0cb89cd2278100c2389cbfff65", - "version": "release/2025-07-02" - }, "motoko-core": { "url": "https://github.com/dfinity/motoko/releases/download/0.16.2/motoko-core.tar.gz", "sha256": "e4154b1cff9387bb1ead2e3c0ddbeeb39fe9aa2c5a4d8af0142b3f7b174a5fa2", "version": "0.16.2" } } -} +} \ No newline at end of file diff --git a/src/dfx/assets/prepare_assets.rs b/src/dfx/assets/prepare_assets.rs index a549d90183..44a6ef8c70 100644 --- a/src/dfx/assets/prepare_assets.rs +++ b/src/dfx/assets/prepare_assets.rs @@ -53,34 +53,6 @@ fn copy_canisters(out_dir: PathBuf) { } } -async fn download_canisters( - client: Client, - sources: Arc>, - out_dir: PathBuf, -) { - // replace with joinset setup from download_binaries if another gets added - let source = sources["ic-btc-canister"].clone(); - let btc_canister = download_and_check_sha(client, source).await; - spawn_blocking(move || { - let mut tar = Builder::new(GzEncoder::new( - BufWriter::new(File::create(out_dir.join("btc_canister.tgz")).unwrap()), - Compression::new(6), - )); - let mut header = Header::new_gnu(); - header.set_mode(0o644); - header.set_size(btc_canister.len() as u64); - tar.append_data( - &mut header, - "ic-btc-canister.wasm.gz", - btc_canister.reader(), - ) - .unwrap(); - tar.finish().unwrap(); - }) - .await - .unwrap(); -} - async fn make_binary_cache(out_dir: PathBuf, sources: HashMap) { let sources = Arc::new(sources); let client = Client::builder() @@ -91,13 +63,8 @@ async fn make_binary_cache(out_dir: PathBuf, sources: HashMap) { let mo_core = spawn(download_mo_core(client.clone(), sources.clone())); let bins = spawn(download_binaries(client.clone(), sources.clone())); let bin_tars = spawn(download_bin_tarballs(client.clone(), sources.clone())); - let canisters = spawn(download_canisters( - client.clone(), - sources.clone(), - out_dir.clone(), - )); - let (mo_base, mo_core, bins, bin_tars, _) = - tokio::try_join!(mo_base, mo_core, bins, bin_tars, canisters).unwrap(); + let (mo_base, mo_core, bins, bin_tars) = + tokio::try_join!(mo_base, mo_core, bins, bin_tars).unwrap(); spawn_blocking(|| write_binary_cache(out_dir, mo_base, mo_core, bins, bin_tars)) .await .unwrap(); diff --git a/src/dfx/src/actors/mod.rs b/src/dfx/src/actors/mod.rs index a70923edce..a3fee263a9 100644 --- a/src/dfx/src/actors/mod.rs +++ b/src/dfx/src/actors/mod.rs @@ -8,7 +8,6 @@ use anyhow::Context; use dfx_core::config::model::local_server_descriptor::LocalServerDescriptor; use dfx_core::config::model::replica_config::ReplicaConfig; use fn_error_context::context; -use pocketic::BitcoinIntegrationConfig; use post_start::PostStart; use std::path::PathBuf; @@ -47,19 +46,12 @@ pub fn start_pocketic_actor( ) })?; - let bitcoin_integration_config = if local_server_descriptor.bitcoin.enabled { - Some(BitcoinIntegrationConfig { - canister_init_arg: local_server_descriptor.bitcoin.canister_init_arg.clone(), - }) - } else { - None - }; let actor_config = pocketic::Config { pocketic_path, effective_config_path: local_server_descriptor.effective_config_path(), replica_config, bitcoind_addr: local_server_descriptor.bitcoin.nodes.clone(), - bitcoin_integration_config, + enable_bitcoin: local_server_descriptor.bitcoin.enabled, port: local_server_descriptor.replica.port, port_file: pocketic_port_path, pid_file: local_server_descriptor.pocketic_pid_path(), diff --git a/src/dfx/src/actors/pocketic.rs b/src/dfx/src/actors/pocketic.rs index 3c65ba1386..139cce2ea1 100644 --- a/src/dfx/src/actors/pocketic.rs +++ b/src/dfx/src/actors/pocketic.rs @@ -8,10 +8,6 @@ use crate::actors::shutdown_controller::signals::outbound::Shutdown; use crate::lib::error::{DfxError, DfxResult}; #[cfg(unix)] use crate::lib::info::replica_rev; -#[cfg(unix)] -use crate::lib::integrations::bitcoin::initialize_bitcoin_canister; -#[cfg(unix)] -use crate::lib::integrations::create_integrations_agent; use actix::{ Actor, ActorContext, ActorFutureExt, Addr, AsyncContext, Context, Handler, Recipient, ResponseActFuture, Running, WrapFuture, @@ -58,7 +54,7 @@ pub struct Config { pub effective_config_path: PathBuf, pub replica_config: ReplicaConfig, pub bitcoind_addr: Option>, - pub bitcoin_integration_config: Option, + pub enable_bitcoin: bool, pub port: Option, pub port_file: PathBuf, pub pid_file: PathBuf, @@ -67,11 +63,6 @@ pub struct Config { pub pocketic_proxy_config: PocketIcProxyConfig, } -#[derive(Clone)] -pub struct BitcoinIntegrationConfig { - pub canister_init_arg: String, -} - /// A PocketIC actor. Starts the server, can subscribe to a Ready signal and a /// Killed signal. /// This starts a thread that monitors the process and send signals to any subscriber @@ -287,7 +278,7 @@ fn pocketic_start_thread( port, &config.effective_config_path, &config.bitcoind_addr, - &config.bitcoin_integration_config, + config.enable_bitcoin, &config.replica_config, config.pocketic_proxy_config.domains.clone(), config.pocketic_proxy_config.bind, @@ -350,7 +341,7 @@ async fn initialize_pocketic( port: u16, effective_config_path: &Path, bitcoind_addr: &Option>, - bitcoin_integration_config: &Option, + enable_bitcoin: bool, replica_config: &ReplicaConfig, domains: Option>, addr: SocketAddr, @@ -383,10 +374,11 @@ async fn initialize_pocketic( } } + let icp_features = IcpFeatures::default(); let icp_features = if replica_config.system_canisters { // Explicitly enabling specific system canisters here // ensures we'll notice if pocket-ic adds support for additional ones - Some(IcpFeatures { + IcpFeatures { registry: Some(IcpFeaturesConfig::default()), cycles_minting: Some(IcpFeaturesConfig::default()), icp_token: Some(IcpFeaturesConfig::default()), @@ -395,10 +387,18 @@ async fn initialize_pocketic( sns: Some(IcpFeaturesConfig::default()), ii: Some(IcpFeaturesConfig::default()), nns_ui: Some(IcpFeaturesConfig::default()), - bitcoin: None, - }) + bitcoin: icp_features.bitcoin, + } + } else { + icp_features + }; + let icp_features = if bitcoind_addr.is_some() || enable_bitcoin { + IcpFeatures { + bitcoin: Some(IcpFeaturesConfig::default()), + ..icp_features + } } else { - None + icp_features }; let resp = init_client @@ -412,7 +412,7 @@ async fn initialize_pocketic( }), log_level: Some(replica_config.log_level.to_pocketic_string()), bitcoind_addr: bitcoind_addr.clone(), - icp_features, + icp_features: Some(icp_features), http_gateway_config: Some(InstanceHttpGatewayConfig { ip_addr: Some(addr.ip().to_string()), port: Some(addr.port()), @@ -455,11 +455,6 @@ async fn initialize_pocketic( debug!(logger, "Waiting for replica to report healthy status"); crate::lib::replica::status::ping_and_wait(&agent_url).await?; - if let Some(bitcoin_integration_config) = bitcoin_integration_config { - let agent = create_integrations_agent(&agent_url, &logger).await?; - initialize_bitcoin_canister(&agent, &logger, bitcoin_integration_config.clone()).await?; - } - debug!(logger, "Initialized PocketIC with gateway."); Ok(server_instance) } @@ -469,7 +464,7 @@ fn initialize_pocketic( _: u16, _: &Path, _: &Option>, - _: &Option, + _: bool, _: &ReplicaConfig, _: Option>, _: SocketAddr, diff --git a/src/dfx/src/commands/canister/logs.rs b/src/dfx/src/commands/canister/logs.rs index c30386eb02..acf518cda1 100644 --- a/src/dfx/src/commands/canister/logs.rs +++ b/src/dfx/src/commands/canister/logs.rs @@ -51,10 +51,7 @@ struct FilterOpts { last_idx: Option, } -fn filter_canister_logs<'a>( - logs: &'a FetchCanisterLogsResult, - opts: FilterOpts, -) -> &'a [CanisterLogRecord] { +fn filter_canister_logs(logs: &FetchCanisterLogsResult, opts: FilterOpts) -> &[CanisterLogRecord] { if let Some(number) = opts.tail { &logs.canister_log_records[logs .canister_log_records diff --git a/src/dfx/src/commands/start.rs b/src/dfx/src/commands/start.rs index cf8cd56eff..19986ae89a 100644 --- a/src/dfx/src/commands/start.rs +++ b/src/dfx/src/commands/start.rs @@ -4,7 +4,6 @@ use crate::config::dfx_version_str; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::info::replica_rev; -use crate::lib::integrations::status::wait_for_integrations_initialized; use crate::lib::network::id::write_network_id; use crate::lib::replica::status::ping_and_wait; use crate::util::get_reusable_socket_addr; @@ -97,8 +96,6 @@ async fn fg_ping_and_wait( pocketic_port_path: &Path, webserver_port_path: &Path, frontend_url: &str, - logger: &Logger, - local_server_descriptor: &LocalServerDescriptor, ) -> DfxResult { let port = wait_for_port(webserver_port_path).await?; _ = wait_for_port(pocketic_port_path).await?; // used as a signal that initialization is complete @@ -110,9 +107,7 @@ async fn fg_ping_and_wait( .rfind(':') .ok_or_else(|| anyhow!("Malformed frontend url: {}", frontend_url))?; frontend_url_mod.replace_range((port_offset + 1).., port.as_str()); - ping_and_wait(&frontend_url_mod).await?; - - wait_for_integrations_initialized(&frontend_url_mod, logger, local_server_descriptor).await + ping_and_wait(&frontend_url_mod).await } async fn wait_for_port(webserver_port_path: &Path) -> DfxResult { @@ -242,14 +237,7 @@ https://github.com/dfinity/sdk/blob/0.27.0/docs/migration/dfx-0.27.0-migration-g return Runtime::new() .expect("Unable to create a runtime") .block_on(async { - fg_ping_and_wait( - &pocketic_port_path, - &webserver_port_path, - &frontend_url, - env.get_logger(), - local_server_descriptor, - ) - .await + fg_ping_and_wait(&pocketic_port_path, &webserver_port_path, &frontend_url).await }); } local_server_descriptor.describe(env.get_logger()); diff --git a/src/dfx/src/lib/integrations/bitcoin.rs b/src/dfx/src/lib/integrations/bitcoin.rs index f63d7a7d01..8f2ccf8798 100644 --- a/src/dfx/src/lib/integrations/bitcoin.rs +++ b/src/dfx/src/lib/integrations/bitcoin.rs @@ -1,31 +1,8 @@ -use crate::actors::pocketic::BitcoinIntegrationConfig; -use crate::lib::error::DfxResult; -use crate::lib::integrations::initialize_integration_canister; -use crate::util::assets::bitcoin_wasm; use candid::Principal; -use fn_error_context::context; -use ic_agent::Agent; -use slog::{Logger, debug}; pub const MAINNET_BITCOIN_CANISTER_ID: Principal = Principal::from_slice(&[0x00, 0x00, 0x00, 0x00, 0x01, 0xA0, 0x00, 0x01, 0x01, 0x01]); -#[context("Failed to initialize bitcoin canister")] -pub async fn initialize_bitcoin_canister( - agent: &Agent, - logger: &Logger, - bitcoin_integration_config: BitcoinIntegrationConfig, -) -> DfxResult { - debug!(logger, "Initializing bitcoin canister"); - - let name = "bitcoin integration"; - let canister_id = MAINNET_BITCOIN_CANISTER_ID; - let wasm = bitcoin_wasm(logger)?; - let init_arg = &bitcoin_integration_config.canister_init_arg; - - initialize_integration_canister(agent, logger, name, canister_id, &wasm, init_arg).await -} - #[cfg(test)] mod tests { use super::*; diff --git a/src/dfx/src/lib/integrations/mod.rs b/src/dfx/src/lib/integrations/mod.rs index c1ad6fb496..39e018be71 100644 --- a/src/dfx/src/lib/integrations/mod.rs +++ b/src/dfx/src/lib/integrations/mod.rs @@ -1,102 +1 @@ -#![cfg_attr(windows, allow(unused))] -use crate::lib::deps::PulledCanister; -use crate::lib::deps::deploy::try_create_canister; -use crate::lib::environment::create_agent; -use crate::lib::error::DfxResult; -use crate::lib::state_tree::canister_info::read_state_tree_canister_module_hash; -use crate::util::blob_from_arguments; -use anyhow::bail; -use candid::Principal; -use dfx_core::identity::Identity; -use dfx_core::{error::root_key::FetchRootKeyError, util::expiry_duration}; -use fn_error_context::context; -use ic_agent::Agent; -use ic_utils::interfaces::ManagementCanister; -use ic_utils::interfaces::management_canister::builders::CanisterInstallMode; -use sha2::Digest; -use slog::{Logger, debug, info}; -use std::time::Duration; - pub mod bitcoin; -pub mod status; - -pub async fn create_integrations_agent(url: &str, logger: &Logger) -> DfxResult { - let timeout = expiry_duration(); - let identity = Box::new(Identity::anonymous()); - let agent = create_agent(logger.clone(), url, identity, timeout).unwrap(); - agent - .fetch_root_key() - .await - .map_err(FetchRootKeyError::AgentError)?; - Ok(agent) -} -#[context("Failed to install {name} integration canister {canister_id}")] -pub async fn initialize_integration_canister( - agent: &Agent, - logger: &Logger, - name: &str, - canister_id: Principal, - wasm: &[u8], - init_arg: &str, -) -> DfxResult { - if already_installed(agent, &canister_id, wasm).await? { - debug!(logger, "Canister {canister_id} already installed"); - return Ok(()); - } - - let pulled_canister = PulledCanister { - name: Some(name.to_string()), - ..Default::default() - }; - try_create_canister(agent, logger, &canister_id, &pulled_canister).await?; - - let install_arg = blob_from_arguments(None, Some(init_arg), None, None, &None, true, false)?; - install_canister(agent, logger, &canister_id, wasm, install_arg, name).await -} - -#[context("Failed to install canister {canister_id}")] -async fn install_canister( - agent: &Agent, - logger: &Logger, - canister_id: &Principal, - wasm: &[u8], - install_args: Vec, - name: &str, -) -> DfxResult { - info!(logger, "Installing canister: {name}"); - ManagementCanister::create(agent) - .install_code(canister_id, wasm) - // always reinstall pulled canister - .with_mode(CanisterInstallMode::Reinstall) - .with_raw_arg(install_args) - .await?; - Ok(()) -} - -#[context("Failed to determine if canister {canister_id} is already installed")] -async fn already_installed(agent: &Agent, canister_id: &Principal, wasm: &[u8]) -> DfxResult { - let installed_module_hash = read_state_tree_canister_module_hash(agent, *canister_id).await?; - let expected_module_hash: [u8; 32] = sha2::Sha256::digest(wasm).into(); - let result = matches!(installed_module_hash, Some(hash) if hash == expected_module_hash); - - Ok(result) -} - -#[context("Failed to wait until canister {canister_id} is installed")] -pub async fn wait_for_canister_installed(agent: &Agent, canister_id: &Principal) -> DfxResult { - let mut retries = 0; - loop { - if read_state_tree_canister_module_hash(agent, *canister_id) - .await? - .is_some() - { - break; - } - if retries >= 60 { - bail!("Canister {canister_id} was never installed"); - } - tokio::time::sleep(Duration::from_secs(1)).await; - retries += 1; - } - Ok(()) -} diff --git a/src/dfx/src/lib/integrations/status.rs b/src/dfx/src/lib/integrations/status.rs deleted file mode 100644 index 2e6146fdd8..0000000000 --- a/src/dfx/src/lib/integrations/status.rs +++ /dev/null @@ -1,23 +0,0 @@ -use crate::lib::error::DfxResult; -use crate::lib::integrations::bitcoin::MAINNET_BITCOIN_CANISTER_ID; -use crate::lib::integrations::{create_integrations_agent, wait_for_canister_installed}; -use dfx_core::config::model::local_server_descriptor::LocalServerDescriptor; -use slog::Logger; - -pub async fn wait_for_integrations_initialized( - agent_url: &str, - logger: &Logger, - local_server_descriptor: &LocalServerDescriptor, -) -> DfxResult { - if !local_server_descriptor.bitcoin.enabled { - return Ok(()); - } - - let agent = create_integrations_agent(agent_url, logger).await?; - - if local_server_descriptor.bitcoin.enabled { - wait_for_canister_installed(&agent, &MAINNET_BITCOIN_CANISTER_ID).await?; - } - - Ok(()) -} diff --git a/src/dfx/src/util/assets.rs b/src/dfx/src/util/assets.rs index 5622ad5455..9c2610ca1b 100644 --- a/src/dfx/src/util/assets.rs +++ b/src/dfx/src/util/assets.rs @@ -64,36 +64,6 @@ pub fn assets_wasm(logger: &slog::Logger) -> DfxResult> { } } -#[allow(unused)] -#[context("Failed to load bitcoin wasm.")] -pub fn bitcoin_wasm(logger: &slog::Logger) -> DfxResult> { - if let Ok(dfx_assets_wasm) = std::env::var("DFX_BITCOIN_WASM") { - info!(logger, "Using wasm at path: {}", dfx_assets_wasm); - Ok(dfx_core::fs::read(dfx_assets_wasm.as_ref())?) - } else { - let mut canister_assets = - btc_canister().context("Failed to load bitcoin canister archive.")?; - for file in canister_assets - .entries() - .context("Failed to read bitcoin canister archive entries.")? - { - let mut file = file.context("Failed to read bitcoin canister archive entry.")?; - if file - .header() - .path() - .context("Failed to read archive entry path.")? - .ends_with("ic-btc-canister.wasm.gz") - { - let mut wasm = vec![]; - file.read_to_end(&mut wasm) - .context("Failed to read archive entry.")?; - return Ok(wasm); - } - } - bail!("Failed to find bitcoin canister archive entry"); - } -} - pub fn management_idl() -> DfxResult { // FIXME get idl from replica when it's available // Pulled from https://github.com/dfinity/interface-spec/blob/master/spec/_attachments/ic.did