#Provable.If + optimization.

1 messages · Page 1 of 1 (latest)

bold hollow
#

I have this line:
Provable.if(Bool,A,B)

Suppose A is very easy to compute and B is very complex , does the proof generation time , or space matter with this.
Sometimes the proof generation takes a lot of memory.
When and How to optimise my contract.

Like, for example
I believe that using field.lessthan takes more constraints than field.add, and hence more computation.

What would be a good place to know about these things?

#

Provable.If + optimization.

sick pumice
#

I would say that the basic optimization technique means that you do all the calculations in the JS code and only check the results in the provable code, trying to use only add and multiply operators.

For example, if your program needs to calculate c = a /b, you calculate c in the JS code, and your SmartContract takes a, b, and c as inputs and uses something like

a.assertsEqual(c.mul(b));

to check that c is calculated correctly

lucid path
#

What would be a good place to know about these things?

@bold hollow print out the constraint system to inspect it and see how much constraints you use!

let cs = Provable.constraintSystem(() => {
  let x = Provable.witness(Field, () => Field(0));
  let y = Provable.witness(Field, () => Field(0));
  x.lessThan(y);
});

cs.print();