Skip to content

Commit 536380c

Browse files
Merge branch 'develop' into fix-flakiness-insufficient-replace-fee
2 parents 1ea5b7e + 43f1816 commit 536380c

File tree

6 files changed

+76
-1
lines changed

6 files changed

+76
-1
lines changed

src/lib/crypto/kimchi_bindings/stubs/pasta_bindings.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ module Fp = struct
6161

6262
external print : t -> unit = "caml_pasta_fp_print"
6363

64+
external print_rust : t -> unit = "caml_pasta_fp_print_rust"
65+
6466
external copy : t -> t -> unit = "caml_pasta_fp_copy"
6567

6668
external mut_add : t -> t -> unit = "caml_pasta_fp_mut_add"
@@ -128,6 +130,8 @@ module Fq = struct
128130

129131
external print : t -> unit = "caml_pasta_fq_print"
130132

133+
external print_rust : t -> unit = "caml_pasta_fq_print_rust"
134+
131135
external copy : t -> t -> unit = "caml_pasta_fq_copy"
132136

133137
external mut_add : t -> t -> unit = "caml_pasta_fq_mut_add"

src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ pub fn caml_pasta_fp_print(x: ocaml::Pointer<CamlFp>) {
207207
);
208208
}
209209

210+
#[ocaml_gen::func]
211+
#[ocaml::func]
212+
pub fn caml_pasta_fp_print_rust(x: ocaml::Pointer<CamlFp>) {
213+
println!("{}", x.as_ref().0);
214+
}
215+
210216
#[ocaml_gen::func]
211217
#[ocaml::func]
212218
pub fn caml_pasta_fp_copy(mut x: ocaml::Pointer<CamlFp>, y: ocaml::Pointer<CamlFp>) {

src/lib/crypto/kimchi_bindings/stubs/src/arkworks/pasta_fq.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ pub fn caml_pasta_fq_print(x: ocaml::Pointer<CamlFq>) {
208208
);
209209
}
210210

211+
#[ocaml_gen::func]
212+
#[ocaml::func]
213+
pub fn caml_pasta_fq_print_rust(x: ocaml::Pointer<CamlFq>) {
214+
println!("{}", x.as_ref().0);
215+
}
216+
211217
#[ocaml_gen::func]
212218
#[ocaml::func]
213219
pub fn caml_pasta_fq_copy(mut x: ocaml::Pointer<CamlFq>, y: ocaml::Pointer<CamlFq>) {

src/lib/crypto/kimchi_bindings/stubs/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ fn generate_pasta_bindings(mut w: impl std::io::Write, env: &mut Env) {
177177
decl_func!(w, env, caml_pasta_fp_to_string => "to_string");
178178
decl_func!(w, env, caml_pasta_fp_of_string => "of_string");
179179
decl_func!(w, env, caml_pasta_fp_print => "print");
180+
decl_func!(w, env, caml_pasta_fp_print_rust => "print_rust");
180181
decl_func!(w, env, caml_pasta_fp_copy => "copy");
181182
decl_func!(w, env, caml_pasta_fp_mut_add => "mut_add");
182183
decl_func!(w, env, caml_pasta_fp_mut_sub => "mut_sub");
@@ -213,6 +214,7 @@ fn generate_pasta_bindings(mut w: impl std::io::Write, env: &mut Env) {
213214
decl_func!(w, env, caml_pasta_fq_to_string => "to_string");
214215
decl_func!(w, env, caml_pasta_fq_of_string => "of_string");
215216
decl_func!(w, env, caml_pasta_fq_print => "print");
217+
decl_func!(w, env, caml_pasta_fq_print_rust => "print_rust");
216218
decl_func!(w, env, caml_pasta_fq_copy => "copy");
217219
decl_func!(w, env, caml_pasta_fq_mut_add => "mut_add");
218220
decl_func!(w, env, caml_pasta_fq_mut_sub => "mut_sub");

src/lib/pickles/test/optional_custom_gates/pickles_test_optional_custom_gates.ml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,31 @@ let main_fixed_lookup_tables_multiple_tables_multiple_lookups () =
281281
; w6 = exists Field.typ ~compute:(fun () -> v3)
282282
} ) )
283283

284+
let main_runtime_table_cfg () =
285+
let table_ids = Array.init 5 ~f:(fun i -> Int32.of_int_exn i) in
286+
let size = 10 in
287+
let first_column = Array.init size ~f:Field.Constant.of_int in
288+
Array.iter table_ids ~f:(fun table_id ->
289+
add_plonk_constraint (AddRuntimeTableCfg { id = table_id; first_column }) ) ;
290+
let num_lookup = 20 in
291+
let rec make_lookup i n =
292+
if i = n then ()
293+
else
294+
let table_id = 3 in
295+
add_plonk_constraint
296+
(Lookup
297+
{ w0 = fresh_int table_id
298+
; w1 = fresh_int 1
299+
; w2 = fresh_int 1
300+
; w3 = fresh_int 2
301+
; w4 = fresh_int 2
302+
; w5 = fresh_int 3
303+
; w6 = fresh_int 3
304+
} ) ;
305+
make_lookup (i + 1) n
306+
in
307+
make_lookup 0 num_lookup
308+
284309
let add_tests, get_tests =
285310
let tests = ref [] in
286311
( (fun name testcases -> tests := (name, testcases) :: !tests)
@@ -306,6 +331,7 @@ let main_body ~(feature_flags : _ Plonk_types.Features.t) () =
306331
if feature_flags.range_check1 then main_range_check1 () ;
307332
if feature_flags.foreign_field_add then main_foreign_field_add () ;
308333
if feature_flags.foreign_field_mul then main_foreign_field_mul () ;
334+
if feature_flags.runtime_tables then main_runtime_table_cfg () ;
309335
if feature_flags.lookup then (
310336
main_fixed_lookup_tables () ;
311337
main_fixed_lookup_tables_multiple_tables_multiple_lookups () )
@@ -390,6 +416,9 @@ let () =
390416
, Plonk_types.Features.{ none_bool with foreign_field_mul = true } )
391417
; ( "Fixed lookup tables"
392418
, Plonk_types.Features.{ none_bool with lookup = true } )
419+
; ( "Runtime lookup tables"
420+
, Plonk_types.Features.
421+
{ none_bool with lookup = true; runtime_tables = true } )
393422
]
394423
in
395424
List.iter ~f:register_feature_test configurations ;

src/lib/pickles/wrap_verifier.ml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,33 @@ struct
911911
absorb sponge PC (Boolean.true_, x_hat) ) ;
912912
let w_comm = messages.w_comm in
913913
Vector.iter ~f:absorb_g w_comm ;
914+
let runtime_comm =
915+
match messages.lookup with
916+
| Nothing
917+
| Maybe (_, { runtime = Nothing; _ })
918+
| Just { runtime = Nothing; _ } ->
919+
Pickles_types.Opt.Nothing
920+
| Maybe (b_lookup, { runtime = Maybe (b_runtime, runtime); _ }) ->
921+
let b = Boolean.( &&& ) b_lookup b_runtime in
922+
Pickles_types.Opt.Maybe (b, runtime)
923+
| Maybe (b, { runtime = Just runtime; _ })
924+
| Just { runtime = Maybe (b, runtime); _ } ->
925+
Pickles_types.Opt.Maybe (b, runtime)
926+
| Just { runtime = Just runtime; _ } ->
927+
Pickles_types.Opt.Just runtime
928+
in
929+
let absorb_runtime_tables () =
930+
match runtime_comm with
931+
| Nothing ->
932+
()
933+
| Maybe (b, runtime) ->
934+
let z = Array.map runtime ~f:(fun z -> (b, z)) in
935+
absorb sponge Without_degree_bound z
936+
| Just runtime ->
937+
let z = Array.map runtime ~f:(fun z -> (Boolean.true_, z)) in
938+
absorb sponge Without_degree_bound z
939+
in
940+
absorb_runtime_tables () ;
914941
let joint_combiner =
915942
let compute_joint_combiner (l : _ Messages.Lookup.In_circuit.t) =
916943
let absorb_sorted_1 sponge =
@@ -1244,7 +1271,7 @@ struct
12441271
let _len_4, len_4_add = Nat.N6.add Plonk_types.Lookup_sorted.n in
12451272
let len_5, len_5_add =
12461273
(* NB: Using explicit 11 because we can't get add on len_4 *)
1247-
Nat.N11.add Nat.N7.n
1274+
Nat.N11.add Nat.N8.n
12481275
in
12491276
let len_6, len_6_add = Nat.N45.add len_5 in
12501277
let num_commitments_without_degree_bound = len_6 in
@@ -1294,6 +1321,7 @@ struct
12941321
[ Pickles_types.Opt.map messages.lookup ~f:(fun l ->
12951322
l.aggreg )
12961323
; lookup_table_comm
1324+
; runtime_comm
12971325
; m.runtime_tables_selector
12981326
; m.lookup_selector_xor
12991327
; m.lookup_selector_lookup

0 commit comments

Comments
 (0)