Skip to content

Commit

Permalink
Merge pull request #11785 from MinaProtocol/properly-expose-pending-c…
Browse files Browse the repository at this point in the history
…oinbase-aux

Properly exposes pending coinbase aux
  • Loading branch information
bkase authored Sep 21, 2022
2 parents 057e68f + 6d3fb07 commit e4a75d6
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 4 deletions.
28 changes: 28 additions & 0 deletions graphql_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -10029,6 +10029,17 @@
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "PendingCoinbaseAuxHash",
"description":
"Base58Check-encoded hash of a pending coinbase auxiliary hash",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": null,
"possibleTypes": null
},
{
"kind": "SCALAR",
"name": "StagedLedgerAuxHash",
Expand Down Expand Up @@ -10141,6 +10152,23 @@
},
{
"name": "stagedLedgerPendingCoinbaseAux",
"description":
"Base58Check-encoded staged ledger hash's pending_coinbase_aux",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "SCALAR",
"name": "PendingCoinbaseAuxHash",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "stagedLedgerPendingCoinbaseHash",
"description":
"Base58Check-encoded hash of the staged ledger hash's pending_coinbase_hash",
"args": [],
Expand Down
3 changes: 3 additions & 0 deletions src/graphql-ppx-config.inc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ Graphql_lib.Scalars.StagedLedgerAuxHash
PendingCoinbaseHash
Graphql_lib.Scalars.PendingCoinbaseHash
-custom-field
PendingCoinbaseAuxHash
Graphql_lib.Scalars.PendingCoinbaseAuxHash
-custom-field
TransactionId
Graphql_lib.Scalars.TransactionId
-extend-query=Graphql_lib.Serializing.ExtendQuery
Expand Down
14 changes: 11 additions & 3 deletions src/lib/mina_base/staged_ledger_hash.ml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ module Pending_coinbase_aux = struct
Base58_check.Version_bytes.staged_ledger_hash_pending_coinbase_aux
end)

let to_yojson s = `String (Base58_check.encode s)
let to_base58_check s = Base58_check.encode s

let of_base58_check_exn s = Base58_check.decode_exn s

let to_yojson s = `String (to_base58_check s)

let of_yojson = function
| `String s -> (
Expand All @@ -89,7 +93,8 @@ module Pending_coinbase_aux = struct
end
end]

[%%define_locally Stable.Latest.(to_yojson, of_yojson)]
[%%define_locally
Stable.Latest.(to_yojson, of_yojson, to_base58_check, of_base58_check_exn)]

let dummy : t = String.init length_in_bytes ~f:(fun _ -> '\000')
end
Expand All @@ -103,7 +108,7 @@ module Non_snark = struct
; aux_hash : Aux_hash.Stable.V1.t
; pending_coinbase_aux : Pending_coinbase_aux.Stable.V1.t
}
[@@deriving sexp, equal, compare, hash, yojson]
[@@deriving sexp, equal, compare, hash, yojson, fields]

let to_latest = Fn.id
end
Expand Down Expand Up @@ -224,6 +229,9 @@ let ledger_hash ({ non_snark; _ } : t) = Non_snark.ledger_hash non_snark

let aux_hash ({ non_snark; _ } : t) = Non_snark.aux_hash non_snark

let pending_coinbase_aux ({ non_snark; _ } : t) =
Non_snark.pending_coinbase_aux non_snark

let pending_coinbase_hash ({ pending_coinbase_hash; _ } : t) =
pending_coinbase_hash

Expand Down
21 changes: 21 additions & 0 deletions src/lib/mina_base/staged_ledger_hash.mli
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,31 @@ module Aux_hash : sig
val dummy : t
end

module Pending_coinbase_aux : sig
type t

module Stable : sig
module V1 : sig
type nonrec t = t
[@@deriving bin_io, sexp, equal, compare, hash, yojson, version]
end

module Latest : module type of V1
end

val to_base58_check : t -> string

val of_base58_check_exn : string -> t

val dummy : t
end

val ledger_hash : t -> Ledger_hash.t

val aux_hash : t -> Aux_hash.t

val pending_coinbase_aux : t -> Pending_coinbase_aux.t

val pending_coinbase_hash : t -> Pending_coinbase.Hash.t

val pending_coinbase_hash_var : var -> Pending_coinbase.Hash.var
Expand Down
9 changes: 9 additions & 0 deletions src/lib/mina_base/unix/graphql_scalars.ml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ module PendingCoinbaseHash =
let doc = "Base58Check-encoded hash of a pending coinbase hash"
end)

module PendingCoinbaseAuxHash =
Make_scalar_using_base58_check
(Mina_base.Staged_ledger_hash.Pending_coinbase_aux)
(struct
let name = "PendingCoinbaseAuxHash"

let doc = "Base58Check-encoded hash of a pending coinbase auxiliary hash"
end)

module FieldElem =
Make_scalar_using_to_string
(Mina_base.Zkapp_basic.F)
Expand Down
10 changes: 9 additions & 1 deletion src/lib/mina_graphql/mina_graphql.ml
Original file line number Diff line number Diff line change
Expand Up @@ -703,8 +703,16 @@ module Types = struct
~doc:"Base58Check-encoded hash of the staged ledger hash's aux_hash"
~args:Arg.[]
~resolve:(fun _ t ->
Staged_ledger_hash.aux_hash (staged_ledger_hash t) )
let staged_ledger_hash = staged_ledger_hash t in
Staged_ledger_hash.aux_hash staged_ledger_hash )
; field "stagedLedgerPendingCoinbaseAux"
~typ:(non_null @@ Graphql_lib.Scalars.PendingCoinbaseAuxHash.typ ())
~doc:"Base58Check-encoded staged ledger hash's pending_coinbase_aux"
~args:Arg.[]
~resolve:(fun _ t ->
let staged_ledger_hash = staged_ledger_hash t in
Staged_ledger_hash.pending_coinbase_aux staged_ledger_hash )
; field "stagedLedgerPendingCoinbaseHash"
~typ:(non_null @@ Graphql_lib.Scalars.PendingCoinbaseHash.typ ())
~doc:
"Base58Check-encoded hash of the staged ledger hash's \
Expand Down

0 comments on commit e4a75d6

Please sign in to comment.