Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling ZkProgram in the browser never ends #1891

Closed
berkay1532 opened this issue Nov 7, 2024 · 16 comments · Fixed by #1906
Closed

Compiling ZkProgram in the browser never ends #1891

berkay1532 opened this issue Nov 7, 2024 · 16 comments · Fixed by #1906

Comments

@berkay1532
Copy link

I noticed that a simple zkprogram I created did not compile in the browser. Then I tried to compile the zkprogram in the tutorial to see if the problem was with my program, but it did not compile either. Finally, when I removed the "SelfProof" parts in the zkprogram and compiled it, I saw that the process was completed without any problems. That's why I decided to open an issue about this.

Tutorial ZkProgram
`
const Add = ZkProgram({
name: 'add-example',
publicInput: Field,

methods: {
init: {
privateInputs: [],

  async method(state: Field) {
    state.assertEquals(Field(0));
  },
},

addNumber: {
  privateInputs: [SelfProof, Field],

  async method(
    newState: Field,
    earlierProof: SelfProof<Field, void>,
    numberToAdd: Field
  ) {
    earlierProof.verify();
    newState.assertEquals(earlierProof.publicInput.add(numberToAdd));
  },
},

add: {
  privateInputs: [SelfProof, SelfProof],

  async method(
    newState: Field,
    earlierProof1: SelfProof<Field, void>,
    earlierProof2: SelfProof<Field, void>
  ) {
    earlierProof1.verify();
    earlierProof2.verify();
    newState.assertEquals(
      earlierProof1.publicInput.add(earlierProof2.publicInput)
    );
  },
},

},
});
`

@YofiY
Copy link

YofiY commented Nov 9, 2024

I have been having the same issue.

@45930
Copy link
Contributor

45930 commented Nov 10, 2024

What version of o1js are you using? Could you make sure it's either 1.9.1 or 2.0.0?

@berkay1532
Copy link
Author

Yes i tried both.Unfortunately neither worked.

@kadirchan
Copy link
Contributor

#1890 (comment)
can you try "o1js": "https://pkg.pr.new/o1-labs/o1js@fc16ce3"

@berkay1532
Copy link
Author

Finally, it's working! This problem took me about 10 days. Thank u @kadirchan.

@45930
Copy link
Contributor

45930 commented Nov 15, 2024

@berkay1532 , I don't think we can close this issue if the fix is to use a non-released version of o1js. We still need to release a fixed version.

@45930 45930 reopened this Nov 15, 2024
@berkay1532
Copy link
Author

Yep , i think so. Let’s not close till it is solved

@mitschabaude
Copy link
Collaborator

It sounds like the fix is to use an older o1js version, so there was a recent regression?

@45930
Copy link
Contributor

45930 commented Nov 19, 2024

@mitschabaude we believe it's this one: #1874

Up to 1.9.0 compiling in the browser didn't work, then at exactly 1.9.0, when the pickles bug was fixed, but we introduced a performance issue, compilation in the browser did work. Then in 1.9.1 and the releases since, after we resolved the performance issue, it doesn't work in the browser again.

@mitschabaude
Copy link
Collaborator

Oh interesting. What about our CI tests which compile in the browser though? Is there a more specific situation in which it doesn't work?

@mitschabaude
Copy link
Collaborator

Ah it's only when using recursion. (Just like the performance regression!)

@mitschabaude
Copy link
Collaborator

The performance regression happened in the recursive verifier.

Since #1874 fixed that regression, we can conclude that maybe_lagrange_basis is called in the recursive verifier.

Since this part now seems to break, a very likely issue is that the lagrange basis is not present in the recursive verifier. in the browser at least!

the browser case is different from nodejs at least in that there is no caching.
so it could be that the cache-miss case doesn't work in the browser. looking into it!

@mitschabaude
Copy link
Collaborator

@45930 I identified and fixed the problem. It's on me 😅

o1-labs/o1js-bindings#313
#1906

@kadirchan
Copy link
Contributor

kadirchan commented Nov 24, 2024

upgraded mine from "o1js": "https://pkg.pr.new/o1-labs/o1js@fc16ce3" to o1js 2.1 and it does not compile recursive zkProgram anymore
it works in nodejs btw

here is corresponding worker

@45930
Copy link
Contributor

45930 commented Nov 24, 2024

@kadirchan the fix has not been released yet. It is scheduled for the next release, which ought to be this week. You can check the changelog for details

@kadirchan
Copy link
Contributor

oh I missed unreleased part sorry for inconvenience 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants