From 04f8ff5defb5a37afcfd149b785e4b432a3c7a49 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Mon, 5 Dec 2022 22:49:16 +0100 Subject: [PATCH 1/3] SCORU: fix encoding of payloads which are binary data --- .../sc_rollup_inbox_merkelized_payload_hashes_repr.ml | 2 +- src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 4d265f187d30..1688125c11b6 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 @@ -116,7 +116,7 @@ let merkelized_and_payload_encoding = merkelized; payload = Sc_rollup_inbox_message_repr.unsafe_of_string payload; }) - (merge_objs encoding (obj1 (req "payload" (string Plain)))) + (merge_objs encoding (obj1 (req "payload" (string Hex)))) module History = struct include 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 7e8ae93dbdf7..5b547fcbd839 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -314,7 +314,7 @@ let level_tree_proof_encoding = (req "proof" Sc_rollup_inbox_merkelized_payload_hashes_repr.proof_encoding) - (opt "payload" (string Plain))) + (opt "payload" (string Hex))) let add_protocol_internal_message payload payloads_history witness = Sc_rollup_inbox_merkelized_payload_hashes_repr.add_payload -- GitLab From 5755b88b910025fe398a04558b18f8064fad3486 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Mon, 5 Dec 2022 22:52:17 +0100 Subject: [PATCH 2/3] SCORU: fix binary encoding of Sc_rollup.t Encoding of Sc_rollup.t is now the same as Sc_rollup.Address.t which is more compact. --- .../lib_protocol/sc_rollup_repr.ml | 39 ++----------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml index 7e992ce3f689..5f9d1b350dc2 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_repr.ml @@ -112,31 +112,6 @@ let description = "A smart contract rollup is identified by a base58 address starting with " ^ Address.prefix -type error += (* `Permanent *) Invalid_sc_rollup_address of string - -let error_description = - Format.sprintf - "A smart contract rollup address must be a valid hash starting with '%s'." - Address.prefix - -let () = - let open Data_encoding in - register_error_kind - `Permanent - ~id:"rollup.invalid_smart_contract_rollup_address" - ~title:"Invalid smart contract rollup address" - ~pp:(fun ppf x -> - Format.fprintf ppf "Invalid smart contract rollup address %S" x) - ~description:error_description - (obj1 (req "address" (string Plain))) - (function Invalid_sc_rollup_address loc -> Some loc | _ -> None) - (fun loc -> Invalid_sc_rollup_address loc) - -let of_b58check s = - match Base58.decode s with - | Some (Address.Data hash) -> ok hash - | _ -> Error (Format.sprintf "Invalid_sc_rollup_address %s" s) - let pp = Address.pp let encoding = @@ -145,19 +120,13 @@ let encoding = "rollup_address" ~title:"A smart contract rollup address" ~description - (conv_with_guard Address.to_b58check of_b58check (string Plain)) + Address.encoding let rpc_arg = - let construct = Address.to_b58check in - let destruct hash = - Result.map_error (fun _ -> error_description) (of_b58check hash) - in - RPC_arg.make + RPC_arg.like + Address.rpc_arg ~descr:"A smart contract rollup address." - ~name:"sc_rollup_address" - ~construct - ~destruct - () + "sc_rollup_address" let in_memory_size (_ : t) = let open Cache_memory_helpers in -- GitLab From a7fe3c92cc157556ef511750a28070dbdc733c99 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Tue, 6 Dec 2022 09:52:33 +0100 Subject: [PATCH 3/3] Tests/Tezt: reset regressions These changes occur because of the previous commit that changes the binary representation (smaller) of Sc_rollup.t. --- ... a refutation game are slashed-rewarded.out | 18 +++++++++--------- ...trypoint- -aux- earliness- 0- external).out | 6 +++--- ...trypoint- -aux- earliness- 0- internal).out | 6 +++--- ...point- -default- earliness- 0- external.out | 6 +++--- ...point- -default- earliness- 0- internal.out | 6 +++--- ...entrypoint- -aux- earliness- 0- externa.out | 6 +++--- ...entrypoint- -aux- earliness- 0- interna.out | 6 +++--- ...entrypoint- -default- earliness- 0- ext.out | 6 +++--- ...entrypoint- -default- earliness- 0- int.out | 6 +++--- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - participant of a refutation game are slashed-rewarded.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - participant of a refutation game are slashed-rewarded.out index 7cd74e1aefcc..1338c8f12de3 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - participant of a refutation game are slashed-rewarded.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - participant of a refutation game are slashed-rewarded.out @@ -46,13 +46,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001044 + Fee to the baker: ꜩ0.001023 Expected counter: 1 Gas limit: 7022 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001044 - payload fees(the block proposer) ....... +ꜩ0.001044 + [PUBLIC_KEY_HASH] ... -ꜩ0.001023 + payload fees(the block proposer) ....... +ꜩ0.001023 Smart contract rollup commitment publishing: Address: [SC_ROLLUP_HASH] Commitment: @@ -82,13 +82,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001067 + Fee to the baker: ꜩ0.001046 Expected counter: 1 Gas limit: 7252 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001067 - payload fees(the block proposer) ....... +ꜩ0.001067 + [PUBLIC_KEY_HASH] ... -ꜩ0.001046 + payload fees(the block proposer) ....... +ꜩ0.001046 Smart contract rollup commitment publishing: Address: [SC_ROLLUP_HASH] Commitment: @@ -118,13 +118,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001033 + Fee to the baker: ꜩ0.001012 Expected counter: 2 Gas limit: 7252 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001033 - payload fees(the block proposer) ....... +ꜩ0.001033 + [PUBLIC_KEY_HASH] ... -ꜩ0.001012 + payload fees(the block proposer) ....... +ꜩ0.001012 Smart contract rollup refutation timeout: Address: [SC_ROLLUP_HASH] First staker (Alice): [PUBLIC_KEY_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- external).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- external).out index 7b596906defb..65b0c87ef0fd 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- external).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- external).out @@ -71,13 +71,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001238 + Fee to the baker: ꜩ0.001217 Expected counter: 2 Gas limit: 5980 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001238 - payload fees(the block proposer) ....... +ꜩ0.001238 + [PUBLIC_KEY_HASH] ... -ꜩ0.001217 + payload fees(the block proposer) ....... +ꜩ0.001217 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- internal).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- internal).out index f262ac7213ad..c5d611771678 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- internal).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -aux- earliness- 0- internal).out @@ -46,13 +46,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001238 + Fee to the baker: ꜩ0.001217 Expected counter: 1 Gas limit: 5980 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001238 - payload fees(the block proposer) ....... +ꜩ0.001238 + [PUBLIC_KEY_HASH] ... -ꜩ0.001217 + payload fees(the block proposer) ....... +ꜩ0.001217 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- external.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- external.out index 7a6415fa6f31..9350536edea4 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- external.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- external.out @@ -71,13 +71,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001242 + Fee to the baker: ꜩ0.001221 Expected counter: 2 Gas limit: 5980 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001242 - payload fees(the block proposer) ....... +ꜩ0.001242 + [PUBLIC_KEY_HASH] ... -ꜩ0.001221 + payload fees(the block proposer) ....... +ꜩ0.001221 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- internal.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- internal.out index e1d10e3132a4..5775c2734495 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- internal.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - trigger exec output (entrypoint- -default- earliness- 0- internal.out @@ -46,13 +46,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001242 + Fee to the baker: ꜩ0.001221 Expected counter: 1 Gas limit: 5980 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001242 - payload fees(the block proposer) ....... +ꜩ0.001242 + [PUBLIC_KEY_HASH] ... -ꜩ0.001221 + payload fees(the block proposer) ....... +ꜩ0.001221 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- externa.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- externa.out index 1093b1c7e5fb..f8436657219e 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- externa.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- externa.out @@ -71,13 +71,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001516 + Fee to the baker: ꜩ0.001495 Expected counter: 2 Gas limit: 6027 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001516 - payload fees(the block proposer) ....... +ꜩ0.001516 + [PUBLIC_KEY_HASH] ... -ꜩ0.001495 + payload fees(the block proposer) ....... +ꜩ0.001495 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- interna.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- interna.out index 51c58fefc775..645ee85da28e 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- interna.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -aux- earliness- 0- interna.out @@ -46,13 +46,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001484 + Fee to the baker: ꜩ0.001463 Expected counter: 1 Gas limit: 6021 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001484 - payload fees(the block proposer) ....... +ꜩ0.001484 + [PUBLIC_KEY_HASH] ... -ꜩ0.001463 + payload fees(the block proposer) ....... +ꜩ0.001463 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- ext.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- ext.out index ca8dfb5a6316..13c5aea95d6e 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- ext.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- ext.out @@ -71,13 +71,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001524 + Fee to the baker: ꜩ0.001503 Expected counter: 2 Gas limit: 6028 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001524 - payload fees(the block proposer) ....... +ꜩ0.001524 + [PUBLIC_KEY_HASH] ... -ꜩ0.001503 + payload fees(the block proposer) ....... +ꜩ0.001503 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- int.out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- int.out index e77ae7c08fb8..0bde2ae70bc5 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- int.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - trigger exec output (entrypoint- -default- earliness- 0- int.out @@ -46,13 +46,13 @@ and/or an external block explorer to make sure that it has been included. This sequence of operations was run: Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.001492 + Fee to the baker: ꜩ0.001471 Expected counter: 1 Gas limit: 6023 Storage limit: 25 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.001492 - payload fees(the block proposer) ....... +ꜩ0.001492 + [PUBLIC_KEY_HASH] ... -ꜩ0.001471 + payload fees(the block proposer) ....... +ꜩ0.001471 Smart contract output message execution: Address: [SC_ROLLUP_HASH] Cemented commitment: [SC_ROLLUP_COMMITMENT_HASH] -- GitLab