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

build error: overflow evaluating the requirement F: FnMut<(&Pk,)> #549

Closed
vincenzopalazzo opened this issue May 19, 2023 · 9 comments
Closed

Comments

@vincenzopalazzo
Copy link

I am building a project with bdk and I am now running the cargo install but
I had this error here

error[E0275]: overflow evaluating the requirement `F: FnMut<(&Pk,)>`
  |
  = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`miniscript`)
  = note: required for `&mut F` to implement `FnMut<(&Pk,)>`
  = note: 128 redundant requirements hidden
  = note: required for `&mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut ...` to implement `FnMut<(&Pk,)>`
  = note: the full type name has been written to '/home/vincent/Github/lndart/lampo.rs/target/release/deps/miniscript-7895a7902d8f17ce.long-type-8047342695735668623.txt'

For more information about this error, try `rustc --explain E0275`.
error: could not compile `miniscript` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `lampod-cli v0.1.0 (/home/vincent/Github/lndart/lampo.rs/lampod-cli)`, intermediate artifacts can be found at `/home/vincent/Github/lndart/lampo.rs/target`
make: *** [Makefile:21: install] Error 101

I am not sure how to reproduce it, but I guess you could have some idea on what kind macros is causing this error?

@apoelstra
Copy link
Member

Are you using a released version of Rust?

I believe you are hitting rust-lang/rust#110475 which should be fixed by #546.

If the bug is affecting released version of rustc then we need to backport the fix.

@vincenzopalazzo
Copy link
Author

Ah, I am on nightly, but I guess I also tried with stable, and at this point, your fix should be included inside the bdk.

Thanks

@dpc
Copy link

dpc commented Aug 14, 2023

Edit: Oh, now I see it was not backported to 8.0.1... . I updated to 9.0.0 since it seems to use the same bitcoin version.

I'm trying to update our CI to Rust 1.71 release. This forced me to update to a proper miniscript 8.0 release, which seems to work fine with existing 1.67.0 rustc.

> rustc --version
rustc 1.71.1 (eb26296b5 2023-08-03)

and i'm hitting:

fedimint-pkgs-deps>    Compiling miniscript v8.0.1
fedimint-pkgs-deps>    Compiling bitcoincore-rpc-json v0.16.0
fedimint-pkgs-deps>    Compiling electrum-client v0.12.1
fedimint-pkgs-deps>    Compiling esplora-client v0.5.0
fedimint-pkgs-deps>    Compiling secp256k1-zkp v0.7.0 (https://github.com/dpc/rust-secp256k1-zkp/?branch=sanket-pr#f29b1b8c)
fedimint-pkgs-deps> error[E0275]: overflow evaluating the requirement `F: FnMut<(&Pk,)>`
fedimint-pkgs-deps>   |
fedimint-pkgs-deps>   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`miniscript`)
fedimint-pkgs-deps>   = note: required for `&mut F` to implement `FnMut<(&Pk,)>`
fedimint-pkgs-deps>   = note: 128 redundant requirements hidden
fedimint-pkgs-deps>   = note: required for `&mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut &mut ...` to implement `FnMut<(&Pk,)>`
fedimint-pkgs-deps>   = note: the full type name has been written to '/build/source/target/release/deps/miniscript-ac0735e57f598110.long-type-2916159546684365784.txt'
fedimint-pkgs-deps> For more information about this error, try `rustc --explain E0275`.
fedimint-pkgs-deps> error: could not compile `miniscript` (lib) due to previous error
fedimint-pkgs-deps> warning: build failed, waiting for other jobs to finish...

The same code seems to fail with

@apoelstra
Copy link
Member

Ok, I can backport to 8.0 as well.

What a freeking chore though. I'm tempted to just say "we don't support rustc after 1.71" because it's incredibly demoralizing to have to clean up after the compiler authors after giving them 3 months notice of a bug.

@dpc
Copy link

dpc commented Aug 14, 2023

Since updating to 9.0 worked, I personally no longer need it. But technically 8.0 is a available, non-yanked version.

@apoelstra
Copy link
Member

I'm not going to yank it. They should yank rustc.

But glad that it's no longer an urgent issue for you.

@dpc
Copy link

dpc commented Aug 15, 2023

BTW. @apoelstra , @sanket1729 that &mut &mut &mut &mut doesn't look good. It seems to me like exactly same thing that was the rationale for rust-bitcoin/rust-bitcoin#1035 (comment) . It probably leads to large code generation increase.

On top of my head:

F: FnMut(&'a Pk) -> bool

would be better as:

F: &mut FnMut(&'a Pk) -> bool

Note: I might be wrong.

@apoelstra
Copy link
Member

@dpc the rationale for rust-bitcoin 1030 was that we had multiple functions that would non-recursively call each other, resulting in a small finite number of &muts, which we were worried would lead to inefficient code generation (and in some cases, some functions would be recompiled with different numbers of &muts yes).

The consensus encoding traits in rust-bitcoin are also not really meant to be used directly, though they can be, so we were willing to make the API a bit worse to improve this.

The situation here is different -- these functions are only called from themselves, so they should be compiled only once (per choice of generics). Basically you either have zero &muts or infinity &muts, nothing in between.

With all of our other rust-miniscript APIs that have this issue, we've fixed by having a private internal function that takes a single &mut and a public one that doesn't.

@apoelstra
Copy link
Member

I'm going to close this. We fixed it and backported to 4 or 5 old versions and nobody has complained about more versions in a while.

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

No branches or pull requests

3 participants