Skip to content

Commit

Permalink
Merge branch 'maksym-ic-admin-rev' into 'master'
Browse files Browse the repository at this point in the history
chore: update external bitcoin_canister & ic-btc-interface to release/2023-06-12

This MR updates the `bitcoin-canister` and `ic-btc-interface` to the release/2023-06-12.

This is a preparation MR before updating ic-admin with watchdog-canister settings, which requires to have updated `Config` from the bitcoin-canister.

Changes:

* Update `btc_canister` and `ic-btc-interface` rev
* Switch from `ic_btc_interface::NetworkSnakeCase` to `ic_btc_interface::Network`
  * add `BtcNetwork` to ckbtc minter to convert between snake-case and lower-case network variants
* Repin Bazel, recalculate cargo lock files 

See merge request dfinity-lab/public/ic!13218
  • Loading branch information
maksymar committed Jun 28, 2023
2 parents 323bb2c + 4d6dd29 commit cfabc9a
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Cargo.Bazel.StaticOpenSSL.json.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "b34153a865fc5ea70a25e0ca5234daeb324dfa6672717394ffaf9ef2cb65f015",
"checksum": "941a604b29cc9607015760617720dba622ff30e135fb09a76406a2abfa4b5171",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down Expand Up @@ -21589,7 +21589,7 @@
"Git": {
"remote": "https://github.com/dfinity/bitcoin-canister",
"commitish": {
"Rev": "e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e"
"Rev": "b1693619e3d4dbc00d8c79e9b6886e1db48b21f7"
},
"strip_prefix": "interface"
}
Expand Down
2 changes: 1 addition & 1 deletion Cargo.Bazel.StaticOpenSSL.toml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4136,7 +4136,7 @@ dependencies = [
[[package]]
name = "ic-btc-interface"
version = "0.1.0"
source = "git+https://github.com/dfinity/bitcoin-canister?rev=e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e#e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e"
source = "git+https://github.com/dfinity/bitcoin-canister?rev=b1693619e3d4dbc00d8c79e9b6886e1db48b21f7#b1693619e3d4dbc00d8c79e9b6886e1db48b21f7"
dependencies = [
"candid 0.8.4",
"serde",
Expand Down
12 changes: 6 additions & 6 deletions Cargo.Bazel.json.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"checksum": "03cf3a6f0e5578d9139b9f1822b0d9f8f2c63391dee87bdfd6a585e4154caa45",
"checksum": "975d206a4721186e03b2edc40d56ecf42bce214b4b206961ab821f51cf7d9312",
"crates": {
"abnf 0.12.0": {
"name": "abnf",
Expand Down Expand Up @@ -21589,7 +21589,7 @@
"Git": {
"remote": "https://github.com/dfinity/bitcoin-canister",
"commitish": {
"Rev": "e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e"
"Rev": "b1693619e3d4dbc00d8c79e9b6886e1db48b21f7"
},
"strip_prefix": "interface"
}
Expand Down Expand Up @@ -53000,8 +53000,8 @@
},
{
"Binary": {
"crate_name": "reader",
"crate_root": "src/bin/reader.rs",
"crate_name": "exit",
"crate_root": "src/bin/exit.rs",
"srcs": {
"include": [
"**/*.rs"
Expand All @@ -53024,8 +53024,8 @@
},
{
"Binary": {
"crate_name": "exit",
"crate_root": "src/bin/exit.rs",
"crate_name": "reader",
"crate_root": "src/bin/reader.rs",
"srcs": {
"include": [
"**/*.rs"
Expand Down
2 changes: 1 addition & 1 deletion Cargo.Bazel.toml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4136,7 +4136,7 @@ dependencies = [
[[package]]
name = "ic-btc-interface"
version = "0.1.0"
source = "git+https://github.com/dfinity/bitcoin-canister?rev=e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e#e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e"
source = "git+https://github.com/dfinity/bitcoin-canister?rev=b1693619e3d4dbc00d8c79e9b6886e1db48b21f7#b1693619e3d4dbc00d8c79e9b6886e1db48b21f7"
dependencies = [
"candid 0.8.4",
"serde",
Expand Down
7 changes: 4 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ pprof = { git = "https://github.com/tikv/pprof-rs", rev = "059d3c80395c74e9f82ca

[workspace.dependencies]
ic-agent = "0.24.1"
ic-btc-interface = { git = "https://github.com/dfinity/bitcoin-canister", rev = "e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e" }
ic-btc-interface = { git = "https://github.com/dfinity/bitcoin-canister", rev = "b1693619e3d4dbc00d8c79e9b6886e1db48b21f7" }
ic-utils = "0.24.1"
k256 = { version = "0.13", default_features = false, features = [
"arithmetic",
Expand Down
4 changes: 2 additions & 2 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,8 @@ http_file(
http_file(
name = "btc_canister",
downloaded_file_path = "ic-btc-canister.wasm.gz",
sha256 = "c4153339cc3d23eae8f5e5a9c3872df5e5713913357e11d493bc5d06f257fb47",
url = "https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-03-31/ic-btc-canister.wasm.gz",
sha256 = "8cc43d3f40bb734a0c87f42ae19eee70c360f2d66a0c88c631f0f0e785505133",
url = "https://github.com/dfinity/bitcoin-canister/releases/download/release%2F2023-06-12/ic-btc-canister.wasm.gz",
)

# Internet Identity canister (test build)
Expand Down
2 changes: 1 addition & 1 deletion bazel/external_crates.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def external_crates_repository(name, static_openssl, cargo_lockfile, lockfile):
),
"ic-btc-interface": crate.spec(
git = "https://github.com/dfinity/bitcoin-canister",
rev = "e4e89f2caedffbe0cfdec6f9d4a77f66dcb9119e",
rev = "b1693619e3d4dbc00d8c79e9b6886e1db48b21f7",
),
"ic-btc-validation": crate.spec(
git = "https://github.com/dfinity/bitcoin-canister",
Expand Down
5 changes: 2 additions & 3 deletions rs/bitcoin/ckbtc/minter/src/guard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,10 @@ pub fn retrieve_btc_guard(p: Principal) -> Result<Guard<RetrieveBtcUpdates>, Gua
mod tests {
use crate::{
guard::{GuardError, MAX_CONCURRENT},
lifecycle::init::{init, InitArgs},
lifecycle::init::{init, BtcNetwork, InitArgs},
state::read_state,
};
use ic_base_types::CanisterId;
use ic_btc_interface::Network;
use ic_cdk::export::Principal;

use super::{balance_update_guard, TimerLogicGuard};
Expand All @@ -139,7 +138,7 @@ mod tests {

fn test_state_args() -> InitArgs {
InitArgs {
btc_network: Network::Regtest,
btc_network: BtcNetwork::Regtest,
ecdsa_key_name: "".to_string(),
retrieve_btc_min_amount: 0,
ledger_id: CanisterId::from_u64(42),
Expand Down
34 changes: 33 additions & 1 deletion rs/bitcoin/ckbtc/minter/src/lifecycle/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,42 @@ pub enum MinterArg {
Upgrade(Option<UpgradeArgs>),
}

// TODO: Use `ic_btc_interface::Network` directly.
// The Bitcoin canister's network enum no longer has snake-case versions
// (refer to [PR171](https://github.com/dfinity/bitcoin-canister/pull/171)),
// instead it uses lower-case candid variants.
// A temporary fix for ckbtc minter is to create a new enum with capital letter variants.
#[derive(CandidType, Clone, Copy, Deserialize, Debug, Eq, PartialEq, Serialize, Hash)]
pub enum BtcNetwork {
Mainnet,
Testnet,
Regtest,
}

impl From<BtcNetwork> for Network {
fn from(network: BtcNetwork) -> Self {
match network {
BtcNetwork::Mainnet => Network::Mainnet,
BtcNetwork::Testnet => Network::Testnet,
BtcNetwork::Regtest => Network::Regtest,
}
}
}

impl From<Network> for BtcNetwork {
fn from(network: Network) -> Self {
match network {
Network::Mainnet => BtcNetwork::Mainnet,
Network::Testnet => BtcNetwork::Testnet,
Network::Regtest => BtcNetwork::Regtest,
}
}
}

#[derive(CandidType, Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
pub struct InitArgs {
/// The bitcoin network that the minter will connect to
pub btc_network: Network,
pub btc_network: BtcNetwork,

/// The name of the [EcdsaKeyId]. Use "dfx_test_key" for local replica and "test_key_1" for
/// a testing key for testnet and mainnet
Expand Down
4 changes: 2 additions & 2 deletions rs/bitcoin/ckbtc/minter/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ impl CkBtcMinterState {
kyt_principal,
}: InitArgs,
) {
self.btc_network = btc_network;
self.btc_network = btc_network.into();
self.ecdsa_key_name = ecdsa_key_name;
self.retrieve_btc_min_amount = retrieve_btc_min_amount;
self.ledger_id = ledger_id;
Expand Down Expand Up @@ -1027,7 +1027,7 @@ fn as_sorted_vec<T, K: Ord>(values: impl Iterator<Item = T>, key: impl Fn(&T) ->
impl From<InitArgs> for CkBtcMinterState {
fn from(args: InitArgs) -> Self {
Self {
btc_network: args.btc_network,
btc_network: args.btc_network.into(),
ecdsa_key_name: args.ecdsa_key_name,
ecdsa_public_key: None,
min_confirmations: args
Expand Down
6 changes: 3 additions & 3 deletions rs/bitcoin/ckbtc/minter/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ proptest! {
accounts in pvec(arb_account(), 5),
) {
let mut state = CkBtcMinterState::from(InitArgs {
btc_network: Network::Regtest,
btc_network: Network::Regtest.into(),
ecdsa_key_name: "".to_string(),
retrieve_btc_min_amount: 0,
ledger_id: CanisterId::from_u64(42),
Expand All @@ -760,7 +760,7 @@ proptest! {
limit in 1..25usize,
) {
let mut state = CkBtcMinterState::from(InitArgs {
btc_network: Network::Regtest,
btc_network: Network::Regtest.into(),
ecdsa_key_name: "".to_string(),
retrieve_btc_min_amount: 5_000u64,
ledger_id: CanisterId::from_u64(42),
Expand Down Expand Up @@ -803,7 +803,7 @@ proptest! {
resubmission_chain_length in 1..=5,
) {
let mut state = CkBtcMinterState::from(InitArgs {
btc_network: Network::Regtest,
btc_network: Network::Regtest.into(),
ecdsa_key_name: "".to_string(),
retrieve_btc_min_amount: 100_000,
ledger_id: CanisterId::from_u64(42),
Expand Down
6 changes: 3 additions & 3 deletions rs/bitcoin/ckbtc/minter/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn install_ledger(env: &StateMachine) -> CanisterId {

fn install_minter(env: &StateMachine, ledger_id: CanisterId) -> CanisterId {
let args = CkbtcMinterInitArgs {
btc_network: Network::Regtest,
btc_network: Network::Regtest.into(),
/// The name of the [EcdsaKeyId]. Use "dfx_test_key" for local replica and "test_key_1" for
/// a testing key for testnet and mainnet
ecdsa_key_name: "dfx_test_key".parse().unwrap(),
Expand Down Expand Up @@ -379,7 +379,7 @@ fn test_minter() {

let env = StateMachine::new();
let args = MinterArg::Init(CkbtcMinterInitArgs {
btc_network: Network::Regtest,
btc_network: Network::Regtest.into(),
ecdsa_key_name: "master_ecdsa_public_key".into(),
retrieve_btc_min_amount: 100_000,
ledger_id: CanisterId::from_u64(0),
Expand Down Expand Up @@ -486,7 +486,7 @@ impl CkBtcSetup {
minter_id,
minter_wasm(),
Encode!(&MinterArg::Init(CkbtcMinterInitArgs {
btc_network: Network::Mainnet,
btc_network: Network::Mainnet.into(),
ecdsa_key_name: "master_ecdsa_public_key".to_string(),
retrieve_btc_min_amount: 100_000,
ledger_id,
Expand Down
8 changes: 3 additions & 5 deletions rs/bitcoin/consensus/src/payload_builder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::metrics::BitcoinPayloadBuilderMetrics;
use ic_btc_interface::NetworkSnakeCase;
use ic_btc_interface::Network;
use ic_btc_types_internal::{
BitcoinAdapterRequestWrapper, BitcoinAdapterResponse, BitcoinAdapterResponseWrapper,
};
Expand Down Expand Up @@ -142,10 +142,8 @@ impl BitcoinPayloadBuilder {
}

let adapter_client = match request.network() {
NetworkSnakeCase::Mainnet => &self.bitcoin_mainnet_adapter_client,
NetworkSnakeCase::Testnet | NetworkSnakeCase::Regtest => {
&self.bitcoin_testnet_adapter_client
}
Network::Mainnet => &self.bitcoin_mainnet_adapter_client,
Network::Testnet | Network::Regtest => &self.bitcoin_testnet_adapter_client,
};

// Send request to the adapter.
Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/consensus/src/payload_builder/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::BitcoinPayloadBuilder;
use ic_btc_interface::NetworkSnakeCase as Network;
use ic_btc_interface::Network;
use ic_btc_types_internal::{
BitcoinAdapterRequestWrapper, BitcoinAdapterResponse, BitcoinAdapterResponseWrapper,
GetSuccessorsRequestInitial, GetSuccessorsResponseComplete,
Expand Down
2 changes: 1 addition & 1 deletion rs/bitcoin/types/internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! only for serialization/deserialization of the ReplicatedState.

use candid::CandidType;
use ic_btc_interface::NetworkSnakeCase as Network;
use ic_btc_interface::Network;
use ic_protobuf::{
bitcoin::v1,
proxy::{try_from_option_field, ProxyDecodeError},
Expand Down
10 changes: 5 additions & 5 deletions rs/replica_tests/tests/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ fn bitcoin_get_successors() {
let response = call_get_successors(
&canister,
ic00::BitcoinGetSuccessorsArgs::Initial(ic00::BitcoinGetSuccessorsRequestInitial {
network: ic_btc_interface::NetworkSnakeCase::Regtest,
network: ic_btc_interface::Network::Regtest,
anchor: vec![],
processed_block_hashes: vec![],
}),
Expand Down Expand Up @@ -181,7 +181,7 @@ fn bitcoin_get_successors_pagination() {
let response = call_get_successors(
&canister,
ic00::BitcoinGetSuccessorsArgs::Initial(ic00::BitcoinGetSuccessorsRequestInitial {
network: ic_btc_interface::NetworkSnakeCase::Regtest,
network: ic_btc_interface::Network::Regtest,
anchor: vec![],
processed_block_hashes: vec![],
}),
Expand Down Expand Up @@ -225,7 +225,7 @@ fn bitcoin_get_successors_pagination_invalid_adapter_request() {
let response = call_get_successors(
&canister,
ic00::BitcoinGetSuccessorsArgs::Initial(ic00::BitcoinGetSuccessorsRequestInitial {
network: ic_btc_interface::NetworkSnakeCase::Regtest,
network: ic_btc_interface::Network::Regtest,
anchor: vec![],
processed_block_hashes: vec![],
}),
Expand Down Expand Up @@ -259,7 +259,7 @@ fn bitcoin_send_transaction_internal_valid_request() {
let response = call_send_transaction_internal(
&canister,
ic00::BitcoinSendTransactionInternalArgs {
network: ic_btc_interface::NetworkSnakeCase::Regtest,
network: ic_btc_interface::Network::Regtest,
transaction: vec![1, 2, 3],
},
);
Expand Down Expand Up @@ -318,7 +318,7 @@ fn bitcoin_send_transaction_internal_no_permissions() {
let response = call_send_transaction_internal(
&canister,
ic00::BitcoinSendTransactionInternalArgs {
network: ic_btc_interface::NetworkSnakeCase::Regtest,
network: ic_btc_interface::Network::Regtest,
transaction: vec![1, 2, 3],
},
);
Expand Down
4 changes: 2 additions & 2 deletions rs/replicated_state/tests/replicated_state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use ic_base_types::{CanisterId, NumBytes, NumSeconds, PrincipalId, SubnetId};
use ic_btc_interface::NetworkSnakeCase;
use ic_btc_interface::Network;
use ic_btc_types_internal::{
BitcoinAdapterResponse, BitcoinAdapterResponseWrapper, GetSuccessorsRequestInitial,
GetSuccessorsResponseComplete,
Expand Down Expand Up @@ -549,7 +549,7 @@ fn insert_bitcoin_response() {
.push_bitcoin_get_successors_request(BitcoinGetSuccessorsContext {
request: RequestBuilder::default().build(),
payload: GetSuccessorsRequestInitial {
network: NetworkSnakeCase::Regtest,
network: Network::Regtest,
anchor: vec![],
processed_block_hashes: vec![],
},
Expand Down

0 comments on commit cfabc9a

Please sign in to comment.