Skip to content

Commit 732e04b

Browse files
committed
Fixed args bug that came from internal o1js change
1 parent 85bea6c commit 732e04b

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

packages/common/src/zkProgram/WithZkProgram.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ export const MOCK_VERIFICATION_KEY = {
7878

7979
export function toProver(
8080
methodName: string,
81-
simulatedMethod: DecoratedMethod,
82-
isFirstParameterPublicInput: boolean,
8381
areProofsEnabled: boolean,
8482
...args: ArgumentTypes
8583
) {

packages/module/src/method/runtimeMethod.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import type { RuntimeModule } from "../runtime/RuntimeModule.js";
1919

2020
import { MethodParameterEncoder } from "./MethodParameterEncoder";
21+
import { Runtime } from "../runtime/Runtime";
2122

2223
const errors = {
2324
runtimeNotProvided: (name: string) =>
@@ -70,6 +71,7 @@ export function toEventsHash(
7071

7172
export type WrappedMethod = (...args: ArgumentTypes) => MethodPublicOutput;
7273
export type AsyncWrappedMethod = (
74+
publicInput: undefined,
7375
...args: ArgumentTypes
7476
) => Promise<{ publicOutput: MethodPublicOutput }>;
7577

@@ -86,6 +88,12 @@ export function toWrappedMethod(
8688
);
8789

8890
const wrappedMethod: AsyncWrappedMethod = async (
91+
/**
92+
* Here, we ignore the publicInput, because o1js internally always populates
93+
* the public input as undefined if a method doesn't use it.
94+
* Therefore, the args array starts at position 1 of the args given by o1js
95+
*/
96+
_publicInput,
8997
...args
9098
): Promise<{ publicOutput: MethodPublicOutput }> => {
9199
await Reflect.apply(moduleMethod, this, args);
@@ -237,19 +245,6 @@ function runtimeMethodInternal(options: {
237245
) {
238246
const constructorName = this.name!;
239247

240-
/**
241-
* If its a top level method call, wrap it into a wrapped method,
242-
* since it'll be turned into a real/mock prover in provableMethod().
243-
*
244-
* Otherwise provableMethod() will just call the originalMethod provided
245-
* if method is not called at the top level.
246-
*/
247-
const simulatedWrappedMethod = Reflect.apply(toWrappedMethod, this, [
248-
methodName,
249-
simulatedMethod,
250-
options,
251-
]);
252-
253248
/**
254249
* Before the prover runs, make sure it is operating on the correct
255250
* RuntimeMethodExecutionContext state, meaning it enters and exits
@@ -259,8 +254,6 @@ function runtimeMethodInternal(options: {
259254
executionContext.beforeMethod(constructorName, methodName, args);
260255
const innerProver = toProver(
261256
combineMethodName(constructorName, methodName),
262-
simulatedWrappedMethod,
263-
false,
264257
this.appChain!.areProofsEnabled,
265258
...args
266259
).bind(this);

0 commit comments

Comments
 (0)