From 5585e870e3695c9fd575def72d8678fd7e5a664d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 16:02:23 +0200 Subject: [PATCH 01/18] Bump up dune, alcotest and js_of_ocaml Run ``` opam install alcotest.1.7.0 dune.3.9.1 js_of_ocaml.5.4.0 opam switch export opam.export ``` --- opam.export | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/opam.export b/opam.export index 655b623d358..17f311a2353 100644 --- a/opam.export +++ b/opam.export @@ -1,6 +1,7 @@ opam-version: "2.0" +compiler: ["ocaml-base-compiler.4.14.0"] roots: [ - "alcotest.1.1.0" + "alcotest.1.7.0" "angstrom.0.15.0" "async_ssl.v0.14.0" "bignum.v0.14.0" @@ -16,9 +17,9 @@ roots: [ "graphql-cohttp.0.13.0" "graphql-lwt.0.13.0" "graphql_ppx.1.2.2" - "js_of_ocaml.4.0.0" - "js_of_ocaml-ppx.4.0.0" - "js_of_ocaml-toplevel.4.0.0" + "js_of_ocaml.5.4.0" + "js_of_ocaml-ppx.5.4.0" + "js_of_ocaml-toplevel.5.4.0" "lmdb.1.0" "menhir.20210419" "merlin.4.5-414" @@ -41,7 +42,7 @@ roots: [ "yojson.1.7.0" ] installed: [ - "alcotest.1.1.0" + "alcotest.1.7.0" "angstrom.0.15.0" "asetmap.0.8.1" "astring.0.8.5" @@ -74,7 +75,7 @@ installed: [ "caqti-driver-postgresql.1.5.1" "charInfo_width.1.1.0" "check_opam_switch.~dev" - "cmdliner.1.0.3" + "cmdliner.1.2.0" "cohttp.5.0.0" "cohttp-async.5.0.0" "conduit.4.0.0" @@ -104,33 +105,35 @@ installed: [ "digestif.0.9.0" "domain-name.0.3.0" "dot-merlin-reader.4.2" - "dune.3.3.1" + "dune.3.9.2" "dune-build-info.3.1.1" "dune-configurator.2.8.2" "dune-private-libs.2.6.2" + "duration.0.2.1" "easy-format.1.3.2" "either.1.0.0" "eqaf.0.9" "extlib.1.7.8" "fieldslib.v0.14.0" "fix.20201120" - "fmt.0.8.6" + "fmt.0.9.0" "fpath.0.7.3" + "gen.1.1" "graphql.0.13.0" "graphql-async.0.13.0" "graphql-cohttp.0.13.0" "graphql-lwt.0.13.0" - "graphql_parser.0.12.2" + "graphql_parser.0.14.0" "graphql_ppx.1.2.2" "incremental.v0.14.0" "integers.0.4.0" "ipaddr.5.0.1" "ipaddr-sexp.5.0.1" "jane-street-headers.v0.14.0" - "js_of_ocaml.4.0.0" - "js_of_ocaml-compiler.4.0.0" - "js_of_ocaml-ppx.4.0.0" - "js_of_ocaml-toplevel.4.0.0" + "js_of_ocaml.5.4.0" + "js_of_ocaml-compiler.5.4.0" + "js_of_ocaml-ppx.5.4.0" + "js_of_ocaml-toplevel.5.4.0" "jsonm.1.0.1" "jst-config.v0.14.1" "lambda-term.3.1.0" @@ -150,8 +153,8 @@ installed: [ "mew.0.1.0" "mew_vi.0.5.0" "minicli.5.0.2" - "mirage-crypto-ec.0.11.0" "mirage-crypto.0.11.0" + "mirage-crypto-ec.0.11.0" "mirage-crypto-rng.0.11.0" "mirage-crypto-rng-async.0.11.0" "mmap.1.1.0" @@ -231,6 +234,7 @@ installed: [ "result.1.5" "rpc_parallel.v0.14.0" "rresult.0.6.0" + "sedlex.2.5" "seq.base" "sexp_diff_kernel.v0.14.0" "sexplib.v0.14.0" From 9e13cccd57f3932a9f21af2fd4d4c90045300c4c Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 16:07:57 +0200 Subject: [PATCH 02/18] Fix build error related to upgrade Inspired from https://github.com/MinaProtocol/mina/pull/12978/ --- src/app/logproc/logproc.ml | 4 ++-- src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/logproc/logproc.ml b/src/app/logproc/logproc.ml index 8c519b962f1..b4eaa01b855 100644 --- a/src/app/logproc/logproc.ml +++ b/src/app/logproc/logproc.ml @@ -291,6 +291,6 @@ let () = , {|logproc -f '.message match /broadcast/ && .metadata.peer.host == "182.9.63.3" || .metadata.peer.discover_port == 8302|} ) ] in - Term.info ~version:"0.1" ~doc ~exits:Term.default_exits ~man "logproc" + Cmd.info ~version:"0.1" ~doc ~man "logproc" in - Term.(exit @@ eval (main_term, main_info)) + Stdlib.exit @@ Cmd.eval @@ Cmd.v main_info main_term diff --git a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml index 925d9801918..9b5625053d5 100644 --- a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml @@ -81,7 +81,7 @@ module TextFormat_0_0_4 = struct | None -> (label_names, label_values) | Some (label_name, label_value) -> - let label_value_str = Fmt.strf "%a" output_value label_value in + let label_value_str = Fmt.str "%a" output_value label_value in (label_name :: label_names, label_value_str :: label_values) in Fmt.pf f "%a%s%a %a@." MetricName.pp base ext From 1a7c4c28fc926f8fbe48f7a0d286e5ed44ccc3e8 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 17:16:21 +0200 Subject: [PATCH 03/18] Bump up container images --- buildkite/src/Constants/ContainerImages.dhall | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/buildkite/src/Constants/ContainerImages.dhall b/buildkite/src/Constants/ContainerImages.dhall index a171c3d2826..f23e75e69e4 100644 --- a/buildkite/src/Constants/ContainerImages.dhall +++ b/buildkite/src/Constants/ContainerImages.dhall @@ -2,15 +2,20 @@ -- NOTE: minaToolchain is the default image for various jobs, set to minaToolchainBullseye -- NOTE: minaToolchainBullseye is also used for building Ubuntu Focal packages in CI -- NOTE: minaToolchainBookworm is also used for building Ubuntu Jammy packages in CI -{ - toolchainBase = "codaprotocol/ci-toolchain-base:v3", - minaToolchainBuster = "gcr.io/o1labs-192920/mina-toolchain@sha256:c3320cb0f75727d5f1e98c138dcf2c4cca29862413b4acfa529828793a650042", - minaToolchainBullseye = "gcr.io/o1labs-192920/mina-toolchain@sha256:1e2feaebd47c330e990fe3c4e0681d16ad42bfa642937c4c5142793da06c890b", - minaToolchainBookworm = "gcr.io/o1labs-192920/mina-toolchain@sha256:1e2feaebd47c330e990fe3c4e0681d16ad42bfa642937c4c5142793da06c890b", - minaToolchain = "gcr.io/o1labs-192920/mina-toolchain@sha256:1e2feaebd47c330e990fe3c4e0681d16ad42bfa642937c4c5142793da06c890b", - delegationBackendToolchain = "gcr.io/o1labs-192920/delegation-backend-production@sha256:8ca5880845514ef56a36bf766a0f9de96e6200d61b51f80d9f684a0ec9c031f4", - elixirToolchain = "elixir:1.10-alpine", - nodeToolchain = "node:14.13.1-stretch-slim", - ubuntu2004 = "ubuntu:20.04", - xrefcheck = "serokell/xrefcheck@sha256:8fbb35a909abc353364f1bd3148614a1160ef3c111c0c4ae84e58fdf16019eeb" +{ toolchainBase = "codaprotocol/ci-toolchain-base:v3" +, minaToolchainBuster = + "gcr.io/o1labs-192920/mina-toolchain@sha256:f4e8034792c6322fa0a93fa5d5ab1cdd4d97a51d21fa4ed286d3326878cd2f19" +, minaToolchainBullseye = + "gcr.io/o1labs-192920/mina-toolchain@sha256:05b7676b81288cec768fa9f913e127e45ede9c70f48615738a44b443dad44fce" +, minaToolchainBookworm = + "gcr.io/o1labs-192920/mina-toolchain@sha256:05b7676b81288cec768fa9f913e127e45ede9c70f48615738a44b443dad44fce" +, minaToolchain = + "gcr.io/o1labs-192920/mina-toolchain@sha256:05b7676b81288cec768fa9f913e127e45ede9c70f48615738a44b443dad44fce" +, delegationBackendToolchain = + "gcr.io/o1labs-192920/delegation-backend-production@sha256:8ca5880845514ef56a36bf766a0f9de96e6200d61b51f80d9f684a0ec9c031f4" +, elixirToolchain = "elixir:1.10-alpine" +, nodeToolchain = "node:14.13.1-stretch-slim" +, ubuntu2004 = "ubuntu:20.04" +, xrefcheck = + "serokell/xrefcheck@sha256:8fbb35a909abc353364f1bd3148614a1160ef3c111c0c4ae84e58fdf16019eeb" } From d3fa40fd5811f55bcc58ad928b0e8c90a056e999 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 18:33:29 +0200 Subject: [PATCH 04/18] Pickles: expose Ro module for testing --- src/lib/pickles/pickles.ml | 1 + src/lib/pickles/pickles_intf.mli | 1 + 2 files changed, 2 insertions(+) diff --git a/src/lib/pickles/pickles.ml b/src/lib/pickles/pickles.ml index 7ab03b59291..f859c8bd1fa 100644 --- a/src/lib/pickles/pickles.ml +++ b/src/lib/pickles/pickles.ml @@ -43,6 +43,7 @@ module Make_str (_ : Wire_types.Concrete) = struct module Cache_handle = Cache_handle module Step_main_inputs = Step_main_inputs module Step_verifier = Step_verifier + module Ro = Ro exception Return_digest = Compile.Return_digest diff --git a/src/lib/pickles/pickles_intf.mli b/src/lib/pickles/pickles_intf.mli index 5dd488a8dc3..4e93ec1f1a0 100644 --- a/src/lib/pickles/pickles_intf.mli +++ b/src/lib/pickles/pickles_intf.mli @@ -15,6 +15,7 @@ module type S = sig module Types_map = Types_map module Step_verifier = Step_verifier module Common = Common + module Ro = Ro exception Return_digest of Md5.t From 053c92ff8abe7618e6fb22d413fd631c4e1da980 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 18:34:12 +0200 Subject: [PATCH 05/18] Pickles: implement consistency check for Ro --- src/lib/pickles/tests/dune | 3 +++ src/lib/pickles/tests/test_ro.ml | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 src/lib/pickles/tests/dune create mode 100644 src/lib/pickles/tests/test_ro.ml diff --git a/src/lib/pickles/tests/dune b/src/lib/pickles/tests/dune new file mode 100644 index 00000000000..e74c6b1de9e --- /dev/null +++ b/src/lib/pickles/tests/dune @@ -0,0 +1,3 @@ +(tests + (names test_ro) + (libraries alcotest core_kernel pickles)) diff --git a/src/lib/pickles/tests/test_ro.ml b/src/lib/pickles/tests/test_ro.ml new file mode 100644 index 00000000000..1510ec8dafd --- /dev/null +++ b/src/lib/pickles/tests/test_ro.ml @@ -0,0 +1,20 @@ +(* initially written to see the consistency between updates of digestif *) +let test_bits_random_oracle_consistency_check () = + let s = "BitsRandomOracle" in + let exp_output_str = + "01000001101110001111111100011000011000100010100011010010110110010011101101101000001110001110100101010100001000001110101110111010" + in + let exp_output = + List.map (fun i -> i = '1') (List.of_seq (String.to_seq exp_output_str)) + in + let output = Pickles.Ro.bits_random_oracle ~length:128 s in + assert (List.for_all2 Bool.equal exp_output output) + +let () = + let open Alcotest in + run "Pickles Random Oracle" + [ ( "bits_random_oracle" + , [ test_case "consistency_check" `Quick + test_bits_random_oracle_consistency_check + ] ) + ] From 64405448cbbbab003b857c5927f401f70ee6ecbc Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 18:34:30 +0200 Subject: [PATCH 06/18] Scripts: remove trailing whitespaces --- scripts/testone.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/testone.sh b/scripts/testone.sh index c41e264c575..bbb91c6d010 100755 --- a/scripts/testone.sh +++ b/scripts/testone.sh @@ -1,9 +1,9 @@ #!/bin/bash set -e -# File assumes tat you are running the program at the program at the root directory of the coda repo +# File assumes tat you are running the program at the program at the root directory of the mina repo -if [[ "$#" -eq "0" ]]; then +if [[ "$#" -eq "0" ]]; then echo "This script needs at least one argument, TEST-FILE, to run" exit 1 fi @@ -22,9 +22,9 @@ DIRPATH=$(dirname "$TEST_FILE") LIBRARY_NAME=$(basename "$DIRPATH") TEST_RUNNER_PROG="$DIRPATH/.$LIBRARY_NAME.inline-tests/inline_test_runner_$LIBRARY_NAME.exe" -if [[ "$#" -eq "1" ]]; then - TEST_CASE="$TEST_FILE" -else +if [[ "$#" -eq "1" ]]; then + TEST_CASE="$TEST_FILE" +else TEST_CASE="$TEST_FILE:$2" fi ( ulimit -s 65532 || true ) && \ From 402e7a7b924b839ffd7838561a50b6a6b543519f Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 18:43:24 +0200 Subject: [PATCH 07/18] OPAM: bump up digestif to 1.1.4 To get compatibility with js_of_ocaml.5, see https://github.com/mirage/digestif/releases/tag/v1.1.4 --- opam.export | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opam.export b/opam.export index 17f311a2353..6dab88efda6 100644 --- a/opam.export +++ b/opam.export @@ -102,7 +102,7 @@ installed: [ "cstruct.6.0.1" "ctypes.0.17.1" "ctypes-foreign.0.4.0" - "digestif.0.9.0" + "digestif.1.1.4" "domain-name.0.3.0" "dot-merlin-reader.4.2" "dune.3.9.2" From f1bfaa5092989bffd54c6df785c641a1a12bae53 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Fri, 28 Jul 2023 18:44:05 +0200 Subject: [PATCH 08/18] Pickles: update Digestif use, 1.1.4 compatibility --- src/lib/pickles/ro.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib/pickles/ro.ml b/src/lib/pickles/ro.ml index bcc9f0f07aa..f2f90c0d154 100644 --- a/src/lib/pickles/ro.ml +++ b/src/lib/pickles/ro.ml @@ -3,9 +3,11 @@ open Backend open Import let bits_random_oracle = - let h = Digestif.blake2s 32 in + let module Blake2s = Digestif.Make_BLAKE2S (struct + let digest_size = 32 + end) in fun ~length s -> - Digestif.digest_string h s |> Digestif.to_raw_string h |> String.to_list + Blake2s.digest_string s |> Blake2s.to_raw_string |> String.to_list |> List.concat_map ~f:(fun c -> let c = Char.to_int c in List.init 8 ~f:(fun i -> (c lsr i) land 1 = 1) ) From 23bf817965e2f8c08c27e008c62833dfb5a86cf5 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 10:03:55 +0200 Subject: [PATCH 09/18] Updating snarkyjs changing ledger from class to object --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index e707dd4f204..c49e6458ea8 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit e707dd4f20411b983649b3953e85992c1fe36658 +Subproject commit c49e6458ea874a3ba5065fa03bad115415e1d6e9 From f65b590dcf4c19bee96b391cc995e7ee40783773 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 10:48:59 +0200 Subject: [PATCH 10/18] Update src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml Co-authored-by: Richard Bonichon --- src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml index 9b5625053d5..73373d0bf22 100644 --- a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml @@ -81,7 +81,7 @@ module TextFormat_0_0_4 = struct | None -> (label_names, label_values) | Some (label_name, label_value) -> - let label_value_str = Fmt.str "%a" output_value label_value in + let label_value_str = Format.sprintf "%a" output_value label_value in (label_name :: label_names, label_value_str :: label_values) in Fmt.pf f "%a%s%a %a@." MetricName.pp base ext From e2e70f8782a38efc0d8d42bbe2008e1dd8717387 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 10:53:37 +0200 Subject: [PATCH 11/18] fixup! Pickles: implement consistency check for Ro --- src/lib/pickles/tests/test_ro.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/pickles/tests/test_ro.ml b/src/lib/pickles/tests/test_ro.ml index 1510ec8dafd..2ba659a6f2a 100644 --- a/src/lib/pickles/tests/test_ro.ml +++ b/src/lib/pickles/tests/test_ro.ml @@ -5,7 +5,7 @@ let test_bits_random_oracle_consistency_check () = "01000001101110001111111100011000011000100010100011010010110110010011101101101000001110001110100101010100001000001110101110111010" in let exp_output = - List.map (fun i -> i = '1') (List.of_seq (String.to_seq exp_output_str)) + List.map (fun i -> i = '1') (Core_kernel.String.to_list exp_output_str) in let output = Pickles.Ro.bits_random_oracle ~length:128 s in assert (List.for_all2 Bool.equal exp_output output) From 2cf1e06a4a2c032fff4b31589bdb3814c60ba26d Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 11:17:57 +0200 Subject: [PATCH 12/18] fixup! Update src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml --- src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml index 73373d0bf22..3131dccf0a4 100644 --- a/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml +++ b/src/lib/mina_metrics/prometheus_metrics/mina_metrics.ml @@ -81,7 +81,7 @@ module TextFormat_0_0_4 = struct | None -> (label_names, label_values) | Some (label_name, label_value) -> - let label_value_str = Format.sprintf "%a" output_value label_value in + let label_value_str = Format.asprintf "%a" output_value label_value in (label_name :: label_names, label_value_str :: label_values) in Fmt.pf f "%a%s%a %a@." MetricName.pp base ext From b2e2edb40b08704efa1aae1df0c1086f47c6cdff Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 15:45:42 +0200 Subject: [PATCH 13/18] Base58_check: move to alcotest + add test vectors --- src/lib/base58_check/base58_check.ml | 50 ------------- src/lib/base58_check/tests/dune | 3 + .../base58_check/tests/test_base58_check.ml | 75 +++++++++++++++++++ 3 files changed, 78 insertions(+), 50 deletions(-) create mode 100644 src/lib/base58_check/tests/dune create mode 100644 src/lib/base58_check/tests/test_base58_check.ml diff --git a/src/lib/base58_check/base58_check.ml b/src/lib/base58_check/base58_check.ml index 14c3faecb0c..d09f28a689d 100644 --- a/src/lib/base58_check/base58_check.ml +++ b/src/lib/base58_check/base58_check.ml @@ -104,53 +104,3 @@ struct end module Version_bytes = Version_bytes - -let%test_module "base58check tests" = - ( module struct - module Base58_check = Make (struct - let description = "Base58check tests" - - let version_byte = '\x53' - end) - - open Base58_check - - let test_roundtrip payload = - let encoded = encode payload in - let payload' = decode_exn encoded in - String.equal payload payload' - - let%test "empty_string" = test_roundtrip "" - - let%test "nonempty_string" = - test_roundtrip "Somewhere, over the rainbow, way up high" - - let%test "longer_string" = - test_roundtrip - "Someday, I wish upon a star, wake up where the clouds are far behind \ - me, where trouble melts like lemon drops, High above the chimney top, \ - that's where you'll find me" - - let%test "invalid checksum" = - try - let encoded = encode "Bluer than velvet were her eyes" in - let bytes = Bytes.of_string encoded in - let len = Bytes.length bytes in - let last_ch = Bytes.get bytes (len - 1) in - (* change last byte to invalidate checksum *) - let new_last_ch = - if Char.equal last_ch '\xFF' then '\x00' - else Char.of_int_exn (Char.to_int last_ch + 1) - in - Bytes.set bytes (len - 1) new_last_ch ; - let encoded_bad_checksum = Bytes.to_string bytes in - let _payload = decode_exn encoded_bad_checksum in - false - with Invalid_base58_checksum _ -> true - - let%test "invalid length" = - try - let _payload = decode_exn "abcd" in - false - with Invalid_base58_check_length _ -> true - end ) diff --git a/src/lib/base58_check/tests/dune b/src/lib/base58_check/tests/dune new file mode 100644 index 00000000000..46019aaed4a --- /dev/null +++ b/src/lib/base58_check/tests/dune @@ -0,0 +1,3 @@ +(tests + (names test_base58_check) + (libraries core_kernel base58_check alcotest)) diff --git a/src/lib/base58_check/tests/test_base58_check.ml b/src/lib/base58_check/tests/test_base58_check.ml new file mode 100644 index 00000000000..735c9fa0e86 --- /dev/null +++ b/src/lib/base58_check/tests/test_base58_check.ml @@ -0,0 +1,75 @@ +module M = Base58_check.Make (struct + let description = "Base58check tests" + + let version_byte = '\x53' +end) + +open M + +let helper_test_roundtrip payload = + let encoded = encode payload in + let payload' = decode_exn encoded in + assert (String.equal payload payload') + +let test_roundtrip_empty_string () = helper_test_roundtrip "" + +let test_roundtrip_nonempty_string () = + helper_test_roundtrip "Somewhere, over the rainbow, way up high" + +let test_roundtrip_longer_string () = + helper_test_roundtrip + "Someday, I wish upon a star, wake up where the clouds are far behind me, \ + where trouble melts like lemon drops, High above the chimney top, that's \ + where you'll find me" + +let test_invalid_checksum () = + try + let encoded = encode "Bluer than velvet were her eyes" in + let bytes = Bytes.of_string encoded in + let len = Bytes.length bytes in + let last_ch = Bytes.get bytes (len - 1) in + (* change last byte to invalidate checksum *) + let new_last_ch = + if Char.equal last_ch '\xFF' then '\x00' + else Core_kernel.Char.of_int_exn (Core_kernel.Char.to_int last_ch + 1) + in + Bytes.set bytes (len - 1) new_last_ch ; + let encoded_bad_checksum = Bytes.to_string bytes in + let _payload = decode_exn encoded_bad_checksum in + assert false + with Base58_check.Invalid_base58_checksum _ -> assert true + +let test_invalid_length () = + try + let _payload = decode_exn "abcd" in + assert false + with Base58_check.Invalid_base58_check_length _ -> assert true + +let test_vectors () = + let vectors = + [ ("", "AR3b7Dr") + ; ("vectors", "2aML9fKacueS1p5W3") + ; ("test", "24cUQZMy5c7Mj") + ] + in + assert ( + List.for_all + (fun (inp, exp_output) -> + let output = M.encode inp in + String.equal output exp_output ) + vectors ) + +let () = + let open Alcotest in + run "Base58_check" + [ ( "test_roundtrip" + , [ test_case "empty string" `Quick test_roundtrip_empty_string + ; test_case "non empty string" `Quick test_roundtrip_nonempty_string + ; test_case "longer string" `Quick test_roundtrip_longer_string + ] ) + ; ( "negative tests" + , [ test_case "invalid checksym" `Quick test_invalid_checksum + ; test_case "invalid length" `Quick test_invalid_length + ] ) + ; ("test vectors", [ test_case "vectors" `Quick test_vectors ]) + ] From 5a47db2ae1cca21db612ba87a9f1ba0bb1b82fc3 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 16:15:53 +0200 Subject: [PATCH 14/18] Base58_check: activate tests for JavaScript digestif.ocaml must be used as digestif will otherwise use the C version, and jsoo stubs are not implemented --- src/lib/base58_check/tests/dune | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/base58_check/tests/dune b/src/lib/base58_check/tests/dune index 46019aaed4a..014e26983b4 100644 --- a/src/lib/base58_check/tests/dune +++ b/src/lib/base58_check/tests/dune @@ -1,3 +1,4 @@ (tests (names test_base58_check) - (libraries core_kernel base58_check alcotest)) + (modes native js) + (libraries core_kernel base58_check digestif.ocaml alcotest)) From 3ffe6b39ec8e53d46ec67f7ed2bceb2add59e9b6 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Mon, 31 Jul 2023 11:08:10 +0200 Subject: [PATCH 15/18] Bump up snarkyjs --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index c49e6458ea8..a650f2e8cdd 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit c49e6458ea874a3ba5065fa03bad115415e1d6e9 +Subproject commit a650f2e8cdd13325457d1119b5840dcfacfc8cd9 From 957093472e0cb25184fde25603438ddfb70ad283 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Tue, 1 Aug 2023 14:29:36 +0200 Subject: [PATCH 16/18] fixup! Bump up container images --- buildkite/src/Constants/ContainerImages.dhall | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/buildkite/src/Constants/ContainerImages.dhall b/buildkite/src/Constants/ContainerImages.dhall index f23e75e69e4..e0c705bf05f 100644 --- a/buildkite/src/Constants/ContainerImages.dhall +++ b/buildkite/src/Constants/ContainerImages.dhall @@ -4,13 +4,13 @@ -- NOTE: minaToolchainBookworm is also used for building Ubuntu Jammy packages in CI { toolchainBase = "codaprotocol/ci-toolchain-base:v3" , minaToolchainBuster = - "gcr.io/o1labs-192920/mina-toolchain@sha256:f4e8034792c6322fa0a93fa5d5ab1cdd4d97a51d21fa4ed286d3326878cd2f19" + "gcr.io/o1labs-192920/mina-toolchain@sha256:64d721c1b26ccfddd8ca3993da5805148ac6fd1041a782f9aae71547bbca41d0" , minaToolchainBullseye = - "gcr.io/o1labs-192920/mina-toolchain@sha256:05b7676b81288cec768fa9f913e127e45ede9c70f48615738a44b443dad44fce" + "gcr.io/o1labs-192920/mina-toolchain@sha256:6ffa3a257f4e5188c4867604b774d82a7a50684b16f47f826ed4d3459eb3699a" , minaToolchainBookworm = - "gcr.io/o1labs-192920/mina-toolchain@sha256:05b7676b81288cec768fa9f913e127e45ede9c70f48615738a44b443dad44fce" + "gcr.io/o1labs-192920/mina-toolchain@sha256:6ffa3a257f4e5188c4867604b774d82a7a50684b16f47f826ed4d3459eb3699a" , minaToolchain = - "gcr.io/o1labs-192920/mina-toolchain@sha256:05b7676b81288cec768fa9f913e127e45ede9c70f48615738a44b443dad44fce" + "gcr.io/o1labs-192920/mina-toolchain@sha256:6ffa3a257f4e5188c4867604b774d82a7a50684b16f47f826ed4d3459eb3699a" , delegationBackendToolchain = "gcr.io/o1labs-192920/delegation-backend-production@sha256:8ca5880845514ef56a36bf766a0f9de96e6200d61b51f80d9f684a0ec9c031f4" , elixirToolchain = "elixir:1.10-alpine" From cf11400b964cd0b9d1272eb798047e1f3ed68f62 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 2 Aug 2023 13:40:18 +0200 Subject: [PATCH 17/18] Replace deprecated Arg.env_var --- src/lib/integration_test_cloud_engine/cli_inputs.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/integration_test_cloud_engine/cli_inputs.ml b/src/lib/integration_test_cloud_engine/cli_inputs.ml index 10879aef94d..64cf300dbc9 100644 --- a/src/lib/integration_test_cloud_engine/cli_inputs.ml +++ b/src/lib/integration_test_cloud_engine/cli_inputs.ml @@ -8,7 +8,7 @@ let term = "Location of the Mina automation repository to use when deploying the \ network." in - let env = Arg.env_var "MINA_AUTOMATION_LOCATION" ~doc in + let env = Cmd.Env.info "MINA_AUTOMATION_LOCATION" ~doc in Arg.( value & opt string "./automation" & info From c29397d09e9c9282fa49cae0aac316b028f41755 Mon Sep 17 00:00:00 2001 From: Danny Willems Date: Wed, 2 Aug 2023 21:37:53 +0200 Subject: [PATCH 18/18] Test_executive: fix deprecated warnings --- src/app/test_executive/test_executive.ml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/test_executive/test_executive.ml b/src/app/test_executive/test_executive.ml index 56c1428097d..d73ab1ba52e 100644 --- a/src/app/test_executive/test_executive.ml +++ b/src/app/test_executive/test_executive.ml @@ -414,7 +414,7 @@ let test_arg = let mina_image_arg = let doc = "Identifier of the Mina docker image to test." in - let env = Arg.env_var "MINA_IMAGE" ~doc in + let env = Cmd.Env.info "MINA_IMAGE" ~doc in Arg.( required & opt (some string) None @@ -422,7 +422,7 @@ let mina_image_arg = let archive_image_arg = let doc = "Identifier of the archive node docker image to test." in - let env = Arg.env_var "ARCHIVE_IMAGE" ~doc in + let env = Cmd.Env.info "ARCHIVE_IMAGE" ~doc in Arg.( value ( opt (some string) None @@ -440,7 +440,7 @@ let help_term = Term.(ret @@ const (`Help (`Plain, None))) let engine_cmd ((engine_name, (module Engine)) : engine) = let info = let doc = "Run mina integration test(s) on remote cloud provider." in - Term.info engine_name ~doc ~exits:Term.default_exits + Cmd.info engine_name ~doc ~exits:Cmd.Exit.defaults in let test_inputs_with_cli_inputs_arg = let wrap_cli_inputs cli_inputs = @@ -462,12 +462,16 @@ let engine_cmd ((engine_name, (module Engine)) : engine) = let help_cmd = let doc = "Print out test executive documentation." in - let info = Term.info "help" ~doc ~exits:Term.default_exits in + let info = Cmd.info "help" ~doc ~exits:Cmd.Exit.defaults in (help_term, info) let default_cmd = let doc = "Run mina integration test(s)." in - let info = Term.info "test_executive" ~doc ~exits:Term.default_error_exits in + let exits = + List.filter Cmd.Exit.defaults ~f:(fun i -> + Cmd.Exit.(info_code i = internal_error || info_code i = cli_error) ) + in + let info = Cmd.info "test_executive" ~doc ~exits in (help_term, info) (* TODO: move required args to positions instead of flags, or provide reasonable defaults to make them optional *)