Skip to content

Commit

Permalink
Merge branch 'rampup' into feature/fix-receipt-chain-hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
psteckler authored Nov 1, 2023
2 parents 142d260 + 7b541d1 commit 5864b0a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 45 deletions.
5 changes: 3 additions & 2 deletions src/app/archive/lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
child_processes
precomputed_values
coda_genesis_ledger
consensus.vrf
mina_runtime_config
hex
sgn
mina_base.util
kimchi_backend.pasta
Expand Down Expand Up @@ -72,9 +72,10 @@
mina_version
staged_ledger_diff
error_json
ppx_deriving_yojson.runtime
ppx_version.runtime
)
(inline_tests (flags -verbose -show-counts))
(modes native)
(instrumentation (backend bisect_ppx))
(preprocess (pps ppx_mina ppx_version ppx_jane ppx_custom_printf h_list.ppx)))
(preprocess (pps ppx_mina ppx_version ppx_jane ppx_custom_printf ppx_deriving_yojson h_list.ppx)))
2 changes: 1 addition & 1 deletion src/app/archive/lib/extensional.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module Block = struct
; parent_hash : State_hash.Stable.V1.t
; creator : Public_key.Compressed.Stable.V1.t
; block_winner : Public_key.Compressed.Stable.V1.t
; last_vrf_output : string
; last_vrf_output : Consensus_vrf.Output.Truncated.Stable.V1.t
; snarked_ledger_hash : Frozen_ledger_hash.Stable.V1.t
; staking_epoch_data : Mina_base.Epoch_data.Value.Stable.V1.t
; next_epoch_data : Mina_base.Epoch_data.Value.Stable.V1.t
Expand Down
34 changes: 16 additions & 18 deletions src/app/archive/lib/processor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1845,7 +1845,7 @@ module User_command = struct
(Caqti_request.find typ Caqti_type.int
(Mina_caqti.insert_into_cols ~returning:"id" ~table_name
~tannot:(function
| "typ" -> Some "user_command_type" | _ -> None )
| "command_type" -> Some "user_command_type" | _ -> None )
~cols:Fields.names () ) )
{ command_type = user_cmd.command_type
; fee_payer_id
Expand Down Expand Up @@ -1994,7 +1994,8 @@ module Internal_command = struct
(Caqti_request.find typ Caqti_type.int
(Mina_caqti.insert_into_cols ~returning:"id" ~table_name
~tannot:(function
| "typ" -> Some "internal_command_type" | _ -> None )
| "command_type" -> Some "internal_command_type" | _ -> None
)
~cols:Fields.names () ) )
{ command_type = internal_cmd.command_type
; receiver_id
Expand Down Expand Up @@ -2767,9 +2768,9 @@ module Block = struct
(Consensus.Data.Consensus_state.block_stake_winner consensus_state)
in
let last_vrf_output =
(* encode as hex, Postgresql won't accept arbitrary bitstrings *)
(* encode as base64, same as in precomputed blocks JSON *)
Consensus.Data.Consensus_state.last_vrf_output consensus_state
|> Hex.Safe.to_hex
|> Base64.encode_exn ~alphabet:Base64.uri_safe_alphabet
in
let%bind snarked_ledger_hash_id =
Snarked_ledger_hash.add_if_doesn't_exist
Expand Down Expand Up @@ -3173,8 +3174,9 @@ module Block = struct
Public_key.add_if_doesn't_exist (module Conn) block.block_winner
in
let last_vrf_output =
(* already encoded as hex *)
(* encode as base64, same as in precomputed blocks JSON *)
block.last_vrf_output
|> Base64.encode_exn ~alphabet:Base64.uri_safe_alphabet
in
let%bind snarked_ledger_hash_id =
Snarked_ledger_hash.add_if_doesn't_exist
Expand Down Expand Up @@ -3214,19 +3216,15 @@ module Block = struct
in
Conn.find
(Caqti_request.find typ Caqti_type.int
{sql| INSERT INTO blocks
(state_hash, parent_id, parent_hash,
creator_id, block_winner_id,last_vrf_output,
snarked_ledger_hash_id, staking_epoch_data_id,
next_epoch_data_id,
min_window_density, sub_window_densities, total_currency,
ledger_hash, height,
global_slot_since_hard_fork, global_slot_since_genesis,
protocol_version, proposed_protocol_version,
timestamp, chain_status)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?::bigint[], ?, ?, ?, ?, ?, ?, ?, ?, ?::chain_status_type)
RETURNING id
|sql} )
(Mina_caqti.insert_into_cols ~returning:"id" ~table_name
~tannot:(function
| "sub_window_densities" ->
Some "bigint[]"
| "chain_status" ->
Some "chain_status_type"
| _ ->
None )
~cols:Fields.names () ) )
{ state_hash = block.state_hash |> State_hash.to_base58_check
; parent_id
; parent_hash = block.parent_hash |> State_hash.to_base58_check
Expand Down
1 change: 1 addition & 0 deletions src/app/extract_blocks/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
uri
async.async_command
;; local libraries
consensus_vrf
mina_wire_types
mina_base
mina_base.import
Expand Down
3 changes: 1 addition & 2 deletions src/app/extract_blocks/extract_blocks.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ let fill_in_block pool (block : Archive_lib.Processor.Block.t) :
let%bind creator = pk_of_id block.creator_id in
let%bind block_winner = pk_of_id block.block_winner_id in
let last_vrf_output =
(* keep hex encoding *)
block.last_vrf_output
Base64.decode_exn ~alphabet:Base64.uri_safe_alphabet block.last_vrf_output
in
let%bind snarked_ledger_hash_str =
query_db ~f:(fun db ->
Expand Down
2 changes: 1 addition & 1 deletion src/app/replayer/replayer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ let () =
Command.async ~summary:"Replay transactions from Mina archive database"
(let%map input_file =
Param.flag "--input-file"
~doc:"file File containing the genesis ledger"
~doc:"file File containing the starting ledger"
Param.(required string)
and output_file_opt =
Param.flag "--output-file"
Expand Down
13 changes: 0 additions & 13 deletions src/app/replayer/sql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -464,16 +464,3 @@ module Parent_block = struct
epoch_ledgers_state_hash =
Conn.find query_parent_state_hash epoch_ledgers_state_hash
end

module Balances = struct
let query_insert_nonce =
Caqti_request.exec
Caqti_type.(tup2 int int64)
{sql| UPDATE balances
SET nonce = $2
WHERE id = $1
|sql}

let insert_nonce (module Conn : Caqti_async.CONNECTION) ~id ~nonce =
Conn.exec query_insert_nonce (id, nonce)
end
23 changes: 15 additions & 8 deletions src/lib/consensus/vrf/consensus_vrf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,20 +165,24 @@ module Output = struct
[%%versioned
module Stable = struct
module V1 = struct
type t = string [@@deriving sexp, equal, compare, hash]
type t = string [@@deriving sexp, equal, compare, hash, yojson]

let to_yojson t =
`String (Base64.encode_exn ~alphabet:Base64.uri_safe_alphabet t)

let of_yojson = function
| `String s ->
Result.map_error
(Base64.decode ~alphabet:Base64.uri_safe_alphabet s)
~f:(function `Msg err ->
sprintf
"Error decoding vrf output in \
Vrf.Output.Truncated.Stable.V1.of_yojson: %s"
err )
(* missing type equation somewhere, add explicit type *)
( match Base64.decode ~alphabet:Base64.uri_safe_alphabet s with
| Ok b64 ->
Ppx_deriving_yojson_runtime.Result.Ok b64
| Error (`Msg err) ->
Error
(sprintf
"Error decoding vrf output in \
Vrf.Output.Truncated.Stable.V1.of_yojson: %s"
err )
: (t, string) Ppx_deriving_yojson_runtime.Result.result )
| _ ->
Error
"Vrf.Output.Truncated.Stable.V1.of_yojson: Expected a string"
Expand All @@ -195,6 +199,9 @@ module Output = struct
let description = "Vrf Truncated Output"
end)

(* don't want the yojson functions from Make_base58_check *)
[%%define_locally Stable.Latest.(of_yojson, to_yojson)]

open Tick

let length_in_bits = Int.min 256 (Field.size_in_bits - 2)
Expand Down
1 change: 1 addition & 0 deletions src/lib/consensus/vrf/dune
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
kimchi_bindings
kimchi_types
pasta_bindings
ppx_deriving_yojson.runtime
ppx_version.runtime
)
(inline_tests (flags -verbose -show-counts))
Expand Down

0 comments on commit 5864b0a

Please sign in to comment.