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

Rename previous_global_slot to genesis_slot in compatible #14263

Closed
Closed
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
2 changes: 1 addition & 1 deletion docs/specs/types_and_structures/serialized_key.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
4 changes: 1 addition & 3 deletions src/lib/consensus/constants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ let create' (type a b c)
| None ->
slots
| Some f ->
M.( + )
(M.constant (Unsigned.UInt32.to_int f.previous_global_slot))
slots
M.( + ) (M.constant (Unsigned.UInt32.to_int f.genesis_slot)) slots
in
let res : (a, b, c) Poly.t =
{ Poly.k = to_length k
Expand Down
10 changes: 5 additions & 5 deletions src/lib/consensus/proof_of_stake.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2033,10 +2033,10 @@ module Data = struct
match constraint_constants.fork with
| None ->
(Length.zero, Mina_numbers.Global_slot.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.
Expand Down Expand Up @@ -3625,7 +3625,7 @@ let%test_module "Proof of stake tests" =
| Some fork ->
assert (
Mina_numbers.Global_slot.(
equal fork.previous_global_slot
equal fork.genesis_slot
previous_consensus_state.global_slot_since_genesis) ) ;
assert (
Mina_numbers.Length.(
Expand Down Expand Up @@ -3701,7 +3701,7 @@ let%test_module "Proof of stake tests" =
assert (
Mina_numbers.Global_slot.(
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.(
Expand Down Expand Up @@ -3806,7 +3806,7 @@ let%test_module "Proof of stake tests" =
(`String
"3NL3bc213VQEFx6XTLbc3HxHqHH9ANbhHxRxSnBcRzXcKgeFA6TY" ) )
; previous_length = Mina_numbers.Length.of_int 100
; previous_global_slot = Mina_numbers.Global_slot.of_int 200
; genesis_slot = Mina_numbers.Global_slot.of_int 200
}
in
{ constraint_constants with fork = fork_constants }
Expand Down
9 changes: 4 additions & 5 deletions src/lib/genesis_constants/genesis_constants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +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.Stable.Latest.t
; genesis_slot : Mina_numbers.Global_slot.Stable.Latest.t
}
[@@deriving bin_io_unversioned, sexp, equal, compare, yojson]
end
Expand Down Expand Up @@ -67,13 +67,12 @@ 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 =
Unsigned.UInt32.to_int previous_global_slot
; genesis_slot = Unsigned.UInt32.to_int genesis_slot
}
| None ->
None )
Expand Down Expand Up @@ -171,7 +170,7 @@ module Constraint_constants = struct
; previous_state_hash =
Data_hash_lib.State_hash.of_base58_check_exn
fork_previous_state_hash
; previous_global_slot =
; genesis_slot =
Mina_numbers.Global_slot.of_int fork_previous_global_slot
}

Expand Down
11 changes: 4 additions & 7 deletions src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -430,13 +430,12 @@ 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.of_int previous_global_slot
; genesis_slot = Mina_numbers.Global_slot.of_int genesis_slot
} )
}

Expand Down Expand Up @@ -465,13 +464,11 @@ 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.to_int previous_global_slot
; genesis_slot = Mina_numbers.Global_slot.to_int genesis_slot
} )
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/mina_graphql/mina_graphql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4340,7 +4340,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 =
Expand Down
4 changes: 2 additions & 2 deletions src/lib/network_pool/indexed_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ let current_global_slot t =
|> to_global_slot)
in
match t.constraint_constants.fork with
| Some { previous_global_slot; _ } ->
Mina_numbers.Global_slot.(add previous_global_slot current_slot)
| Some { genesis_slot; _ } ->
Mina_numbers.Global_slot.(add genesis_slot current_slot)
| None ->
current_slot

Expand Down
5 changes: 1 addition & 4 deletions src/lib/runtime_config/runtime_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/lib/snark_keys_header/snark_keys_header.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down