a16z / jolt

The simplest and most extensible zkVM. Fast and fully open source from a16z crypto and friends. ⚡
https://jolt.a16zcrypto.com
MIT License
580 stars 105 forks source link

guest can't use serde #394

Open sid-alluri opened 2 weeks ago

sid-alluri commented 2 weeks ago

I am trying to read some JSON files from the guest using serde_json, which is leading to an error. Instead of reading from the guest, I can read the data from the host and send it to the guest. I am using a custom struct to read the data and ideally would want to pass it to the guest (as it has many fields). But to do that, I need serde Serialize, Deserialize to make the struct serializable, which again causes the same error.

The error:

error[E0152]: found duplicate lang item `panic_impl`
  --> guest/src/lib.rs:44:1
   |
44 | #[jolt::provable]
   | ^^^^^^^^^^^^^^^^^
   |
   = note: the lang item is first defined in crate `std` (which `serde` depends on)
   = note: first definition in `std` loaded from /Users/alluri/.jolt/rust/build/host/stage2/lib/rustlib/riscv32i-jolt-zkvm-elf/lib/libstd-8cbddb4876a7be76.rlib
   = note: second definition in the local crate (`guest`)
   = note: this error originates in the attribute macro `jolt::provable` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0152`.
error: could not compile `guest` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

how can I resolve this? thanks.

moodlezoup commented 2 weeks ago

Is there a reason why you aren't passing the struct directly from host to guest?