diff --git a/client-libs/kaitai-struct-files/files/alpha__smart_rollup__reveal.ksy b/client-libs/kaitai-struct-files/files/alpha__smart_rollup__reveal.ksy index 68847120ac50e7b6dfb1418bc4c749cafe88817c..7e96ef15559ec539853607064e46cf5282c68786 100644 --- a/client-libs/kaitai-struct-files/files/alpha__smart_rollup__reveal.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__smart_rollup__reveal.ksy @@ -3,6 +3,18 @@ meta: endian: be doc: ! 'Encoding id: alpha.smart_rollup.reveal' types: + alpha__contract_id: + seq: + - id: alpha__contract_id_tag + type: u1 + enum: alpha__contract_id_tag + - id: implicit + type: public_key_hash + if: (alpha__contract_id_tag == alpha__contract_id_tag::implicit) + doc: A Ed25519, Secp256k1, P256, or BLS public key hash + - id: originated + type: originated + if: (alpha__contract_id_tag == alpha__contract_id_tag::originated) input_hash: seq: - id: input_hash_tag @@ -11,6 +23,13 @@ types: - id: reveal_data_hash_v0 size: 32 if: (input_hash_tag == input_hash_tag::reveal_data_hash_v0) + originated: + seq: + - id: contract_hash + size: 20 + - id: originated_padding + size: 1 + doc: This field is for padding, ignore page_id: seq: - id: published_level @@ -19,14 +38,82 @@ types: type: u1 - id: page_index type: s2be + public_key_hash: + seq: + - id: public_key_hash_tag + type: u1 + enum: public_key_hash_tag + - id: ed25519 + size: 20 + if: (public_key_hash_tag == public_key_hash_tag::ed25519) + - id: secp256k1 + size: 20 + if: (public_key_hash_tag == public_key_hash_tag::secp256k1) + - id: p256 + size: 20 + if: (public_key_hash_tag == public_key_hash_tag::p256) + - id: bls + size: 20 + if: (public_key_hash_tag == public_key_hash_tag::bls) + request_adaptive_dal_page: + seq: + - id: page_id + type: page_id + - id: min_attested_shards + type: u2be + - id: expected_total_shards + type: u2be + - id: restricted_commitments_publishers + type: restricted_commitments_publishers + restricted_commitments_publishers: + seq: + - id: restricted_commitments_publishers_tag + type: u1 + enum: restricted_commitments_publishers_tag + - id: some + type: some_0 + if: (restricted_commitments_publishers_tag == restricted_commitments_publishers_tag::some) + some: + seq: + - id: some_entries + type: some_entries + repeat: eos + some_0: + seq: + - id: len_some + type: u4be + valid: + max: 220 + - id: some + type: some + size: len_some + some_entries: + seq: + - id: alpha__contract_id + type: alpha__contract_id + doc: ! >- + A contract handle: A contract notation as given to an RPC or inside scripts. + Can be a base58 implicit contract hash or a base58 originated contract hash. enums: + alpha__contract_id_tag: + 0: implicit + 1: originated alpha__smart_rollup__reveal_tag: 0: reveal_raw_data 1: reveal_metadata 2: request_dal_page 3: reveal_dal_parameters + 4: request_adaptive_dal_page input_hash_tag: 0: reveal_data_hash_v0 + public_key_hash_tag: + 0: ed25519 + 1: secp256k1 + 2: p256 + 3: bls + restricted_commitments_publishers_tag: + 0: none + 1: some seq: - id: alpha__smart_rollup__reveal_tag type: u1 @@ -37,3 +124,6 @@ seq: - id: request_dal_page type: page_id if: (alpha__smart_rollup__reveal_tag == alpha__smart_rollup__reveal_tag::request_dal_page) +- id: request_adaptive_dal_page + type: request_adaptive_dal_page + if: (alpha__smart_rollup__reveal_tag == alpha__smart_rollup__reveal_tag::request_adaptive_dal_page) diff --git a/src/lib_wasm_debugger/commands.ml b/src/lib_wasm_debugger/commands.ml index da513686471a99947120d1b733315f8ab3bc6030..116f95e9b3e7db6c0769fa15658fd98f229502ff 100644 --- a/src/lib_wasm_debugger/commands.ml +++ b/src/lib_wasm_debugger/commands.ml @@ -433,6 +433,11 @@ let reveals config request = supported by the debugger." | Request_dal_page {slot_id = {published_level; index}; page_index} -> request_dal_page config num_retries published_level index page_index + | Request_adal_page _ -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + Handle this case for adaptive DAL. *) + assert false let write_debug_default config = match config.Config.timings_file with diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index de30bace905e2596f4abb68d924f85c0b9a9a52f..af251499a08d422317c10b6b46e28f59f772a271 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -3258,6 +3258,12 @@ module Sc_rollup : sig | Reveal_raw_data of Sc_rollup_reveal_hash.t | Reveal_metadata | Request_dal_page of Dal.Page.t + | Request_adal_page of { + page_id : Dal.Page.t; + min_attested_shards : int; + expected_total_shards : int; + restricted_commitments_publishers : Contract.t list option; + } | Reveal_dal_parameters type is_reveal_enabled = current_block_level:Raw_level.t -> reveal -> bool diff --git a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml index 2fe94f9cbf478deea1898dc61bf8487c5d3a74d7..2321f852d3923493ae969d798e37f9608e7bbfc3 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml @@ -218,9 +218,18 @@ type reveal = | Reveal_raw_data of Sc_rollup_reveal_hash.t | Reveal_metadata | Request_dal_page of Dal_slot_repr.Page.t + | Request_adal_page of { + page_id : Dal_slot_repr.Page.t; + (* The id of the DAL page we want to import. *) + min_attested_shards : int; + (* The expected minimal number of attested shards of the slot. *) + expected_total_shards : int; (* The total number of shards of the slot. *) + restricted_commitments_publishers : Contract_repr.t list option; + (* If none, no filtering by commitments publishers is made. *) + } | Reveal_dal_parameters (** Request DAL parameters that were used for the slots published at - the current inbox level. *) + the current inbox level. *) let reveal_encoding = let open Data_encoding in @@ -260,7 +269,55 @@ let reveal_encoding = (function Reveal_dal_parameters -> Some () | _ -> None) (fun () -> Reveal_dal_parameters) in - union [case_raw_data; case_metadata; case_dal_page; case_dal_parameters] + let case_adal_page = + case + ~title:"Request_adaptive_dal_page" + (Tag 4) + (obj5 + (kind "request_adaptive_dal_page") + (req "page_id" Dal_slot_repr.Page.encoding) + (req "min_attested_shards" Data_encoding.uint16) + (req "expected_total_shards" Data_encoding.uint16) + (dft + "restricted_commitments_publishers" + (option (list ~max_length:10 Contract_repr.encoding)) + None)) + (function + | Request_adal_page + { + page_id; + min_attested_shards; + expected_total_shards; + restricted_commitments_publishers; + } -> + Some + ( (), + page_id, + min_attested_shards, + expected_total_shards, + restricted_commitments_publishers ) + | _ -> None) + (fun ( (), + page_id, + min_attested_shards, + expected_total_shards, + restricted_commitments_publishers ) -> + Request_adal_page + { + page_id; + min_attested_shards; + expected_total_shards; + restricted_commitments_publishers; + }) + in + union + [ + case_raw_data; + case_metadata; + case_dal_page; + case_dal_parameters; + case_adal_page; + ] (** [is_reveal_enabled] is the type of a predicate that tells if a kind of reveal is activated at a certain block level. *) @@ -277,6 +334,12 @@ let is_reveal_enabled_predicate | Blake2B -> t.raw_data.blake2B) | Reveal_metadata -> t.metadata | Request_dal_page _ -> t.dal_page + | Request_adal_page _ -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + Handle this case for adaptive DAL. We should probably add activation + level in the parameters. *) + assert false | Reveal_dal_parameters -> t.dal_parameters in Raw_level_repr.(current_block_level >= activation_level) @@ -340,7 +403,28 @@ let input_request_encoding = let pp_reveal fmt = function | Reveal_raw_data hash -> Sc_rollup_reveal_hash.pp fmt hash | Reveal_metadata -> Format.pp_print_string fmt "Reveal metadata" - | Request_dal_page id -> Dal_slot_repr.Page.pp fmt id + | Request_dal_page id -> Format.fprintf fmt "DAL:%a" Dal_slot_repr.Page.pp id + | Request_adal_page + { + page_id; + min_attested_shards; + expected_total_shards; + restricted_commitments_publishers; + } -> + Format.fprintf + fmt + "ADAL:{page:%a; min_attested_shards:%d; expected_total_shards:%d; \ + publishers:%a}" + Dal_slot_repr.Page.pp + page_id + min_attested_shards + expected_total_shards + (Format.pp_print_option + ~none:(fun fmt () -> Format.fprintf fmt "Any") + (Format.pp_print_list + ~pp_sep:(fun fmt () -> Format.pp_print_string fmt ", ") + Contract_repr.pp_short)) + restricted_commitments_publishers | Reveal_dal_parameters -> Format.pp_print_string fmt "Reveal DAL parameters" (** [pp_input_request fmt i] pretty prints the given input [i] to the formatter @@ -368,6 +452,22 @@ let reveal_equal p1 p2 = | Reveal_metadata, _ -> false | Request_dal_page a, Request_dal_page b -> Dal_slot_repr.Page.equal a b | Request_dal_page _, _ -> false + | ( Request_adal_page + { + page_id; + min_attested_shards; + expected_total_shards; + restricted_commitments_publishers; + }, + Request_adal_page b ) -> + Dal_slot_repr.Page.equal page_id b.page_id + && Compare.Int.equal min_attested_shards b.min_attested_shards + && Compare.Int.equal expected_total_shards b.expected_total_shards + && Option.equal + (List.equal Contract_repr.equal) + restricted_commitments_publishers + b.restricted_commitments_publishers + | Request_adal_page _, _ -> false | Reveal_dal_parameters, Reveal_dal_parameters -> true | Reveal_dal_parameters, _ -> false diff --git a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml index 6962e7fec37de0cec4318b5ce7ebe74bb7a4bda4..4387d3c6861bdeaad9e07c70780d342b678795c2 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -999,6 +999,8 @@ module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : return PS.(Needs_reveal Reveal_metadata) | Waiting_for_reveal (Request_dal_page page) -> return PS.(Needs_reveal (Request_dal_page page)) + | Waiting_for_reveal (Request_adal_page arg) -> + return PS.(Needs_reveal (Request_adal_page arg)) | Waiting_for_reveal Reveal_dal_parameters -> return PS.(Needs_reveal Reveal_dal_parameters) | Halted | Parsing | Evaluating -> return PS.No_input_required @@ -1134,8 +1136,11 @@ module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : | None, Some (Request_dal_page page_id) -> (* We are in the same level, fetch the next page. *) next_dal_page dal_params ~target:(`Page_after page_id) - | _, Some Reveal_metadata | _, Some Reveal_dal_parameters -> + | _, Some Reveal_metadata + | _, Some Reveal_dal_parameters + | _, Some (Request_adal_page _) -> (* Should not happen. *) + (* These cases are not supported by the "toy" Arith PVM. *) assert false | _, Some (Reveal_raw_data _) -> (* Note that, providing a DAC input via a DAL page will interrupt @@ -1609,7 +1614,11 @@ module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : error "Invalid set_input: expecting a dal page reveal, got an inbox \ message or a raw data reveal." + | PS.Needs_reveal (PS.Request_adal_page _), _ -> + error + "Invalid set_input: Flexible DAL is not supported in the arith PVM." in + return (state, request) type error += Arith_proof_verification_failed diff --git a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml index 1edd697386cc78995d199e75b1f10ae85b3a5864..2b5f35ecac8d722a735a07e7969e857fa12d7c44 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml @@ -444,10 +444,17 @@ let valid (type state proof output) | ( Some (Reveal_proof Dal_parameters_proof), Needs_reveal Reveal_dal_parameters ) -> return_unit + | Some (Reveal_proof _), Needs_reveal (Request_dal_page _pid) -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 implement + refutation games for adaptive DAL. *) + assert false | None, (Initial | First_after _ | Needs_reveal _) | Some _, No_input_required | Some (Inbox_proof _), Needs_reveal _ | _ -> + (* ADAL/TODO: https://gitlab.com/tezos/tezos/-/milestones/410 + + Remove this fragile pattern matching. *) proof_error "Inbox proof and input request are dissociated." in return (input, input_requested) @@ -569,6 +576,11 @@ let produce ~metadata pvm_and_state commit_inbox_level ~is_reveal_enabled = ~get_history ~dal_attested_slots_validity_lag confirmed_slots_history + | Needs_reveal (Request_adal_page _info) -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + Implement refutations for adaptive DAL *) + assert false | Needs_reveal Reveal_dal_parameters -> let open Dal_with_history in return diff --git a/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml index 133a589ecd601cd0b2f5429e73a5058a441da1c5..d0b53961f95006efbe6e6249c4fef4affa41dc72 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/sc_rollup_helpers.ml @@ -874,8 +874,14 @@ struct | Needs_reveal Reveal_metadata | Needs_reveal Reveal_dal_parameters | Initial | First_after _ -> - return (state, fuel, tick, our_states)) + return (state, fuel, tick, our_states) + | Needs_reveal (Request_adal_page _) -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + to be implemented when needed. *) + assert false) in + go ~our_states fuel start_tick state let eval_metadata ~fuel ~our_states tick state ~metadata = diff --git a/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml b/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml index f45d1d0518a7efb717cee38f97900fc9de47031a..7eaf212f6faa8e6c9eba6c74f5c58b61a53f7656 100644 --- a/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml +++ b/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml @@ -174,7 +174,13 @@ module Make_fueled (F : Fuel.S) : FUELED_PVM with type fuel = F.t = struct (Data_encoding.Binary.to_string_exn Sc_rollup.Dal_parameters.encoding dal_parameters) + | Request_adal_page _ -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + To be implemented. *) + assert false in + let eval_tick_consume_fuel fuel failing_ticks state = let normal_eval state fuel = let max_steps = F.max_ticks fuel in @@ -311,6 +317,11 @@ module Make_fueled (F : Fuel.S) : FUELED_PVM with type fuel = F.t = struct go fuel (Int64.succ current_tick) failing_ticks state) | Initial | First_after _ -> return @@ Completed {fuel; current_tick; failing_ticks} + | Needs_reveal (Request_adal_page _) -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + to be implemented. *) + assert false in go fuel start_tick failing_ticks state diff --git a/src/proto_alpha/lib_sc_rollup_node/wasm_2_0_0_pvm.ml b/src/proto_alpha/lib_sc_rollup_node/wasm_2_0_0_pvm.ml index 0510ed5ac27f73983b02d408eaf1a2cafd09db8e..0b7dd6504335fdf88502061798ccdd034dd0984d 100644 --- a/src/proto_alpha/lib_sc_rollup_node/wasm_2_0_0_pvm.ml +++ b/src/proto_alpha/lib_sc_rollup_node/wasm_2_0_0_pvm.ml @@ -201,6 +201,11 @@ module Impl : Pvm_sig.S with type Unsafe_patches.t = unsafe_patch = struct | Waiting_for_reveal Sc_rollup.Reveal_dal_parameters -> "Waiting for DAL parameters" | Computing -> "Computing" + | Waiting_for_reveal (Request_adal_page _) -> + (* ADAL/FIXME: https://gitlab.com/tezos/tezos/-/milestones/410 + + To be implemented. *) + assert false let eval_many ~reveal_builtins ~write_debug ~is_reveal_enabled:_ = Backend.compute_step_many @@ -209,7 +214,7 @@ module Impl : Pvm_sig.S with type Unsafe_patches.t = unsafe_patch = struct ~write_debug ?hooks:None - (** WASM PVM Mutable API works by holding a reference to an immutable state + (** WASM PVM Mutable API works by holding a reference to an immutable state and wrapping all immutable functionality around the reference *) module Mutable_state : Pvm_sig.MUTABLE_STATE_S