diff --git a/src/lib_crypto/signature_v0.ml b/src/lib_crypto/signature_v0.ml index 1827f52ef661fe627001feb1549e098256cf99a8..dfacd2180060b6f3dea1bc657b3b6e13bb57d3dc 100644 --- a/src/lib_crypto/signature_v0.ml +++ b/src/lib_crypto/signature_v0.ml @@ -45,6 +45,8 @@ type secret_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of Bytes.t @@ -621,6 +623,10 @@ let bytes_of_watermark = function Bytes.cat (Bytes.of_string "\x01") (Chain_id.to_bytes chain_id) | Endorsement chain_id -> Bytes.cat (Bytes.of_string "\x02") (Chain_id.to_bytes chain_id) + | Attestation chain_id -> + Bytes.cat (Bytes.of_string "\x13") (Chain_id.to_bytes chain_id) + | Preattestation chain_id -> + Bytes.cat (Bytes.of_string "\x12") (Chain_id.to_bytes chain_id) | Generic_operation -> Bytes.of_string "\x03" | Custom bytes -> bytes @@ -629,6 +635,9 @@ let pp_watermark ppf = function | Block_header chain_id -> fprintf ppf "Block-header: %a" Chain_id.pp chain_id | Endorsement chain_id -> fprintf ppf "Endorsement: %a" Chain_id.pp chain_id + | Attestation chain_id -> fprintf ppf "Attestation: %a" Chain_id.pp chain_id + | Preattestation chain_id -> + fprintf ppf "Preattestation: %a" Chain_id.pp chain_id | Generic_operation -> pp_print_string ppf "Generic-operation" | Custom bytes -> let hexed = Hex.of_bytes bytes |> Hex.show in diff --git a/src/lib_crypto/signature_v0.mli b/src/lib_crypto/signature_v0.mli index 88769a465b61158a0fb89e34172306f038197d42..355f4af9946f12dce014c5e75a2a53eb4056dcfc 100644 --- a/src/lib_crypto/signature_v0.mli +++ b/src/lib_crypto/signature_v0.mli @@ -42,6 +42,8 @@ type secret_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of Bytes.t diff --git a/src/lib_crypto/signature_v1.ml b/src/lib_crypto/signature_v1.ml index 6f17d6c602023f0081e0767a8fd9fdad6e77aded..e87f83fe0f429b3159adebb4bdaa0d5dde6ee114 100644 --- a/src/lib_crypto/signature_v1.ml +++ b/src/lib_crypto/signature_v1.ml @@ -48,6 +48,8 @@ type secret_key = type watermark = Signature_v0.watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of Bytes.t @@ -764,6 +766,10 @@ let bytes_of_watermark = function Bytes.cat (Bytes.of_string "\x01") (Chain_id.to_bytes chain_id) | Endorsement chain_id -> Bytes.cat (Bytes.of_string "\x02") (Chain_id.to_bytes chain_id) + | Attestation chain_id -> + Bytes.cat (Bytes.of_string "\x13") (Chain_id.to_bytes chain_id) + | Preattestation chain_id -> + Bytes.cat (Bytes.of_string "\x12") (Chain_id.to_bytes chain_id) | Generic_operation -> Bytes.of_string "\x03" | Custom bytes -> bytes @@ -772,6 +778,9 @@ let pp_watermark ppf = function | Block_header chain_id -> fprintf ppf "Block-header: %a" Chain_id.pp chain_id | Endorsement chain_id -> fprintf ppf "Endorsement: %a" Chain_id.pp chain_id + | Attestation chain_id -> fprintf ppf "Attestation: %a" Chain_id.pp chain_id + | Preattestation chain_id -> + fprintf ppf "Preattestation: %a" Chain_id.pp chain_id | Generic_operation -> pp_print_string ppf "Generic-operation" | Custom bytes -> let hexed = Hex.of_bytes bytes |> Hex.show in diff --git a/src/lib_crypto/signature_v1.mli b/src/lib_crypto/signature_v1.mli index 22f1856bc0bc57cd3d54a4063477d5c2247f0d47..f086c20234f12d30e9fdf7d78bd05b8fb9e57ec8 100644 --- a/src/lib_crypto/signature_v1.mli +++ b/src/lib_crypto/signature_v1.mli @@ -45,6 +45,8 @@ type secret_key = type watermark = Signature_v0.watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of Bytes.t diff --git a/src/lib_protocol_environment/sigs/v0.ml b/src/lib_protocol_environment/sigs/v0.ml index 068dd33080f234c6de0aaabe41deaa097f7fd3c9..24f099d139a2eda3c4314a5d0739ca6646f0f6f7 100644 --- a/src/lib_protocol_environment/sigs/v0.ml +++ b/src/lib_protocol_environment/sigs/v0.ml @@ -5245,6 +5245,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of MBytes.t diff --git a/src/lib_protocol_environment/sigs/v0/signature.mli b/src/lib_protocol_environment/sigs/v0/signature.mli index 21e6ae5e230c77cba2caa9e981cd291054996c36..95b253de0b9c14b5c309decb9e73c99a8e705380 100644 --- a/src/lib_protocol_environment/sigs/v0/signature.mli +++ b/src/lib_protocol_environment/sigs/v0/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of MBytes.t diff --git a/src/lib_protocol_environment/sigs/v1.ml b/src/lib_protocol_environment/sigs/v1.ml index 3d13f7ee82f26d74d6d6586a4b5f19f209d75886..ffb82123fa5e8d0f18ed7074fa40d4d3fe9b692f 100644 --- a/src/lib_protocol_environment/sigs/v1.ml +++ b/src/lib_protocol_environment/sigs/v1.ml @@ -6170,6 +6170,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v1/signature.mli b/src/lib_protocol_environment/sigs/v1/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v1/signature.mli +++ b/src/lib_protocol_environment/sigs/v1/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v10.ml b/src/lib_protocol_environment/sigs/v10.ml index 4462553c534598c161fabb7d11055f84854895a1..5c23f92f5860891420a49d43f8f47cc12f2a355e 100644 --- a/src/lib_protocol_environment/sigs/v10.ml +++ b/src/lib_protocol_environment/sigs/v10.ml @@ -9793,6 +9793,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v10/signature.mli b/src/lib_protocol_environment/sigs/v10/signature.mli index 67b9dd7aca160201b8c7a64c0e9d9bd849247c1e..38f4f83d9fd86c8901262fce80e0cba44bdadee6 100644 --- a/src/lib_protocol_environment/sigs/v10/signature.mli +++ b/src/lib_protocol_environment/sigs/v10/signature.mli @@ -39,6 +39,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v2.ml b/src/lib_protocol_environment/sigs/v2.ml index fb8b992a9ba4ac37b38b64f4323389d2142e1d11..846e5b3520f55cb77e0283f0c6e54e00419b9c42 100644 --- a/src/lib_protocol_environment/sigs/v2.ml +++ b/src/lib_protocol_environment/sigs/v2.ml @@ -6235,6 +6235,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v2/signature.mli b/src/lib_protocol_environment/sigs/v2/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v2/signature.mli +++ b/src/lib_protocol_environment/sigs/v2/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v3.ml b/src/lib_protocol_environment/sigs/v3.ml index 564064b803b4e258ecb862372dc51b2858e89f30..3a10e87e698a4247747eaaeae333bf8d6864f8fe 100644 --- a/src/lib_protocol_environment/sigs/v3.ml +++ b/src/lib_protocol_environment/sigs/v3.ml @@ -7004,6 +7004,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v3/signature.mli b/src/lib_protocol_environment/sigs/v3/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v3/signature.mli +++ b/src/lib_protocol_environment/sigs/v3/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v4.ml b/src/lib_protocol_environment/sigs/v4.ml index 4f2e468ab803726eaa0c1f4d58b292f3f38d6084..0d38a78642ede7a860e13b2a0d5951d7d79a924e 100644 --- a/src/lib_protocol_environment/sigs/v4.ml +++ b/src/lib_protocol_environment/sigs/v4.ml @@ -7173,6 +7173,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v4/signature.mli b/src/lib_protocol_environment/sigs/v4/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v4/signature.mli +++ b/src/lib_protocol_environment/sigs/v4/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v5.ml b/src/lib_protocol_environment/sigs/v5.ml index d43a15ccc721980d0b3599a2dc8e7f4cdbdfdb00..b2efe29cfec181c1d0bf042dd22c8ac2d5a4a0bc 100644 --- a/src/lib_protocol_environment/sigs/v5.ml +++ b/src/lib_protocol_environment/sigs/v5.ml @@ -9143,6 +9143,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v5/signature.mli b/src/lib_protocol_environment/sigs/v5/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v5/signature.mli +++ b/src/lib_protocol_environment/sigs/v5/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v6.ml b/src/lib_protocol_environment/sigs/v6.ml index 2056296fd2e015f1e2efcb420b7269d6fd1b199b..46ec880a076ac0e8b62a3b359d294eeaa7a4980d 100644 --- a/src/lib_protocol_environment/sigs/v6.ml +++ b/src/lib_protocol_environment/sigs/v6.ml @@ -9143,6 +9143,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v6/signature.mli b/src/lib_protocol_environment/sigs/v6/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v6/signature.mli +++ b/src/lib_protocol_environment/sigs/v6/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v7.ml b/src/lib_protocol_environment/sigs/v7.ml index db54ebbef4e433c58b1e5744056b64e9ebc7f3c4..40628f56906fdda33f3c4273a11694bcd62892b8 100644 --- a/src/lib_protocol_environment/sigs/v7.ml +++ b/src/lib_protocol_environment/sigs/v7.ml @@ -9548,6 +9548,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v7/signature.mli b/src/lib_protocol_environment/sigs/v7/signature.mli index 1a1d295d60256c308962d6f9a6a6cfee24308d8f..75582016691c22a86b0d906ab48579e0a2d5c6ae 100644 --- a/src/lib_protocol_environment/sigs/v7/signature.mli +++ b/src/lib_protocol_environment/sigs/v7/signature.mli @@ -36,6 +36,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v8.ml b/src/lib_protocol_environment/sigs/v8.ml index e10325fec77989fc2554d28eb18d29d8f2cf60f9..efba429c91cbf7528278f59b83f2e2e1eb6d1cc0 100644 --- a/src/lib_protocol_environment/sigs/v8.ml +++ b/src/lib_protocol_environment/sigs/v8.ml @@ -9852,6 +9852,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v8/signature.mli b/src/lib_protocol_environment/sigs/v8/signature.mli index 67b9dd7aca160201b8c7a64c0e9d9bd849247c1e..38f4f83d9fd86c8901262fce80e0cba44bdadee6 100644 --- a/src/lib_protocol_environment/sigs/v8/signature.mli +++ b/src/lib_protocol_environment/sigs/v8/signature.mli @@ -39,6 +39,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v9.ml b/src/lib_protocol_environment/sigs/v9.ml index 92d867725c6dbb506c75d071f1250a6438f610cd..1a16c47c1aafa14d1bff3faa0b00167253a5ef00 100644 --- a/src/lib_protocol_environment/sigs/v9.ml +++ b/src/lib_protocol_environment/sigs/v9.ml @@ -9779,6 +9779,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/lib_protocol_environment/sigs/v9/signature.mli b/src/lib_protocol_environment/sigs/v9/signature.mli index 67b9dd7aca160201b8c7a64c0e9d9bd849247c1e..38f4f83d9fd86c8901262fce80e0cba44bdadee6 100644 --- a/src/lib_protocol_environment/sigs/v9/signature.mli +++ b/src/lib_protocol_environment/sigs/v9/signature.mli @@ -39,6 +39,8 @@ type public_key = type watermark = | Block_header of Chain_id.t | Endorsement of Chain_id.t + | Attestation of Chain_id.t + | Preattestation of Chain_id.t | Generic_operation | Custom of bytes diff --git a/src/proto_alpha/lib_delegate/baking_actions.ml b/src/proto_alpha/lib_delegate/baking_actions.ml index ed949d4e6d20e93df9d64b380071b1629e869799..65501d0b630865792e74053055c28f0ad5b0cf41 100644 --- a/src/proto_alpha/lib_delegate/baking_actions.ml +++ b/src/proto_alpha/lib_delegate/baking_actions.ml @@ -426,7 +426,7 @@ let inject_preendorsements state ~preendorsements = >>=? fun may_sign -> (if may_sign then let unsigned_operation = (shell, Contents_list contents) in - let watermark = Operation.(to_watermark (Preattestation chain_id)) in + let watermark = Signature.Preattestation chain_id in let unsigned_operation_bytes = Data_encoding.Binary.to_bytes_exn Operation.unsigned_encoding_with_legacy_attestation_name @@ -506,7 +506,7 @@ let sign_endorsements state endorsements = | false -> return state.global_state.config.force) >>=? fun may_sign -> (if may_sign then - let watermark = Operation.(to_watermark (Attestation chain_id)) in + let watermark = Signature.Attestation chain_id in let unsigned_operation = (shell, Contents_list contents) in let unsigned_operation_bytes = Data_encoding.Binary.to_bytes_exn diff --git a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml index 4d3cbfc8892f7a689104e56c8a92533457775280..cb4c855a9bfd2ccebb271cc1c475beda01c260c6 100644 --- a/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml +++ b/src/proto_alpha/lib_delegate/test/mockup_simulator/mockup_simulator.ml @@ -1342,10 +1342,8 @@ let op_is_signed_by ~public_key (op_hash : Operation_hash.t) | Single op_contents -> return (match op_contents with - | Attestation _ -> - Alpha_context.Operation.to_watermark (Attestation chain_id) - | Preattestation _ -> - Alpha_context.Operation.to_watermark (Preattestation chain_id) + | Attestation _ -> Signature.Attestation chain_id + | Preattestation _ -> Signature.Preattestation chain_id | _ -> Signature.Generic_operation) | _ -> failwith "unexpected contents in %a@." Operation_hash.pp op_hash) >>=? fun watermark -> diff --git a/src/proto_alpha/lib_protocol/operation_repr.ml b/src/proto_alpha/lib_protocol/operation_repr.ml index 1fd6be0b4aa497137513489709f2a81f3cb1e8b2..df4127a843507b6691723dbf9cf5655cb98a91cf 100644 --- a/src/proto_alpha/lib_protocol/operation_repr.ml +++ b/src/proto_alpha/lib_protocol/operation_repr.ml @@ -183,9 +183,7 @@ type consensus_watermark = | Dal_attestation of Chain_id.t let to_watermark = function - | Preattestation chain_id -> - Signature.Custom - (Bytes.cat (Bytes.of_string "\x12") (Chain_id.to_bytes chain_id)) + | Preattestation chain_id -> Signature.Preattestation chain_id | Dal_attestation chain_id (* FIXME: https://gitlab.com/tezos/tezos/-/issues/4479 @@ -194,23 +192,11 @@ let to_watermark = function later on. Moreover, there is a leak of abstraction with the shell which makes adding a new watermark a bit awkward. *) | Attestation chain_id -> - Signature.Custom - (Bytes.cat (Bytes.of_string "\x13") (Chain_id.to_bytes chain_id)) + Signature.Attestation chain_id let of_watermark = function - | Signature.Custom b -> - if Compare.Int.(Bytes.length b > 0) then - match Bytes.get b 0 with - | '\x12' -> - Option.map - (fun chain_id -> Preattestation chain_id) - (Chain_id.of_bytes_opt (Bytes.sub b 1 (Bytes.length b - 1))) - | '\x13' -> - Option.map - (fun chain_id -> Attestation chain_id) - (Chain_id.of_bytes_opt (Bytes.sub b 1 (Bytes.length b - 1))) - | _ -> None - else None + | Signature.Attestation chain_id -> Some (Attestation chain_id) + | Signature.Preattestation chain_id -> Some (Preattestation chain_id) | _ -> None type raw = Operation.t = {shell : Operation.shell_header; proto : bytes}