Skip to content

Commit

Permalink
Merge branch 'berkeley' into dkijania/mina-profile-docker
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania authored Sep 27, 2023
2 parents f58a2fa + 2e7ba61 commit dff55db
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 40 deletions.
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 @@ -2066,10 +2066,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 @@ -3592,7 +3592,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 @@ -3673,7 +3673,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 @@ -3781,8 +3781,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

0 comments on commit dff55db

Please sign in to comment.