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

Can trigger assertation failure in experimental compiler #656

Open
apoelstra opened this issue Mar 12, 2024 · 3 comments · Fixed by #657
Open

Can trigger assertation failure in experimental compiler #656

apoelstra opened this issue Mar 12, 2024 · 3 comments · Fixed by #657

Comments

@apoelstra
Copy link
Member

The following unit test

commit c4a38f269369f87e7a9c210eba15a9f54e171965
Author: Andrew Poelstra <apoelstra@wpsoftware.net>
Date:   Tue Mar 12 14:54:09 2024 +0000

    compiler: add unit test that triggers assertation in compile_private_experimental

diff --git a/src/policy/mod.rs b/src/policy/mod.rs
index 7faccbc1..d9e119f4 100644
--- a/src/policy/mod.rs
+++ b/src/policy/mod.rs
@@ -520,6 +520,18 @@ mod tests {
             assert_eq!(desc, expected_desc);
         }
 
+        {
+            let pol = Concrete::<String>::from_str(
+                "thresh(3,pk(A),pk(B),pk(C),pk(D),pk(E),pk(F),pk(G),pk(H))",
+            )
+            .unwrap();
+            pol.compile::<Tap>().unwrap();
+            pol.compile_tr_private_experimental(Some(unspendable_key.clone()))
+                .unwrap();
+            // Don't bother checking the output, which is huge; just confirm that it
+            // does not trigger an assertation failure within the compiler.
+        }
+
         {
             let pol =
                 Concrete::<String>::from_str("thresh(3,pk(A),pk(B),pk(C),pk(D),pk(E))").unwrap();

Causes an assertation failure, as

---- policy::tests::experimental_taproot_compile stdout ----
thread 'policy::tests::experimental_taproot_compile' panicked at src/policy/concrete.rs:507:25:
assertion failed: tapleaf_prob_vec.remove(&(Reverse(*prev_prob), policy.clone()))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@sanket1729
Copy link
Member

I can take a look at this weekend.

apoelstra added a commit that referenced this issue Mar 12, 2024
…s and multi/multi_a

200991d compiler: improve logic for deciding between thresholds and ands (Andrew Poelstra)
bc3b8dc policy: rename Threshold variant to Thresh (Andrew Poelstra)
78db616 consolidate some FIXMEs (Andrew Poelstra)
0666aef error: remove some unused variants (Andrew Poelstra)
b2ec4a8 clippy: fix some nits introduced by #651 (Andrew Poelstra)

Pull request description:

  The compiler logic when encountering thresholds of pks is currently a bit confused, and therefore chooses multi/multi_a in cases where this is not the most efficient compilation.

  This PR fixes that, and also brings in a few other cleanup commits that I had laying around.

  This does **not** fix #656, which I didn't know how to approach.

ACKs for top commit:
  sanket1729:
    ACK 200991d

Tree-SHA512: 252a60891cf1c1d1cd3ded88d97122fd1e76bd25807770f4843ae68bd2d854fc617518f26be86dcb57cd7fc369e1a4be81daa42ee1a6d4bc976dbad6dc1150f6
@darosior
Copy link
Contributor

darosior commented Apr 1, 2024

This should probably be re-opened. This was marked as fix due to the magic link in #657.

@apoelstra
Copy link
Member Author

Thanks for noticing!

Lol that github reads "this does not fix X" as "Fixes X".

@apoelstra apoelstra reopened this Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants