3

I have a contract that implements some ZKP verification logic with plonk. The verification logic is contained in some other crate that can be compiled to Wasm, and there are wasm-pack tests like this:

#[wasm_bindgen_test]
fn generate_proof_test() {
        // const DEPTH: usize = DEFAULT_DEPTH;
        let R = ...;
        let proof: [u8; 1040] = ...;
        let account = alice_account;
        let h: [u8; 32] = ...;

        verify_proof(R, proof, account, h).unwrap();
    }

The problem is that this test works fine with wasm-pack test, but when I import this very same logic into my ink! contract, the call fails and I get { Err: { Module: { index: 8 error: 0x0b000000 } } }, which is ContractTrapped in polkadot-v0.9.37 version of pallet-contracts. The verification function is quite large (roughly 70kB, optimized), and it made me wonder if there can be differences between wasm-pack Wasm and wasmi Wasm in pallet-contracts. When I debugged the exact Trap reason, it turned out to be an unreachable instruction encountered.

So, my question is: should I try looking harder for any logical errors in my code, or can the call somehow fail with an unreachable instruction due to the size?

2 Answers 2

1

I don't think this is related of the size (of your contract) you can still tweak this value and check. But this will happen at upload time not at call time.

One great option would be to add ink! e2e tests it will be easier to debug.

Can you share which node & version are you using ?

1
  • 1
    I'm using the latest pallet-contracts at 0.9.37, ink version 4. E2E tests don't work yet because of this issue :) Mar 2, 2023 at 13:20
0

The problem was within some of my dependencies. Rolling them back helped.

2
  • Which dependencies were the cause of this issue?
    – Snowmead
    May 19, 2023 at 14:49
  • @Snowmead it was a ZKP library, dusk_plonk. May 20, 2023 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.