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

Considering ZkProgram Interface #1701

Open
harrysolovay opened this issue Jun 25, 2024 · 2 comments
Open

Considering ZkProgram Interface #1701

harrysolovay opened this issue Jun 25, 2024 · 2 comments

Comments

@harrysolovay
Copy link
Collaborator

Looking at the recursion docs, I think some subtle changes would result in greater legibility. Let's consider the following:

const Rollup = ZkProgram({
  name: "rollup-example",
  publicInput: Field,

  methods: {
    oneStep: {
    privateInputs: [ Field, Field, Field, Field, Field, MerkleMapWitness ],

    method(
      state: RollupState,
      initialRoot: Field,
      latestRoot: Field,
      key: Field,
      currentValue: Field,
      incrementAmount: Field,
      merkleMapWitness: MerkleMapWitness
    ) {
      // ...
  1. It's difficult to identify which element of privateInputs corresponds to which of the rest-spread parameters of method.
  2. We should be able to infer the types of the rest-spread tuple from privateInputs.
  3. We're unable to attach tsdocs to parameters. This would potentially be valuable for consumers of the program.

Ideally we could do the following.

const Rollup = ZkProgram({
  name: "rollup-example",
  publicInput: Field,

  methods: {
    oneStep: Method({
      /** some docs that are now attached to the `initialRoot` key */
      initialRoot: Field,
      latestRoot: Field,
      key: Field,
      currentValue: Field,
      incrementAmount: Field,
      merkleMapWitness: MerkleMapWitness,
    }, (state, { initialRoot, latestRoot, key, currentValue, incrementAmount, merkleMapWitness }) => {
      // ...

This also spares the developer of needing to––in their minds––shift the private inputs over by 1 (accommodating the public input).

@mitschabaude
Copy link
Member

I agree with this proposal! Much more self-documenting. The required base type for method inputs could be Record<string, Provable<any>>

@mitschabaude mitschabaude added breaking Issues that will lead to breaking changes and removed breaking Issues that will lead to breaking changes labels Jul 4, 2024
@mitschabaude
Copy link
Member

would be awesome to combine this with #510 somehow

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

No branches or pull requests

2 participants