2019-09-05 17:21:01 +04:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Open Source License *)
|
|
|
|
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* Permission is hereby granted, free of charge, to any person obtaining a *)
|
|
|
|
(* copy of this software and associated documentation files (the "Software"),*)
|
|
|
|
(* to deal in the Software without restriction, including without limitation *)
|
|
|
|
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
|
|
|
|
(* and/or sell copies of the Software, and to permit persons to whom the *)
|
|
|
|
(* Software is furnished to do so, subject to the following conditions: *)
|
|
|
|
(* *)
|
|
|
|
(* The above copyright notice and this permission notice shall be included *)
|
|
|
|
(* in all copies or substantial portions of the Software. *)
|
|
|
|
(* *)
|
|
|
|
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
|
|
|
|
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
|
|
|
|
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
|
|
|
|
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
|
|
|
|
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
|
|
|
|
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
|
|
|
|
(* DEALINGS IN THE SOFTWARE. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
|
|
|
|
|
|
|
(* Tezos Protocol Implementation - Low level Repr. of Operations *)
|
|
|
|
|
|
|
|
module Kind : sig
|
|
|
|
type seed_nonce_revelation = Seed_nonce_revelation_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type double_endorsement_evidence = Double_endorsement_evidence_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type double_baking_evidence = Double_baking_evidence_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type activate_account = Activate_account_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type endorsement = Endorsement_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type proposals = Proposals_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type ballot = Ballot_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type reveal = Reveal_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type transaction = Transaction_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type origination = Origination_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type delegation = Delegation_kind
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type 'a manager =
|
|
|
|
| Reveal_manager_kind : reveal manager
|
|
|
|
| Transaction_manager_kind : transaction manager
|
|
|
|
| Origination_manager_kind : origination manager
|
|
|
|
| Delegation_manager_kind : delegation manager
|
|
|
|
end
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
type raw = Operation.t = {shell : Operation.shell_header; proto : MBytes.t}
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val raw_encoding : raw Data_encoding.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type 'kind operation = {
|
2020-02-12 20:40:17 +04:00
|
|
|
shell : Operation.shell_header;
|
|
|
|
protocol_data : 'kind protocol_data;
|
2019-09-05 17:21:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
and 'kind protocol_data = {
|
2020-02-12 20:40:17 +04:00
|
|
|
contents : 'kind contents_list;
|
|
|
|
signature : Signature.t option;
|
2019-09-05 17:21:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
and _ contents_list =
|
|
|
|
| Single : 'kind contents -> 'kind contents_list
|
2020-02-12 20:40:17 +04:00
|
|
|
| Cons :
|
|
|
|
'kind Kind.manager contents * 'rest Kind.manager contents_list
|
|
|
|
-> ('kind * 'rest) Kind.manager contents_list
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
and _ contents =
|
2020-02-12 20:40:17 +04:00
|
|
|
| Endorsement : {level : Raw_level_repr.t} -> Kind.endorsement contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Seed_nonce_revelation : {
|
2020-02-12 20:40:17 +04:00
|
|
|
level : Raw_level_repr.t;
|
|
|
|
nonce : Seed_repr.nonce;
|
|
|
|
}
|
|
|
|
-> Kind.seed_nonce_revelation contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Double_endorsement_evidence : {
|
2020-02-12 20:40:17 +04:00
|
|
|
op1 : Kind.endorsement operation;
|
|
|
|
op2 : Kind.endorsement operation;
|
|
|
|
}
|
|
|
|
-> Kind.double_endorsement_evidence contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Double_baking_evidence : {
|
2020-02-12 20:40:17 +04:00
|
|
|
bh1 : Block_header_repr.t;
|
|
|
|
bh2 : Block_header_repr.t;
|
|
|
|
}
|
|
|
|
-> Kind.double_baking_evidence contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Activate_account : {
|
2020-02-12 20:40:17 +04:00
|
|
|
id : Ed25519.Public_key_hash.t;
|
|
|
|
activation_code : Blinded_public_key_hash.activation_code;
|
|
|
|
}
|
|
|
|
-> Kind.activate_account contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Proposals : {
|
2020-02-12 20:40:17 +04:00
|
|
|
source : Signature.Public_key_hash.t;
|
|
|
|
period : Voting_period_repr.t;
|
|
|
|
proposals : Protocol_hash.t list;
|
|
|
|
}
|
|
|
|
-> Kind.proposals contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Ballot : {
|
2020-02-12 20:40:17 +04:00
|
|
|
source : Signature.Public_key_hash.t;
|
|
|
|
period : Voting_period_repr.t;
|
|
|
|
proposal : Protocol_hash.t;
|
|
|
|
ballot : Vote_repr.ballot;
|
|
|
|
}
|
|
|
|
-> Kind.ballot contents
|
2019-09-05 17:21:01 +04:00
|
|
|
| Manager_operation : {
|
2020-02-12 20:40:17 +04:00
|
|
|
source : Signature.Public_key_hash.t;
|
|
|
|
fee : Tez_repr.tez;
|
|
|
|
counter : counter;
|
|
|
|
operation : 'kind manager_operation;
|
|
|
|
gas_limit : Z.t;
|
|
|
|
storage_limit : Z.t;
|
|
|
|
}
|
|
|
|
-> 'kind Kind.manager contents
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
and _ manager_operation =
|
|
|
|
| Reveal : Signature.Public_key.t -> Kind.reveal manager_operation
|
|
|
|
| Transaction : {
|
2020-02-12 20:40:17 +04:00
|
|
|
amount : Tez_repr.tez;
|
|
|
|
parameters : Script_repr.lazy_expr;
|
|
|
|
entrypoint : string;
|
|
|
|
destination : Contract_repr.contract;
|
|
|
|
}
|
|
|
|
-> Kind.transaction manager_operation
|
2019-09-05 17:21:01 +04:00
|
|
|
| Origination : {
|
2020-02-12 20:40:17 +04:00
|
|
|
delegate : Signature.Public_key_hash.t option;
|
|
|
|
script : Script_repr.t;
|
|
|
|
credit : Tez_repr.tez;
|
|
|
|
preorigination : Contract_repr.t option;
|
|
|
|
}
|
|
|
|
-> Kind.origination manager_operation
|
2019-09-05 17:21:01 +04:00
|
|
|
| Delegation :
|
2020-02-12 20:40:17 +04:00
|
|
|
Signature.Public_key_hash.t option
|
|
|
|
-> Kind.delegation manager_operation
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
and counter = Z.t
|
|
|
|
|
|
|
|
type 'kind internal_operation = {
|
2020-02-12 20:40:17 +04:00
|
|
|
source : Contract_repr.contract;
|
|
|
|
operation : 'kind manager_operation;
|
|
|
|
nonce : int;
|
2019-09-05 17:21:01 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
type packed_manager_operation =
|
|
|
|
| Manager : 'kind manager_operation -> packed_manager_operation
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
type packed_contents = Contents : 'kind contents -> packed_contents
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type packed_contents_list =
|
|
|
|
| Contents_list : 'kind contents_list -> packed_contents_list
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val of_list : packed_contents list -> packed_contents_list
|
|
|
|
|
|
|
|
val to_list : packed_contents_list -> packed_contents list
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type packed_protocol_data =
|
|
|
|
| Operation_data : 'kind protocol_data -> packed_protocol_data
|
|
|
|
|
|
|
|
type packed_operation = {
|
2020-02-12 20:40:17 +04:00
|
|
|
shell : Operation.shell_header;
|
|
|
|
protocol_data : packed_protocol_data;
|
2019-09-05 17:21:01 +04:00
|
|
|
}
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val pack : 'kind operation -> packed_operation
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type packed_internal_operation =
|
|
|
|
| Internal_operation : 'kind internal_operation -> packed_internal_operation
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val manager_kind : 'kind manager_operation -> 'kind Kind.manager
|
|
|
|
|
|
|
|
val encoding : packed_operation Data_encoding.t
|
|
|
|
|
|
|
|
val contents_encoding : packed_contents Data_encoding.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val contents_list_encoding : packed_contents_list Data_encoding.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val protocol_data_encoding : packed_protocol_data Data_encoding.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val unsigned_operation_encoding :
|
|
|
|
(Operation.shell_header * packed_contents_list) Data_encoding.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val raw : _ operation -> raw
|
|
|
|
|
|
|
|
val hash_raw : raw -> Operation_hash.t
|
|
|
|
|
|
|
|
val hash : _ operation -> Operation_hash.t
|
|
|
|
|
|
|
|
val hash_packed : packed_operation -> Operation_hash.t
|
|
|
|
|
|
|
|
val acceptable_passes : packed_operation -> int list
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type error += Missing_signature (* `Permanent *)
|
2020-02-12 20:40:17 +04:00
|
|
|
|
2019-09-05 17:21:01 +04:00
|
|
|
type error += Invalid_signature (* `Permanent *)
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val check_signature :
|
2019-09-05 17:21:01 +04:00
|
|
|
Signature.Public_key.t -> Chain_id.t -> _ operation -> unit tzresult Lwt.t
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val check_signature_sync :
|
|
|
|
Signature.Public_key.t -> Chain_id.t -> _ operation -> unit tzresult
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val internal_operation_encoding : packed_internal_operation Data_encoding.t
|
2019-09-05 17:21:01 +04:00
|
|
|
|
|
|
|
type ('a, 'b) eq = Eq : ('a, 'a) eq
|
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val equal : 'a operation -> 'b operation -> ('a, 'b) eq option
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
module Encoding : sig
|
2019-09-05 17:21:01 +04:00
|
|
|
type 'b case =
|
2020-02-12 20:40:17 +04:00
|
|
|
| Case : {
|
|
|
|
tag : int;
|
|
|
|
name : string;
|
|
|
|
encoding : 'a Data_encoding.t;
|
|
|
|
select : packed_contents -> 'b contents option;
|
|
|
|
proj : 'b contents -> 'a;
|
|
|
|
inj : 'a -> 'b contents;
|
|
|
|
}
|
|
|
|
-> 'b case
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val endorsement_case : Kind.endorsement case
|
|
|
|
|
|
|
|
val seed_nonce_revelation_case : Kind.seed_nonce_revelation case
|
|
|
|
|
|
|
|
val double_endorsement_evidence_case : Kind.double_endorsement_evidence case
|
|
|
|
|
|
|
|
val double_baking_evidence_case : Kind.double_baking_evidence case
|
|
|
|
|
|
|
|
val activate_account_case : Kind.activate_account case
|
|
|
|
|
|
|
|
val proposals_case : Kind.proposals case
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val ballot_case : Kind.ballot case
|
|
|
|
|
|
|
|
val reveal_case : Kind.reveal Kind.manager case
|
|
|
|
|
|
|
|
val transaction_case : Kind.transaction Kind.manager case
|
|
|
|
|
|
|
|
val origination_case : Kind.origination Kind.manager case
|
|
|
|
|
|
|
|
val delegation_case : Kind.delegation Kind.manager case
|
|
|
|
|
|
|
|
module Manager_operations : sig
|
2019-09-05 17:21:01 +04:00
|
|
|
type 'b case =
|
2020-02-12 20:40:17 +04:00
|
|
|
| MCase : {
|
|
|
|
tag : int;
|
|
|
|
name : string;
|
|
|
|
encoding : 'a Data_encoding.t;
|
|
|
|
select : packed_manager_operation -> 'kind manager_operation option;
|
|
|
|
proj : 'kind manager_operation -> 'a;
|
|
|
|
inj : 'a -> 'kind manager_operation;
|
|
|
|
}
|
|
|
|
-> 'kind case
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val reveal_case : Kind.reveal case
|
|
|
|
|
|
|
|
val transaction_case : Kind.transaction case
|
2019-09-05 17:21:01 +04:00
|
|
|
|
2020-02-12 20:40:17 +04:00
|
|
|
val origination_case : Kind.origination case
|
|
|
|
|
|
|
|
val delegation_case : Kind.delegation case
|
|
|
|
end
|
2019-09-05 17:21:01 +04:00
|
|
|
end
|