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

Upgrade bdk to 0.20.0 #8

Merged
merged 2 commits into from
Aug 4, 2022
Merged

Conversation

afilini
Copy link
Member

@afilini afilini commented Jul 8, 2022

The only notable change in this release is that by default bdk tries to prevent fee-sniping attacks by setting the nlocktime to the current height, so it's now necessary to set it at zero explicitly to get deterministic proof of reserves.

On top of this, the new default behavior is to remove partial signatures after finalizing a tx, which should shrink down the size of proofs quite a bit as you can see in the test updated here: bitcoindevkit/bdk-cli#108

This is a draft for now while we wait for the release, there's a one-week window to report bugs so if you notice anything wrong here let us know.

@ulrichard
Copy link
Collaborator

With the following changes, most tests pass:

From 5c1d91080fef8675ae61e0332d49fe4f55d4f39d Mon Sep 17 00:00:00 2001
From: Richard Ulrich <richard.ulrich@seba.swiss>
Date: Mon, 11 Jul 2022 13:29:52 +0200
Subject: [PATCH] testing

---
 Cargo.toml          | 1 +
 tests/multi_sig.rs  | 1 +
 tests/single_sig.rs | 1 +
 3 files changed, 3 insertions(+)

diff --git a/Cargo.toml b/Cargo.toml
index a33beb7..6598e6f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,5 +15,6 @@ bitcoinconsensus = "0.19.0-3"
 log = "^0.4"
 
 [dev-dependencies]
+bdk = { git = "https://github.com/bitcoindevkit/bdk.git", branch = "release/0.20.0", default-features = true }
 rstest = "^0.11"
 bdk-testutils = "^0.4"
diff --git a/tests/multi_sig.rs b/tests/multi_sig.rs
index e2e6e00..965009a 100644
--- a/tests/multi_sig.rs
+++ b/tests/multi_sig.rs
@@ -128,6 +128,7 @@ fn test_proof_multisig(
 
     let signopts = SignOptions {
         trust_witness_utxo: true,
+        remove_partial_sigs: false,
         ..Default::default()
     };
     let finalized = wallet1.sign(&mut psbt, signopts.clone())?;
diff --git a/tests/single_sig.rs b/tests/single_sig.rs
index 4dd9b41..72f4a91 100644
--- a/tests/single_sig.rs
+++ b/tests/single_sig.rs
@@ -23,6 +23,7 @@ fn test_proof(#[case] descriptor: &'static str) -> Result<(), ProofError> {
     let finalized = wallet.sign(
         &mut psbt,
         SignOptions {
+            remove_partial_sigs: false,
             trust_witness_utxo: true,
             ..Default::default()
         },
-- 
2.30.2

but the following still fails. I didn't investigate so far.

---- test_proof::case_3 stdout ----
-------------- TEST START --------------
thread 'test_proof::case_3' panicked at 'called `Result::unwrap()` on an `Err` value: Generic("TxBuilder requested timelock of `0`, but at least `100000` is required to spend from this script")', /home/richi/src/github/bdk-reserves/src/reserves.rs:137:49
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@afilini
Copy link
Member Author

afilini commented Jul 13, 2022

The last error means you have a timelock in your script and in order to spend correctly from it you need to set the nLockTime to 100000, but with my changes I'm always forcing it to zero and that's why it fails.

I can change it so that I don't force bdk to use zero, just tell the library to use zero for anti fee sniping (essentially disabling it).

@afilini afilini force-pushed the upgrade/bdk-0.20.0 branch 2 times, most recently from e72af02 to 975f983 Compare July 15, 2022 10:31
@afilini afilini marked this pull request as ready for review July 15, 2022 10:31
Copy link
Contributor

@rajarshimaitra rajarshimaitra left a comment

Choose a reason for hiding this comment

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

tACK 975f983, modulo the cargo.toml update..

I verified the test passes with bdk20.0..

I wouldn't worry about the locktime setup much in bdk-reserves as they don't represent real transactions. But would good to get it to bdk 20 along with bdk-cli..

bitcoinconsensus = "0.19.0-3"
log = "^0.4"

[dev-dependencies]
rstest = "^0.11"
bdk-testutils = "^0.4"
bdk = { version = "0.19", default-features = true }
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this line needs to stay.. it uses electrum while running integration tests..

@ulrichard ulrichard merged commit d4f078e into bitcoindevkit:main Aug 4, 2022
@ulrichard
Copy link
Collaborator

Thanks for the work, and sorry for the delay.
During the family holiday, my computer time was limited.

@afilini afilini deleted the upgrade/bdk-0.20.0 branch August 4, 2022 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants