-
Notifications
You must be signed in to change notification settings - Fork 316
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
base: master
Are you sure you want to change the base?
Conversation
8dba269
to
c0302d0
Compare
f72fb2d
to
950a000
Compare
27b6316
to
8362c92
Compare
3211b0b
to
7e73089
Compare
948c6d8
to
ddbd46e
Compare
17fa74e
to
e3fa5ac
Compare
ddd5024
to
4b68ab1
Compare
e3fa5ac
to
5ee77b5
Compare
9baf221
to
1f6fc46
Compare
…for bitcoind so that https-outcall can go through.
1f6fc46
to
be92bbc
Compare
oci_tar( | ||
name = "minica.tar", | ||
image = "@minica", | ||
repo_tags = ["minica:image"], | ||
) | ||
|
||
uvm_config_image( | ||
name = "ckbtc_uvm_config_image", | ||
srcs = [ | ||
":minica.tar", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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) |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?; |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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)), |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
// Put the kyt canister into accept all utxos mode. |
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.