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

Reenable warning 22 across the codebase #14361

Merged
merged 5 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/lib/allocation_functor/dune
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@
ppx_version.runtime
)
(instrumentation (backend bisect_ppx))
(preprocess (pps ppx_jane ppx_compare ppx_deriving_yojson ppx_version))
; ignore ppx_version errors for this library
(flags -w -22))
(preprocess (pps ppx_jane ppx_compare ppx_deriving_yojson ppx_version)))
12 changes: 6 additions & 6 deletions src/lib/allocation_functor/make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ module Versioned_v1 = struct
module Latest = V1
end

type t = Stable.V1.t
type t = Stable.Latest.t
end

module Sexp (M : Intf.Input.Versioned_v1.Sexp_intf) : sig
Expand All @@ -145,7 +145,7 @@ module Versioned_v1 = struct
module Latest = V1
end

type t = Stable.V1.t
type t = Stable.Latest.t
end

module Yojson (M : Intf.Input.Versioned_v1.Yojson_intf) : sig
Expand All @@ -170,7 +170,7 @@ module Versioned_v1 = struct
module Latest = V1
end

type t = Stable.V1.t
type t = Stable.Latest.t
end

module Full_compare_eq_hash
Expand Down Expand Up @@ -204,7 +204,7 @@ module Versioned_v1 = struct
module Latest = V1
end

type t = Stable.V1.t
type t = Stable.Latest.t

let equal = M.equal

Expand Down Expand Up @@ -237,7 +237,7 @@ module Versioned_v1 = struct
module Latest = V1
end

type t = Stable.V1.t
type t = Stable.Latest.t
end
end

Expand Down Expand Up @@ -280,6 +280,6 @@ module Versioned_v2 = struct
module Latest = V2
end

type t = Stable.V2.t
type t = Stable.Latest.t
end
end
2 changes: 1 addition & 1 deletion src/lib/currency/currency.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,7 @@ module Make_str (A : Wire_types.Concrete) = struct
end

include Make_str (struct
type t = Unsigned_extended.UInt64.Stable.V1.t
type t = Unsigned_extended.UInt64.Stable.Latest.t
end)
(*include Wire_types.Make.Amount (Make_sig) (Make_str)*)
end
Expand Down
1 change: 0 additions & 1 deletion src/lib/currency/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
(name currency)
(public_name currency)
(library_flags -linkall)
(flags -w -22) ; Silence ppx_version's warnings
(inline_tests (flags -verbose -show-counts))
(libraries
;; opam libraries
Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina_base/account.ml
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ let cliff_time Poly.{ timing; _ } =
let cliff_amount Poly.{ timing; _ } =
match timing with Timing.Untimed -> None | Timed t -> Some t.cliff_amount

let vesting_increment Poly.{ timing } =
let vesting_increment Poly.{ timing; _ } =
match timing with
| Timing.Untimed ->
None
Expand Down
19 changes: 4 additions & 15 deletions src/lib/mina_base/account_timing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ end

type as_record =
( bool
, Global_slot_since_genesis.Stable.V1.t
, Global_slot_span.Stable.V1.t
, Balance.Stable.V1.t
, Amount.Stable.V1.t )
, Global_slot_since_genesis.Stable.Latest.t
Copy link
Member

Choose a reason for hiding this comment

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

Can these types omit the Stable.Latest, so Global_slot_since_genesis.t, for example. That's the same type.

, Global_slot_span.Stable.Latest.t
, Balance.Stable.Latest.t
, Amount.Stable.Latest.t )
As_record.t

(* convert sum type to record format, useful for to_bits and typ *)
Expand Down Expand Up @@ -137,17 +137,6 @@ let of_record
}
else Untimed

let of_record (r : as_record) : t =
if r.is_timed then
Timed
{ initial_minimum_balance = r.initial_minimum_balance
; cliff_time = r.cliff_time
; cliff_amount = r.cliff_amount
; vesting_period = r.vesting_period
; vesting_increment = r.vesting_increment
}
else Untimed

let to_input t =
let As_record.
{ is_timed
Expand Down
18 changes: 1 addition & 17 deletions src/lib/mina_base/account_update.ml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ module Authorization_kind = struct

let deriver obj =
let open Fields_derivers_zkapps in
let open Fields in
let ( !. ) = ( !. ) ~t_fields_annots in
let verification_key_hash =
needs_custom_js ~js_type:field ~name:"VerificationKeyHash" field
Expand Down Expand Up @@ -977,7 +976,6 @@ module Account_precondition = struct
(* we used to have 3 constructors, Full, Nonce, and Accept for the type t
nowadays, the generator creates these 3 different kinds of values, but all mapped to t
*)
let open Zkapp_basic in
Quickcheck.Generator.variant3 Zkapp_precondition.Account.gen
Account.Nonce.gen Unit.quickcheck_generator
|> Quickcheck.Generator.map ~f:(function
Expand Down Expand Up @@ -1429,21 +1427,7 @@ module Body = struct
}

let to_fee_payer_exn (t : t) : Fee_payer.t =
let { public_key
; token_id = _
; update = _
; balance_change
; increment_nonce = _
; events = _
; actions = _
; call_data = _
; preconditions
; use_full_commitment = _
; may_use_token = _
; authorization_kind = _
} =
t
in
let { public_key; preconditions; balance_change; _ } = t in
let fee =
Currency.Fee.of_uint64
(balance_change.magnitude |> Currency.Amount.to_uint64)
Expand Down
1 change: 0 additions & 1 deletion src/lib/mina_base/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
(public_name mina_base)
(inline_tests (flags -verbose -show-counts))
(library_flags -linkall)
(flags -w -22)
(libraries
;; opam libraries
async_kernel
Expand Down
1 change: 0 additions & 1 deletion src/lib/mina_base/ledger_hash.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
open Core_kernel
open Mina_base_import
open Snark_params
open Snarky_backendless
Expand Down
9 changes: 8 additions & 1 deletion src/lib/mina_base/pending_coinbase.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ module Make_str (A : Wire_types.Concrete) = struct
[%%versioned:
module Stable : sig
module V1 : sig
type t [@@deriving sexp, yojson, compare, equal]
type t [@@deriving sexp, to_yojson, compare, equal]
end
end]

val of_yojson : Yojson.Safe.t -> (t, string) result

val of_int : int -> t

val to_int : t -> int
Expand Down Expand Up @@ -734,9 +736,14 @@ module Make_str (A : Wire_types.Concrete) = struct
end

module Hash = struct
(* the type below triggers the ppx derivers to insert unused `rec` flags, so we ignore such warnings *)
[@@@warning "-39"]

type t = Hash_builder.t constraint t = Hash_versioned.t
[@@deriving equal, compare, sexp, yojson, hash]

[@@@warning "+39"]

type var = Hash_builder.var

[%%define_locally
Expand Down
8 changes: 3 additions & 5 deletions src/lib/mina_base/signed_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ module Make_str (_ : Wire_types.Concrete) = struct
end]

(* type of signed commands, pre-Berkeley hard fork *)
type t_v1 = Stable.V1.t

let (_ : (t, (Payload.t, Public_key.t, Signature.t) Poly.t) Type_equal.t) =
Type_equal.T

Expand Down Expand Up @@ -206,7 +204,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
and fee =
Int.gen_incl min_fee max_fee >>| Currency.Fee.of_nanomina_int_exn
and memo = String.quickcheck_generator in
let%map body = create_body signer receiver in
let%map body = create_body receiver in
let payload : Payload.t =
Payload.create ~fee
~fee_payer_pk:(Public_key.compress signer.public_key)
Expand All @@ -224,7 +222,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
let gen_inner (sign' : Signature_lib.Keypair.t -> Payload.t -> t) ~key_gen
?nonce ?(min_amount = 1) ~max_amount ~fee_range () =
gen_inner sign' ~key_gen ?nonce ~fee_range
@@ fun { public_key = signer; _ } { public_key = receiver; _ } ->
@@ fun { public_key = receiver; _ } ->
let open Quickcheck.Generator.Let_syntax in
let%map amount =
Int.gen_incl min_amount max_amount
Expand All @@ -249,7 +247,7 @@ module Make_str (_ : Wire_types.Concrete) = struct
module Stake_delegation = struct
let gen ~key_gen ?nonce ~fee_range () =
gen_inner For_tests.fake_sign ~key_gen ?nonce ~fee_range
(fun { public_key = signer; _ } { public_key = new_delegate; _ } ->
(fun { public_key = new_delegate; _ } ->
Quickcheck.Generator.return
@@ Signed_command_payload.Body.Stake_delegation
(Set_delegate
Expand Down
14 changes: 9 additions & 5 deletions src/lib/mina_base/signed_command_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,15 @@ module type Full = sig

module V2 : sig
type t =
( Payload.Stable.V2.t
, Public_key.Stable.V1.t
, Signature.Stable.V1.t )
( Payload.Stable.Latest.t
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should do this. A versioned type should be built from other specific versioned types. If those other types add new versions, this type will change.

It is true that the new version linter will detect such changes, but still.

Copy link
Member

Choose a reason for hiding this comment

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

It is also true that this is a signature, not an implementation. But still ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed these to get around the ppx_version warning, but have since disabled it, so I can undo all of these changes to refer to the latest versions.

, Public_key.Stable.Latest.t
, Signature.Stable.Latest.t )
Poly.Stable.V1.t
[@@deriving sexp, hash, yojson, version]
[@@deriving sexp, hash, version]

val to_yojson : t -> Yojson.Safe.t

val of_yojson : Yojson.Safe.t -> (t, string) result

include Comparable.S with type t := t

Expand All @@ -266,5 +270,5 @@ module type Full = sig
end
end]

include S with type t = Stable.V2.t and type t_v1 = Stable.V1.t
include S with type t = Stable.V2.t and type t_v1 := Stable.V1.t
end
5 changes: 1 addition & 4 deletions src/lib/mina_base/token_id.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ Account_id.Digest.
, gen_non_default
, to_field_unsafe
, of_field
, to_string
, of_string
, comparator
, ( <> ) )]
, to_string )]

let of_string s =
try Account_id.Digest.of_string s
Expand Down
1 change: 0 additions & 1 deletion src/lib/mina_base/zkapp_account.ml
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ let gen : t Quickcheck.Generator.t =
in
let%bind zkapp_version = Mina_numbers.Zkapp_version.gen in
let%bind seq_state = Generator.list_with_length 5 Field.gen in
let%bind last_sequence_slot = Mina_numbers.Global_slot_since_genesis.gen in
let%map zkapp_uri = gen_uri in
let five = Pickles_types.Nat.(S (S (S (S (S Z))))) in
{ app_state
Expand Down
69 changes: 40 additions & 29 deletions src/lib/mina_base/zkapp_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -205,19 +205,32 @@ module Call_forest = struct
and type Forest.Stable.V1.t = T.Forest.V1.t
end

module Make_digest_str
(T : Mina_wire_types.Mina_base.Zkapp_command.Digest_concrete) :
Make_digest_sig(T).S = struct
module M = struct
open Pickles.Impls.Step.Field
module Checked = Pickles.Impls.Step.Field
module Make_digest_types = struct
module Account_update = struct
[%%versioned
module Stable = struct
module V1 = struct
type t = Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t
[@@deriving sexp, compare, equal, hash, yojson]

let typ = typ
let to_latest = Fn.id
end
end]
end

let constant = constant
module Forest = struct
[%%versioned
module Stable = struct
module V1 = struct
type t = Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t
[@@deriving sexp, compare, equal, hash, yojson]

let to_latest = Fn.id
end
end]
end

module Account_update = struct
module Tree = struct
[%%versioned
module Stable = struct
module V1 = struct
Expand All @@ -227,7 +240,23 @@ module Call_forest = struct
let to_latest = Fn.id
end
end]
end
end

module Make_digest_str
(T : Mina_wire_types.Mina_base.Zkapp_command.Digest_concrete) :
Make_digest_sig(T).S = struct
module M = struct
open Pickles.Impls.Step.Field
module Checked = Pickles.Impls.Step.Field

let typ = typ

let constant = constant
end

module Account_update = struct
include Make_digest_types.Account_update
include M

module Checked = struct
Expand All @@ -247,16 +276,7 @@ module Call_forest = struct
end

module Forest = struct
[%%versioned
module Stable = struct
module V1 = struct
type t = Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t
[@@deriving sexp, compare, equal, hash, yojson]

let to_latest = Fn.id
end
end]

include Make_digest_types.Forest
include M

module Checked = struct
Expand All @@ -277,16 +297,7 @@ module Call_forest = struct
end

module Tree = struct
[%%versioned
module Stable = struct
module V1 = struct
type t = Kimchi_backend.Pasta.Basic.Fp.Stable.V1.t
[@@deriving sexp, compare, equal, hash, yojson]

let to_latest = Fn.id
end
end]

include Make_digest_types.Tree
include M

module Checked = struct
Expand Down
4 changes: 1 addition & 3 deletions src/lib/mina_wire_types/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
)
(preprocessor_deps ../../config.mlh)
(preprocess (pps ppx_version ppx_optcomp))
(instrumentation (backend bisect_ppx))
(flags -w -22) ; Allow using versioned types outside of ppx
)
(instrumentation (backend bisect_ppx)))

; Include index.mld in generated doc
(documentation (package mina_wire_types))
Loading