Skip to content

Exception: deserialiseLazyOrPanic ... DeserialiseFailure 1 "Expected index < 2" #13

Open
@haroldcarr

Description

@haroldcarr

Do you have any ideas off-the-top-of-your-head.

I know from looking around that the "real" error is coming from Codec.Borsch.Decoding decodeEnum

Also, note the size - it is BIG.

groth16ProvingKeyJsonNew rng 8 eg
-- *** Exception: deserialiseLazyOrPanic for Proxy * (Either Text Groth16ProvingKeyJSON): DeserialiseFailure 1 "Expected index < 2"
.....
44,49,53,53,44,49,57,52,44,50,50,54,44,49,52,57,44,49,56,57,44,49,55,49,44,49,56,51,93,125] (14839025)
CallStack (from HasCallStack):
  error, called at src/Foreign/Rust/Marshall/Util.hs:39:19 in frgn-rst-0.1.0-bce6ec5d:Foreign.Rust.Marshall.Util
  deserialiseLazyOrPanic, called at src/Foreign/Rust/Marshall/Util.hs:31:28 in frgn-rst-0.1.0-bce6ec5d:Foreign.Rust.Marshall.Util
  deserialiseStrictOrPanic, called at src/Foreign/Rust/Marshall/Variable.hs:96:17 in frgn-rst-0.1.0-bce6ec5d:Foreign.Rust.Marshall.Variable

For serialization in Rust, I use this macro:

macro_rules! to_from_haskell_via_ark_compressed {
    ($impl_ty:ty) => {

        impl ToHaskell<DNC> for $impl_ty {
            fn to_haskell<W: Write>(&self, writer: &mut W, tag: PhantomData<DNC>) -> Result<()> {
                let mut serz = vec![];
                match CanonicalSerialize::serialize_compressed(self, &mut serz)
                {
                    Ok(()) => serz.to_haskell(writer, tag),
                    Err(e) =>
                        Err(Box::new(std::io::Error::new(
                            std::io::ErrorKind::InvalidData,
                            format!("to_haskell serialization error: {:?}", e)
                        )))

                }
            }
        }

        impl FromHaskell<DNC> for $impl_ty {
            fn from_haskell(buf: &mut &[u8], tag: PhantomData<DNC>) -> Result<Self> {
                let bytes = <Vec<u8>>::from_haskell(buf, tag)?;
                match CanonicalDeserialize::deserialize_compressed(&bytes[..])
                {
                    Ok(deserz) => Ok(deserz),
                    Err(e)     =>
                        Err(Box::new(std::io::Error::new(
                            std::io::ErrorKind::InvalidData,
                            format!("from_haskell deserialization error: {:?}", e)
                        )))
                }
            }
        }
    }
}

I have used that macro for other types with with smaller instances successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions