From 63cceeb50b2b69883fafb5d3200403e72a6c857c Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 16:48:21 +0200 Subject: [PATCH 01/11] Shell: smart rollup commitment hashes as base hash --- src/lib_crypto/base58.ml | 2 + src/lib_crypto/base58.mli | 2 + .../smart_rollup_commitment_hash.ml | 42 +++++++++++++++++++ .../smart_rollup_commitment_hash.mli | 28 +++++++++++++ src/lib_crypto/tezos_crypto.ml | 1 + 5 files changed, 75 insertions(+) create mode 100644 src/lib_crypto/smart_rollup_commitment_hash.ml create mode 100644 src/lib_crypto/smart_rollup_commitment_hash.mli diff --git a/src/lib_crypto/base58.ml b/src/lib_crypto/base58.ml index fe8cd281dd0c..11b60eb51859 100644 --- a/src/lib_crypto/base58.ml +++ b/src/lib_crypto/base58.ml @@ -398,6 +398,8 @@ module Prefix = struct let p256_secret_key = "\016\081\238\189" (* p2sk(54) *) + let smart_rollup_commitment = "\017\165\134\138" (* src1(54) *) + (* 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 dbb13934764f..e5c17b4f41b6 100644 --- a/src/lib_crypto/base58.mli +++ b/src/lib_crypto/base58.mli @@ -57,6 +57,8 @@ module Prefix : sig val smart_rollup_address : string + val smart_rollup_commitment : string + val cryptobox_public_key_hash : string val ed25519_seed : string 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 000000000000..19a9529f2f9e --- /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_crypto/smart_rollup_commitment_hash.mli b/src/lib_crypto/smart_rollup_commitment_hash.mli new file mode 100644 index 000000000000..e253a4dba5a2 --- /dev/null +++ b/src/lib_crypto/smart_rollup_commitment_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/tezos_crypto.ml b/src/lib_crypto/tezos_crypto.ml index 4894d7f1f5aa..a07bb494a2aa 100644 --- a/src/lib_crypto/tezos_crypto.ml +++ b/src/lib_crypto/tezos_crypto.ml @@ -38,6 +38,7 @@ 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 end module Signature = struct -- GitLab From 6cf663e32d0ea67b32b3f94c3fa1c349f847412f Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 16:50:00 +0200 Subject: [PATCH 02/11] Shell: Smart rollup PVM state hashes as base hash --- src/lib_crypto/base58.ml | 2 + src/lib_crypto/base58.mli | 2 + src/lib_crypto/smart_rollup_state_hash.ml | 53 ++++++++++++++++++++++ src/lib_crypto/smart_rollup_state_hash.mli | 40 ++++++++++++++++ src/lib_crypto/tezos_crypto.ml | 1 + 5 files changed, 98 insertions(+) create mode 100644 src/lib_crypto/smart_rollup_state_hash.ml create mode 100644 src/lib_crypto/smart_rollup_state_hash.mli diff --git a/src/lib_crypto/base58.ml b/src/lib_crypto/base58.ml index 11b60eb51859..70acfc1b6472 100644 --- a/src/lib_crypto/base58.ml +++ b/src/lib_crypto/base58.ml @@ -400,6 +400,8 @@ module Prefix = struct let smart_rollup_commitment = "\017\165\134\138" (* src1(54) *) + let smart_rollup_state = "\017\165\235\240" (* srs1(54) *) + (* 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 e5c17b4f41b6..65244b612977 100644 --- a/src/lib_crypto/base58.mli +++ b/src/lib_crypto/base58.mli @@ -59,6 +59,8 @@ module Prefix : sig val smart_rollup_commitment : string + val smart_rollup_state : string + val cryptobox_public_key_hash : string val ed25519_seed : string 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 000000000000..3776e03d1b94 --- /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 000000000000..19deac2ad0be --- /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 a07bb494a2aa..81c895490c48 100644 --- a/src/lib_crypto/tezos_crypto.ml +++ b/src/lib_crypto/tezos_crypto.ml @@ -39,6 +39,7 @@ module Hashed = struct 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 end module Signature = struct -- GitLab From db6d5c9f11f2357939f65cbb2c0f3849febe0bac Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Wed, 3 May 2023 14:33:43 +0200 Subject: [PATCH 03/11] Shell: Smart rollup merkelized payload hash as base hash --- src/lib_crypto/base58.ml | 2 + src/lib_crypto/base58.mli | 2 + ...t_rollup_merkelized_payload_hashes_hash.ml | 43 +++++++++++++++++++ ..._rollup_merkelized_payload_hashes_hash.mli | 28 ++++++++++++ src/lib_crypto/tezos_crypto.ml | 2 + 5 files changed, 77 insertions(+) create mode 100644 src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.ml create mode 100644 src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.mli diff --git a/src/lib_crypto/base58.ml b/src/lib_crypto/base58.ml index 70acfc1b6472..0bf3da231338 100644 --- a/src/lib_crypto/base58.ml +++ b/src/lib_crypto/base58.ml @@ -402,6 +402,8 @@ module Prefix = struct let smart_rollup_state = "\017\165\235\240" (* srs1(54) *) + 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 65244b612977..748ae20b5a61 100644 --- a/src/lib_crypto/base58.mli +++ b/src/lib_crypto/base58.mli @@ -61,6 +61,8 @@ module Prefix : sig val smart_rollup_state : 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_merkelized_payload_hashes_hash.ml b/src/lib_crypto/smart_rollup_merkelized_payload_hashes_hash.ml new file mode 100644 index 000000000000..18579f4fc4f7 --- /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 000000000000..e253a4dba5a2 --- /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/tezos_crypto.ml b/src/lib_crypto/tezos_crypto.ml index 81c895490c48..62d6d163ed3e 100644 --- a/src/lib_crypto/tezos_crypto.ml +++ b/src/lib_crypto/tezos_crypto.ml @@ -40,6 +40,8 @@ module Hashed = struct 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_merkelized_payload_hashes_hash = + Smart_rollup_merkelized_payload_hashes_hash end module Signature = struct -- GitLab From 193078e3a20142a799059d9cb9bbaaa5e770c319 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Wed, 3 May 2023 14:37:51 +0200 Subject: [PATCH 04/11] Shell: Smart rollup inbox hash as base hash --- src/lib_crypto/base58.ml | 2 ++ src/lib_crypto/base58.mli | 2 ++ src/lib_crypto/smart_rollup_inbox_hash.ml | 42 ++++++++++++++++++++++ src/lib_crypto/smart_rollup_inbox_hash.mli | 28 +++++++++++++++ src/lib_crypto/tezos_crypto.ml | 1 + 5 files changed, 75 insertions(+) create mode 100644 src/lib_crypto/smart_rollup_inbox_hash.ml create mode 100644 src/lib_crypto/smart_rollup_inbox_hash.mli diff --git a/src/lib_crypto/base58.ml b/src/lib_crypto/base58.ml index 0bf3da231338..0c8d96f57008 100644 --- a/src/lib_crypto/base58.ml +++ b/src/lib_crypto/base58.ml @@ -402,6 +402,8 @@ module Prefix = struct 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 *) diff --git a/src/lib_crypto/base58.mli b/src/lib_crypto/base58.mli index 748ae20b5a61..7e9c3a12d8bf 100644 --- a/src/lib_crypto/base58.mli +++ b/src/lib_crypto/base58.mli @@ -61,6 +61,8 @@ module Prefix : sig val smart_rollup_state : string + val smart_rollup_inbox : string + val smart_rollup_merkelized_payload : string val cryptobox_public_key_hash : string 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 000000000000..7c79cdad0fd7 --- /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 000000000000..e253a4dba5a2 --- /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/tezos_crypto.ml b/src/lib_crypto/tezos_crypto.ml index 62d6d163ed3e..f33d8d750744 100644 --- a/src/lib_crypto/tezos_crypto.ml +++ b/src/lib_crypto/tezos_crypto.ml @@ -40,6 +40,7 @@ module Hashed = struct 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 -- GitLab From ca8e430fee06a44ad308a1b065c9d328d48a6e0b Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 16:13:59 +0200 Subject: [PATCH 05/11] Environment: Encapsulate smart rollup address in Smart_rollup module --- src/lib_crypto/smart_rollup_address.ml | 2 +- src/lib_protocol_environment/environment_V10.ml | 6 ++++-- src/lib_protocol_environment/environment_V10.mli | 2 +- src/lib_protocol_environment/sigs/v10.in.ml | 2 +- src/lib_protocol_environment/sigs/v10.ml | 6 +++--- .../v10/{smart_rollup_address.mli => smart_rollup.mli} | 2 +- src/proto_alpha/lib_protocol/alpha_context.mli | 9 ++++----- src/proto_alpha/lib_protocol/sc_rollup_repr.ml | 6 +++--- src/proto_alpha/lib_protocol/sc_rollup_repr.mli | 5 +++-- 9 files changed, 21 insertions(+), 19 deletions(-) rename src/lib_protocol_environment/sigs/v10/{smart_rollup_address.mli => smart_rollup.mli} (98%) diff --git a/src/lib_crypto/smart_rollup_address.ml b/src/lib_crypto/smart_rollup_address.ml index 2c5a0abe7aff..230f2565460e 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_protocol_environment/environment_V10.ml b/src/lib_protocol_environment/environment_V10.ml index d73054185334..edf8bdee7830 100644 --- a/src/lib_protocol_environment/environment_V10.ml +++ b/src/lib_protocol_environment/environment_V10.ml @@ -123,7 +123,7 @@ 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 type error += Ecoproto_error of Error_monad.error @@ -1466,5 +1466,7 @@ 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 + end end diff --git a/src/lib_protocol_environment/environment_V10.mli b/src/lib_protocol_environment/environment_V10.mli index f227964cee8b..022f75b50287 100644 --- a/src/lib_protocol_environment/environment_V10.mli +++ b/src/lib_protocol_environment/environment_V10.mli @@ -123,7 +123,7 @@ 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 (** 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 df0ab695f92f..32aef9e0e931 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 3c934e3943db..eba96c47f562 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,7 @@ end (*****************************************************************************) (** Smart rollup addresses *) -include S.HASH +module Address : S.HASH end # 138 "v10.in.ml" diff --git a/src/lib_protocol_environment/sigs/v10/smart_rollup_address.mli b/src/lib_protocol_environment/sigs/v10/smart_rollup.mli similarity index 98% rename from src/lib_protocol_environment/sigs/v10/smart_rollup_address.mli rename to src/lib_protocol_environment/sigs/v10/smart_rollup.mli index 753911a4c88c..bd0fd9c27747 100644 --- a/src/lib_protocol_environment/sigs/v10/smart_rollup_address.mli +++ b/src/lib_protocol_environment/sigs/v10/smart_rollup.mli @@ -24,4 +24,4 @@ (*****************************************************************************) (** Smart rollup addresses *) -include S.HASH +module Address : S.HASH diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index ce0980048d0e..91e60621a006 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 diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index 91f2ef976238..999e4714c427 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 @@ -88,7 +88,7 @@ module State_hash = struct end (* 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 30e2f3315ba1..ed7f7b6cdce3 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 -- GitLab From e2733036a6048c5367cac6ccd4eb73259c321311 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 17:00:21 +0200 Subject: [PATCH 06/11] Environment: expose smart rollup hash types --- .../environment_V10.ml | 14 +++++++++++ .../environment_V10.mli | 8 +++++++ src/lib_protocol_environment/sigs/v10.ml | 24 +++++++++++++++++++ .../sigs/v10/smart_rollup.mli | 24 +++++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/src/lib_protocol_environment/environment_V10.ml b/src/lib_protocol_environment/environment_V10.ml index edf8bdee7830..e0fa3c8e83f2 100644 --- a/src/lib_protocol_environment/environment_V10.ml +++ b/src/lib_protocol_environment/environment_V10.ml @@ -125,6 +125,14 @@ module type T = sig and type Wasm_2_0_0.info = Tezos_scoru_wasm.Wasm_pvm_state.info 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 @@ -1468,5 +1476,11 @@ struct 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 022f75b50287..e47f16cbdea6 100644 --- a/src/lib_protocol_environment/environment_V10.mli +++ b/src/lib_protocol_environment/environment_V10.mli @@ -125,6 +125,14 @@ module type T = sig and type Wasm_2_0_0.info = Tezos_scoru_wasm.Wasm_pvm_state.info 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.ml b/src/lib_protocol_environment/sigs/v10.ml index eba96c47f562..c5d5ce9af7ff 100644 --- a/src/lib_protocol_environment/sigs/v10.ml +++ b/src/lib_protocol_environment/sigs/v10.ml @@ -12352,6 +12352,30 @@ end (** 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 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 index bd0fd9c27747..39221dc057e6 100644 --- a/src/lib_protocol_environment/sigs/v10/smart_rollup.mli +++ b/src/lib_protocol_environment/sigs/v10/smart_rollup.mli @@ -25,3 +25,27 @@ (** 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 -- GitLab From ba167c1c530e86fd4ea29b11664bd0e48aef1929 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 17:03:32 +0200 Subject: [PATCH 07/11] Proto: use environment smart rollup commitment hash --- .../lib_protocol/alpha_context.mli | 2 +- .../lib_protocol/sc_rollup_commitment_repr.ml | 28 ++----------------- .../sc_rollup_commitment_repr.mli | 2 +- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 91e60621a006..8e5dea6cf7e8 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3898,7 +3898,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 ce04a6078871..7672212c8f0b 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 50fc983bb9dd..c875c6171756 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 -- GitLab From afc56eadeed77439a3b71c63720e84ea35710677 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 2 May 2023 17:08:02 +0200 Subject: [PATCH 08/11] Proto: use environment smart rollup state hash --- .../lib_protocol/alpha_context.mli | 12 +---- .../lib_protocol/sc_rollup_repr.ml | 44 +------------------ .../lib_protocol/sc_rollup_repr.mli | 16 +------ 3 files changed, 5 insertions(+), 67 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 8e5dea6cf7e8..a2f842f0629d 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3258,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}. *) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index 999e4714c427..9dae54444251 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml @@ -43,49 +43,7 @@ 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. *) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli index ed7f7b6cdce3..d4d6aa0dcbfb 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.mli @@ -56,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 -- GitLab From 7d3130341dd8013782fc537725f7bba343c627a6 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Wed, 3 May 2023 14:53:11 +0200 Subject: [PATCH 09/11] Proto: use environment smart rollup merkelized payload hash --- .../lib_protocol/alpha_context.mli | 3 +- ...up_inbox_merkelized_payload_hashes_repr.ml | 29 +------------------ ...p_inbox_merkelized_payload_hashes_repr.mli | 2 +- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index a2f842f0629d..1b70d203dc9f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3314,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 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 b9c49ea88f4b..ade00f181de9 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 1d0bf1ce1572..3846e5364d67 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 -- GitLab From 4da8746e90ca5d198512a0cdbaaf75dc3389c333 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Wed, 3 May 2023 14:56:00 +0200 Subject: [PATCH 10/11] Proto: use environment smart rollup inbox hash --- .../lib_protocol/alpha_context.mli | 2 +- .../lib_protocol/sc_rollup_inbox_repr.ml | 30 +------------------ .../lib_protocol/sc_rollup_inbox_repr.mli | 2 +- 3 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 1b70d203dc9f..62f800366a9a 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3418,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; 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 d1f076c9c08d..4c803b8f16eb 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 311ee0f5dfb0..de423ed624d5 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 -- GitLab From 1caea173ed79efb5d3fd8aff3c5cc65eaae28334 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Fri, 5 May 2023 15:48:32 +0200 Subject: [PATCH 11/11] Doc: Changelog --- docs/protocols/alpha.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 40a1882ead94..92c4550dbfae 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`) -- GitLab