Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions .github/workflows/bitcoin-canister-update.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions e2e/tests-dfx/bitcoin.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 0 additions & 31 deletions scripts/update-btc-canister.sh

This file was deleted.

1 change: 0 additions & 1 deletion src/dfx/assets/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 1 addition & 6 deletions src/dfx/assets/dfx-asset-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
37 changes: 2 additions & 35 deletions src/dfx/assets/prepare_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,34 +53,6 @@ fn copy_canisters(out_dir: PathBuf) {
}
}

async fn download_canisters(
client: Client,
sources: Arc<HashMap<String, Source>>,
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<String, Source>) {
let sources = Arc::new(sources);
let client = Client::builder()
Expand All @@ -91,13 +63,8 @@ async fn make_binary_cache(out_dir: PathBuf, sources: HashMap<String, Source>) {
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();
Expand Down
10 changes: 1 addition & 9 deletions src/dfx/src/actors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(),
Expand Down
41 changes: 18 additions & 23 deletions src/dfx/src/actors/pocketic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -58,7 +54,7 @@ pub struct Config {
pub effective_config_path: PathBuf,
pub replica_config: ReplicaConfig,
pub bitcoind_addr: Option<Vec<SocketAddr>>,
pub bitcoin_integration_config: Option<BitcoinIntegrationConfig>,
pub enable_bitcoin: bool,
pub port: Option<u16>,
pub port_file: PathBuf,
pub pid_file: PathBuf,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -350,7 +341,7 @@ async fn initialize_pocketic(
port: u16,
effective_config_path: &Path,
bitcoind_addr: &Option<Vec<SocketAddr>>,
bitcoin_integration_config: &Option<BitcoinIntegrationConfig>,
enable_bitcoin: bool,
replica_config: &ReplicaConfig,
domains: Option<Vec<String>>,
addr: SocketAddr,
Expand Down Expand Up @@ -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()),
Expand All @@ -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
Expand All @@ -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()),
Expand Down Expand Up @@ -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)
}
Expand All @@ -469,7 +464,7 @@ fn initialize_pocketic(
_: u16,
_: &Path,
_: &Option<Vec<SocketAddr>>,
_: &Option<BitcoinIntegrationConfig>,
_: bool,
_: &ReplicaConfig,
_: Option<Vec<String>>,
_: SocketAddr,
Expand Down
5 changes: 1 addition & 4 deletions src/dfx/src/commands/canister/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ struct FilterOpts {
last_idx: Option<u64>,
}

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
Expand Down
Loading