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

Change version byte for transaction hashes #12651

Merged
merged 4 commits into from
Feb 13, 2023
Merged
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
4 changes: 3 additions & 1 deletion src/lib/base58_check/version_bytes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let state_hash : t = '\x10'

let state_body_hash : t = '\x11'

let transaction_hash : t = '\x12'
(* don't use \x12, which was for pre-Berkeley hard fork transaction hashes *)

(* used only to deserialize transaction ids, pre-Berkeley hard fork *)
let signed_command_v1 : t = '\x13'
Expand All @@ -57,6 +57,8 @@ let verification_key : t = '\x1B'

let token_id_key : t = '\x1C'

let transaction_hash : t = '\x1D'

(** used for testing only *)

let ledger_test_hash : t = '\x30'
Expand Down
2 changes: 0 additions & 2 deletions src/lib/blake2/blake2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ module Make () = struct

[%%versioned_binable
module Stable = struct
[@@@with_top_version_tag]

module V1 = struct
type t = T1.t [@@deriving hash, sexp, compare, equal]

Expand Down
2 changes: 0 additions & 2 deletions src/lib/blake2/intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module type S = sig

[%%versioned:
module Stable : sig
[@@@with_top_version_tag]

module V1 : sig
type t [@@deriving sexp, compare, hash, equal, yojson]
end
Expand Down
7 changes: 6 additions & 1 deletion src/lib/mina_base/payment_payload.mli
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ module Poly : sig
end

module V1 : sig
type ('pk, 'token_id, 'amount) t
type ('pk, 'token_id, 'amount) t =
{ source_pk : 'pk
; receiver_pk : 'pk
; token_id : 'token_id
; amount : 'amount
}
[@@deriving bin_io, equal, sexp, hash, yojson, version]
end

Expand Down
28 changes: 26 additions & 2 deletions src/lib/mina_base/signed_command.ml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,32 @@ module Make_str (_ : Wire_types.Concrete) = struct
Poly.Stable.V1.t
[@@deriving compare, sexp, hash, yojson]

(* don't need to coerce old commands to new ones *)
let to_latest _ = failwith "Not implemented"
let to_latest ({ payload; signer; signature } : t) : Latest.t =
let payload : Signed_command_payload.t =
let common : Signed_command_payload.Common.t =
{ fee = payload.common.fee
; fee_payer_pk = payload.common.fee_payer_pk
; nonce = payload.common.nonce
; valid_until = payload.common.valid_until
; memo = payload.common.memo
}
in
let body : Signed_command_payload.Body.t =
match payload.body with
| Payment payment_payload ->
let payload' : Payment_payload.t =
{ source_pk = payment_payload.source_pk
; receiver_pk = payment_payload.receiver_pk
; amount = payment_payload.amount
}
in
Payment payload'
| Stake_delegation stake_delegation_payload ->
Stake_delegation stake_delegation_payload
in
{ common; body }
in
{ payload; signer; signature }
end
end]

Expand Down
2 changes: 2 additions & 0 deletions src/lib/mina_base/signed_command_intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ module type Full = sig
, Signature.Stable.V1.t )
Poly.Stable.V1.t
[@@deriving compare, sexp, hash, yojson]

val to_latest : t -> Latest.t
end
end]

Expand Down
5 changes: 4 additions & 1 deletion src/lib/mina_base/signed_command_payload.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ module Body : sig
end

module V1 : sig
type t [@@deriving compare, equal, sexp, hash, yojson]
type t =
| Payment of Payment_payload.Stable.V1.t
| Stake_delegation of Stake_delegation.Stable.V1.t
[@@deriving compare, equal, sexp, hash, yojson]
end
end]

Expand Down
120 changes: 59 additions & 61 deletions src/lib/transaction/transaction_hash.ml

Large diffs are not rendered by default.