From e07f99aea138f1fbd0ef79fe2d7f2395d2cc98b6 Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Thu, 31 Aug 2023 02:13:42 +0800 Subject: [PATCH 1/5] renaming fork-previous-global-slot to fork-genesis-slot --- src/config/fork.mlh | 2 +- src/config/fork_at_3757.mlh | 2 +- src/lib/genesis_constants/genesis_constants.ml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config/fork.mlh b/src/config/fork.mlh index 0c8e8dab67e4..65e7457ec821 100644 --- a/src/config/fork.mlh +++ b/src/config/fork.mlh @@ -1,3 +1,3 @@ [%%undef fork_previous_length] [%%undef fork_previous_state_hash] -[%%undef fork_previous_global_slot] +[%%undef fork_genesis_slot] diff --git a/src/config/fork_at_3757.mlh b/src/config/fork_at_3757.mlh index 5ff73e82f57b..0c27577faf0c 100644 --- a/src/config/fork_at_3757.mlh +++ b/src/config/fork_at_3757.mlh @@ -1,3 +1,3 @@ [%%define fork_previous_length 3757] [%%define fork_previous_state_hash "3NKR3QYJ7qwxiGgX39umahgdT8BH5yXBQwQtpYZdvodCXcsndK7f"] -[%%define fork_previous_global_slot 12796] \ No newline at end of file +[%%define fork_genesis_slot 12796] \ No newline at end of file diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 203a81356d5f..20fad94a95ad 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -165,7 +165,7 @@ module Constraint_constants = struct [%%inject "fork_previous_state_hash", fork_previous_state_hash] - [%%inject "fork_previous_global_slot", fork_previous_global_slot] + [%%inject "fork_genesis_slot", fork_genesis_slot] let fork = Some @@ -175,7 +175,7 @@ module Constraint_constants = struct ; previous_length = Mina_numbers.Length.of_int fork_previous_length ; previous_global_slot = Mina_numbers.Global_slot_since_genesis.of_int - fork_previous_global_slot + fork_genesis_slot } [%%endif] From ebe54a034caf3aa7e1df089f803aab2b6f9187fe Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Fri, 1 Sep 2023 01:27:38 +0800 Subject: [PATCH 2/5] reformat --- src/lib/genesis_constants/genesis_constants.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index 20fad94a95ad..a0d5a6095c40 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -174,8 +174,7 @@ module Constraint_constants = struct fork_previous_state_hash ; previous_length = Mina_numbers.Length.of_int fork_previous_length ; previous_global_slot = - Mina_numbers.Global_slot_since_genesis.of_int - fork_genesis_slot + Mina_numbers.Global_slot_since_genesis.of_int fork_genesis_slot } [%%endif] From 2be03bf57fc73fc0bcc58db7a24f349f06d99364 Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Tue, 5 Sep 2023 23:51:02 +0800 Subject: [PATCH 3/5] change previous_global_slot to genesis_slot --- docs/specs/types_and_structures/serialized_key.md | 2 +- src/app/test_executive/hard_fork.ml | 6 +++--- src/lib/consensus/constants.ml | 3 +-- src/lib/consensus/proof_of_stake.ml | 11 +++++------ src/lib/genesis_constants/genesis_constants.ml | 11 +++++------ .../lib/genesis_ledger_helper_lib.ml | 14 ++++++-------- src/lib/mina_graphql/mina_graphql.ml | 2 +- src/lib/network_pool/indexed_pool.ml | 5 ++--- src/lib/runtime_config/runtime_config.ml | 5 +---- src/lib/snark_keys_header/snark_keys_header.ml | 2 +- 10 files changed, 26 insertions(+), 35 deletions(-) diff --git a/docs/specs/types_and_structures/serialized_key.md b/docs/specs/types_and_structures/serialized_key.md index a116e926cc98..9fcfd7eb3f17 100644 --- a/docs/specs/types_and_structures/serialized_key.md +++ b/docs/specs/types_and_structures/serialized_key.md @@ -130,7 +130,7 @@ To help ensure no download errors have occurred, the `length` field should match | - | - | - | | `previous_state_hash` | `String` | State hash in hex | | `previous_length` | `Number` | Height | -| `previous_global_slot` | `Number` | Slot | +| `genesis_slot` | `Number` | Slot | ### `commits` diff --git a/src/app/test_executive/hard_fork.ml b/src/app/test_executive/hard_fork.ml index c8118b202a44..387e419f16ac 100644 --- a/src/app/test_executive/hard_fork.ml +++ b/src/app/test_executive/hard_fork.ml @@ -21,7 +21,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct { previous_state_hash = "3NKSiqFZQmAS12U8qeX4KNo8b4199spwNh7mrSs4Ci1Vacpfix2Q" ; previous_length = 300000 - ; previous_global_slot = 500000 + ; genesis_slot = 500000 } let config = @@ -267,7 +267,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct let bad_slot = Mina_numbers.Global_slot_since_genesis.to_int global_slot_since_genesis - < fork_config.previous_global_slot + < fork_config.genesis_slot in if bad_height && bad_slot then Malleable_error.hard_error @@ -290,7 +290,7 @@ module Make (Inputs : Intf.Test.Inputs_intf) = struct section_hard "running replayer" (let%bind logs = Network.Node.run_replayer - ~start_slot_since_genesis:fork_config.previous_global_slot ~logger + ~start_slot_since_genesis:fork_config.genesis_slot ~logger (List.hd_exn @@ (Network.archive_nodes network |> Core.Map.data)) in check_replayer_logs ~logger logs ) diff --git a/src/lib/consensus/constants.ml b/src/lib/consensus/constants.ml index c2a6f029825b..2c67f951a6f5 100644 --- a/src/lib/consensus/constants.ml +++ b/src/lib/consensus/constants.ml @@ -239,8 +239,7 @@ let create' (type a b c) | Some f -> M.( + ) (M.constant - (Mina_numbers.Global_slot_since_genesis.to_int - f.previous_global_slot ) ) + (Mina_numbers.Global_slot_since_genesis.to_int f.genesis_slot) ) slots in let res : (a, b, c) Poly.t = diff --git a/src/lib/consensus/proof_of_stake.ml b/src/lib/consensus/proof_of_stake.ml index 696f0c028b75..f86a4cf34098 100644 --- a/src/lib/consensus/proof_of_stake.ml +++ b/src/lib/consensus/proof_of_stake.ml @@ -2093,10 +2093,10 @@ module Make_str (A : Wire_types.Concrete) = struct match constraint_constants.fork with | None -> (Length.zero, Mina_numbers.Global_slot_since_genesis.zero) - | Some { previous_length; previous_global_slot; _ } -> + | Some { previous_length; genesis_slot; _ } -> (*Note: global_slot_since_genesis at fork point is the same as global_slot_since_genesis in the new genesis. This value is used to check transaction validity and existence of locked tokens. For reviewers, should this be incremented by 1 because it's technically a new block? we don't really know how many slots passed since the fork point*) - (previous_length, previous_global_slot) + (previous_length, genesis_slot) in let default_epoch_data = Genesis_epoch_data.Data. @@ -3623,7 +3623,7 @@ module Make_str (A : Wire_types.Concrete) = struct | Some fork -> assert ( Mina_numbers.Global_slot_since_genesis.( - equal fork.previous_global_slot + equal fork.genesis_slot previous_consensus_state.global_slot_since_genesis) ) ; assert ( Mina_numbers.Length.( @@ -3704,7 +3704,7 @@ module Make_str (A : Wire_types.Concrete) = struct assert ( Mina_numbers.Global_slot_since_genesis.( equal - (add fork.previous_global_slot slot_diff) + (add fork.genesis_slot slot_diff) next_consensus_state.global_slot_since_genesis) ) ; assert ( Mina_numbers.Length.( @@ -3812,8 +3812,7 @@ module Make_str (A : Wire_types.Concrete) = struct "3NL3bc213VQEFx6XTLbc3HxHqHH9ANbhHxRxSnBcRzXcKgeFA6TY" ) ) ; previous_length = Mina_numbers.Length.of_int 100 - ; previous_global_slot = - Mina_numbers.Global_slot_since_genesis.of_int 200 + ; genesis_slot = Mina_numbers.Global_slot_since_genesis.of_int 200 } in { constraint_constants with fork = fork_constants } diff --git a/src/lib/genesis_constants/genesis_constants.ml b/src/lib/genesis_constants/genesis_constants.ml index a0d5a6095c40..aae92cf5d62b 100644 --- a/src/lib/genesis_constants/genesis_constants.ml +++ b/src/lib/genesis_constants/genesis_constants.ml @@ -28,8 +28,7 @@ module Fork_constants = struct type t = { previous_state_hash : Pickles.Backend.Tick.Field.Stable.Latest.t ; previous_length : Mina_numbers.Length.Stable.Latest.t - ; previous_global_slot : - Mina_numbers.Global_slot_since_genesis.Stable.Latest.t + ; genesis_slot : Mina_numbers.Global_slot_since_genesis.Stable.Latest.t } [@@deriving bin_io_unversioned, sexp, equal, compare, yojson] end @@ -68,15 +67,15 @@ module Constraint_constants = struct ; account_creation_fee = Currency.Fee.to_uint64 t.account_creation_fee ; fork = ( match t.fork with - | Some { previous_length; previous_state_hash; previous_global_slot } -> + | Some { previous_length; previous_state_hash; genesis_slot } -> Some { previous_length = Unsigned.UInt32.to_int previous_length ; previous_state_hash = Pickles.Backend.Tick.Field.to_string previous_state_hash - ; previous_global_slot = + ; genesis_slot = Unsigned.UInt32.to_int (Mina_numbers.Global_slot_since_genesis.to_uint32 - previous_global_slot ) + genesis_slot ) } | None -> None ) @@ -173,7 +172,7 @@ module Constraint_constants = struct Data_hash_lib.State_hash.of_base58_check_exn fork_previous_state_hash ; previous_length = Mina_numbers.Length.of_int fork_previous_length - ; previous_global_slot = + ; genesis_slot = Mina_numbers.Global_slot_since_genesis.of_int fork_genesis_slot } diff --git a/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml b/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml index fd8c59e669e9..d452b4dfe233 100644 --- a/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml +++ b/src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml @@ -458,14 +458,13 @@ let make_constraint_constants ( match config.fork with | None -> default.fork - | Some { previous_state_hash; previous_length; previous_global_slot } -> + | Some { previous_state_hash; previous_length; genesis_slot } -> Some { previous_state_hash = State_hash.of_base58_check_exn previous_state_hash ; previous_length = Mina_numbers.Length.of_int previous_length - ; previous_global_slot = - Mina_numbers.Global_slot_since_genesis.of_int - previous_global_slot + ; genesis_slot = + Mina_numbers.Global_slot_since_genesis.of_int genesis_slot } ) } @@ -494,13 +493,12 @@ let runtime_config_of_constraint_constants ; account_creation_fee = Some constraint_constants.account_creation_fee ; fork = Option.map constraint_constants.fork - ~f:(fun { previous_state_hash; previous_length; previous_global_slot } - -> + ~f:(fun { previous_state_hash; previous_length; genesis_slot } -> { Runtime_config.Fork_config.previous_state_hash = State_hash.to_base58_check previous_state_hash ; previous_length = Mina_numbers.Length.to_int previous_length - ; previous_global_slot = - Mina_numbers.Global_slot_since_genesis.to_int previous_global_slot + ; genesis_slot = + Mina_numbers.Global_slot_since_genesis.to_int genesis_slot } ) } diff --git a/src/lib/mina_graphql/mina_graphql.ml b/src/lib/mina_graphql/mina_graphql.ml index bb89f0732670..3fc100ae2080 100644 --- a/src/lib/mina_graphql/mina_graphql.ml +++ b/src/lib/mina_graphql/mina_graphql.ml @@ -6097,7 +6097,7 @@ module Queries = struct protocol_state.previous_state_hash ; previous_length = Option.value ~default:global_slot previous_length - ; previous_global_slot = global_slot + ; genesis_slot = global_slot } in let update = diff --git a/src/lib/network_pool/indexed_pool.ml b/src/lib/network_pool/indexed_pool.ml index 5b5b7a07c8db..88c7d2688e7b 100644 --- a/src/lib/network_pool/indexed_pool.ml +++ b/src/lib/network_pool/indexed_pool.ml @@ -259,13 +259,12 @@ let global_slot_since_genesis conf = |> to_global_slot) in match conf.constraint_constants.fork with - | Some { previous_global_slot; _ } -> + | Some { genesis_slot; _ } -> let slot_span = Mina_numbers.Global_slot_since_hard_fork.to_uint32 current_slot |> Mina_numbers.Global_slot_span.of_uint32 in - Mina_numbers.Global_slot_since_genesis.( - add previous_global_slot slot_span) + Mina_numbers.Global_slot_since_genesis.(add genesis_slot slot_span) | None -> (* we're in the genesis "hard fork", so consider current slot as since-genesis diff --git a/src/lib/runtime_config/runtime_config.ml b/src/lib/runtime_config/runtime_config.ml index 72d18880719b..e41b84f2ef7c 100644 --- a/src/lib/runtime_config/runtime_config.ml +++ b/src/lib/runtime_config/runtime_config.ml @@ -2,10 +2,7 @@ open Core_kernel module Fork_config = struct type t = - { previous_state_hash : string - ; previous_length : int - ; previous_global_slot : int - } + { previous_state_hash : string; previous_length : int; genesis_slot : int } [@@deriving yojson, dhall_type, bin_io_unversioned] end diff --git a/src/lib/snark_keys_header/snark_keys_header.ml b/src/lib/snark_keys_header/snark_keys_header.ml index e34b387c7733..2ec090fc5e36 100644 --- a/src/lib/snark_keys_header/snark_keys_header.ml +++ b/src/lib/snark_keys_header/snark_keys_header.ml @@ -89,7 +89,7 @@ module Constraint_constants = struct type t = { previous_state_hash : string ; previous_length : int - ; previous_global_slot : int + ; genesis_slot : int } [@@deriving yojson, sexp, ord, equal] From 6f55d7278e8ed36db16eca18add59d25a4c14211 Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Wed, 6 Sep 2023 00:03:57 +0800 Subject: [PATCH 4/5] update snarkyjs bindings --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index 92ebf4de20c6..8e8ace44cd70 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit 92ebf4de20c69df091a881a2d77c80218cae6ea3 +Subproject commit 8e8ace44cd70339b8feb6263ba36304145e9126d From 71ffa7e7cacda8c26f2d058e8b89659f0b47882a Mon Sep 17 00:00:00 2001 From: Tang Jiawei Date: Sat, 9 Sep 2023 03:27:35 +0800 Subject: [PATCH 5/5] undo changes to snarkyjs --- src/lib/snarkyjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/snarkyjs b/src/lib/snarkyjs index 8e8ace44cd70..92ebf4de20c6 160000 --- a/src/lib/snarkyjs +++ b/src/lib/snarkyjs @@ -1 +1 @@ -Subproject commit 8e8ace44cd70339b8feb6263ba36304145e9126d +Subproject commit 92ebf4de20c69df091a881a2d77c80218cae6ea3