Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ckbtc): Use the new KYT canister in ckbtc deposit flow #2304

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ninegua
Copy link
Member

@ninegua ninegua commented Oct 29, 2024

Switch to the new KYT canister in the ckBTC deposit flow.

Also enable real https outcalls in system tests with a SSL reverse proxy + bitcoind regtest network.

@github-actions github-actions bot added the feat label Oct 29, 2024
@ninegua ninegua changed the title feat(ckbtc): Use the new KYT canister in ckbtc withdrawal flow feat(ckbtc): Use the new KYT canister in ckbtc deposit flow Oct 29, 2024
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-withdrawal branch from 8dba269 to c0302d0 Compare November 1, 2024 07:38
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-deposit branch from f72fb2d to 950a000 Compare November 1, 2024 07:40
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-withdrawal branch from 27b6316 to 8362c92 Compare November 4, 2024 12:21
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-deposit branch from 3211b0b to 7e73089 Compare November 5, 2024 04:30
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-deposit branch 2 times, most recently from 948c6d8 to ddbd46e Compare November 12, 2024 06:00
@ninegua ninegua changed the base branch from paulliu/new-kyt-in-ckbtc-withdrawal to paulliu/check-address-before-burn November 12, 2024 06:00
@ninegua ninegua force-pushed the paulliu/check-address-before-burn branch from 17fa74e to e3fa5ac Compare November 13, 2024 05:52
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-deposit branch from ddd5024 to 4b68ab1 Compare November 13, 2024 06:01
@ninegua ninegua force-pushed the paulliu/check-address-before-burn branch from e3fa5ac to 5ee77b5 Compare November 14, 2024 00:52
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-deposit branch 4 times, most recently from 9baf221 to 1f6fc46 Compare November 15, 2024 03:38
@ninegua ninegua added the CI_ALL_BAZEL_TARGETS Runs all bazel targets and uploads them to S3 label Nov 15, 2024
Base automatically changed from paulliu/check-address-before-burn to master November 15, 2024 08:15
@ninegua ninegua force-pushed the paulliu/new-kyt-in-ckbtc-deposit branch from 1f6fc46 to be92bbc Compare November 15, 2024 08:18
@ninegua ninegua marked this pull request as ready for review November 15, 2024 08:28
@ninegua ninegua requested review from a team as code owners November 15, 2024 08:28
Comment on lines +58 to +67
oci_tar(
name = "minica.tar",
image = "@minica",
repo_tags = ["minica:image"],
)

uvm_config_image(
name = "ckbtc_uvm_config_image",
srcs = [
":minica.tar",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about moving the equivalent //rs/tests/networking/canister_http:minica.tar to /rs/tests/BUILD.bazel and removing this one?

# Run nginx auto proxy
docker run -d --name=proxy -e ENABLE_IPV6=true -e DEFAULT_HOST=localhost -p 80:80 -p {HTTPS_PORT}:443 \
-v /tmp/certs:/etc/nginx/certs -v /var/run/docker.sock:/tmp/docker.sock:ro \
nginxproxy/nginx-proxy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that since this runs in a fresh Universal VM it will have to download nginxproxy/nginx-proxy for every run. This will very soon hit the docker hub rate limit and cause these tests to start failing.

Could you move this image into the UVM config image like you do for minica above?

docker run --name=bitcoind-node -d \
-e VIRTUAL_HOST=localhost -e VIRTUAL_PORT={BITCOIND_RPC_PORT} -v /tmp:/bitcoin/.bitcoin \
-p {BITCOIN_CLI_PORT}:{BITCOIN_CLI_PORT} -p {BITCOIND_RPC_PORT}:{BITCOIND_RPC_PORT} \
ghcr.io/dfinity/bitcoind@sha256:17c7dd21690f3be34630db7389d2f0bff14649e27a964afef03806a6d631e0f1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this image is also moved in the UVM config image so that it doesn't have to be downloaded each time.

Copy link
Member

@gregorydemay gregorydemay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @ninegua for this PR! I have a couple of minor comments but nothing critical.

InternetComputer::new()
.with_bitcoind_addr(SocketAddr::new(IpAddr::V6(btc_node_ipv6), 18444))
.with_bitcoind_addr(SocketAddr::new(IpAddr::V6(btc_node_ipv6), BITCOIN_CLI_PORT))
.add_subnet(
Subnet::new(SubnetType::System)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shouldn't it be an application subnet since the ckBTC minter runs on pzp6e?

@@ -390,7 +405,7 @@ pub async fn install_minter(
min_confirmations: Some(BTC_MIN_CONFIRMATIONS as u32),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here for a lack of a better place: Why do we use

ecdsa_key_name: TEST_KEY_LOCAL.parse().unwrap(),

?

Shouldn't we use a real tECDSA setup, meaning ecdsa_key_name should be something like key_1 or test_key_1? If that's the case, then it's probably better to address this as a separate PR/ticket, since it probably won't be sufficient to just change the key name (one has to activate tECDSA by proposal, similarly to what is described here)

);
let kyt_init_args = NewKytArg::InitArg(NewKytInitArg {
btc_network: BtcNetwork::Regtest { json_rpc_url },
kyt_mode: NewKytMode::AcceptAll,
kyt_mode: NewKytMode::Normal,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@@ -230,9 +230,9 @@ pub async fn update_balance(
utxo_statuses.push(UtxoStatus::ValueTooSmall(utxo));
continue;
}
let (uuid, status, kyt_provider) = kyt_check_utxo(caller_account.owner, &utxo).await?;
let status = kyt_check_utxo(&utxo).await?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here for a lack of a better place, we should update the value of kyt_fee used L.221 in the NNS upgrade proposal when we rollout this feature, correct? I don't remember, is the value going to be 0?

mutate_state(|s| {
crate::state::audit::mark_utxo_checked(s, &utxo, uuid.clone(), status, kyt_provider);
crate::state::audit::mark_utxo_checked(s, &utxo, None, status, None);
});
if status == UtxoCheckStatus::Tainted {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be preferable to match against the value of status to ensure by the compiler that we exhausted all variants

state.mark_utxo_checked(
utxo,
uuid,
if uuid.is_empty() { None } else { Some(uuid) },
UtxoCheckStatus::from_clean_flag(clean),
kyt_provider,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to the initial code, shouldn't we check that kyt_provider either corresponds to kyt_principal or to new_kyt_principal?

return Err(ReplayLogError::InconsistentLog(format!("Attempted to distribute {amount} to {kyt_provider}, causing an overdraft of {overdraft}")));
if Some(kyt_provider) != previous_kyt_principal {
if let Err(Overdraft(overdraft)) =
state.distribute_kyt_fee(kyt_provider, amount)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused here. Shouldn't we only do this if State::new_kyt_principal.is_none()?

kyt_principal: None,
new_kyt_principal: None
retrieve_btc_min_amount: 1000,
..default_init_args()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

much more readable, thanks!

mode: Some(Mode::RestrictedTo(vec![authorized_principal])),
kyt_fee: None,
new_kyt_principal: Some(CanisterId::from(0)),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Shouldn't we enforce in validate_config that either kyt_principal or new_kyt_principal is set, but not both?

@@ -193,11 +173,10 @@ pub fn test_kyt(env: TestEnv) {
);
}
}
start_canister(&kyt_canister).await;
start_canister(&new_kyt_canister).await;

// Put the kyt canister into accept all utxos mode.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would remove this comment, IMO it doesn't add anything and is no longer actual.

Suggested change
// Put the kyt canister into accept all utxos mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI_ALL_BAZEL_TARGETS Runs all bazel targets and uploads them to S3 @cross-chain-team feat @idx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants