framework icon indicating copy to clipboard operation
framework copied to clipboard

Provable.array doesn't work as state, if passed within a struct without a key.

Open maht0rz opened this issue 2 years ago • 0 comments

The following array-struct breaks the on-chain state due to Provable.witness not being able to process the dummy value we generate from the Ballot struct.

const BALLOT_LENGTH = 10;
export class Ballot extends Struct(Provable.Array(UInt64, BALLOT_LENGTH)) {
  static empty(): Ballot {
    const uints = new Array(10).fill(UInt64.from(0));
    return new Ballot(uints);
  }
}

Temporary workaround is to define the Ballot like this:

const BALLOT_LENGTH = 10;
class Ballot extends Struct({
  uints: Provable.Array(UInt64, BALLOT_LENGTH),
}) {
  public static empty(): Ballot {
    const uints = new Array(10).fill(UInt64.from(0));
    return new Ballot({ uints });
  }
}

maht0rz avatar Oct 12 '23 14:10 maht0rz