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

renaming fork-previous-global-slot to fork-genesis-slot #14014

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e07f99a
renaming fork-previous-global-slot to fork-genesis-slot
Aug 30, 2023
ebe54a0
reformat
Aug 31, 2023
ae89b34
Merge branch 'berkeley' of github.com:MinaProtocol/mina into renaming…
Aug 31, 2023
2be03bf
change previous_global_slot to genesis_slot
Sep 5, 2023
67edce3
Merge branch 'berkeley' of github.com:MinaProtocol/mina into renaming…
Sep 5, 2023
6f55d72
update snarkyjs bindings
Sep 5, 2023
36234bf
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
psteckler Sep 5, 2023
38343ee
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 6, 2023
b14a28e
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 7, 2023
3a8ca36
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 8, 2023
08abe93
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 8, 2023
71ffa7e
undo changes to snarkyjs
Sep 8, 2023
b3734b6
Merge branch 'renaming-previous-slot-to-genesis-slot' of github.com:M…
Sep 8, 2023
5929311
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 11, 2023
68cf7bc
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 11, 2023
56dfd82
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 18, 2023
e01fa7b
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 19, 2023
17d7f9d
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 20, 2023
870a7a1
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 20, 2023
62ebdc8
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 21, 2023
30036cb
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 21, 2023
ce27309
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 21, 2023
e94ef0b
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 25, 2023
8a9808b
Merge branch 'berkeley' into renaming-previous-slot-to-genesis-slot
ghost-not-in-the-shell Sep 25, 2023
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
6 changes: 3 additions & 3 deletions src/app/test_executive/hard_fork.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -448,7 +448,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
Expand All @@ -472,7 +472,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 )
Expand Down
2 changes: 1 addition & 1 deletion src/config/fork.mlh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[%%undef fork_previous_length]
[%%undef fork_previous_state_hash]
[%%undef fork_previous_global_slot]
[%%undef fork_genesis_slot]
2 changes: 1 addition & 1 deletion src/config/fork_at_3757.mlh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[%%define fork_previous_length 3757]
[%%define fork_previous_state_hash "3NKR3QYJ7qwxiGgX39umahgdT8BH5yXBQwQtpYZdvodCXcsndK7f"]
[%%define fork_previous_global_slot 12796]
[%%define fork_genesis_slot 12796]
3 changes: 1 addition & 2 deletions src/lib/consensus/constants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
11 changes: 5 additions & 6 deletions src/lib/consensus/proof_of_stake.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.(
Expand Down Expand Up @@ -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.(
Expand Down Expand Up @@ -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 }
Expand Down
16 changes: 7 additions & 9 deletions src/lib/genesis_constants/genesis_constants.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -165,17 +164,16 @@ 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
{ Fork_constants.previous_state_hash =
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 =
Mina_numbers.Global_slot_since_genesis.of_int
fork_previous_global_slot
; genesis_slot =
Mina_numbers.Global_slot_since_genesis.of_int fork_genesis_slot
}

[%%endif]
Expand Down
14 changes: 6 additions & 8 deletions src/lib/genesis_ledger_helper/lib/genesis_ledger_helper_lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
} )
}

Expand Down Expand Up @@ -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
} )
}

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 @@ -2347,7 +2347,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
5 changes: 2 additions & 3 deletions src/lib/network_pool/indexed_pool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 1 addition & 1 deletion src/lib/snarkyjs