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

[o1js-main] Add missing runtime table commits in wrap verifier. #14662

Closed
wants to merge 6 commits into from

Conversation

dannywillems
Copy link
Member

Orthogonal to the issue raised by o1-labs/o1js#1284, but there is a discrepancy between o1js-main and develop for Pickles. In particular this one.

Explain your changes:

  • Add runtime table commitments to compute the joint combiner in the wrap verifier.

Explain how you tested your changes:

  • cd src/lib/pickles && dune build @runtest

Checklist:

  • Dependency versions are unchanged
    • Notify Velocity team if dependencies must change in CI
  • Modified the current draft of release notes with details on what is completed or incomplete within this project
  • Document code purpose, how to use it
    • Mention expected invariants, implicit constraints
  • Tests were added for the new behavior
    • Document test purpose, significance of failures
    • Test names should reflect their purpose
  • All tests pass (CI will check this if you didn't)
  • Serialized types are in stable-versioned modules
  • Does this close issues? List them
  • Closes #0000

@dannywillems dannywillems requested a review from a team as a code owner December 5, 2023 12:38
@dannywillems
Copy link
Member Author

!ci-build-me

Copy link
Contributor

@rbonichon rbonichon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes suggested

Comment on lines 285 to 287
let table_ids = Array.init 5 ~f:(fun i -> Int32.of_int_exn i) in
let size = 10 in
let first_column = Array.init size ~f:Field.Constant.of_int in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 mini points here:

  • pick one style indirect let size = ... in Array.init size or the direct Array.init <size> (indirect is ok)
  • why 5 or 10? could they be optional labeled parameters?
  • preferInt32.of_int_exn to`(fun i -> Int32.of_int_exn i)

Comment on lines 292 to 305
if i = n then ()
else
let table_id = 3 in
add_plonk_constraint
(Lookup
{ w0 = fresh_int table_id
; w1 = fresh_int 1
; w2 = fresh_int 1
; w3 = fresh_int 2
; w4 = fresh_int 2
; w5 = fresh_int 3
; w6 = fresh_int 3
} ) ;
make_lookup (i + 1) n
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simpler code is possible

Suggested change
if i = n then ()
else
let table_id = 3 in
add_plonk_constraint
(Lookup
{ w0 = fresh_int table_id
; w1 = fresh_int 1
; w2 = fresh_int 1
; w3 = fresh_int 2
; w4 = fresh_int 2
; w5 = fresh_int 3
; w6 = fresh_int 3
} ) ;
make_lookup (i + 1) n
if i <> n then
let table_id = 3 in
add_plonk_constraint
(Lookup
{ w0 = fresh_int table_id
; w1 = fresh_int 1
; w2 = fresh_int 1
; w3 = fresh_int 2
; w4 = fresh_int 2
; w5 = fresh_int 3
; w6 = fresh_int 3
} ) ;
make_lookup (i + 1) n

@rbonichon
Copy link
Contributor

rbonichon commented Dec 5, 2023

Also nix build is failing with

error: hash mismatch in fixed-output derivation '/nix/store/rmb0zgvs7rplhpsf70wqz7xi02xm7c2p-wasm-bindgen-cli-0.2.85.tar.gz.drv':
         specified: sha256-0rK+Yx4/Jy44Fw5VwJ3tG243ZsyOIBBehYU54XP/JGk=
            got:    sha256-0pTIzpu7dJM34CXmi83e8UV0E3N2bKJiOMw5WJQ2s/Y=

What did we change wrt to wasm-bindgen-cli?

Copy link
Contributor

@rbonichon rbonichon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to have a fix ready for failing nix build

Copy link
Contributor

@jspada jspada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, but better for someone familiar with runtime tables to approve.

let rec make_lookup i n =
if i = n then ()
else
let table_id = 3 in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's 3?

@@ -390,6 +416,9 @@ let () =
, Plonk_types.Features.{ none_bool with foreign_field_mul = true } )
; ( "Fixed lookup tables"
, Plonk_types.Features.{ none_bool with lookup = true } )
; ( "Runtime lookup tables"
, Plonk_types.Features.
{ none_bool with lookup = true; runtime_tables = true } )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

let runtime_comm =
match messages.lookup with
| Nothing
| Maybe (_, { runtime = Nothing; _ })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is for nondeterminism?

match messages.lookup with
| Nothing
| Maybe (_, { runtime = Nothing; _ })
| Just { runtime = Nothing; _ } ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's Just?

| Maybe (_, { runtime = Nothing; _ })
| Just { runtime = Nothing; _ } ->
Pickles_types.Opt.Nothing
| Maybe (b_lookup, { runtime = Maybe (b_runtime, runtime); _ }) ->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future, can you explain (to me here) the format / what's going on here?

()
| Maybe (b, runtime) ->
let z = Array.map runtime ~f:(fun z -> (b, z)) in
absorb sponge Without_degree_bound z
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why without degree bound?

@dannywillems
Copy link
Member Author

Closing as it is in develop.

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 this pull request may close these issues.

5 participants