diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 40a1882ead94855e4d8a3f1cb697a2b406e14e47..92c4550dbfaebde2b8636f6153ac79727f668835 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -87,8 +87,9 @@ Internal - Refactor declarations of ``make_empty_context`` and ``make_empty_tree`` for easier use. (MR :gl:`!8550`) -- Move notion of Smart rollup address in the shell to make it common to all protocols, - and expose it in the environment. (MR :gl:`!8562`) +- Move notions of Smart rollup address and various smart rollup hashes types to + the shell to make them common to all protocols though the environment. (MR + :gl:`!8562`, MR :gl:`!8625`) - Refactoring : stake splitted between a frozen part and a delegated part. (MR :gl:`!8051`) diff --git a/src/lib_crypto/base58.ml b/src/lib_crypto/base58.ml index fe8cd281dd0c11e2eecc03c072c8100c7025a504..0c8d96f5700838d606eba4c79dd7ffeff3d065df 100644 --- a/src/lib_crypto/base58.ml +++ b/src/lib_crypto/base58.ml @@ -398,6 +398,14 @@ module Prefix = struct let p256_secret_key = "\016\081\238\189" (* p2sk(54) *) + let smart_rollup_commitment = "\017\165\134\138" (* src1(54) *) + + let smart_rollup_state = "\017\165\235\240" (* srs1(54) *) + + let smart_rollup_inbox = "\003\255\138\145\110" (* srib1(55) *) + + let smart_rollup_merkelized_payload = "\003\255\138\145\140" (* srib2(55) *) + (* 56 *) let ed25519_encrypted_seed = "\007\090\060\179\041" (* edesk(88) *) diff --git a/src/lib_crypto/base58.mli b/src/lib_crypto/base58.mli index dbb13934764f436812463d33f9b7de4641149cfd..7e9c3a12d8bf1ac5152ec121a36c916d53ed9513 100644 --- a/src/lib_crypto/base58.mli +++ b/src/lib_crypto/base58.mli @@ -57,6 +57,14 @@ module Prefix : sig val smart_rollup_address : string + val smart_rollup_commitment : string + + val smart_rollup_state : string + + val smart_rollup_inbox : string + + val smart_rollup_merkelized_payload : string + val cryptobox_public_key_hash : string val ed25519_seed : string diff --git a/src/lib_crypto/smart_rollup_address.ml b/src/lib_crypto/smart_rollup_address.ml index 2c5a0abe7aff7807c930895525a1d1ded164cfee..230f2565460e540b88679b172184fb037a7d34b4 100644 --- a/src/lib_crypto/smart_rollup_address.ml +++ b/src/lib_crypto/smart_rollup_address.ml @@ -30,7 +30,7 @@ include Blake2B.Make (Base58) (struct - let name = "Smart_rollup_address" + let name = "smart_rollup_address" let title = "A smart rollup address" diff --git a/src/lib_crypto/smart_rollup_commitment_hash.ml b/src/lib_crypto/smart_rollup_commitment_hash.ml new file mode 100644 index 0000000000000000000000000000000000000000..19a9529f2f9ecdd3a2b878339bb639265048b3a4 --- /dev/null +++ b/src/lib_crypto/smart_rollup_commitment_hash.ml @@ -0,0 +1,42 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include + Blake2B.Make + (Base58) + (struct + let name = "smart_rollup_commitment_hash" + + let title = "The hash of a commitment of a smart rollup" + + let b58check_prefix = Base58.Prefix.smart_rollup_commitment + + (* defaults to 32 *) + let size = None + end) + +let () = Base58.check_encoded_prefix b58check_encoding "src1" 54 diff --git a/src/lib_protocol_environment/sigs/v10/smart_rollup_address.mli b/src/lib_crypto/smart_rollup_commitment_hash.mli similarity index 92% rename from src/lib_protocol_environment/sigs/v10/smart_rollup_address.mli rename to src/lib_crypto/smart_rollup_commitment_hash.mli index 753911a4c88c608867f46e8801b9ff75ca0aa724..e253a4dba5a26c03884f72fed046a35c7750449a 100644 --- a/src/lib_protocol_environment/sigs/v10/smart_rollup_address.mli +++ b/src/lib_crypto/smart_rollup_commitment_hash.mli @@ -1,6 +1,8 @@ (*****************************************************************************) (* *) (* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) (* Copyright (c) 2023 Functori, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) @@ -23,5 +25,4 @@ (* *) (*****************************************************************************) -(** Smart rollup addresses *) include S.HASH diff --git a/src/lib_crypto/smart_rollup_inbox_hash.ml b/src/lib_crypto/smart_rollup_inbox_hash.ml new file mode 100644 index 0000000000000000000000000000000000000000..7c79cdad0fd7021820fe6cc738c1aa53f7225cc2 --- /dev/null +++ b/src/lib_crypto/smart_rollup_inbox_hash.ml @@ -0,0 +1,42 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include + Blake2B.Make + (Base58) + (struct + let name = "smart_rollup_inbox_hash" + + let title = "The hash of an inbox of a smart rollup" + + let b58check_prefix = Base58.Prefix.smart_rollup_inbox + + (* defaults to 32 *) + let size = None + end) + +let () = Base58.check_encoded_prefix b58check_encoding "srib1" 55 diff --git a/src/lib_crypto/smart_rollup_inbox_hash.mli b/src/lib_crypto/smart_rollup_inbox_hash.mli new file mode 100644 index 0000000000000000000000000000000000000000..e253a4dba5a26c03884f72fed046a35c7750449a --- /dev/null +++ b/src/lib_crypto/smart_rollup_inbox_hash.mli @@ -0,0 +1,28 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include S.HASH diff --git a/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.ml b/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.ml new file mode 100644 index 0000000000000000000000000000000000000000..18579f4fc4f7155b0cf4fb426a2ede851b73879b --- /dev/null +++ b/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.ml @@ -0,0 +1,43 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include + Blake2B.Make + (Base58) + (struct + let name = "smart_rollup_merkelized_payload_hashes_hash" + + let title = + "The hash of the Merkelized payload hashes of a smart rollup inbox" + + let b58check_prefix = Base58.Prefix.smart_rollup_merkelized_payload + + (* defaults to 32 *) + let size = None + end) + +let () = Base58.check_encoded_prefix b58check_encoding "srib2" 55 diff --git a/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.mli b/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.mli new file mode 100644 index 0000000000000000000000000000000000000000..e253a4dba5a26c03884f72fed046a35c7750449a --- /dev/null +++ b/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.mli @@ -0,0 +1,28 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include S.HASH diff --git a/src/lib_crypto/smart_rollup_state_hash.ml b/src/lib_crypto/smart_rollup_state_hash.ml new file mode 100644 index 0000000000000000000000000000000000000000..3776e03d1b941b23b16fbba4ef87f7acc3458d1a --- /dev/null +++ b/src/lib_crypto/smart_rollup_state_hash.ml @@ -0,0 +1,53 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include + Blake2B.Make + (Base58) + (struct + let name = "smart_rollup_state_hash" + + let title = "The hash of the VM state of a smart rollup" + + let b58check_prefix = Base58.Prefix.smart_rollup_state + + (* Same size as context hashes, from which they are derived. *) + let size = Some Context_hash.size + end) + +let () = Base58.check_encoded_prefix b58check_encoding "srs1" 54 + +let context_hash_to_state_hash h = of_bytes_exn @@ Context_hash.to_bytes h + +(* Hackish way to disable hash_bytes and hash_string to force people to use + context_hash_to_state_hash (without changing content of S.HASH) *) +type unreachable__use_context_hash_to_state_hash = + | Unreachable__use_context_hash_to_state_hash + +let hash_bytes = Unreachable__use_context_hash_to_state_hash + +let hash_string = Unreachable__use_context_hash_to_state_hash diff --git a/src/lib_crypto/smart_rollup_state_hash.mli b/src/lib_crypto/smart_rollup_state_hash.mli new file mode 100644 index 0000000000000000000000000000000000000000..19deac2ad0beaf5e37ab6905c67eba289c4517cd --- /dev/null +++ b/src/lib_crypto/smart_rollup_state_hash.mli @@ -0,0 +1,40 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs *) +(* Copyright (c) 2022 Trili Tech, *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +include S.HASH + +(** [context_hash_to_state_hash ch] turns an (Irmin) context hash into a state + hash. *) +val context_hash_to_state_hash : Context_hash.t -> t + +(** Hackish way to disable [hash_bytes] and [hash_string] to force people to use + {!context_hash_to_state_hash} (without changing content of {!S.HASH}). *) +type unreachable__use_context_hash_to_state_hash + +val hash_bytes : unreachable__use_context_hash_to_state_hash + +val hash_string : unreachable__use_context_hash_to_state_hash diff --git a/src/lib_crypto/tezos_crypto.ml b/src/lib_crypto/tezos_crypto.ml index 4894d7f1f5aa2bee16afc77462ad3c0eea50e9cc..f33d8d750744c615c49a96b9fd391c0ee2a428df 100644 --- a/src/lib_crypto/tezos_crypto.ml +++ b/src/lib_crypto/tezos_crypto.ml @@ -38,6 +38,11 @@ module Hashed = struct module Operation_metadata_list_list_hash = Operation_metadata_list_list_hash module Protocol_hash = Protocol_hash module Smart_rollup_address = Smart_rollup_address + module Smart_rollup_commitment_hash = Smart_rollup_commitment_hash + module Smart_rollup_state_hash = Smart_rollup_state_hash + module Smart_rollup_inbox_hash = Smart_rollup_inbox_hash + module Smart_rollup_merkelized_payload_hashes_hash = + Smart_rollup_merkelized_payload_hashes_hash end module Signature = struct diff --git a/src/lib_protocol_environment/environment_V10.ml b/src/lib_protocol_environment/environment_V10.ml index d73054185334cf3dca32619c5c6951ff5faabf71..e0fa3c8e83f282d39954ca772c5df98d5e00f32d 100644 --- a/src/lib_protocol_environment/environment_V10.ml +++ b/src/lib_protocol_environment/environment_V10.ml @@ -123,8 +123,16 @@ module type T = sig and type Wasm_2_0_0.input_request = Tezos_scoru_wasm.Wasm_pvm_state.input_request and type Wasm_2_0_0.info = Tezos_scoru_wasm.Wasm_pvm_state.info - and type Smart_rollup_address.t = + and type Smart_rollup.Address.t = Tezos_crypto.Hashed.Smart_rollup_address.t + and type Smart_rollup.Commitment_hash.t = + Tezos_crypto.Hashed.Smart_rollup_commitment_hash.t + and type Smart_rollup.State_hash.t = + Tezos_crypto.Hashed.Smart_rollup_state_hash.t + and type Smart_rollup.Inbox_hash.t = + Tezos_crypto.Hashed.Smart_rollup_inbox_hash.t + and type Smart_rollup.Merkelized_payload_hashes_hash.t = + Tezos_crypto.Hashed.Smart_rollup_merkelized_payload_hashes_hash.t type error += Ecoproto_error of Error_monad.error @@ -1466,5 +1474,13 @@ struct | Ok () -> Ok true end - module Smart_rollup_address = Tezos_crypto.Hashed.Smart_rollup_address + module Smart_rollup = struct + module Address = Tezos_crypto.Hashed.Smart_rollup_address + module Commitment_hash = Tezos_crypto.Hashed.Smart_rollup_commitment_hash + module State_hash = Tezos_crypto.Hashed.Smart_rollup_state_hash + module Inbox_hash = Tezos_crypto.Hashed.Smart_rollup_inbox_hash + + module Merkelized_payload_hashes_hash = + Tezos_crypto.Hashed.Smart_rollup_merkelized_payload_hashes_hash + end end diff --git a/src/lib_protocol_environment/environment_V10.mli b/src/lib_protocol_environment/environment_V10.mli index f227964cee8b2ede652ea7c775acbf3d96540ad5..e47f16cbdea6424a41df86e11a1e0dd987e6b5c6 100644 --- a/src/lib_protocol_environment/environment_V10.mli +++ b/src/lib_protocol_environment/environment_V10.mli @@ -123,8 +123,16 @@ module type T = sig and type Wasm_2_0_0.input_request = Tezos_scoru_wasm.Wasm_pvm_state.input_request and type Wasm_2_0_0.info = Tezos_scoru_wasm.Wasm_pvm_state.info - and type Smart_rollup_address.t = + and type Smart_rollup.Address.t = Tezos_crypto.Hashed.Smart_rollup_address.t + and type Smart_rollup.Commitment_hash.t = + Tezos_crypto.Hashed.Smart_rollup_commitment_hash.t + and type Smart_rollup.State_hash.t = + Tezos_crypto.Hashed.Smart_rollup_state_hash.t + and type Smart_rollup.Inbox_hash.t = + Tezos_crypto.Hashed.Smart_rollup_inbox_hash.t + and type Smart_rollup.Merkelized_payload_hashes_hash.t = + Tezos_crypto.Hashed.Smart_rollup_merkelized_payload_hashes_hash.t (** An [Ecoproto_error e] is a shell error that carry a protocol error. diff --git a/src/lib_protocol_environment/sigs/v10.in.ml b/src/lib_protocol_environment/sigs/v10.in.ml index df0ab695f92fbb7b0b6ea4c46c0bbce2c6aea9b7..32aef9e0e9314aaa47af9ba058585719b192488e 100644 --- a/src/lib_protocol_environment/sigs/v10.in.ml +++ b/src/lib_protocol_environment/sigs/v10.in.ml @@ -135,5 +135,5 @@ module type T = sig module Dal : [%sig "v10/dal.mli"] - module Smart_rollup_address : [%sig "v10/smart_rollup_address.mli"] + module Smart_rollup : [%sig "v10/smart_rollup.mli"] end diff --git a/src/lib_protocol_environment/sigs/v10.ml b/src/lib_protocol_environment/sigs/v10.ml index 3c934e3943db8718e316b8af5f7419cb31c8d507..c5d5ce9af7ff62353d439030d9a05706623301de 100644 --- a/src/lib_protocol_environment/sigs/v10.ml +++ b/src/lib_protocol_environment/sigs/v10.ml @@ -12323,8 +12323,8 @@ end # 136 "v10.in.ml" - module Smart_rollup_address : sig -# 1 "v10/smart_rollup_address.mli" + module Smart_rollup : sig +# 1 "v10/smart_rollup.mli" (*****************************************************************************) (* *) (* Open Source License *) @@ -12351,7 +12351,31 @@ end (*****************************************************************************) (** Smart rollup addresses *) -include S.HASH +module Address : S.HASH + +(** Smart rollup commitment hashes *) +module Commitment_hash : S.HASH + +(** Smart rollup PVM state hashes. Refer to + {!Tezos_crypto.Hashed.Smart_rollup_state_hash} in + [src/lib_crypto/smart_rollup_state_hash.mli] for documentation. *) +module State_hash : sig + include S.HASH + + val context_hash_to_state_hash : Context_hash.t -> t + + type unreachable__use_context_hash_to_state_hash + + val hash_bytes : unreachable__use_context_hash_to_state_hash + + val hash_string : unreachable__use_context_hash_to_state_hash +end + +(** Smart rollup inbox hashes *) +module Inbox_hash : S.HASH + +(** Smart rollup merkelized payload hashes' hash *) +module Merkelized_payload_hashes_hash : S.HASH end # 138 "v10.in.ml" diff --git a/src/lib_protocol_environment/sigs/v10/smart_rollup.mli b/src/lib_protocol_environment/sigs/v10/smart_rollup.mli new file mode 100644 index 0000000000000000000000000000000000000000..39221dc057e6fc2c9e994436305996e6d5acf845 --- /dev/null +++ b/src/lib_protocol_environment/sigs/v10/smart_rollup.mli @@ -0,0 +1,51 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2023 Functori, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** Smart rollup addresses *) +module Address : S.HASH + +(** Smart rollup commitment hashes *) +module Commitment_hash : S.HASH + +(** Smart rollup PVM state hashes. Refer to + {!Tezos_crypto.Hashed.Smart_rollup_state_hash} in + [src/lib_crypto/smart_rollup_state_hash.mli] for documentation. *) +module State_hash : sig + include S.HASH + + val context_hash_to_state_hash : Context_hash.t -> t + + type unreachable__use_context_hash_to_state_hash + + val hash_bytes : unreachable__use_context_hash_to_state_hash + + val hash_string : unreachable__use_context_hash_to_state_hash +end + +(** Smart rollup inbox hashes *) +module Inbox_hash : S.HASH + +(** Smart rollup merkelized payload hashes' hash *) +module Merkelized_payload_hashes_hash : S.HASH diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index ce0980048d0ec498c313130b9fc02af9a14212c7..62f800366a9a8ec7931033b59edc59c12ad3a2fc 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2353,7 +2353,7 @@ end module Bond_id : sig type t = | Tx_rollup_bond_id of Tx_rollup.t - | Sc_rollup_bond_id of Smart_rollup_address.t + | Sc_rollup_bond_id of Smart_rollup.Address.t val pp : Format.formatter -> t -> unit @@ -3232,12 +3232,11 @@ module Sc_rollup : sig module Map : Map.S with type key = t end - module Address : sig - include - module type of Smart_rollup_address with type t = Smart_rollup_address.t + module Address : module type of struct + include Smart_rollup.Address end - type t = Smart_rollup_address.t + type t = Smart_rollup.Address.t type rollup := t @@ -3259,16 +3258,8 @@ module Sc_rollup : sig end end - module State_hash : sig - include S.HASH - - val context_hash_to_state_hash : Context_hash.t -> t - - type unreachable = | - - val hash_bytes : unreachable -> t - - val hash_string : unreachable -> t + module State_hash : module type of struct + include Smart_rollup.State_hash end (** See {!Sc_rollup_metadata_repr}. *) @@ -3323,7 +3314,8 @@ module Sc_rollup : sig end module Inbox_merkelized_payload_hashes : sig - module Hash : S.HASH + module Hash : + S.HASH with type t = Smart_rollup.Merkelized_payload_hashes_hash.t type t @@ -3426,7 +3418,7 @@ module Sc_rollup : sig module Inbox : sig module Skip_list : Skip_list_repr.S - module Hash : S.HASH + module Hash : S.HASH with type t = Smart_rollup.Inbox_hash.t type level_proof = { hash : Inbox_merkelized_payload_hashes.Hash.t; @@ -3899,7 +3891,7 @@ module Sc_rollup : sig end module Commitment : sig - module Hash : S.HASH + module Hash : S.HASH with type t = Smart_rollup.Commitment_hash.t type t = { compressed_state : State_hash.t; diff --git a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml index ce04a607887171e9da61761a6875ae6993a9ef53..7672212c8f0b1a29a444e64fb64aec7545d99bf7 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.ml @@ -26,33 +26,9 @@ open Sc_rollup_repr -(* 32 *) -let hash_prefix = "\017\165\134\138" (* src1(54) *) - module Hash = struct - let prefix = "src1" - - let encoded_size = 54 - - module H = - Blake2B.Make - (Base58) - (struct - let name = "Smart_rollup_commitment_hash" - - let title = "The hash of a commitment of a smart rollup" - - let b58check_prefix = hash_prefix - - (* defaults to 32 *) - let size = None - end) - - include H - - let () = Base58.check_encoded_prefix b58check_encoding prefix encoded_size - - include Path_encoding.Make_hex (H) + include Smart_rollup.Commitment_hash + include Path_encoding.Make_hex (Smart_rollup.Commitment_hash) end module V1 = struct diff --git a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli index 50fc983bb9dd9b5eb6d4ada0e3e3b2318a691995..c875c6171756c1f4bdfbcef6ad744cfeb044afab 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_commitment_repr.mli @@ -27,7 +27,7 @@ open Sc_rollup_repr module Hash : sig - include S.HASH + include S.HASH with type t = Smart_rollup.Commitment_hash.t include Storage_description.INDEX with type t := t end diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml index b9c49ea88f4b1fd2667464ef10ade70cce5fe243..ade00f181de9f5efdfc93d4c1f2a8dbc341cdc86 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.ml @@ -42,34 +42,7 @@ module Skip_list_parameters = struct end module Skip_list = Skip_list_repr.Make (Skip_list_parameters) - -(* 32 *) -let hash_prefix = "\003\255\138\145\140" (* srib2(55) *) - -module Hash = struct - let prefix = "srib2" - - let encoded_size = 55 - - module H = - Blake2B.Make - (Base58) - (struct - let name = "Smart_rollup_merkelized_payload_hashes_hash" - - let title = - "The merkelized payload hashes' hash of the smart rollup inbox" - - let b58check_prefix = hash_prefix - - (* defaults to 32 *) - let size = None - end) - - include H - - let () = Base58.check_encoded_prefix b58check_encoding prefix encoded_size -end +module Hash = Smart_rollup.Merkelized_payload_hashes_hash type t = (Sc_rollup_inbox_message_repr.Hash.t, Hash.t) Skip_list.cell diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.mli index 1d0bf1ce15724ae59a59c88966cb2f111349a6bc..3846e5364d672646684654736c85f41bafd6525d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_merkelized_payload_hashes_repr.mli @@ -24,7 +24,7 @@ type error += Merkelized_payload_hashes_proof_error of string -module Hash : S.HASH +module Hash : S.HASH with type t = Smart_rollup.Merkelized_payload_hashes_hash.t (** A type representing the head of a merkelized list of {!Sc_rollup_inbox_message_repr.serialized} message. It contains the hash of diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml index d1f076c9c08dd10e9cb7e1f3890e8e294b3c91c3..4c803b8f16ebca598ec6158dd8b42840b70d537b 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -99,35 +99,7 @@ let () = (fun () -> Inbox_level_reached_messages_limit) module Int64_map = Map.Make (Int64) - -(* 32 *) -let hash_prefix = "\003\255\138\145\110" (* srib1(55) *) - -module Hash = struct - let prefix = "srib1" - - let encoded_size = 55 - - module H = - Blake2B.Make - (Base58) - (struct - let name = "Smart_rollup_inbox_hash" - - let title = "The hash of an inbox of a smart rollup" - - let b58check_prefix = hash_prefix - - (* defaults to 32 *) - let size = None - end) - - include H - - let () = Base58.check_encoded_prefix b58check_encoding prefix encoded_size - - include Path_encoding.Make_hex (H) -end +module Hash = Smart_rollup.Inbox_hash module Skip_list_parameters = struct let basis = 4 diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli index 311ee0f5dfb046756457d030586e5b476bbf775b..de423ed624d5ec7aa42c984e92b9e10d1ccf4c07 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.mli @@ -121,7 +121,7 @@ type error += Inbox_level_reached_messages_limit *) -module Hash : S.HASH +module Hash : S.HASH with type t = Smart_rollup.Inbox_hash.t module Skip_list : Skip_list_repr.S diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index 91f2ef976238564e03509c107849eb409551ceb4..9dae544442515647796a6c4a39b62b7f7ac28e13 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml @@ -26,13 +26,13 @@ (*****************************************************************************) module Address = struct - include Smart_rollup_address + include Smart_rollup.Address let prefix = "sr1" let () = Base58.check_encoded_prefix b58check_encoding prefix 36 - let of_b58data = function Smart_rollup_address.Data h -> Some h | _ -> None + let of_b58data = function Smart_rollup.Address.Data h -> Some h | _ -> None end module Internal_for_tests = struct @@ -43,52 +43,10 @@ module Internal_for_tests = struct Address.hash_bytes [data] end -(* 32 *) -let state_hash_prefix = "\017\165\235\240" (* srs1(54) *) - -module State_hash = struct - let prefix = "srs1" - - let encoded_size = 54 - - module H = - Blake2B.Make - (Base58) - (struct - let name = "Smart_rollup_state_hash" - - let title = "The hash of the VM state of a smart rollup" - - let b58check_prefix = state_hash_prefix - - (* defaults to 32 *) - let size = None - end) - - include H - - let () = Base58.check_encoded_prefix b58check_encoding prefix encoded_size - - include Path_encoding.Make_hex (H) - - let context_hash_to_state_hash = - (* Both State_hash and Context_hash's hashes are supposed to have the - same size. This top-level check enforces this invariant, in which case, - no exception could be thrown by [of_bytes_exn] below *) - let () = assert (Compare.Int.equal size Context_hash.size) in - fun h -> of_bytes_exn @@ Context_hash.to_bytes h - - (* Hackish way to disable hash_bytes and hash_string to force people to use - context_hash_to_state_hash (without changing content of HASH.S) *) - type unreachable = | - - let hash_bytes = function (_ : unreachable) -> . - - let hash_string = function (_ : unreachable) -> . -end +module State_hash = Smart_rollup.State_hash (* TODO: https://gitlab.com/tezos/tezos/-/issues/5506 - Remove type and module aliases for Smart_rollup_address. *) + Remove type and module aliases for Smart_rollup.Address. *) type t = Address.t diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli index 30e2f3315ba1a6beae2367690fc96f8e74f36e99..d4d6aa0dcbfb8687d560414a09a87734a8e79889 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli @@ -42,8 +42,9 @@ (** A smart rollup has an address starting with "sr1". *) module Address : sig - include - module type of Smart_rollup_address with type t = Smart_rollup_address.t + include module type of struct + include Smart_rollup.Address + end val of_b58data : Base58.data -> t option @@ -55,20 +56,8 @@ module Internal_for_tests : sig val originated_sc_rollup : Origination_nonce.t -> Address.t end -module State_hash : sig - include S.HASH - - (** [context_hash_to_state_hash ch] turns an (Irmin) context hash - into a state hash. *) - val context_hash_to_state_hash : Context_hash.t -> t - - (* Hackish way to disable hash_bytes and hash_string to force people to use - context_hash_to_state_hash (without changing content of HASH.S) *) - type unreachable = | - - val hash_bytes : unreachable -> t - - val hash_string : unreachable -> t +module State_hash : module type of struct + include Smart_rollup.State_hash end (** Number of ticks computed by a single commitment. This represents a claim