From aaa0020db9d4e3718551b75a562af61111c1030b Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Thu, 18 Aug 2022 17:16:02 +0200 Subject: [PATCH 01/22] Tezt,SCORU: Add a test for outbox message execution --- tezt/lib_tezos/client.ml | 29 ++++ tezt/lib_tezos/client.mli | 15 ++ tezt/lib_tezos/sc_rollup_client.ml | 61 ++++++++ tezt/lib_tezos/sc_rollup_client.mli | 35 +++++ ...x message should be executable (arith).out | 73 ++++++++++ ...sage should be executable (wasm_2_0_0).out | 73 ++++++++++ tezt/tests/sc_rollup.ml | 134 +++++++++++++++++- 7 files changed, 419 insertions(+), 1 deletion(-) create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out diff --git a/tezt/lib_tezos/client.ml b/tezt/lib_tezos/client.ml index 76094c1c311c..454c0292f736 100644 --- a/tezt/lib_tezos/client.ml +++ b/tezt/lib_tezos/client.ml @@ -1856,6 +1856,35 @@ module Sc_rollup = struct in let parse process = Process.check process in {value = process; run = parse} + + (** Run [tezos-client execute outbox message of sc rollup from + for commitment hash and output proof ]. *) + let execute_outbox_message ?(wait = "none") ?burn_cap ?storage_limit ?fee + ?hooks ~rollup ~src ~commitment_hash ~proof client = + let process = + spawn_command + ?hooks + client + (["--wait"; wait] + @ ["execute"; "outbox"; "message"; "of"; "sc"; "rollup"; rollup] + @ ["from"; src] + @ ["for"; "commitment"; "hash"; commitment_hash] + @ ["and"; "output"; "proof"; proof] + @ Option.fold + ~none:[] + ~some:(fun burn_cap -> ["--burn-cap"; Tez.to_string burn_cap]) + burn_cap + @ Option.fold + ~none:[] + ~some:(fun fee -> ["--fee"; Tez.to_string fee]) + fee + @ Option.fold + ~none:[] + ~some:(fun s -> ["--storage-limit"; string_of_int s]) + storage_limit) + in + let parse process = Process.check process in + {value = process; run = parse} end let init ?path ?admin_path ?name ?color ?base_dir ?endpoint ?media_type () = diff --git a/tezt/lib_tezos/client.mli b/tezt/lib_tezos/client.mli index a2751b616bc7..aa49b4cfe78e 100644 --- a/tezt/lib_tezos/client.mli +++ b/tezt/lib_tezos/client.mli @@ -1383,6 +1383,21 @@ module Sc_rollup : sig src:string -> t -> unit Runnable.process + + (** Run [tezos-client execute outbox message of sc rollup from + for commitment hash and output proof ]. *) + val execute_outbox_message : + ?wait:string -> + ?burn_cap:Tez.t -> + ?storage_limit:int -> + ?fee:Tez.t -> + ?hooks:Process.hooks -> + rollup:string -> + src:string -> + commitment_hash:string -> + proof:string -> + t -> + unit Runnable.process end (** {2 High-Level Functions} *) diff --git a/tezt/lib_tezos/sc_rollup_client.ml b/tezt/lib_tezos/sc_rollup_client.ml index ac6078c225f2..f8ecc8bcd1f3 100644 --- a/tezt/lib_tezos/sc_rollup_client.ml +++ b/tezt/lib_tezos/sc_rollup_client.ml @@ -108,6 +108,62 @@ let state_value ?hooks sc_client ~key = in return (Scanf.sscanf (String.trim out) "%S" (fun s -> s) |> String.to_bytes) +type transaction = { + destination : string; + entrypoint : string option; + parameters : string; +} + +let string_of_transaction {destination; entrypoint; parameters} = + Format.asprintf + {| { "destination" : "%s", %s"parameters" : "%s" } |} + destination + (match entrypoint with + | None -> "" + | Some entrypoint -> {| "entrypoint" : |} ^ entrypoint) + parameters + +let string_of_batch ts = + "[ " ^ String.concat "," (List.map string_of_transaction ts) ^ " ]" + +type outbox_proof = {commitment_hash : string; proof : string} + +let outbox_proof_batch ?hooks sc_client ~message_index ~outbox_level batch = + let* answer = + spawn_command + ?hooks + sc_client + [ + "get"; + "proof"; + "for"; + "message"; + string_of_int message_index; + "of"; + "outbox"; + "at"; + "level"; + string_of_int outbox_level; + "transferring"; + string_of_batch batch; + ] + |> Process.check_and_read_stdout + in + let open JSON in + let json = parse ~origin:"outbox_proof" answer in + let commitment_hash = json |-> "commitment_hash" |> as_string in + let proof = json |-> "proof" |> as_string in + return {commitment_hash; proof} + +let outbox_proof_single ?hooks ?entrypoint sc_client ~message_index + ~outbox_level ~destination ~parameters = + outbox_proof_batch + ?hooks + sc_client + ~message_index + ~outbox_level + [{destination; entrypoint; parameters}] + let rpc_get ?hooks sc_client path = let process = spawn_command ?hooks sc_client ["rpc"; "get"; Client.string_of_path path] @@ -135,6 +191,11 @@ let status ?hooks sc_client = let+ res = rpc_get ?hooks sc_client ["global"; "status"] in JSON.as_string res +let outbox ?hooks sc_client = + let open Lwt.Syntax in + let+ res = rpc_get ?hooks sc_client ["global"; "outbox"] in + JSON.encode res + let last_stored_commitment ?hooks sc_client = let open Lwt.Syntax in let+ json = rpc_get ?hooks sc_client ["global"; "last_stored_commitment"] in diff --git a/tezt/lib_tezos/sc_rollup_client.mli b/tezt/lib_tezos/sc_rollup_client.mli index 535d5292fc43..1d4eec9d9603 100644 --- a/tezt/lib_tezos/sc_rollup_client.mli +++ b/tezt/lib_tezos/sc_rollup_client.mli @@ -70,6 +70,41 @@ val state_value : ?hooks:Process.hooks -> t -> key:string -> bytes Lwt.t (** [status client] gets the corresponding PVM status for the current head block. *) val status : ?hooks:Process.hooks -> t -> string Lwt.t +(** [outbox client] gets the rollup outbox for the current head block. *) +val outbox : ?hooks:Process.hooks -> t -> string Lwt.t + +type outbox_proof = {commitment_hash : string; proof : string} + +(** [outbox_proof_single] asks the rollup node for a proof that an + output of a given [message_index] is available in the outbox at a + given [outbox_level] as a latent call to [destination]'s + [entrypoint] with the given [parameters]. *) +val outbox_proof_single : + ?hooks:Process.hooks -> + ?entrypoint:string -> + t -> + message_index:int -> + outbox_level:int -> + destination:string -> + parameters:string -> + outbox_proof Lwt.t + +type transaction = { + destination : string; + entrypoint : string option; + parameters : string; +} + +(** Same as [outbox_proof_single] except that the claim is about a batch + of output transactions. *) +val outbox_proof_batch : + ?hooks:Process.hooks -> + t -> + message_index:int -> + outbox_level:int -> + transaction list -> + outbox_proof Lwt.t + (** [commitment_from_json] parses a commitment from its JSON representation. *) val commitment_from_json : JSON.t -> commitment option diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out new file mode 100644 index 000000000000..b9291d20bf5c --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out @@ -0,0 +1,73 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind arith of type string booting with --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3110.429 units (will add 100 for safety) +Estimated storage: 6651 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000674 + Expected counter: 1 + Gas limit: 3211 + Storage limit: 6671 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000674 + payload fees(the block proposer) ....... +ꜩ0.000674 + Smart contract rollup origination: + Kind: arith + Parameter type: string + Boot sector: '' + This smart contract rollup origination was successfully applied + Consumed gas: 3110.429 + Storage size: 6651 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ1.66275 + storage fees ........................... +ꜩ1.66275 + + +./tezos-client --wait none send sc rollup message 'text:["37 [CONTRACT_HASH]"]' from bootstrap2 to '[SC_ROLLUP_HASH]' +Node is bootstrapped. +Estimated gas: 1877.377 units (will add 100 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.00051 + Expected counter: 1 + Gas limit: 1978 + Storage limit: 0 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.00051 + payload fees(the block proposer) ....... +ꜩ0.00051 + Smart contract rollup messages submission: + Address: [SC_ROLLUP_HASH] + This smart contract rollup messages submission was successfully applied + Consumed gas: 1877.377 + Resulting inbox state: { rollup = [SC_ROLLUP_HASH] + level = 4 + current messages hash = [SC_ROLLUP_INBOX_HASH] + nb_messages_in_commitment_period = 1 + starting_level_of_current_commitment_period = 4 + message_counter = 1 + old_levels_messages = hash : [SC_ROLLUP_INBOX_HASH] + + content = [SC_ROLLUP_INBOX_HASH] + index = 1 + back_pointers = [SC_ROLLUP_INBOX_HASH] + + } + diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out new file mode 100644 index 000000000000..5f542022bd1a --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out @@ -0,0 +1,73 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 010fa03030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303000d5024ff4c33df62141bd485af4154641aa9220c5dede9aed006eb5d3c88bff3b --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3126.573 units (will add 100 for safety) +Estimated storage: 10687 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.004717 + Expected counter: 1 + Gas limit: 3227 + Storage limit: 10707 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.004717 + payload fees(the block proposer) ....... +ꜩ0.004717 + Smart contract rollup origination: + Kind: wasm_2_0_0 + Parameter type: string + Boot sector: ' 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ÕOôÃ=ö!A½HZôFAª’ ÅÞÞšínµÓÈ‹ÿ;' + This smart contract rollup origination was successfully applied + Consumed gas: 3126.573 + Storage size: 10687 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ2.67175 + storage fees ........................... +ꜩ2.67175 + + +./tezos-client --wait none send sc rollup message 'text:[""]' from bootstrap2 to '[SC_ROLLUP_HASH]' +Node is bootstrapped. +Estimated gas: 1876.714 units (will add 100 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000471 + Expected counter: 1 + Gas limit: 1977 + Storage limit: 0 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000471 + payload fees(the block proposer) ....... +ꜩ0.000471 + Smart contract rollup messages submission: + Address: [SC_ROLLUP_HASH] + This smart contract rollup messages submission was successfully applied + Consumed gas: 1876.714 + Resulting inbox state: { rollup = [SC_ROLLUP_HASH] + level = 4 + current messages hash = [SC_ROLLUP_INBOX_HASH] + nb_messages_in_commitment_period = 1 + starting_level_of_current_commitment_period = 4 + message_counter = 1 + old_levels_messages = hash : [SC_ROLLUP_INBOX_HASH] + + content = [SC_ROLLUP_INBOX_HASH] + index = 1 + back_pointers = [SC_ROLLUP_INBOX_HASH] + + } + diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index a74ab376d710..1753535db80d 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -2975,6 +2975,137 @@ let test_refutation_reward_and_punishment protocols = unit) protocols +(* Testing the execution of outbox messages + ---------------------------------------- + + When the PVM interprets an input message that produces an output + message, the outbox in the PVM state is populated with this output + message. When the state is cemented (after the refutation period + has passed without refutation), one can trigger the execution of + the outbox message, that is a call to a given L1 contract. + + This test first populates an L1 contract that waits for an integer + and stores this integer in its state. Then, the test executes a + rollup operation that produces a call to this contract. Finally, + the test triggers this call and we check that the L1 contract has + been correctly executed by observing its local store. + + The input depends on the PVM. +*) +let test_outbox_message_generic skip input_message expected_storage kind = + let commitment_period = 2 and challenge_window = 5 in + test_scenario + ~kind + ~commitment_period + ~challenge_window + { + tags = ["outbox"]; + variant = kind; + description = "an outbox message should be executable"; + } + @@ fun _protocol sc_rollup_node sc_rollup _node client -> + let* () = Sc_rollup_node.run sc_rollup_node in + let sc_client = Sc_rollup_client.create sc_rollup_node in + let src = Constant.bootstrap1.public_key_hash in + let originate_target_contract () = + let prg = + {| + { + parameter (int :p); + storage (int :s); + + code + { + UNPAIR; + SWAP ; + DROP; + NIL operation; + PAIR; + } + } |} + in + let* address = + Client.originate_contract + ~alias:"target" + ~amount:(Tez.of_int 100) + ~burn_cap:(Tez.of_int 100) + ~src + ~prg + ~init:"0" + client + in + let* () = Client.bake_for_and_wait client in + return address + in + let check_contract_execution address expected_storage = + let* storage = Client.contract_storage address client in + return + @@ Check.( + (storage = expected_storage) + string + ~error_msg:"Invalid contract storage: expecting '%R', got '%L'.") + in + let perform_rollup_execution_and_cement address = + let* () = send_text_messages client sc_rollup [input_message address] in + let* () = + repeat (2 + (2 * commitment_period) + challenge_window) @@ fun () -> + Client.bake_for client + in + let* _c, l = last_cemented_commitment_hash_with_level ~sc_rollup client in + Check.( + (l = 6) int ~error_msg:"Invalid level for LCC: expected '%R', 'got '%L'.") ; + return () + in + let trigger_outbox_message_execution address = + let* {commitment_hash; proof} = + let message_index = 0 in + let outbox_level = 4 in + let destination = address in + let parameters = "37" in + Sc_rollup_client.outbox_proof_single + sc_client + ~message_index + ~outbox_level + ~destination + ~parameters + in + let*! () = + Client.Sc_rollup.execute_outbox_message + ~burn_cap:(Tez.of_int 10) + ~rollup:sc_rollup + ~src + ~commitment_hash + ~proof + client + in + Client.bake_for client + in + if skip then return () + else + let* target_contract_address = originate_target_contract () in + let* () = perform_rollup_execution_and_cement target_contract_address in + let* () = trigger_outbox_message_execution target_contract_address in + let* () = + check_contract_execution target_contract_address expected_storage + in + return () + +let test_outbox_message ~kind = + let skip, input_message, expected_storage = + match kind with + | "arith" -> + (false, (fun contract_address -> "37 " ^ contract_address), "37\n") + | "wasm_2_0_0" -> + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3790 + For the moment, the WASM PVM has no support for + output. Hence, the storage is unchanged.*) + (true, Fun.const "", "0\n") + | _ -> + (* There is no other PVM in the protocol. *) + assert false + in + test_outbox_message_generic skip input_message expected_storage kind + let register ~kind ~protocols = test_origination ~kind protocols ; test_rollup_node_running ~kind protocols ; @@ -3085,7 +3216,8 @@ let register ~kind ~protocols = ~kind ; test_consecutive_commitments protocols ~kind ; test_refutation protocols ~kind ; - test_late_rollup_node protocols ~kind + test_late_rollup_node protocols ~kind ; + test_outbox_message protocols ~kind let register ~protocols = (* PVM-independent tests. We still need to specify a PVM kind -- GitLab From 762edd5bf404fdd87688cc655bdf1b952479852a Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Fri, 9 Sep 2022 09:23:22 +0200 Subject: [PATCH 02/22] Proto,SCORU: Expose outbox message serialization function Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_protocol/alpha_context.mli | 8 +++----- .../sc_rollup_management_protocol.ml | 3 +-- .../sc_rollup_outbox_message_repr.ml | 16 +++++++++------- .../sc_rollup_outbox_message_repr.mli | 16 +++++++++++----- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 0b6aefe14906..251b21c2c957 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3137,13 +3137,11 @@ module Sc_rollup : sig type serialized = private string + val unsafe_of_string : string -> serialized + val deserialize : serialized -> t tzresult - (** This module discloses definitions that are only useful for tests and - must not be used otherwise. *) - module Internal_for_tests : sig - val serialize : t -> serialized tzresult - end + val serialize : t -> serialized tzresult end val record_applied_message : diff --git a/src/proto_alpha/lib_protocol/sc_rollup_management_protocol.ml b/src/proto_alpha/lib_protocol/sc_rollup_management_protocol.ml index 575a60114f3e..4b5845b24e0a 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_management_protocol.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_management_protocol.ml @@ -164,8 +164,7 @@ module Internal_for_tests = struct let output_message_internal = Sc_rollup.Outbox.Message.Atomic_transaction_batch {transactions} in - Sc_rollup.Outbox.Message.Internal_for_tests.serialize - output_message_internal + Sc_rollup.Outbox.Message.serialize output_message_internal let deserialize_inbox_message = Sc_rollup.Inbox_message.deserialize end diff --git a/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml index 4fb174a241a1..7b7956ce8154 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml @@ -122,10 +122,12 @@ let deserialize data = | Some x -> return x | None -> fail Error_decode_outbox_message -module Internal_for_tests = struct - let serialize outbox_message = - let open Tzresult_syntax in - match Data_encoding.Binary.to_string_opt encoding outbox_message with - | Some str -> return str - | None -> fail Error_encode_outbox_message -end +let serialize outbox_message = + let open Tzresult_syntax in + match Data_encoding.Binary.to_string_opt encoding outbox_message with + | Some str -> return str + | None -> fail Error_encode_outbox_message + +let unsafe_of_string s = s + +let unsafe_to_string s = s diff --git a/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.mli index b896335fe9bc..4edae272da7e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.mli @@ -56,8 +56,14 @@ type serialized = private string typed values. *) val deserialize : serialized -> t tzresult -(** Module containing functions exposed so they can be used in tests. *) -module Internal_for_tests : sig - (** [serialize msg] serializes the given outbox message [msg]. *) - val serialize : t -> serialized tzresult -end +(** [serialize msg] serializes the given outbox message [msg]. *) +val serialize : t -> serialized tzresult + +(** [unsafe_of_string s] builds a serialized value out of a string. + You must understand the invariants of [serialized] to do so. *) +val unsafe_of_string : string -> serialized + +(** [unsafe_to_string s] builds a string out of a serialized value. + You must understand the invariants of [serialized] to manipulate + the resulting string. *) +val unsafe_to_string : serialized -> string -- GitLab From 259c41b5cefa8555627a693b40509d9e3fad0008 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:44:06 +0200 Subject: [PATCH 03/22] SCORU,Node: Fix typo Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/bin_sc_rollup_node/context.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/context.ml b/src/proto_alpha/bin_sc_rollup_node/context.ml index d4ff0301ba51..74aa8c0c9910 100644 --- a/src/proto_alpha/bin_sc_rollup_node/context.ml +++ b/src/proto_alpha/bin_sc_rollup_node/context.ml @@ -209,7 +209,7 @@ module Inbox = struct end) end -(** State of the PVM that this rollup node deals with *) +(** State of the PVM that this rollup node deals with. *) module PVMState = struct type value = tree -- GitLab From 4842a31268b3dccaa2fefc26d5313e9ec75e48da Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:45:41 +0200 Subject: [PATCH 04/22] Proto,SCORU: Make outbox readable through RPC A client needs to observe the rollup outbox to determine the exact characteristics of the output message it wants to execute. Signed-off-by: Yann Regis-Gianas --- .../bin_sc_rollup_node/RPC_server.ml | 19 +++++++- src/proto_alpha/bin_sc_rollup_node/pvm.ml | 5 +++ .../lib_protocol/alpha_context.mli | 6 +++ .../lib_protocol/sc_rollup_arith.ml | 11 ++++- .../lib_protocol/sc_rollup_arith.mli | 3 ++ .../lib_protocol/sc_rollup_wasm.ml | 7 +++ .../lib_protocol/sc_rollup_wasm.mli | 3 ++ .../lib_sc_rollup/sc_rollup_services.ml | 45 +++++++++++++++++++ 8 files changed, 97 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml index 56c9e153945c..b839001951a5 100644 --- a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml +++ b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml @@ -145,11 +145,17 @@ end module Make (PVM : Pvm.S) : S with module PVM = PVM = struct include Common module PVM = PVM + module Outbox = Outbox.Make (PVM) - let get_state (node_ctxt : Node_context.t) = + let get_context (node_ctxt : Node_context.t) = let open Lwt_result_syntax in let* head = get_head node_ctxt.store in let* ctxt = Node_context.checkout_context node_ctxt head in + return ctxt + + let get_state (node_ctxt : Node_context.t) = + let open Lwt_result_syntax in + let* ctxt = get_context node_ctxt in let*! state = PVM.State.find ctxt in match state with None -> failwith "No state" | Some state -> return state @@ -254,6 +260,16 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct (Sc_rollup_services.Global.dal_confirmed_slots ()) (fun () () -> get_dal_confirmed_slots store) + let register_current_outbox node_ctxt dir = + RPC_directory.register0 + dir + (Sc_rollup_services.Global.current_outbox ()) + (fun () () -> + let open Lwt_result_syntax in + let* state = get_state node_ctxt in + let*! outbox = PVM.get_outbox state in + return outbox) + let register (node_ctxt : Node_context.t) configuration = RPC_directory.empty |> register_sc_rollup_address configuration @@ -270,6 +286,7 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct |> register_dal_slot_subscriptions node_ctxt.store |> register_dal_slots node_ctxt.store |> register_dal_confirmed_slots node_ctxt.store + |> register_current_outbox node_ctxt let start node_ctxt configuration = Common.start configuration (register node_ctxt configuration) diff --git a/src/proto_alpha/bin_sc_rollup_node/pvm.ml b/src/proto_alpha/bin_sc_rollup_node/pvm.ml index 53d078950dbe..0fa214ff08f5 100644 --- a/src/proto_alpha/bin_sc_rollup_node/pvm.ml +++ b/src/proto_alpha/bin_sc_rollup_node/pvm.ml @@ -2,6 +2,7 @@ (* *) (* Open Source License *) (* Copyright (c) 2022 TriliTech *) +(* Copyright (c) 2022 Nomadic Labs, *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) @@ -45,6 +46,10 @@ module type S = sig (** [string_of_status status] returns a string representation of [status]. *) val string_of_status : status -> string + (** [get_outbox state] returns a list of outputs available in the + outbox of [state]. *) + val get_outbox : state -> Sc_rollup.output list Lwt.t + (** State storage for this PVM. *) module State : sig (** [find context] returns the PVM state stored in the [context], if any. *) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 251b21c2c957..d13ec7c1aaee 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3158,6 +3158,8 @@ module Sc_rollup : sig message : Outbox.Message.t; } + val output_encoding : output Data_encoding.t + module PVM : sig type boot_sector = string @@ -3289,6 +3291,8 @@ module Sc_rollup : sig type status = Halted | Waiting_for_input_message | Parsing | Evaluating val get_status : state -> status Lwt.t + + val get_outbox : state -> output list Lwt.t end val reference_initial_state_hash : State_hash.t @@ -3340,6 +3344,8 @@ module Sc_rollup : sig val get_status : state -> status Lwt.t + val get_outbox : state -> output list Lwt.t + val produce_proof : context -> input option -> state -> proof tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index f59f7ce7d8a8..c63add39962e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -92,6 +92,8 @@ module type S = sig val get_status : state -> status Lwt.t + val get_outbox : state -> Sc_rollup_PVM_sig.output list Lwt.t + type instruction = | IPush : int -> instruction | IAdd : instruction @@ -365,6 +367,8 @@ module Make (Context : P) : let set k v = set_value (key k) P.encoding v + let entries = children [P.name] P.encoding + let mapped_to k v state = let open Lwt_syntax in let* state', _ = Monad.(run (set k v) state) in @@ -374,7 +378,7 @@ module Make (Context : P) : let pp = let open Monad.Syntax in - let* l = children [P.name] P.encoding in + let* l = entries in let pp_elem fmt (key, value) = Format.fprintf fmt "@[%s : %a@]" key P.pp value in @@ -819,6 +823,11 @@ module Make (Context : P) : let get_status = result_of ~default:Waiting_for_input_message @@ Status.get + let get_outbox state = + let open Lwt_syntax in + let* entries = (result_of ~default:[] @@ Output.entries) state in + return @@ List.map snd entries + let get_code = result_of ~default:[] @@ Code.to_list let get_parsing_result = result_of ~default:None @@ Parsing_result.get diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli index 6479568c6fa7..97856bed7d02 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.mli @@ -85,6 +85,9 @@ module type S = sig (** [get_status state] returns the machine status in [state]. *) val get_status : state -> status Lwt.t + (** [get_outbox state] returns the outbox in [state]. *) + val get_outbox : state -> Sc_rollup_PVM_sig.output list Lwt.t + (** The machine has only three instructions. *) type instruction = | IPush : int -> instruction diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml index 4386f5e07050..2111ad146852 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.ml @@ -93,6 +93,8 @@ module V2_0_0 = struct (** [get_status state] gives you the current execution status for the PVM. *) val get_status : state -> status Lwt.t + + val get_outbox : state -> Sc_rollup_PVM_sig.output list Lwt.t end (* TODO: https://gitlab.com/tezos/tezos/-/issues/3091 @@ -269,6 +271,11 @@ module V2_0_0 = struct let get_status : state -> status Lwt.t = result_of get_status + let get_outbox _state = + (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3790 *) + let open Lwt_syntax in + return [] + let set_input_state input = let open PS in let open Monad.Syntax in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli index b5dffdfc1530..16c817018dc2 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_wasm.mli @@ -57,6 +57,9 @@ module V2_0_0 : sig (** [get_status state] gives you the current execution status for the PVM. *) val get_status : state -> status Lwt.t + + (** [get_outbox state] returns the outbox in [state]. *) + val get_outbox : state -> Sc_rollup_PVM_sig.output list Lwt.t end module type P = sig diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml index 6f0a82d99f4b..b4a5e7c8ec85 100644 --- a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml +++ b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml @@ -131,6 +131,13 @@ module Global = struct ~output:Data_encoding.string (prefix / "status") + let current_outbox () = + RPC_service.get_service + ~description:"Current outbox" + ~query:RPC_query.empty + ~output:Data_encoding.(list Sc_rollup.output_encoding) + (prefix / "outbox") + let dal_slot_subscriptions () = RPC_service.get_service ~description:"Current data availability layer slot subscriptions" @@ -151,6 +158,44 @@ module Global = struct ~query:RPC_query.empty ~output:(Data_encoding.list Dal.Slot.encoding) (prefix / "dal" / "confirmed_slots") + + let outbox_proof_query = + let open RPC_query in + let open Sc_rollup in + let invalid_message e = + raise + (Invalid + (Format.asprintf + "Invalid message (%a)" + Environment.Error_monad.pp_trace + e)) + in + query (fun outbox_level message_index serialized_outbox_message -> + let outbox_level = Raw_level.of_int32_exn outbox_level in + let message_index = Z.of_int64 message_index in + let message = + Outbox.Message.( + unsafe_of_string serialized_outbox_message |> deserialize) + in + match message with + | Error e -> invalid_message e + | Ok message -> {outbox_level; message_index; message}) + |+ field "outbox_level" RPC_arg.int32 0l (fun o -> + Raw_level.to_int32 o.outbox_level) + |+ field "message_counter" RPC_arg.int64 0L (fun o -> + Z.to_int64 o.message_index) + |+ field "serialized_outbox_message" RPC_arg.string "" (fun o -> + match Outbox.Message.serialize o.message with + | Ok message -> (message :> string) + | Error e -> invalid_message e) + |> seal + + let outbox_proof () = + RPC_service.get_service + ~description:"Generate serialized output proof for some outbox message" + ~query:outbox_proof_query + ~output:Data_encoding.(tup2 string string) + (prefix / "proofs" / "outbox") end module Local = struct -- GitLab From 33cfa114f8f20c888f264b15414f0e6711493dbc Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:50:16 +0200 Subject: [PATCH 05/22] SCORU,Node: Add RPC to generate output proof Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/bin_sc_rollup_client/RPC.ml | 3 + .../bin_sc_rollup_client/commands.ml | 73 +++++++++++++++++ .../bin_sc_rollup_node/RPC_server.ml | 7 ++ src/proto_alpha/bin_sc_rollup_node/outbox.ml | 81 +++++++++++++++++++ .../client_proto_context_commands.ml | 4 +- .../lib_sc_rollup/sc_rollup_services.ml | 4 +- 6 files changed, 168 insertions(+), 4 deletions(-) create mode 100644 src/proto_alpha/bin_sc_rollup_node/outbox.ml diff --git a/src/proto_alpha/bin_sc_rollup_client/RPC.ml b/src/proto_alpha/bin_sc_rollup_client/RPC.ml index dffca04b90a5..d1d9721017eb 100644 --- a/src/proto_alpha/bin_sc_rollup_client/RPC.ml +++ b/src/proto_alpha/bin_sc_rollup_client/RPC.ml @@ -32,3 +32,6 @@ let get_sc_rollup_addresses_command cctxt = let get_state_value_command cctxt key = call cctxt (Sc_rollup_services.Local.current_state_value ()) () {key} () + +let get_outbox_proof cctxt serialized_output = + call cctxt (Sc_rollup_services.Global.outbox_proof ()) () serialized_output () diff --git a/src/proto_alpha/bin_sc_rollup_client/commands.ml b/src/proto_alpha/bin_sc_rollup_client/commands.ml index aef42ec0160a..7372a84a6e70 100644 --- a/src/proto_alpha/bin_sc_rollup_client/commands.ml +++ b/src/proto_alpha/bin_sc_rollup_client/commands.ml @@ -84,6 +84,78 @@ let display_answer (cctxt : #Configuration.sc_client_context) : cctxt#error "@[[HTTP 403] Access denied to: %a@]@." Uri.pp cctxt#base | _ -> cctxt#error "Unexpected server answer\n%!" +let get_output_proof () = + let parse_transactions transactions = + let json = Ezjsonm.from_string transactions in + let open Ezjsonm in + let open Sc_rollup.Outbox.Message in + let open Lwt_result_syntax in + let transaction json = + let destination = + find json ["destination"] |> get_string + |> Protocol.Contract_hash.of_b58check_exn + in + let entrypoint = + try + find json ["entrypoint"] |> get_string + |> Entrypoint.of_string_strict_exn + with Not_found -> Entrypoint.default + in + let*? parameters = + Tezos_micheline.Micheline_parser.no_parsing_error + @@ (find json ["parameters"] |> get_string + |> Michelson_v1_parser.parse_expression) + in + let unparsed_parameters = parameters.expanded in + return @@ {destination; entrypoint; unparsed_parameters} + in + match json with + | `A messages -> + let* transactions = List.map_es transaction messages in + return @@ Atomic_transaction_batch {transactions} + | `O _ -> + let* transaction = transaction json in + return @@ Atomic_transaction_batch {transactions = [transaction]} + | _ -> + failwith + "An outbox message must be either a single transaction or a list of \ + transactions." + in + + command + ~desc:"Ask the rollup node for an output proof." + no_options + (prefixes ["get"; "proof"; "for"; "message"] + @@ string ~name:"index" ~desc:"The index of the message in the outbox" + @@ prefixes ["of"; "outbox"; "at"; "level"] + @@ string + ~name:"level" + ~desc:"The level of the rollup outbox where the message is available" + @@ prefixes ["transferring"] + @@ string + ~name:"transactions" + ~desc:"A JSON description of the transactions" + @@ stop) + (fun () index level transactions (cctxt : #Configuration.sc_client_context) -> + let open Lwt_result_syntax in + let* message = parse_transactions transactions in + let output = + Protocol.Alpha_context.Sc_rollup. + { + message_index = Z.of_string index; + outbox_level = Raw_level.of_int32_exn (Int32.of_string level); + message; + } + in + RPC.get_outbox_proof cctxt output >>=? fun (commitment_hash, proof) -> + cctxt#message + {|@[{ "proof" : "0x%a", "commitment_hash" : "%a"@]}|} + Hex.pp + (Hex.of_string proof) + Protocol.Alpha_context.Sc_rollup.Commitment.Hash.pp + commitment_hash + >>= fun () -> return_unit) + (** [call_get cctxt raw_url] executes a GET RPC call against the [raw_url]. *) let call_get (cctxt : #Configuration.sc_client_context) raw_url = let open Lwt_result_syntax in @@ -155,6 +227,7 @@ let all () = [ get_sc_rollup_addresses_command (); get_state_value_command (); + get_output_proof (); rpc_get_command; Keys.generate_keys (); Keys.list_keys (); diff --git a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml index b839001951a5..939c10cd0d52 100644 --- a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml +++ b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml @@ -270,6 +270,12 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct let*! outbox = PVM.get_outbox state in return outbox) + let register_outbox_proof node_ctxt dir = + RPC_directory.register0 + dir + (Sc_rollup_services.Global.outbox_proof ()) + (fun output () -> Outbox.proof_of_output node_ctxt output) + let register (node_ctxt : Node_context.t) configuration = RPC_directory.empty |> register_sc_rollup_address configuration @@ -287,6 +293,7 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct |> register_dal_slots node_ctxt.store |> register_dal_confirmed_slots node_ctxt.store |> register_current_outbox node_ctxt + |> register_outbox_proof node_ctxt let start node_ctxt configuration = Common.start configuration (register node_ctxt configuration) diff --git a/src/proto_alpha/bin_sc_rollup_node/outbox.ml b/src/proto_alpha/bin_sc_rollup_node/outbox.ml new file mode 100644 index 000000000000..29ae63ecceed --- /dev/null +++ b/src/proto_alpha/bin_sc_rollup_node/outbox.ml @@ -0,0 +1,81 @@ +(*****************************************************************************) +(* *) +(* Open Source License *) +(* Copyright (c) 2022 Nomadic Labs, *) +(* *) +(* 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. *) +(* *) +(*****************************************************************************) + +(** This module provides helper to interact with PVM outboxes. *) + +open Node_context +open Protocol.Alpha_context + +module Make (PVM : Pvm.S) = struct + let get_head store = + let open Lwt_result_syntax in + let*! head = Layer1.current_head_hash store in + match head with None -> failwith "No head" | Some head -> return head + + let get_context (node_ctxt : Node_context.t) = + let open Lwt_result_syntax in + let* head = get_head node_ctxt.store in + let* ctxt = Node_context.checkout_context node_ctxt head in + return ctxt + + let get_state_of_lcc node_ctxt = + let open Lwt_result_syntax in + let*! lcc_level = + Store.Last_cemented_commitment_level.get node_ctxt.store + in + let*! block_hash = + Layer1.hash_of_level node_ctxt.store (Raw_level.to_int32 lcc_level) + in + let* ctxt = Node_context.checkout_context node_ctxt block_hash in + let*! state = PVM.State.find ctxt in + return state + + let proof_of_output node_ctxt output = + let open Lwt_result_syntax in + let*! commitment_hash = + Store.Last_cemented_commitment_hash.get node_ctxt.store + in + let* state = get_state_of_lcc node_ctxt in + match state with + | None -> + (* + This case should never happen as origination creates an LCC which + must have been considered by the rollup node at startup time. + *) + failwith "Error producing outbox proof (no cemented state in the node)" + | Some state -> ( + let*! proof = PVM.produce_output_proof node_ctxt.context state output in + match proof with + | Ok proof -> + let serialized_proof = + Data_encoding.Binary.to_string_exn PVM.output_proof_encoding proof + in + return @@ (commitment_hash, serialized_proof) + | Error err -> + failwith + "Error producing outbox proof (%a)" + Environment.Error_monad.pp + err) +end diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 7393c2ecee14..5a0ef98b7f91 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -3325,7 +3325,7 @@ let commands_rw () = ~name:"output proof" ~desc: "The output proof containing the outbox level, index and message." - Sc_rollup_params.unchecked_payload_parameter + bytes_parameter @@ stop) (fun ( fee, dry_run, @@ -3356,7 +3356,7 @@ let commands_rw () = ~source ~rollup ~cemented_commitment - ~output_proof + ~output_proof:(Bytes.to_string output_proof) ~src_pk ~src_sk ~fee_parameter diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml index b4a5e7c8ec85..3ffdce6b458d 100644 --- a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml +++ b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml @@ -182,7 +182,7 @@ module Global = struct | Ok message -> {outbox_level; message_index; message}) |+ field "outbox_level" RPC_arg.int32 0l (fun o -> Raw_level.to_int32 o.outbox_level) - |+ field "message_counter" RPC_arg.int64 0L (fun o -> + |+ field "message_index" RPC_arg.int64 0L (fun o -> Z.to_int64 o.message_index) |+ field "serialized_outbox_message" RPC_arg.string "" (fun o -> match Outbox.Message.serialize o.message with @@ -194,7 +194,7 @@ module Global = struct RPC_service.get_service ~description:"Generate serialized output proof for some outbox message" ~query:outbox_proof_query - ~output:Data_encoding.(tup2 string string) + ~output:Data_encoding.(tup2 Sc_rollup.Commitment.Hash.encoding string) (prefix / "proofs" / "outbox") end -- GitLab From 395aa21f2ce589cb43efc1e23b259f2aa7add91f Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:51:06 +0200 Subject: [PATCH 06/22] Proto,SCORU: Fix error registration of Arith PVM proof generation Signed-off-by: Yann Regis-Gianas --- .../lib_protocol/sc_rollup_arith.ml | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index c63add39962e..da2917e42c67 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -53,6 +53,44 @@ let reference_initial_state_hash = State_hash.of_b58check_exn "scs11cXwQJJ5dkpEQGq3x2MJm3cM73cbEkHJqo5eDSoRpHUPyEQLB4" +type error += + | Arith_proof_production_failed + | Arith_output_proof_production_failed + | Arith_invalid_claim_about_outbox + +let () = + let open Data_encoding in + let msg = "Invalid claim about outbox" in + register_error_kind + `Permanent + ~id:"sc_rollup_arith_invalid_claim_about_outbox" + ~title:msg + ~pp:(fun fmt () -> Format.fprintf fmt "%s" msg) + ~description:msg + unit + (function Arith_invalid_claim_about_outbox -> Some () | _ -> None) + (fun () -> Arith_invalid_claim_about_outbox) ; + let msg = "Output proof production failed" in + register_error_kind + `Permanent + ~id:"sc_rollup_arith_output_proof_production_failed" + ~title:msg + ~pp:(fun fmt () -> Format.fprintf fmt "%s" msg) + ~description:msg + unit + (function Arith_output_proof_production_failed -> Some () | _ -> None) + (fun () -> Arith_output_proof_production_failed) ; + let msg = "Proof production failed" in + register_error_kind + `Permanent + ~id:"sc_rollup_arith_proof_production_failed" + ~title:msg + ~pp:(fun fmt () -> Format.fprintf fmt "%s" msg) + ~description:msg + unit + (function Arith_proof_production_failed -> Some () | _ -> None) + (fun () -> Arith_proof_production_failed) + module type P = sig module Tree : Context.TREE with type key = string list and type value = bytes @@ -1105,8 +1143,6 @@ module Make (Context : P) : | Some (_, request) -> return (PS.input_request_equal request proof.requested) - type error += Arith_proof_production_failed - let produce_proof context input_given state = let open Lwt_tzresult_syntax in let*! result = @@ -1179,10 +1215,6 @@ module Make (Context : P) : let* result = Context.verify_proof p.output_proof transition in match result with None -> return false | Some _ -> return true - type error += Arith_output_proof_production_failed - - type error += Arith_invalid_claim_about_outbox - let produce_output_proof context state output_proof_output = let open Lwt_result_syntax in let*! output_proof_state = state_hash state in -- GitLab From 18ad181298af2d2f11ad15f59e2a3f29b1eb9a60 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:51:37 +0200 Subject: [PATCH 07/22] Proto,SCORU: Generalize outbox support in Arith PVM We can now target any contract. Signed-off-by: Yann Regis-Gianas --- .../bin_sc_rollup_node/RPC_server.ml | 24 ++++++++++++++----- .../lib_protocol/sc_rollup_arith.ml | 23 +++++++++++++----- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml index 939c10cd0d52..50f8f64762ec 100644 --- a/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml +++ b/src/proto_alpha/bin_sc_rollup_node/RPC_server.ml @@ -26,6 +26,7 @@ open Tezos_rpc open Tezos_rpc_http open Tezos_rpc_http_server +open Protocol let get_head store = let open Lwt_result_syntax in @@ -147,15 +148,19 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct module PVM = PVM module Outbox = Outbox.Make (PVM) - let get_context (node_ctxt : Node_context.t) = + let get_context ?block_hash (node_ctxt : Node_context.t) = let open Lwt_result_syntax in - let* head = get_head node_ctxt.store in - let* ctxt = Node_context.checkout_context node_ctxt head in + let* block_hash = + match block_hash with + | None -> get_head node_ctxt.store + | Some block_hash -> return block_hash + in + let* ctxt = Node_context.checkout_context node_ctxt block_hash in return ctxt - let get_state (node_ctxt : Node_context.t) = + let get_state ?block_hash (node_ctxt : Node_context.t) = let open Lwt_result_syntax in - let* ctxt = get_context node_ctxt in + let* ctxt = get_context ?block_hash node_ctxt in let*! state = PVM.State.find ctxt in match state with None -> failwith "No state" | Some state -> return state @@ -266,7 +271,14 @@ module Make (PVM : Pvm.S) : S with module PVM = PVM = struct (Sc_rollup_services.Global.current_outbox ()) (fun () () -> let open Lwt_result_syntax in - let* state = get_state node_ctxt in + let store = node_ctxt.Node_context.store in + let*! lcc_level = Store.Last_cemented_commitment_level.get store in + let*! block_hash = + Layer1.hash_of_level + store + (Alpha_context.Raw_level.to_int32 lcc_level) + in + let* state = get_state ~block_hash node_ctxt in let*! outbox = PVM.get_outbox state in return outbox) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index da2917e42c67..74b608637ed4 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -999,7 +999,10 @@ module Make (Context : P) : return () in let is_digit d = Compare.Char.(d >= '0' && d <= '9') in - let is_letter d = Compare.Char.(d >= 'a' && d <= 'z') in + let is_letter d = + Compare.Char.((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z')) + in + let is_identifier_char d = is_digit d || is_letter d in let* parser_state = Parser_state.get in match parser_state with | ParseInt -> ( @@ -1021,7 +1024,7 @@ module Make (Context : P) : | ParseVar -> ( let* char = current_char in match char with - | Some d when is_letter d -> next_char + | Some d when is_identifier_char d -> next_char | Some '+' -> let* () = produce_var in let* () = produce_add in @@ -1052,7 +1055,7 @@ module Make (Context : P) : | None -> stop_parsing true | _ -> stop_parsing false) - let output v = + let output destination v = let open Monad.Syntax in let open Sc_rollup_outbox_message_repr in let* counter = Output_counter.get in @@ -1060,7 +1063,6 @@ module Make (Context : P) : let unparsed_parameters = Micheline.(Int ((), Z.of_int v) |> strip_locations) in - let destination = Contract_hash.zero in let entrypoint = Entrypoint_repr.default in let transaction = {unparsed_parameters; destination; entrypoint} in let message = Atomic_transaction_batch {transactions = [transaction]} in @@ -1070,6 +1072,13 @@ module Make (Context : P) : in Output.set (Z.to_string counter) output + let identifies_target_contract x = + if Compare.String.(x = "out") then Some Contract_hash.zero + else if + Compare.Int.(String.length x >= 3) && String.(equal (sub x 0 3) "KT1") + then Contract_hash.of_b58check_opt x + else None + let evaluate = let open Monad.Syntax in let* i = Code.pop in @@ -1080,8 +1089,10 @@ module Make (Context : P) : let* v = Stack.top in match v with | None -> stop_evaluating false - | Some v -> - if Compare.String.(x = "out") then output v else Vars.set x v) + | Some v -> ( + match identifies_target_contract x with + | Some hash -> output hash v + | None -> Vars.set x v)) | Some IAdd -> ( let* v = Stack.pop in match v with -- GitLab From 0c1b3845e055264494ec31483671ea875f693de0 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:52:28 +0200 Subject: [PATCH 08/22] Proto,SCORU: Make entrypoint optional in output message encoding Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml index 7b7956ce8154..839f313cf8fa 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_outbox_message_repr.ml @@ -72,7 +72,7 @@ let transaction_encoding = @@ obj3 (req "parameters" Script_repr.expr_encoding) (req "destination" Contract_repr.originated_encoding) - (req "entrypoint" Entrypoint_repr.simple_encoding) + Entrypoint_repr.(dft "entrypoint" simple_encoding default) let encoding = let open Data_encoding in -- GitLab From 9735c6c20005010e8937ed659b472bc505f6640d Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Mon, 12 Sep 2022 10:52:53 +0200 Subject: [PATCH 09/22] Tezt: Update regression traces Signed-off-by: Yann Regis-Gianas --- ...box message should be executable (_0).out} | 22 +++--- ...tbox message should be executable (_5).out | 73 +++++++++++++++++++ ...x message should be executable (aux_0).out | 73 +++++++++++++++++++ ...x message should be executable (aux_5).out | 73 +++++++++++++++++++ ...ing of commitments (batcher_does_not_p.out | 2 +- ...ing of commitments (commitment_is_stor.out | 4 +- ...ing of commitments (maintenance_publis.out | 4 +- ...ing of commitments (node_use_proto_par.out | 4 +- ...ing of commitments (observer_does_not_.out | 2 +- ...ing of commitments (operator_publishes.out | 4 +- ...ing of commitments (robust_to_failures.out | 4 +- ...box message should be executable (_0).out} | 61 +++------------- ...tbox message should be executable (_5).out | 34 +++++++++ ...x message should be executable (aux_0).out | 34 +++++++++ ...x message should be executable (aux_5).out | 34 +++++++++ 15 files changed, 355 insertions(+), 73 deletions(-) rename tezt/tests/expected/sc_rollup.ml/{Alpha- arith - an outbox message should be executable (arith).out => Alpha- arith - an outbox message should be executable (_0).out} (82%) create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_5).out create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_0).out create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_5).out rename tezt/tests/expected/sc_rollup.ml/{Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out => Alpha- wasm_2_0_0 - an outbox message should be executable (_0).out} (59%) create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_5).out create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_0).out create mode 100644 tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_5).out diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_0).out similarity index 82% rename from tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out rename to tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_0).out index b9291d20bf5c..276b7ecf55ed 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (arith).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_0).out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from bootstrap1 of kind arith of type string booting with --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 3110.429 units (will add 100 for safety) -Estimated storage: 6651 bytes added (will add 20 for safety) +Estimated gas: 3110.449 units (will add 100 for safety) +Estimated storage: 6655 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,25 +12,25 @@ 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.000674 + Fee to the baker: ꜩ0.000671 Expected counter: 1 Gas limit: 3211 - Storage limit: 6671 bytes + Storage limit: 6675 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000674 - payload fees(the block proposer) ....... +ꜩ0.000674 + [PUBLIC_KEY_HASH] ... -ꜩ0.000671 + payload fees(the block proposer) ....... +ꜩ0.000671 Smart contract rollup origination: Kind: arith Parameter type: string - Boot sector: '' + Boot sector Blake2B hash: '0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8' This smart contract rollup origination was successfully applied - Consumed gas: 3110.429 - Storage size: 6651 bytes + Consumed gas: 3110.449 + Storage size: 6655 bytes Address: [SC_ROLLUP_HASH] Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ1.66275 - storage fees ........................... +ꜩ1.66275 + [PUBLIC_KEY_HASH] ... -ꜩ1.66375 + storage fees ........................... +ꜩ1.66375 ./tezos-client --wait none send sc rollup message 'text:["37 [CONTRACT_HASH]"]' from bootstrap2 to '[SC_ROLLUP_HASH]' diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_5).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_5).out new file mode 100644 index 000000000000..276b7ecf55ed --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (_5).out @@ -0,0 +1,73 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind arith of type string booting with --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3110.449 units (will add 100 for safety) +Estimated storage: 6655 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000671 + Expected counter: 1 + Gas limit: 3211 + Storage limit: 6675 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000671 + payload fees(the block proposer) ....... +ꜩ0.000671 + Smart contract rollup origination: + Kind: arith + Parameter type: string + Boot sector Blake2B hash: '0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8' + This smart contract rollup origination was successfully applied + Consumed gas: 3110.449 + Storage size: 6655 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ1.66375 + storage fees ........................... +ꜩ1.66375 + + +./tezos-client --wait none send sc rollup message 'text:["37 [CONTRACT_HASH]"]' from bootstrap2 to '[SC_ROLLUP_HASH]' +Node is bootstrapped. +Estimated gas: 1877.377 units (will add 100 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.00051 + Expected counter: 1 + Gas limit: 1978 + Storage limit: 0 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.00051 + payload fees(the block proposer) ....... +ꜩ0.00051 + Smart contract rollup messages submission: + Address: [SC_ROLLUP_HASH] + This smart contract rollup messages submission was successfully applied + Consumed gas: 1877.377 + Resulting inbox state: { rollup = [SC_ROLLUP_HASH] + level = 4 + current messages hash = [SC_ROLLUP_INBOX_HASH] + nb_messages_in_commitment_period = 1 + starting_level_of_current_commitment_period = 4 + message_counter = 1 + old_levels_messages = hash : [SC_ROLLUP_INBOX_HASH] + + content = [SC_ROLLUP_INBOX_HASH] + index = 1 + back_pointers = [SC_ROLLUP_INBOX_HASH] + + } + diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_0).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_0).out new file mode 100644 index 000000000000..aa61e69130ca --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_0).out @@ -0,0 +1,73 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind arith of type string booting with --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3110.449 units (will add 100 for safety) +Estimated storage: 6655 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000671 + Expected counter: 1 + Gas limit: 3211 + Storage limit: 6675 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000671 + payload fees(the block proposer) ....... +ꜩ0.000671 + Smart contract rollup origination: + Kind: arith + Parameter type: string + Boot sector Blake2B hash: '0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8' + This smart contract rollup origination was successfully applied + Consumed gas: 3110.449 + Storage size: 6655 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ1.66375 + storage fees ........................... +ꜩ1.66375 + + +./tezos-client --wait none send sc rollup message 'text:["37 [CONTRACT_HASH]%aux"]' from bootstrap2 to '[SC_ROLLUP_HASH]' +Node is bootstrapped. +Estimated gas: 1877.445 units (will add 100 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000514 + Expected counter: 1 + Gas limit: 1978 + Storage limit: 0 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000514 + payload fees(the block proposer) ....... +ꜩ0.000514 + Smart contract rollup messages submission: + Address: [SC_ROLLUP_HASH] + This smart contract rollup messages submission was successfully applied + Consumed gas: 1877.445 + Resulting inbox state: { rollup = [SC_ROLLUP_HASH] + level = 4 + current messages hash = [SC_ROLLUP_INBOX_HASH] + nb_messages_in_commitment_period = 1 + starting_level_of_current_commitment_period = 4 + message_counter = 1 + old_levels_messages = hash : [SC_ROLLUP_INBOX_HASH] + + content = [SC_ROLLUP_INBOX_HASH] + index = 1 + back_pointers = [SC_ROLLUP_INBOX_HASH] + + } + diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_5).out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_5).out new file mode 100644 index 000000000000..aa61e69130ca --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - an outbox message should be executable (aux_5).out @@ -0,0 +1,73 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind arith of type string booting with --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3110.449 units (will add 100 for safety) +Estimated storage: 6655 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000671 + Expected counter: 1 + Gas limit: 3211 + Storage limit: 6675 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000671 + payload fees(the block proposer) ....... +ꜩ0.000671 + Smart contract rollup origination: + Kind: arith + Parameter type: string + Boot sector Blake2B hash: '0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8' + This smart contract rollup origination was successfully applied + Consumed gas: 3110.449 + Storage size: 6655 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ1.66375 + storage fees ........................... +ꜩ1.66375 + + +./tezos-client --wait none send sc rollup message 'text:["37 [CONTRACT_HASH]%aux"]' from bootstrap2 to '[SC_ROLLUP_HASH]' +Node is bootstrapped. +Estimated gas: 1877.445 units (will add 100 for safety) +Estimated storage: no bytes added +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.000514 + Expected counter: 1 + Gas limit: 1978 + Storage limit: 0 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000514 + payload fees(the block proposer) ....... +ꜩ0.000514 + Smart contract rollup messages submission: + Address: [SC_ROLLUP_HASH] + This smart contract rollup messages submission was successfully applied + Consumed gas: 1877.445 + Resulting inbox state: { rollup = [SC_ROLLUP_HASH] + level = 4 + current messages hash = [SC_ROLLUP_INBOX_HASH] + nb_messages_in_commitment_period = 1 + starting_level_of_current_commitment_period = 4 + message_counter = 1 + old_levels_messages = hash : [SC_ROLLUP_INBOX_HASH] + + content = [SC_ROLLUP_INBOX_HASH] + index = 1 + back_pointers = [SC_ROLLUP_INBOX_HASH] + + } + diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (batcher_does_not_p.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (batcher_does_not_p.out index bab0708aeb93..8399310fa013 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (batcher_does_not_p.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (batcher_does_not_p.out @@ -2622,7 +2622,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (commitment_is_stor.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (commitment_is_stor.out index 37e9350e0e5a..2b75de97a9bd 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (commitment_is_stor.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (commitment_is_stor.out @@ -1307,7 +1307,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -1316,6 +1316,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (maintenance_publis.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (maintenance_publis.out index c8f60a0627aa..46aed3af8888 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (maintenance_publis.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (maintenance_publis.out @@ -2622,7 +2622,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } @@ -2632,6 +2632,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (node_use_proto_par.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (node_use_proto_par.out index 831a202ba3f1..52dacd0135f1 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (node_use_proto_par.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (node_use_proto_par.out @@ -662,7 +662,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 17, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "361" }, + "number_of_ticks": "1321" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /local/last_published_commitment @@ -671,6 +671,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 17, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "361" }, + "number_of_ticks": "1321" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 20 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (observer_does_not_.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (observer_does_not_.out index bab0708aeb93..8399310fa013 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (observer_does_not_.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (observer_does_not_.out @@ -2622,7 +2622,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (operator_publishes.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (operator_publishes.out index c8f60a0627aa..46aed3af8888 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (operator_publishes.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (operator_publishes.out @@ -2622,7 +2622,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } @@ -2632,6 +2632,6 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]", "published_at_level": 35 } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (robust_to_failures.out b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (robust_to_failures.out index 2f7b05a2dd78..4693419900c7 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (robust_to_failures.out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- arith - rollup node - correct handling of commitments (robust_to_failures.out @@ -1307,7 +1307,7 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } ./tezos-sc-rollup-client-alpha rpc get /global/last_stored_commitment @@ -1316,5 +1316,5 @@ This sequence of operations was run: "[SC_ROLLUP_PVM_STATE_HASH]", "inbox_level": 32, "predecessor": "[SC_ROLLUP_COMMITMENT_HASH]", - "number_of_ticks": "1396" }, + "number_of_ticks": "5116" }, "hash": "[SC_ROLLUP_COMMITMENT_HASH]" } diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_0).out similarity index 59% rename from tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out rename to tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_0).out index 5f542022bd1a..b3b89b562766 100644 --- a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (wasm_2_0_0).out +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_0).out @@ -1,8 +1,8 @@ ./tezos-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 010fa03030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303000d5024ff4c33df62141bd485af4154641aa9220c5dede9aed006eb5d3c88bff3b --burn-cap 9999999 Node is bootstrapped. -Estimated gas: 3126.573 units (will add 100 for safety) -Estimated storage: 10687 bytes added (will add 20 for safety) +Estimated gas: 3126.593 units (will add 100 for safety) +Estimated storage: 10691 bytes added (will add 20 for safety) Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' NOT waiting for the operation to be included. @@ -12,62 +12,23 @@ 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.004717 + Fee to the baker: ꜩ0.004714 Expected counter: 1 Gas limit: 3227 - Storage limit: 10707 bytes + Storage limit: 10711 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.004717 - payload fees(the block proposer) ....... +ꜩ0.004717 + [PUBLIC_KEY_HASH] ... -ꜩ0.004714 + payload fees(the block proposer) ....... +ꜩ0.004714 Smart contract rollup origination: Kind: wasm_2_0_0 Parameter type: string - Boot sector: ' 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ÕOôÃ=ö!A½HZôFAª’ ÅÞÞšínµÓÈ‹ÿ;' + Boot sector Blake2B hash: '789431137a40057a39867cbc5cd7f984139360559c655c0508821b9be8047a02' This smart contract rollup origination was successfully applied - Consumed gas: 3126.573 - Storage size: 10687 bytes + Consumed gas: 3126.593 + Storage size: 10691 bytes Address: [SC_ROLLUP_HASH] Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ2.67175 - storage fees ........................... +ꜩ2.67175 - - -./tezos-client --wait none send sc rollup message 'text:[""]' from bootstrap2 to '[SC_ROLLUP_HASH]' -Node is bootstrapped. -Estimated gas: 1876.714 units (will add 100 for safety) -Estimated storage: no bytes added -Operation successfully injected in the node. -Operation hash is '[OPERATION_HASH]' -NOT waiting for the operation to be included. -Use command - tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] -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.000471 - Expected counter: 1 - Gas limit: 1977 - Storage limit: 0 bytes - Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000471 - payload fees(the block proposer) ....... +ꜩ0.000471 - Smart contract rollup messages submission: - Address: [SC_ROLLUP_HASH] - This smart contract rollup messages submission was successfully applied - Consumed gas: 1876.714 - Resulting inbox state: { rollup = [SC_ROLLUP_HASH] - level = 4 - current messages hash = [SC_ROLLUP_INBOX_HASH] - nb_messages_in_commitment_period = 1 - starting_level_of_current_commitment_period = 4 - message_counter = 1 - old_levels_messages = hash : [SC_ROLLUP_INBOX_HASH] - - content = [SC_ROLLUP_INBOX_HASH] - index = 1 - back_pointers = [SC_ROLLUP_INBOX_HASH] - - } + [PUBLIC_KEY_HASH] ... -ꜩ2.67275 + storage fees ........................... +ꜩ2.67275 diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_5).out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_5).out new file mode 100644 index 000000000000..b3b89b562766 --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (_5).out @@ -0,0 +1,34 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 010fa03030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303000d5024ff4c33df62141bd485af4154641aa9220c5dede9aed006eb5d3c88bff3b --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3126.593 units (will add 100 for safety) +Estimated storage: 10691 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.004714 + Expected counter: 1 + Gas limit: 3227 + Storage limit: 10711 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.004714 + payload fees(the block proposer) ....... +ꜩ0.004714 + Smart contract rollup origination: + Kind: wasm_2_0_0 + Parameter type: string + Boot sector Blake2B hash: '789431137a40057a39867cbc5cd7f984139360559c655c0508821b9be8047a02' + This smart contract rollup origination was successfully applied + Consumed gas: 3126.593 + Storage size: 10691 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ2.67275 + storage fees ........................... +ꜩ2.67275 + diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_0).out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_0).out new file mode 100644 index 000000000000..b3b89b562766 --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_0).out @@ -0,0 +1,34 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 010fa03030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303000d5024ff4c33df62141bd485af4154641aa9220c5dede9aed006eb5d3c88bff3b --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3126.593 units (will add 100 for safety) +Estimated storage: 10691 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.004714 + Expected counter: 1 + Gas limit: 3227 + Storage limit: 10711 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.004714 + payload fees(the block proposer) ....... +ꜩ0.004714 + Smart contract rollup origination: + Kind: wasm_2_0_0 + Parameter type: string + Boot sector Blake2B hash: '789431137a40057a39867cbc5cd7f984139360559c655c0508821b9be8047a02' + This smart contract rollup origination was successfully applied + Consumed gas: 3126.593 + Storage size: 10691 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ2.67275 + storage fees ........................... +ꜩ2.67275 + diff --git a/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_5).out b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_5).out new file mode 100644 index 000000000000..b3b89b562766 --- /dev/null +++ b/tezt/tests/expected/sc_rollup.ml/Alpha- wasm_2_0_0 - an outbox message should be executable (aux_5).out @@ -0,0 +1,34 @@ + +./tezos-client --wait none originate sc rollup from bootstrap1 of kind wasm_2_0_0 of type string booting with 010fa03030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303030303000d5024ff4c33df62141bd485af4154641aa9220c5dede9aed006eb5d3c88bff3b --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 3126.593 units (will add 100 for safety) +Estimated storage: 10691 bytes added (will add 20 for safety) +Operation successfully injected in the node. +Operation hash is '[OPERATION_HASH]' +NOT waiting for the operation to be included. +Use command + tezos-client wait for [OPERATION_HASH] to be included --confirmations 1 --branch [BLOCK_HASH] +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.004714 + Expected counter: 1 + Gas limit: 3227 + Storage limit: 10711 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.004714 + payload fees(the block proposer) ....... +ꜩ0.004714 + Smart contract rollup origination: + Kind: wasm_2_0_0 + Parameter type: string + Boot sector Blake2B hash: '789431137a40057a39867cbc5cd7f984139360559c655c0508821b9be8047a02' + This smart contract rollup origination was successfully applied + Consumed gas: 3126.593 + Storage size: 10691 bytes + Address: [SC_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ2.67275 + storage fees ........................... +ꜩ2.67275 + -- GitLab From 1f991a5c5447a3772c3c017bda9bacca7be52fdd Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Tue, 13 Sep 2022 10:57:25 +0200 Subject: [PATCH 10/22] Proto,SCORU: Fix typo Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml index 25e11c1a7da4..59238d4f3815 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml @@ -188,7 +188,7 @@ let test_parsing_message ~valid (source, expected_code) = Assert.equal ~loc:__LOC__ (Option.equal Bool.equal) - "Unexpected parsing resutlt" + "Unexpected parsing result" (fun fmt r -> Format.fprintf fmt -- GitLab From 100e855c6aa3eeab1f747d59977de6f815244e66 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Tue, 13 Sep 2022 11:10:03 +0200 Subject: [PATCH 11/22] Proto,SCORU: Fix a test input A syntactically incorrect input is now syntactically correct. Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml index 59238d4f3815..be8af5b04e20 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_arith.ml @@ -229,7 +229,7 @@ let syntactically_valid_messages = let syntactically_invalid_messages = List.map (fun s -> (s, [])) - ["@"; " @"; " @ "; "---"; "12 +++ --"; "1a"; "a1"] + ["@"; " @"; " @ "; "---"; "12 +++ --"; "1a"; "a_"] let test_parsing_messages () = List.iter_es (test_parsing_message ~valid:true) syntactically_valid_messages -- GitLab From 79c9d4a828db9e597511b4a684fb69851c8e559c Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Tue, 13 Sep 2022 17:00:57 +0200 Subject: [PATCH 12/22] Proto,SCORU: Add support for L1 contract entrypoints in arith output Signed-off-by: Yann Regis-Gianas --- .../lib_protocol/sc_rollup_arith.ml | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 74b608637ed4..fd44a5e1c049 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -1002,7 +1002,9 @@ module Make (Context : P) : let is_letter d = Compare.Char.((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z')) in - let is_identifier_char d = is_digit d || is_letter d in + let is_identifier_char d = + is_digit d || is_letter d || Compare.Char.(d = '%') + in let* parser_state = Parser_state.get in match parser_state with | ParseInt -> ( @@ -1055,7 +1057,7 @@ module Make (Context : P) : | None -> stop_parsing true | _ -> stop_parsing false) - let output destination v = + let output (destination, entrypoint) v = let open Monad.Syntax in let open Sc_rollup_outbox_message_repr in let* counter = Output_counter.get in @@ -1063,7 +1065,6 @@ module Make (Context : P) : let unparsed_parameters = Micheline.(Int ((), Z.of_int v) |> strip_locations) in - let entrypoint = Entrypoint_repr.default in let transaction = {unparsed_parameters; destination; entrypoint} in let message = Atomic_transaction_batch {transactions = [transaction]} in let* outbox_level = Current_level.get in @@ -1073,11 +1074,28 @@ module Make (Context : P) : Output.set (Z.to_string counter) output let identifies_target_contract x = - if Compare.String.(x = "out") then Some Contract_hash.zero + let open Option_syntax in + if Compare.String.(x = "out") then + return (Contract_hash.zero, Entrypoint_repr.default) else if Compare.Int.(String.length x >= 3) && String.(equal (sub x 0 3) "KT1") - then Contract_hash.of_b58check_opt x - else None + then + match String.split_on_char '%' x with + | destination :: entrypoint -> + let* destination = Contract_hash.of_b58check_opt destination in + let* entrypoint = + match entrypoint with + | [] -> return Entrypoint_repr.default + | _ -> + let* entrypoint = + Non_empty_string.of_string (String.concat "" entrypoint) + in + let* entrypoint = Entrypoint_repr.of_annot_lax_opt entrypoint in + return entrypoint + in + return (destination, entrypoint) + | [] -> fail + else fail let evaluate = let open Monad.Syntax in @@ -1091,7 +1109,7 @@ module Make (Context : P) : | None -> stop_evaluating false | Some v -> ( match identifies_target_contract x with - | Some hash -> output hash v + | Some contract_entrypoint -> output contract_entrypoint v | None -> Vars.set x v)) | Some IAdd -> ( let* v = Stack.pop in -- GitLab From 676763cd80fbd2464373f6b775bec0ea457d2ca9 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Tue, 13 Sep 2022 18:00:34 +0200 Subject: [PATCH 13/22] Tezt,SCORU: Test output to a non default entrypoint Signed-off-by: Yann Regis-Gianas --- tezt/lib_tezos/sc_rollup_client.ml | 31 +++++---- tezt/lib_tezos/sc_rollup_client.mli | 6 +- tezt/tests/sc_rollup.ml | 100 +++++++++++++++++++--------- 3 files changed, 91 insertions(+), 46 deletions(-) diff --git a/tezt/lib_tezos/sc_rollup_client.ml b/tezt/lib_tezos/sc_rollup_client.ml index f8ecc8bcd1f3..04d5876c988e 100644 --- a/tezt/lib_tezos/sc_rollup_client.ml +++ b/tezt/lib_tezos/sc_rollup_client.ml @@ -120,7 +120,7 @@ let string_of_transaction {destination; entrypoint; parameters} = destination (match entrypoint with | None -> "" - | Some entrypoint -> {| "entrypoint" : |} ^ entrypoint) + | Some entrypoint -> Format.asprintf {| "entrypoint" : "%s", |} entrypoint) parameters let string_of_batch ts = @@ -128,8 +128,9 @@ let string_of_batch ts = type outbox_proof = {commitment_hash : string; proof : string} -let outbox_proof_batch ?hooks sc_client ~message_index ~outbox_level batch = - let* answer = +let outbox_proof_batch ?hooks ?expected_error sc_client ~message_index + ~outbox_level batch = + let process = spawn_command ?hooks sc_client @@ -147,18 +148,24 @@ let outbox_proof_batch ?hooks sc_client ~message_index ~outbox_level batch = "transferring"; string_of_batch batch; ] - |> Process.check_and_read_stdout in - let open JSON in - let json = parse ~origin:"outbox_proof" answer in - let commitment_hash = json |-> "commitment_hash" |> as_string in - let proof = json |-> "proof" |> as_string in - return {commitment_hash; proof} - -let outbox_proof_single ?hooks ?entrypoint sc_client ~message_index - ~outbox_level ~destination ~parameters = + match expected_error with + | None -> + let* answer = Process.check_and_read_stdout process in + let open JSON in + let json = parse ~origin:"outbox_proof" answer in + let commitment_hash = json |-> "commitment_hash" |> as_string in + let proof = json |-> "proof" |> as_string in + return (Some {commitment_hash; proof}) + | Some msg -> + let* () = Process.check_error ~msg process in + return None + +let outbox_proof_single ?hooks ?expected_error ?entrypoint sc_client + ~message_index ~outbox_level ~destination ~parameters = outbox_proof_batch ?hooks + ?expected_error sc_client ~message_index ~outbox_level diff --git a/tezt/lib_tezos/sc_rollup_client.mli b/tezt/lib_tezos/sc_rollup_client.mli index 1d4eec9d9603..47007915b00c 100644 --- a/tezt/lib_tezos/sc_rollup_client.mli +++ b/tezt/lib_tezos/sc_rollup_client.mli @@ -81,13 +81,14 @@ type outbox_proof = {commitment_hash : string; proof : string} [entrypoint] with the given [parameters]. *) val outbox_proof_single : ?hooks:Process.hooks -> + ?expected_error:Base.rex -> ?entrypoint:string -> t -> message_index:int -> outbox_level:int -> destination:string -> parameters:string -> - outbox_proof Lwt.t + outbox_proof option Lwt.t type transaction = { destination : string; @@ -99,11 +100,12 @@ type transaction = { of output transactions. *) val outbox_proof_batch : ?hooks:Process.hooks -> + ?expected_error:Base.rex -> t -> message_index:int -> outbox_level:int -> transaction list -> - outbox_proof Lwt.t + outbox_proof option Lwt.t (** [commitment_from_json] parses a commitment from its JSON representation. *) val commitment_from_json : JSON.t -> commitment option diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 1753535db80d..57b5209c5baf 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -2992,15 +2992,19 @@ let test_refutation_reward_and_punishment protocols = The input depends on the PVM. *) -let test_outbox_message_generic skip input_message expected_storage kind = +let test_outbox_message_generic ?expected_error skip earliness entrypoint + input_message expected_storage kind = let commitment_period = 2 and challenge_window = 5 in + let variant = + (if entrypoint = "" then "" else entrypoint) ^ "_" ^ string_of_int earliness + in test_scenario ~kind ~commitment_period ~challenge_window { tags = ["outbox"]; - variant = kind; + variant; description = "an outbox message should be executable"; } @@ fun _protocol sc_rollup_node sc_rollup _node client -> @@ -3011,15 +3015,15 @@ let test_outbox_message_generic skip input_message expected_storage kind = let prg = {| { - parameter (int :p); + parameter (or (int %default) (int %aux)); storage (int :s); code { UNPAIR; - SWAP ; - DROP; - NIL operation; + IF_LEFT + { SWAP ; DROP; NIL operation } + { SWAP ; DROP; NIL operation }; PAIR; } } |} @@ -3047,54 +3051,66 @@ let test_outbox_message_generic skip input_message expected_storage kind = in let perform_rollup_execution_and_cement address = let* () = send_text_messages client sc_rollup [input_message address] in - let* () = - repeat (2 + (2 * commitment_period) + challenge_window) @@ fun () -> - Client.bake_for client + let blocks_to_wait = + 2 + (2 * commitment_period) + challenge_window - earliness in - let* _c, l = last_cemented_commitment_hash_with_level ~sc_rollup client in - Check.( - (l = 6) int ~error_msg:"Invalid level for LCC: expected '%R', 'got '%L'.") ; - return () + repeat blocks_to_wait @@ fun () -> Client.bake_for client in let trigger_outbox_message_execution address = - let* {commitment_hash; proof} = + let* outbox = Sc_rollup_client.outbox sc_client in + Log.info "Outbox is %s" outbox ; + let* answer = let message_index = 0 in let outbox_level = 4 in let destination = address in let parameters = "37" in + let entrypoint = if entrypoint = "" then None else Some entrypoint in Sc_rollup_client.outbox_proof_single sc_client + ?expected_error ~message_index ~outbox_level ~destination + ?entrypoint ~parameters in - let*! () = - Client.Sc_rollup.execute_outbox_message - ~burn_cap:(Tez.of_int 10) - ~rollup:sc_rollup - ~src - ~commitment_hash - ~proof - client - in - Client.bake_for client + match (answer, expected_error) with + | Some _, Some _ -> assert false + | None, None -> failwith "Unexpected error during proof generation" + | None, Some _ -> return () + | Some {commitment_hash; proof}, None -> + let*! () = + Client.Sc_rollup.execute_outbox_message + ~burn_cap:(Tez.of_int 10) + ~rollup:sc_rollup + ~src + ~commitment_hash + ~proof + client + in + Client.bake_for client in if skip then return () else let* target_contract_address = originate_target_contract () in let* () = perform_rollup_execution_and_cement target_contract_address in let* () = trigger_outbox_message_execution target_contract_address in - let* () = - check_contract_execution target_contract_address expected_storage - in - return () + match expected_error with + | None -> + let* () = + check_contract_execution target_contract_address expected_storage + in + return () + | Some _ -> return () -let test_outbox_message ~kind = +let test_outbox_message ?expected_error ~earliness entrypoint ~kind = let skip, input_message, expected_storage = + let entrypoint = if entrypoint = "" then entrypoint else "%" ^ entrypoint in match kind with | "arith" -> - (false, (fun contract_address -> "37 " ^ contract_address), "37\n") + ( false, + (fun contract_address -> "37 " ^ contract_address ^ entrypoint), + "37\n" ) | "wasm_2_0_0" -> (* FIXME: https://gitlab.com/tezos/tezos/-/issues/3790 For the moment, the WASM PVM has no support for @@ -3104,7 +3120,14 @@ let test_outbox_message ~kind = (* There is no other PVM in the protocol. *) assert false in - test_outbox_message_generic skip input_message expected_storage kind + test_outbox_message_generic + ?expected_error + skip + earliness + entrypoint + input_message + expected_storage + kind let register ~kind ~protocols = test_origination ~kind protocols ; @@ -3217,7 +3240,20 @@ let register ~kind ~protocols = test_consecutive_commitments protocols ~kind ; test_refutation protocols ~kind ; test_late_rollup_node protocols ~kind ; - test_outbox_message protocols ~kind + test_outbox_message ~earliness:0 "" protocols ~kind ; + test_outbox_message ~earliness:0 "aux" protocols ~kind ; + test_outbox_message + ~expected_error:(Base.rex ".*Invalid claim about outbox") + ~earliness:5 + "" + protocols + ~kind ; + test_outbox_message + ~expected_error:(Base.rex ".*Invalid claim about outbox") + ~earliness:5 + "aux" + protocols + ~kind let register ~protocols = (* PVM-independent tests. We still need to specify a PVM kind -- GitLab From 606ce31f85514aa9b05b45de4bf834ff7b07c132 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Wed, 14 Sep 2022 09:16:40 +0200 Subject: [PATCH 14/22] Proto,SCORU: Make message serialization API more consistent Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_protocol/alpha_context.mli | 8 ++++++-- src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index d13ec7c1aaee..457fac89365f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2928,12 +2928,14 @@ module Sc_rollup : sig type t = Internal of internal_inbox_message | External of string - type serialized = private string + type serialized val encoding : t Data_encoding.t val unsafe_of_string : string -> serialized + val unsafe_to_string : serialized -> string + val serialize : t -> serialized tzresult val deserialize : serialized -> t tzresult @@ -3135,10 +3137,12 @@ module Sc_rollup : sig type t = Atomic_transaction_batch of {transactions : transaction list} - type serialized = private string + type serialized val unsafe_of_string : string -> serialized + val unsafe_to_string : serialized -> string + val deserialize : serialized -> t tzresult val serialize : t -> serialized tzresult diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml index 3ffdce6b458d..d54d7cd0d24c 100644 --- a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml +++ b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml @@ -186,7 +186,7 @@ module Global = struct Z.to_int64 o.message_index) |+ field "serialized_outbox_message" RPC_arg.string "" (fun o -> match Outbox.Message.serialize o.message with - | Ok message -> (message :> string) + | Ok message -> Outbox.Message.unsafe_to_string message | Error e -> invalid_message e) |> seal -- GitLab From 9c6fad9d194400d1e6081230a3892f79c37ab4e3 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 15 Sep 2022 11:53:50 +0000 Subject: [PATCH 15/22] Tezt,SCORU: Fix typo --- tezt/tests/sc_rollup.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tezt/tests/sc_rollup.ml b/tezt/tests/sc_rollup.ml index 57b5209c5baf..1650dd46f8cd 100644 --- a/tezt/tests/sc_rollup.ml +++ b/tezt/tests/sc_rollup.ml @@ -2988,7 +2988,7 @@ let test_refutation_reward_and_punishment protocols = and stores this integer in its state. Then, the test executes a rollup operation that produces a call to this contract. Finally, the test triggers this call and we check that the L1 contract has - been correctly executed by observing its local store. + been correctly executed by observing its local storage. The input depends on the PVM. *) -- GitLab From 730d06260990926cb0b59e64597662581648e8f6 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 15 Sep 2022 12:01:46 +0000 Subject: [PATCH 16/22] Proto,SCORU: Improve code quality --- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index fd44a5e1c049..9ebf5199e924 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -863,8 +863,8 @@ module Make (Context : P) : let get_outbox state = let open Lwt_syntax in - let* entries = (result_of ~default:[] @@ Output.entries) state in - return @@ List.map snd entries + let+ entries = result_of ~default:[] Output.entries state in + List.map snd entries let get_code = result_of ~default:[] @@ Code.to_list -- GitLab From 0acc8319dba5c43f19258f34c29c7146a6c29329 Mon Sep 17 00:00:00 2001 From: Alain Mebsout Date: Thu, 15 Sep 2022 12:42:50 +0000 Subject: [PATCH 17/22] Proto,SCORU: Improve code quality --- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 9ebf5199e924..65bac8189a1a 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -65,7 +65,7 @@ let () = `Permanent ~id:"sc_rollup_arith_invalid_claim_about_outbox" ~title:msg - ~pp:(fun fmt () -> Format.fprintf fmt "%s" msg) + ~pp:(fun fmt () -> Format.pp_print_string fmt msg) ~description:msg unit (function Arith_invalid_claim_about_outbox -> Some () | _ -> None) -- GitLab From a7998e726889181a5d4018a1fadf8f9b1dfc4ed7 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Thu, 15 Sep 2022 14:44:10 +0200 Subject: [PATCH 18/22] Proto,SCORU: Improve code quality Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_protocol/sc_rollup_arith.ml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 65bac8189a1a..ee201a11f560 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -1002,8 +1002,9 @@ module Make (Context : P) : let is_letter d = Compare.Char.((d >= 'a' && d <= 'z') || (d >= 'A' && d <= 'Z')) in - let is_identifier_char d = - is_digit d || is_letter d || Compare.Char.(d = '%') + let is_identifier_char = function + | '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '%' -> true + | _ -> false in let* parser_state = Parser_state.get in match parser_state with -- GitLab From 8bf41b758f86efed923612599f85bbbdd313575f Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Thu, 15 Sep 2022 14:51:12 +0200 Subject: [PATCH 19/22] Proto,SCORU: Make Arith PVM contract hash parsing future proof Signed-off-by: Yann Regis-Gianas --- .../lib_protocol/sc_rollup_arith.ml | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index ee201a11f560..ad892e902ad3 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -1076,27 +1076,29 @@ module Make (Context : P) : let identifies_target_contract x = let open Option_syntax in - if Compare.String.(x = "out") then - return (Contract_hash.zero, Entrypoint_repr.default) - else if - Compare.Int.(String.length x >= 3) && String.(equal (sub x 0 3) "KT1") - then - match String.split_on_char '%' x with - | destination :: entrypoint -> - let* destination = Contract_hash.of_b58check_opt destination in - let* entrypoint = - match entrypoint with - | [] -> return Entrypoint_repr.default - | _ -> - let* entrypoint = - Non_empty_string.of_string (String.concat "" entrypoint) - in - let* entrypoint = Entrypoint_repr.of_annot_lax_opt entrypoint in - return entrypoint - in - return (destination, entrypoint) - | [] -> fail - else fail + match Contract_hash.of_b58check_opt x with + | None -> + if Compare.String.(x = "out") then + return (Contract_hash.zero, Entrypoint_repr.default) + else fail + | Some _ -> ( + match String.split_on_char '%' x with + | destination :: entrypoint -> + let* destination = Contract_hash.of_b58check_opt destination in + let* entrypoint = + match entrypoint with + | [] -> return Entrypoint_repr.default + | _ -> + let* entrypoint = + Non_empty_string.of_string (String.concat "" entrypoint) + in + let* entrypoint = + Entrypoint_repr.of_annot_lax_opt entrypoint + in + return entrypoint + in + return (destination, entrypoint) + | [] -> fail) let evaluate = let open Monad.Syntax in -- GitLab From 654d8b2a9e57ca312564bd189f33bdd2fe18ef2b Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Thu, 15 Sep 2022 18:01:03 +0200 Subject: [PATCH 20/22] Proto,SCORU: Fix unit test Signed-off-by: Yann Regis-Gianas --- .../unit/test_sc_rollup_management_protocol.ml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml index 86ae64837a90..e5f1cf1e62e0 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_sc_rollup_management_protocol.ml @@ -49,7 +49,10 @@ let check_encode_decode_inbox_message message = let*? bytes' = Environment.wrap_tzresult @@ Sc_rollup.Inbox_message.serialize message' in - Assert.equal_string ~loc:__LOC__ (bytes :> string) (bytes' :> string) + Assert.equal_string + ~loc:__LOC__ + (Sc_rollup.Inbox_message.unsafe_to_string bytes) + (Sc_rollup.Inbox_message.unsafe_to_string bytes') let check_encode_decode_outbox_message ctxt message = let open Lwt_result_syntax in @@ -68,7 +71,10 @@ let check_encode_decode_outbox_message ctxt message = Environment.wrap_tzresult @@ Internal_for_tests.serialize_outbox_message message' in - Assert.equal_string ~loc:__LOC__ (bytes :> string) (bytes' :> string) + Assert.equal_string + ~loc:__LOC__ + (Sc_rollup.Outbox.Message.unsafe_to_string bytes) + (Sc_rollup.Outbox.Message.unsafe_to_string bytes') let string_ticket ticketer contents amount = let open WithExceptions in @@ -152,7 +158,9 @@ let test_encode_decode_external_inbox_message () = Environment.wrap_tzresult @@ Sc_rollup.Inbox_message.serialize inbox_message in - let real_encoding = (real_encoding :> string) in + let real_encoding = + Sc_rollup.Inbox_message.unsafe_to_string real_encoding + in (* The prefix consists of a tag (0 for internal, 1 for external). *) let real_prefix = String.get real_encoding 0 in let expected_prefix = '\001' in -- GitLab From 912c82df3c075d7c63ee8f0a806668f872a93122 Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Fri, 16 Sep 2022 10:24:00 +0200 Subject: [PATCH 21/22] SCORU: Improve encoding of outbox proof in RPC Signed-off-by: Yann Regis-Gianas --- src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml index d54d7cd0d24c..483f98296429 100644 --- a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml +++ b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml @@ -190,11 +190,19 @@ module Global = struct | Error e -> invalid_message e) |> seal + let hex_string = + let open Data_encoding in + conv Bytes.of_string Bytes.to_string bytes + let outbox_proof () = RPC_service.get_service ~description:"Generate serialized output proof for some outbox message" ~query:outbox_proof_query - ~output:Data_encoding.(tup2 Sc_rollup.Commitment.Hash.encoding string) + ~output: + Data_encoding.( + obj2 + (req "commitment" Sc_rollup.Commitment.Hash.encoding) + (req "proof" hex_string)) (prefix / "proofs" / "outbox") end -- GitLab From c13a53586d052fcb67f82f67eeda32d88fab87ae Mon Sep 17 00:00:00 2001 From: Yann Regis-Gianas Date: Fri, 16 Sep 2022 10:58:59 +0200 Subject: [PATCH 22/22] SCORU: Make outbox proof RPC arguments mandatory Signed-off-by: Yann Regis-Gianas --- .../lib_sc_rollup/sc_rollup_services.ml | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml index 483f98296429..39f1f0626a55 100644 --- a/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml +++ b/src/proto_alpha/lib_sc_rollup/sc_rollup_services.ml @@ -171,22 +171,32 @@ module Global = struct e)) in query (fun outbox_level message_index serialized_outbox_message -> - let outbox_level = Raw_level.of_int32_exn outbox_level in - let message_index = Z.of_int64 message_index in + let req name f = function + | None -> + raise + (Invalid (Format.sprintf "Query parameter %s is required" name)) + | Some arg -> f arg + in + let outbox_level = + req "outbox_level" Raw_level.of_int32_exn outbox_level + in + let message_index = req "message_index" Z.of_int64 message_index in let message = - Outbox.Message.( - unsafe_of_string serialized_outbox_message |> deserialize) + req + "serialized_outbox_message" + (fun s -> Outbox.Message.(unsafe_of_string s |> deserialize)) + serialized_outbox_message in match message with | Error e -> invalid_message e | Ok message -> {outbox_level; message_index; message}) - |+ field "outbox_level" RPC_arg.int32 0l (fun o -> - Raw_level.to_int32 o.outbox_level) - |+ field "message_index" RPC_arg.int64 0L (fun o -> - Z.to_int64 o.message_index) - |+ field "serialized_outbox_message" RPC_arg.string "" (fun o -> + |+ opt_field "outbox_level" RPC_arg.int32 (fun o -> + Some (Raw_level.to_int32 o.outbox_level)) + |+ opt_field "message_index" RPC_arg.int64 (fun o -> + Some (Z.to_int64 o.message_index)) + |+ opt_field "serialized_outbox_message" RPC_arg.string (fun o -> match Outbox.Message.serialize o.message with - | Ok message -> Outbox.Message.unsafe_to_string message + | Ok message -> Some (Outbox.Message.unsafe_to_string message) | Error e -> invalid_message e) |> seal -- GitLab