Skip to content

Commit

Permalink
fix batch reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
mitschabaude committed Sep 24, 2024
1 parent 73e509a commit a91ed3a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/lib/mina/actions/batch-reducer-program.unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ await describe('action stack prover', async () => {
let { isEmpty, proof } = await proveActionStack(
endActionState,
witnesses,
stackProgram as any
stackProgram
);
console.timeEnd('prove');

Expand All @@ -67,7 +67,7 @@ await describe('action stack prover', async () => {
let { isEmpty, proof } = await proveActionStack(
endActionState,
witnesses,
stackProgram as any
stackProgram
);
console.timeEnd('prove');

Expand Down
22 changes: 10 additions & 12 deletions src/lib/mina/actions/batch-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class BatchReducer<
this.Batch = ActionBatch(this.actionType);

this.maxUpdatesFinalProof = maxUpdatesFinalProof;
this.program = actionStackProgram(maxUpdatesPerProof) as any;
this.program = actionStackProgram(maxUpdatesPerProof);
this.BatchProof = ZkProgram.Proof(this.program);

assert(
Expand Down Expand Up @@ -689,12 +689,12 @@ async function proveActionStack(

for (let i = nChunks - 1; i >= 0; i--) {
let isRecursive = Bool(i < nChunks - 1);
proof = await program.proveChunk(
({ proof } = await program.proveChunk(
endActionState,
proof,
isRecursive,
chunks[i]
);
));
}
// sanity check
proof.publicOutput.stack.assertEquals(stack.hash, 'Stack hash mismatch');
Expand Down Expand Up @@ -729,7 +729,7 @@ type ActionStackProgram = {
proofSoFar: ActionStackProof,
isRecursive: Bool,
actionWitnesses: Unconstrained<ActionWitnesses>
): Promise<ActionStackProof>;
): Promise<{ proof: ActionStackProof }>;

maxUpdatesPerProof: number;
};
Expand Down Expand Up @@ -799,14 +799,12 @@ function actionStackProgram(maxUpdatesPerProof: number) {
proofSoFar.publicOutput,
initialState
);

return {
publicOutput: actionStackChunk(
maxUpdatesPerProof,
startState,
witnesses
),
};
let publicOutput = actionStackChunk(
maxUpdatesPerProof,
startState,
witnesses
);
return { publicOutput };
},
},
},
Expand Down
6 changes: 2 additions & 4 deletions src/lib/mina/actions/offchain-state-rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,13 @@ function OffchainStateRollup({
actions: ActionIterator,
tree: IndexedMerkleMapN
) {
let commitment = merkleUpdateBatch(
let commitments = merkleUpdateBatch(
{ maxActionsPerProof, maxActionsPerUpdate },
stateA,
actions,
tree
);
return {
publicOutput: commitment,
};
return { publicOutput: commitments };
},
},
/**
Expand Down
3 changes: 1 addition & 2 deletions src/lib/proof-system/zkprogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -923,8 +923,7 @@ type ZkProgram<
InferProvableOrVoid<Get<Config, 'publicOutput'>>,
Config['methods'][I]
>;
},
_Unused extends any = any // TODO remove, left here to be non-breaking
}
> = ReturnType<typeof ZkProgram<Config, Methods>>;

class SelfProof<PublicInput, PublicOutput> extends Proof<
Expand Down

0 comments on commit a91ed3a

Please sign in to comment.