zkp-ld / rdf-proofs

MIT License
6 stars 2 forks source link

Circuits panic #12

Open lebedenko-ubique opened 17 hours ago

lebedenko-ubique commented 17 hours ago

When running the tests for this project the code panics with:

thread 'derive_proof::tests::derive_and_verify_proof_with_less_than_eq_predicates_datetime' panicked at library/core/src/panicking.rs:221:5:
unsafe precondition(s) violated: ptr::copy requires that both pointer arguments are aligned and non-null

This is the full backtrace:

thread 'derive_proof::tests::derive_and_verify_proof_with_less_than_predicates_integer' panicked at library/core/src/panicking.rs:221:5:
unsafe precondition(s) violated: ptr::copy requires that both pointer arguments are aligned and non-null
stack backtrace:
   0: rust_begin_unwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_nounwind_fmt::runtime
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:112:18
   2: core::panicking::panic_nounwind_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:122:5
   3: core::panicking::panic_nounwind
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/panicking.rs:221:5
   4: core::intrinsics::copy::precondition_check
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ub_checks.rs:68:21
   5: core::intrinsics::copy
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ub_checks.rs:75:17
   6: wasmer_vm::instance::VMInstance::new
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-vm-3.3.0/src/instance/mod.rs:1088:9
   7: wasmer_compiler::engine::artifact::Artifact::instantiate
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-compiler-3.3.0/src/engine/artifact.rs:517:22
   8: wasmer::sys::module::Module::instantiate
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-3.3.0/src/sys/module.rs:142:39
   9: wasmer::sys::instance::Instance::new
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-3.3.0/src/sys/instance.rs:49:26
  10: wasmer::instance::Instance::new
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wasmer-3.3.0/src/instance.rs:69:33
  11: legogroth16::circom::witness::WitnessCalculator<E>::from_module
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/legogroth16-0.15.0/src/circom/witness.rs:91:34
  12: legogroth16::circom::witness::WitnessCalculator<E>::from_wasm_bytes
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/legogroth16-0.15.0/src/circom/witness.rs:75:9
  13: proof_system::sub_protocols::r1cs_legogorth16::R1CSLegogroth16Protocol<E>::init
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proof_system-0.31.0/src/sub_protocols/r1cs_legogorth16.rs:72:29
  14: proof_system::prover::<impl proof_system::proof::Proof<E>>::new
             at /Users/alexey/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proof_system-0.31.0/src/prover.rs:591:33
  15: rdf_proofs::derive_proof::derive_proof_value
             at ./src/derive_proof.rs:1180:17
  16: rdf_proofs::derive_proof::derive_proof
             at ./src/derive_proof.rs:254:31
  17: rdf_proofs::derive_proof::derive_proof_string
             at ./src/derive_proof.rs:349:25
  18: rdf_proofs::derive_proof::tests::derive_and_verify_proof_with_less_than_predicates_integer
             at ./src/derive_proof.rs:3550:29
  19: rdf_proofs::derive_proof::tests::derive_and_verify_proof_with_less_than_predicates_integer::{{closure}}
             at ./src/derive_proof.rs:3494:67
  20: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
  21: core::ops::function::FnOnce::call_once
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread caused non-unwinding panic. aborting.

I'm running the code on a MacBook Pro.

yamdan commented 3 hours ago

Thank you for your report. The issue you're encountering stems from an older version of wasmer that we are indirectly relying on, which seems to be imcompatible with the latest Rust upgrade. You can temporarily work around this problem using one of the following methods:

a. Downgrade Rust to version 1.77 or below:
rustup default 1.77

OR

b. Update the libraries related to docknetwork/crypto that depend on wasmer to their latest versions. Specifically, you can modify the Cargo.toml of this crate (@zkp-ld/rdf-proofs) to point to the latest GitHub versions as follows:

proof_system = { git = "https://github.com/docknetwork/crypto", version = "0.31", default-features = false }
bbs_plus = { git = "https://github.com/docknetwork/crypto", version = "0.22", default-features = false }
dock_crypto_utils = { git = "https://github.com/docknetwork/crypto", version = "0.20", default-features = false }
legogroth16 = { git = "https://github.com/docknetwork/crypto", version = "0.15", default-features = false, features = ["circom"] }

(ref: https://github.com/docknetwork/crypto/issues/25)

Once the upgraded docknetwork/crypto crates are officially released, we’ll be able to replace the GitHub references with direct links to crates.io. This will be the permanent solution going forward.