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

Merkle trees readme example fails to compile with Nargo 1.0.0-beta-* #32

Open
chancehudson opened this issue Feb 20, 2025 · 0 comments
Open
Labels
bug 🐛 Something isn't working

Comments

@chancehudson
Copy link

Describe the bug
Nargo 1.0.0 beta fails to compile merkle tree example. This is problematic because the 1.0.0 beta is the default version installed by noirup. This problem can be avoided by running noirup -v 0.39.0

To Reproduce
Install the latest noir version using the quick-start instructions. Take the demo code from the merkle trees package and attempt to compile.

Expected behavior
Circuit compiles.

Screenshots
Error output

error: expected type SparseMerkleTree<T>, found type ()
  ┌─ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:7:12
  │
7 │     pub fn default(root: T, leaf_hasher: fn([T; 3]) -> T, hasher: fn([T; 2]) -> T) -> Self {}
  │            -------                                                                    ---- expected SparseMerkleTree<T> because of return type
  │            │
  │            () returned here
  │
  = implicitly returns `()` as its body has no tail or `return` expression

error: Expected type fn([Field; 3]) -> Field, found type fn([T; 3]) -> T
   ┌─ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:23:23
   │
23 │         Self::from(0, leaf_hasher, hasher)
   │                       -----------
   │

error: Expected type fn([Field; 2]) -> Field, found type fn([T; 2]) -> T
   ┌─ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:23:36
   │
23 │         Self::from(0, leaf_hasher, hasher)
   │                                    ------
   │

error: Only struct types can be used in constructor expressions
   ┌─ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:29:9
   │
29 │         Self { root, hasher }
   │         ---- _ has no fields to construct it with
   │

error: Could not resolve 'T' in path
   ┌─ /Users/chance/nargo/github.com/privacy-scaling-explorations/zk-kit.noir/main/packages/merkle-trees/src/types.nr:46:20
   │
46 │         Self::from(T::default(), hasher)
   │                    -
   │

Aborting due to 5 previous errors

main.nr:

use trees::merkle::MerkleTree;
use std::hash::poseidon;
use trees::types::MT_Creator;
use trees::types::Modifier;

fn main(entry: Field, paths: [Field; 0]) -> pub Field {
    let mut mt = MerkleTree::new(poseidon::bn254::hash_2);
    mt.add(entry, 0, paths);
    //mt.membership(entry, 0, paths);
    0
}

#[test]
fn test_main() {
    //let _ = main(1, 2);

    // Uncomment to make test fail
    // main(1, 1);
}

Technologies (please complete the following information):

nargo --version
nargo version = 1.0.0-beta.2
noirc version = 1.0.0-beta.2+1a2a08cbcb68646ff1aaef383cfc1798933c1355
(git version hash: 1a2a08cbcb68646ff1aaef383cfc1798933c1355, is dirty: false)

Additional context
Add any other context about the problem here.

@chancehudson chancehudson added the bug 🐛 Something isn't working label Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant