diff --git a/buildkite/scripts/connect/connect-to-network.sh b/buildkite/scripts/connect/connect-to-network.sh index 2efe5d676b3..edf11c8da63 100755 --- a/buildkite/scripts/connect/connect-to-network.sh +++ b/buildkite/scripts/connect/connect-to-network.sh @@ -56,7 +56,7 @@ for ((i=1;i<=$num_status_retries;i++)); do done # Check that the daemon has connected to peers and is still up after 2 mins -sleep $WAIT_AFTER_FINAL_CHECK +sleep "$WAIT_AFTER_FINAL_CHECK" mina client status if [ "$(mina advanced get-peers | wc -l)" -gt 0 ]; then echo "Found some peers" @@ -65,3 +65,19 @@ else exit 1 fi +# Check network id +NETWORK_ID=$(curl 'http://localhost:3085/graphql' \ + -H 'accept: application/json' \ + -H 'content-type: application/json' \ + --data-raw '{"query":"query MyQuery {\n networkID\n}\n","variables":null,"operationName":"MyQuery"}' \ + | jq -r .data.networkID) + +EXPECTED_NETWORK=mina:$NETWORK_NAME + +if [[ "$NETWORK_ID" == "$EXPECTED_NETWORK" ]]; then + echo "Network id correct ($NETWORK_ID)" +else + echo "Network id incorrect (expected: $EXPECTED_NETWORK got: $NETWORK_ID)" + exit 1 +fi + diff --git a/src/app/heap_usage/values.ml b/src/app/heap_usage/values.ml index 00ec2173720..3dadeeb032d 100644 --- a/src/app/heap_usage/values.ml +++ b/src/app/heap_usage/values.ml @@ -689,7 +689,7 @@ let staged_ledger_diff = } |json} in - Staged_ledger_diff.of_yojson json |> Result.ok_or_failwith + Staged_ledger_diff.Stable.Latest.of_yojson json |> Result.ok_or_failwith let merkle_path ~(constraint_constants : Genesis_constants.Constraint_constants.t) = diff --git a/src/lib/block_producer/block_producer.ml b/src/lib/block_producer/block_producer.ml index 3d6b5582f16..cb7e4a4a8fa 100644 --- a/src/lib/block_producer/block_producer.ml +++ b/src/lib/block_producer/block_producer.ml @@ -315,8 +315,8 @@ let generate_next_state ~proof_cache_db ~commit_id ~zkapp_cmd_limit , `String (Staged_ledger.Staged_ledger_error.to_string e) ) ; ( "diff" - , Staged_ledger_diff.With_valid_signatures_and_proofs - .to_yojson diff ) + , Staged_ledger_diff.Stable.Latest.to_yojson + @@ Staged_ledger_diff.forget diff ) ] "Error applying the diff $diff: $error" | Error e -> @@ -526,7 +526,7 @@ let handle_block_production_errors ~logger ~rejected_blocks_logger in let metadata = [ ("error", Error_json.error_to_yojson e) - ; ("diff", Staged_ledger_diff.to_yojson staged_ledger_diff) + ; ("diff", Staged_ledger_diff.Stable.Latest.to_yojson staged_ledger_diff) ] in [%log error] ~metadata msg ; diff --git a/src/lib/mina_block/internal_transition.ml b/src/lib/mina_block/internal_transition.ml index 4b9543a998a..a1258d3cc83 100644 --- a/src/lib/mina_block/internal_transition.ml +++ b/src/lib/mina_block/internal_transition.ml @@ -52,7 +52,7 @@ type t = Stable.Latest.t = ; prover_state : Consensus.Data.Prover_state.t ; staged_ledger_diff : Staged_ledger_diff.t } -[@@deriving sexp, fields, to_yojson] +[@@deriving fields] let create ~snark_transition ~ledger_proof ~prover_state ~staged_ledger_diff = { Stable.Latest.snark_transition diff --git a/src/lib/mina_block/precomputed_block.ml b/src/lib/mina_block/precomputed_block.ml index d487f1ad3fa..217408bd5de 100644 --- a/src/lib/mina_block/precomputed_block.ml +++ b/src/lib/mina_block/precomputed_block.ml @@ -53,7 +53,7 @@ module T = struct { scheduled_time : Block_time.t ; protocol_state : Protocol_state.value ; protocol_state_proof : Proof.t - ; staged_ledger_diff : Staged_ledger_diff.t + ; staged_ledger_diff : Staged_ledger_diff.Stable.Latest.t ; delta_transition_chain_proof : Frozen_ledger_hash.t * Frozen_ledger_hash.t list ; protocol_version : Protocol_version.t diff --git a/src/lib/mina_lmdb_storage/block.ml b/src/lib/mina_lmdb_storage/block.ml index d093c74f732..f730b19874f 100644 --- a/src/lib/mina_lmdb_storage/block.ml +++ b/src/lib/mina_lmdb_storage/block.ml @@ -166,10 +166,13 @@ let%test_module "Block storage tests" = let id = match id_ with `Ok a -> a | _ -> failwith "unexpected" in [%log info] "Push message received" ; [%test_eq: String.t] (Consensus.Body_reference.to_raw_string body_ref) id ; - [%test_eq: - ( Mina_block.Body.t - , [ `Invalid_structure of Error.t | `Non_full | `Tx_failed ] ) - Result.t] (Ok body) (read_body db body_ref) + let body' = + read_body db body_ref + |> function + | Ok a -> a | Error _ -> failwith "unexpected failure to read_body" + in + if not (Mina_block.Body.Stable.Latest.equal body body') then + failwith "Retrieved body not equal to original body" let%test_unit "Write many blocks" = let n = 300 in diff --git a/src/lib/staged_ledger/staged_ledger.ml b/src/lib/staged_ledger/staged_ledger.ml index 4511ab17f83..b474ee58cd3 100644 --- a/src/lib/staged_ledger/staged_ledger.ml +++ b/src/lib/staged_ledger/staged_ledger.ml @@ -1324,7 +1324,6 @@ module T = struct { commands_rev : User_command.Valid.t Sequence.t ; completed_work : Transaction_snark_work.Checked.t Sequence.t } - [@@deriving sexp_of] let add_user_command t uc = { t with @@ -1354,7 +1353,6 @@ module T = struct ; is_coinbase_receiver_new : bool ; logger : (Logger.t[@sexp.opaque]) } - [@@deriving sexp_of] let coinbase_ft (cw : Transaction_snark_work.Checked.t) = let fee = Transaction_snark_work.Checked.fee cw in @@ -3772,11 +3770,9 @@ let%test_module "staged ledger tests" = let work = List.hd_exn (List.drop work_done 1) in assert_same_fee single work.fee ) | _ -> - failwith - (sprintf - !"Incorrect coinbase in the diff %{sexp: \ - Staged_ledger_diff.t}" - diff ) + failwith @@ "Incorrect coinbase in the diff " + ^ ( Staged_ledger_diff.Stable.Latest.to_yojson diff + |> Yojson.Safe.to_string ) in (diff, List.tl_exn proofs_available_left) ) in @@ -4381,10 +4377,6 @@ let%test_module "staged ledger tests" = .commands diff ) = 1 ) ; let f, s = diff.diff in - [%log info] "Diff %s" - ( Staged_ledger_diff.With_valid_signatures_and_proofs - .to_yojson diff - |> Yojson.Safe.to_string ) ; let failed_command = With_status. { data = invalid_command diff --git a/src/lib/staged_ledger_diff/body.ml b/src/lib/staged_ledger_diff/body.ml index 55a9566ba36..ddbcba25123 100644 --- a/src/lib/staged_ledger_diff/body.ml +++ b/src/lib/staged_ledger_diff/body.ml @@ -8,23 +8,19 @@ end module Make_str (A : Wire_types.Concrete) = struct [%%versioned module Stable = struct + [@@@no_toplevel_latest_type] + module V1 = struct type t = A.V1.t = { staged_ledger_diff : Diff.Stable.V2.t } - [@@deriving equal, compare, sexp, fields] + [@@deriving equal, fields, sexp] let to_latest = Fn.id - let to_yojson _ = `String "" - module Creatable = struct let id = "block_body" type nonrec t = t - let sexp_of_t = sexp_of_t - - let t_of_sexp = t_of_sexp - type 'a creator = Diff.Stable.Latest.t -> 'a let map_creator c ~f staged_ledger_diff = f (c staged_ledger_diff) @@ -38,21 +34,12 @@ module Make_str (A : Wire_types.Concrete) = struct Allocation_functor.Intf.Output.Basic_intf with type t := t and type 'a creator := 'a Creatable.creator ) - - include ( - Allocation_functor.Make.Sexp - (Creatable) : - Allocation_functor.Intf.Output.Sexp_intf - with type t := t - and type 'a creator := 'a Creatable.creator ) end end] type t = Stable.Latest.t - [%%define_locally - Stable.Latest. - (create, to_yojson, sexp_of_t, t_of_sexp, equal, compare, staged_ledger_diff)] + [%%define_locally Stable.Latest.(create, staged_ledger_diff)] let to_binio_bigstring b = let sz = Stable.V1.bin_size_t b in diff --git a/src/lib/staged_ledger_diff/body_intf.ml b/src/lib/staged_ledger_diff/body_intf.ml index ebd27f6db8e..53066354bd6 100644 --- a/src/lib/staged_ledger_diff/body_intf.ml +++ b/src/lib/staged_ledger_diff/body_intf.ml @@ -4,11 +4,11 @@ module type Full = sig [@@@no_toplevel_latest_type] module V1 : sig - type t [@@deriving equal, compare, sexp, to_yojson, bin_io] + type t [@@deriving equal, sexp] end end] - type t = Stable.Latest.t [@@deriving equal, compare, sexp, to_yojson] + type t = Stable.Latest.t val create : Diff.t -> t diff --git a/src/lib/staged_ledger_diff/diff.ml b/src/lib/staged_ledger_diff/diff.ml index a2be739fb69..0f97e827a5b 100644 --- a/src/lib/staged_ledger_diff/diff.ml +++ b/src/lib/staged_ledger_diff/diff.ml @@ -169,13 +169,13 @@ module Make_str (A : Wire_types.Concrete) = struct ( Transaction_snark_work.Stable.V2.t , User_command.Stable.V2.t With_status.Stable.V2.t ) Pre_diff_two.Stable.V2.t - [@@deriving equal, compare, sexp, yojson] + [@@deriving equal, sexp, yojson] let to_latest = Fn.id end end] - type t = Stable.Latest.t [@@deriving equal, compare, sexp, yojson] + type t = Stable.Latest.t end module Pre_diff_with_at_most_one_coinbase = struct @@ -188,13 +188,13 @@ module Make_str (A : Wire_types.Concrete) = struct ( Transaction_snark_work.Stable.V2.t , User_command.Stable.V2.t With_status.Stable.V2.t ) Pre_diff_one.Stable.V2.t - [@@deriving equal, compare, sexp, yojson] + [@@deriving equal, sexp, yojson] let to_latest = Fn.id end end] - type t = Stable.Latest.t [@@deriving equal, compare, sexp, yojson] + type t = Stable.Latest.t end module Diff = struct @@ -206,13 +206,13 @@ module Make_str (A : Wire_types.Concrete) = struct type t = Pre_diff_with_at_most_two_coinbase.Stable.V2.t * Pre_diff_with_at_most_one_coinbase.Stable.V2.t option - [@@deriving equal, compare, sexp, yojson] + [@@deriving equal, sexp, yojson] let to_latest = Fn.id end end] - type t = Stable.Latest.t [@@deriving equal, compare, sexp, yojson] + type t = Stable.Latest.t end [%%versioned @@ -221,34 +221,30 @@ module Make_str (A : Wire_types.Concrete) = struct module V2 = struct type t = A.V2.t = { diff : Diff.Stable.V2.t } - [@@deriving equal, compare, sexp, yojson] + [@@deriving equal, sexp, yojson] let to_latest = Fn.id end end] - type t = Stable.Latest.t = { diff : Diff.t } - [@@deriving equal, compare, sexp, yojson, fields] + type t = Stable.Latest.t = { diff : Diff.t } [@@deriving fields] module With_valid_signatures_and_proofs = struct type pre_diff_with_at_most_two_coinbase = ( Transaction_snark_work.Checked.t , User_command.Valid.t With_status.t ) Pre_diff_two.t - [@@deriving compare, sexp, to_yojson] type pre_diff_with_at_most_one_coinbase = ( Transaction_snark_work.Checked.t , User_command.Valid.t With_status.t ) Pre_diff_one.t - [@@deriving compare, sexp, to_yojson] type diff = pre_diff_with_at_most_two_coinbase * pre_diff_with_at_most_one_coinbase option - [@@deriving compare, sexp, to_yojson] - type t = { diff : diff } [@@deriving compare, sexp, to_yojson] + type t = { diff : diff } let empty_diff : t = { diff = @@ -297,20 +293,17 @@ module Make_str (A : Wire_types.Concrete) = struct ( Transaction_snark_work.t , User_command.Valid.t With_status.t ) Pre_diff_two.t - [@@deriving compare, sexp, to_yojson] type pre_diff_with_at_most_one_coinbase = ( Transaction_snark_work.t , User_command.Valid.t With_status.t ) Pre_diff_one.t - [@@deriving compare, sexp, to_yojson] type diff = pre_diff_with_at_most_two_coinbase * pre_diff_with_at_most_one_coinbase option - [@@deriving compare, sexp, to_yojson] - type t = { diff : diff } [@@deriving compare, sexp, to_yojson] + type t = { diff : diff } let coinbase ~(constraint_constants : Genesis_constants.Constraint_constants.t) @@ -461,6 +454,19 @@ module Make_str (A : Wire_types.Concrete) = struct } , None ) } + + let is_empty = function + | { diff = + ( { completed_works = [] + ; commands = [] + ; coinbase = At_most_two.Zero + ; internal_command_statuses = [] + } + , None ) + } -> + true + | _ -> + false end include Wire_types.Make (Make_sig) (Make_str) diff --git a/src/lib/staged_ledger_diff/diff_intf.ml b/src/lib/staged_ledger_diff/diff_intf.ml index 1294db0e2be..5a3267875dd 100644 --- a/src/lib/staged_ledger_diff/diff_intf.ml +++ b/src/lib/staged_ledger_diff/diff_intf.ml @@ -67,11 +67,10 @@ module type Full = sig module Pre_diff_with_at_most_two_coinbase : sig type t = (Transaction_snark_work.t, User_command.t With_status.t) Pre_diff_two.t - [@@deriving equal, compare, sexp, yojson] module Stable : sig module V2 : sig - type t [@@deriving equal, compare, sexp, yojson, bin_io, version] + type t end end with type V2.t = t @@ -80,11 +79,10 @@ module type Full = sig module Pre_diff_with_at_most_one_coinbase : sig type t = (Transaction_snark_work.t, User_command.t With_status.t) Pre_diff_one.t - [@@deriving equal, compare, sexp, yojson] module Stable : sig module V2 : sig - type t [@@deriving equal, compare, sexp, yojson, bin_io, version] + type t end end with type V2.t = t @@ -94,23 +92,21 @@ module type Full = sig type t = Pre_diff_with_at_most_two_coinbase.t * Pre_diff_with_at_most_one_coinbase.t option - [@@deriving equal, compare, sexp, yojson] module Stable : sig module V2 : sig - type t [@@deriving equal, compare, sexp, bin_io, yojson, version] + type t end end with type V2.t = t end - type t = { diff : Diff.t } - [@@deriving equal, compare, sexp, compare, yojson, fields] + type t = { diff : Diff.t } [@@deriving fields] module Stable : sig module V2 : sig type t = { diff : Diff.Stable.V2.t } - [@@deriving equal, compare, sexp, compare, yojson, bin_io, version] + [@@deriving bin_io, equal, sexp, version, yojson] val to_latest : t -> t end @@ -124,20 +120,17 @@ module type Full = sig ( Transaction_snark_work.Checked.t , User_command.Valid.t With_status.t ) Pre_diff_two.t - [@@deriving compare, sexp, to_yojson] type pre_diff_with_at_most_one_coinbase = ( Transaction_snark_work.Checked.t , User_command.Valid.t With_status.t ) Pre_diff_one.t - [@@deriving compare, sexp, to_yojson] type diff = pre_diff_with_at_most_two_coinbase * pre_diff_with_at_most_one_coinbase option - [@@deriving compare, sexp, to_yojson] - type t = { diff : diff } [@@deriving compare, sexp, to_yojson] + type t = { diff : diff } val empty_diff : t @@ -149,20 +142,17 @@ module type Full = sig ( Transaction_snark_work.t , User_command.Valid.t With_status.t ) Pre_diff_two.t - [@@deriving compare, sexp, to_yojson] type pre_diff_with_at_most_one_coinbase = ( Transaction_snark_work.t , User_command.Valid.t With_status.t ) Pre_diff_one.t - [@@deriving compare, sexp, to_yojson] type diff = pre_diff_with_at_most_two_coinbase * pre_diff_with_at_most_one_coinbase option - [@@deriving compare, sexp, to_yojson] - type t = { diff : diff } [@@deriving compare, sexp, to_yojson] + type t = { diff : diff } val coinbase : constraint_constants:Genesis_constants.Constraint_constants.t @@ -201,4 +191,6 @@ module type Full = sig -> Currency.Amount.t option val empty_diff : t + + val is_empty : t -> bool end diff --git a/src/lib/transaction_snark_work/transaction_snark_work.ml b/src/lib/transaction_snark_work/transaction_snark_work.ml index 5a1fe8fa16f..afca360ffef 100644 --- a/src/lib/transaction_snark_work/transaction_snark_work.ml +++ b/src/lib/transaction_snark_work/transaction_snark_work.ml @@ -75,7 +75,7 @@ module Info = struct end module type S = sig - type t [@@deriving compare, sexp, yojson] + type t val fee : t -> Fee.t @@ -95,7 +95,7 @@ module T = struct ; proofs : Ledger_proof.Stable.V2.t One_or_two.Stable.V1.t ; prover : Public_key.Compressed.Stable.V1.t } - [@@deriving equal, compare, sexp, yojson] + [@@deriving equal, sexp, yojson] let to_latest = Fn.id end @@ -106,7 +106,7 @@ module T = struct ; proofs : Ledger_proof.t One_or_two.t ; prover : Public_key.Compressed.t } - [@@deriving compare, fields, yojson, sexp] + [@@deriving fields] let statement t = One_or_two.map t.proofs ~f:Ledger_proof.statement diff --git a/src/lib/transaction_snark_work/transaction_snark_work.mli b/src/lib/transaction_snark_work/transaction_snark_work.mli index a109015358c..cc5b1633506 100644 --- a/src/lib/transaction_snark_work/transaction_snark_work.mli +++ b/src/lib/transaction_snark_work/transaction_snark_work.mli @@ -52,7 +52,7 @@ end *) module type S = sig - type t [@@deriving compare, sexp, yojson] + type t val fee : t -> Fee.t @@ -75,7 +75,7 @@ val statement : t -> Statement.t module Stable : sig module V2 : sig - type t [@@deriving equal, sexp, compare, bin_io, yojson, version] + type t [@@deriving bin_io, equal, sexp, version, yojson] end end with type V2.t = t diff --git a/src/lib/transition_handler/validator.ml b/src/lib/transition_handler/validator.ml index cb1e39b4df2..cb62b1f229e 100644 --- a/src/lib/transition_handler/validator.ml +++ b/src/lib/transition_handler/validator.ml @@ -101,9 +101,7 @@ let validate_transition_is_relevant ~context:(module Context : CONTEXT) Body.staged_ledger_diff @@ body transition_data in Result.ok_if_true - ( Staged_ledger_diff.compare Staged_ledger_diff.empty_diff - staged_ledger_diff - = 0 ) + (Staged_ledger_diff.is_empty staged_ledger_diff) ~error:`Non_empty_staged_ledger_diff_after_stop_slot | None | Some _ -> Result.(Ok ())