Bitcoin API regtest not accepting cycles?

I’m trying to build a BTC→ckBTC converter

dfx start --enable-bitcoin --background --clean

dfx ledger fabricate-cycles --canister <my canister id> --cycles 10_000_000_000_000 # 10 trillion

I’ve attached 20 billion cycles to the intercanister call

let statuses = switch (await (with cycles = 20_000_000_000) ckbtc_minter.update_balance(account)) {
  case (#Ok utxo_statuses) utxo_statuses;
  case (#Err err) return #Err err;
};

but i still got this error:

TemporarilyUnavailable = "management call \'bitcoin_get_utxos\' failed: canister error: IC0503: Error from Canister g4xu7-jiaaa-aaaan-aaaaq-cai: Canister called `ic0.trap` with message: \'Panicked at \'Received 4000000000 cycles. 10000000000 cycles are required.

I suspect there’s a mismatch between the ckBTC minter configuration and the bitcoin canister configuration. Given the error message, it seems that the ckBTC minter is configured for testnet (lower fees), but the bitcoin canister is configured for mainnet (higher fees). The exact amount of fees you attached does not matter since the call to the bitcoin canister is performed by the ckBTC minter which determines the amount of cycles attached to that call.

Since the bitcoin canister configuration is fixed by dfx, maybe you can try to alter your ckBTC minter configuration?

by configuration, do you mean the deployment arg?
i’m running dfx v0.29.2 btw

dfx start --enable-bitcoin --background --clean

dfx deploy --specified-id ml52i-qqaaa-aaaar-qaaba-cai ckbtc_minter --argument '(variant{
  Init = record {
    btc_network = variant { Regtest };
    ledger_id = principal "mc6ru-gyaaa-aaaar-qaaaq-cai";
    ecdsa_key_name = "dfx_test_key";
    retrieve_btc_min_amount = 10_000;
    max_time_in_queue_nanos = 10_000_000_000;
    min_confirmations = opt 1;
    mode = variant { GeneralAvailability };
    kyt_fee = opt 100;
    kyt_principal = opt principal "pvm5g-xaaaa-aaaar-qaaia-cai"                
  }
})'

Indeed, but now that I think about it, using mainnet would mean that the bitcoin mainnet canister ID is used which is not deployed by dfx. The proper solution would be to fix dfx:

  • enable the bitcoin feature in PocketIC here;
  • or update the bitcoin canister init arg to use testnet fees.

I’ll follow up with dfx maintainers on this.

2 Likes

Should be fixed with this PR. It will likely end up in the next dfx beta

what dfx version i should use in the meantime?

Are you willing to use the one on master? Should be a simple git clone, cargo build, and then adding target/debug/dfx to your PATH