diff --git a/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs b/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs index 0ae2f6876fbcb99994c13b1a2af656d0aebf5b13..6fe08252f498229bd2d9d8c731b62684f5b3038d 100644 --- a/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs +++ b/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs @@ -158,7 +158,7 @@ impl SdkRuntime for EvalHost { } #[inline(always)] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, @@ -166,9 +166,23 @@ impl SdkRuntime for EvalHost { destination: &mut [u8], ) -> Result { self.host - .reveal_dal_page(published_level, slot_index, page_index, destination) + .reveal_dal_page2(published_level, slot_index, page_index, destination) } + #[inline(always)] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil : i16, + destination: &mut [u8], + ) -> Result { + self.host + .reveal_adal_page(published_level, slot_index, page_index, attestation_threshold_per_mil, destination) + } + + #[inline(always)] fn reveal_dal_parameters(&self) -> RollupDalParameters { self.host.reveal_dal_parameters() diff --git a/etherlink/kernel_evm/kernel/src/dal.rs b/etherlink/kernel_evm/kernel/src/dal.rs index 5c538fa184ca380a0a387fde3f1828b583bf51db..24daa25bf51a61d0d7dff9a042bdbdb7516122c5 100644 --- a/etherlink/kernel_evm/kernel/src/dal.rs +++ b/etherlink/kernel_evm/kernel/src/dal.rs @@ -21,6 +21,9 @@ enum ParsedInput { Padding, } +// None means that we use DAL instead of Adaptive DAL +const ADAL_ATTESTATION_THRESHOLD_PER_MIL: Option = Some(210); + // Import all the pages of a DAL slot and concatenate them. fn import_dal_slot( host: &mut Host, @@ -40,16 +43,31 @@ fn import_dal_slot( let number_of_pages = (params.slot_size / params.page_size) as i16; let mut page_start = 0usize; for page_index in 0..number_of_pages { - let imported_page_len = host - .reveal_dal_page( - published_level as i32, - slot_index, - page_index, - &mut slot[page_start..page_start + page_size], - ) - .unwrap_or(0); + let imported_page_len = if let Some(attestation_threshold_per_mil) = ADAL_ATTESTATION_THRESHOLD_PER_MIL { + // Call reveal_adal_page when ADAL_ATTESTATION_THRESHOLD_PER_MIL is Some(value) + host + .reveal_adal_page( + published_level as i32, + slot_index, + page_index, + attestation_threshold_per_mil, + &mut slot[page_start..page_start + page_size], + ) + .unwrap_or(0) + } else { + // Call reveal_dal_page2 when ADAL_ATTESTATION_THRESHOLD_PER_MIL is None + host + .reveal_dal_page2( + published_level as i32, + slot_index, + page_index, + &mut slot[page_start..page_start + page_size], + ) + .unwrap_or(0) + }; + if imported_page_len == page_size { - page_start += imported_page_len + page_start += imported_page_len; } else { return None; } diff --git a/etherlink/kernel_evm/runtime/src/runtime.rs b/etherlink/kernel_evm/runtime/src/runtime.rs index ebb683d969a771b90a819e5e0b6d5b69fbe9a915..759ad49974cfad814703190659bc09882b2d1da9 100644 --- a/etherlink/kernel_evm/runtime/src/runtime.rs +++ b/etherlink/kernel_evm/runtime/src/runtime.rs @@ -183,14 +183,14 @@ impl + Borrow, Internal: InternalRuntime> S } #[inline(always)] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, page_index: i16, destination: &mut [u8], ) -> Result { - self.host.borrow().reveal_dal_page( + self.host.borrow().reveal_dal_page2( published_level, slot_index, page_index, @@ -198,6 +198,24 @@ impl + Borrow, Internal: InternalRuntime> S ) } + #[inline(always)] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil : i16, + destination: &mut [u8], + ) -> Result { + self.host.borrow().reveal_adal_page( + published_level, + slot_index, + page_index, + attestation_threshold_per_mil, + destination, + ) + } + #[inline(always)] fn reveal_dal_parameters(&self) -> RollupDalParameters { self.host.borrow().reveal_dal_parameters() diff --git a/etherlink/kernel_evm/runtime/src/safe_storage.rs b/etherlink/kernel_evm/runtime/src/safe_storage.rs index bce9d0ac6af8d42b7ee14525ac0dec75f172c758..58fcf5f996c447f424eaee7f2794cca18ffd6f01 100644 --- a/etherlink/kernel_evm/runtime/src/safe_storage.rs +++ b/etherlink/kernel_evm/runtime/src/safe_storage.rs @@ -184,7 +184,7 @@ impl SdkRuntime for SafeStorage<&mut Host> { } #[inline(always)] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, @@ -192,7 +192,20 @@ impl SdkRuntime for SafeStorage<&mut Host> { destination: &mut [u8], ) -> Result { self.host - .reveal_dal_page(published_level, slot_index, page_index, destination) + .reveal_dal_page2(published_level, slot_index, page_index, destination) + } + + #[inline(always)] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil : i16, + destination: &mut [u8], + ) -> Result { + self.host + .reveal_adal_page(published_level, slot_index, page_index, attestation_threshold_per_mil, destination) } #[inline(always)] diff --git a/src/bin_dal_node/RPC_server.ml b/src/bin_dal_node/RPC_server.ml index a6d99d98acc604e0dff996ec7040dd64f5d51d8e..a0f2f9bc144dd1fae4e653a7709653c1d0c776d8 100644 --- a/src/bin_dal_node/RPC_server.ml +++ b/src/bin_dal_node/RPC_server.ml @@ -542,7 +542,8 @@ let register : Services.health (Health.get_health ctxt) -let register_plugin node_ctxt = +let register_plugin _node_ctxt = Tezos_rpc.Directory.empty +(* let open Lwt_syntax in Tezos_rpc.Directory.register_dynamic_directory Tezos_rpc.Directory.empty @@ -567,6 +568,7 @@ let register_plugin node_ctxt = Tezos_rpc.Directory.empty (Node_context.get_all_plugins node_ctxt) |> return) +*) let start configuration ctxt = let open Lwt_syntax in diff --git a/src/kernel_adal_echo/Cargo.lock b/src/kernel_adal_echo/Cargo.lock new file mode 100644 index 0000000000000000000000000000000000000000..0aa40d9cfef0e96c86213f1002fafd2f0b8b9b5d --- /dev/null +++ b/src/kernel_adal_echo/Cargo.lock @@ -0,0 +1,1884 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "adal_echo_kernel" +version = "0.1.0" +dependencies = [ + "tezos-smart-rollup", + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-entrypoint", + "tezos-smart-rollup-host", + "tezos-smart-rollup-mock", + "tezos-smart-rollup-storage", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[package]] +name = "arrayref" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" + +[[package]] +name = "bitvec" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blst" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a30d0edd9dd1c60ddb42b80341c7852f6f985279a5c1a83659dcb65899dec99" +dependencies = [ + "cc", + "glob", + "threadpool", + "which", + "zeroize", +] + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.0.99" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c51067fd44124faa7f870b4b1c969379ad32b2ba805aa959430ceaa384f695" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cpufeatures" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "crypto-bigint" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8658c15c5d921ddf980f7fe25b1e82f4b7a4083b2c4985fea4922edb8e43e07d" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "crypto-mac" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714" +dependencies = [ + "generic-array", + "subtle", +] + +[[package]] +name = "cryptoxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382ce8820a5bb815055d3553a610e8cb542b2d767bbacea99038afda96cd760d" + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest 0.10.7", + "fiat-crypto", + "rustc_version", + "subtle", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fdaf97f4804dcebfa5862639bc9ce4121e82140bec2a987ac5140294865b5b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "der" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79b71cca7d95d7681a4b3b9cdf63c8dbc3730d0584c2c74e31416d64a90493f4" + +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer 0.10.4", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "5.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.48.0", +] + +[[package]] +name = "displaydoc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "dlmalloc" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "203540e710bfadb90e5e29930baf5d10270cec1f43ab34f46f78b147b2de715a" +dependencies = [ + "libc", +] + +[[package]] +name = "ecdsa" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43ee23aa5b4f68c7a092b5c3beb25f50c406adc75e2363634f242f28ab255372" +dependencies = [ + "der", + "elliptic-curve", + "hmac", + "signature 1.3.2", +] + +[[package]] +name = "ed25519" +version = "2.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60f6d271ca33075c88028be6f04d502853d63a5ece419d269c15315d4fc1cf1d" +dependencies = [ + "signature 2.1.0", +] + +[[package]] +name = "ed25519-dalek" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7277392b266383ef8396db7fdeb1e77b6c52fed775f5df15bb24f35b72156980" +dependencies = [ + "curve25519-dalek", + "ed25519", + "sha2 0.10.8", +] + +[[package]] +name = "either" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" + +[[package]] +name = "elliptic-curve" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e5c176479da93a0983f0a6fdc3c1b8e7d5be0d7fe3fe05a99f15b96582b9a8" +dependencies = [ + "crypto-bigint", + "ff", + "generic-array", + "group", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "ff" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0f40b2dcd8bc322217a5f6559ae5f9e9d1de202a2ecee2e9eafcbece7562a4f" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0870c84016d4b481be5c9f323c24f65e31e901ae618f0e80f4308fb00de1d2d" + +[[package]] +name = "filetime" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "windows-sys 0.52.0", +] + +[[package]] +name = "flate2" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "group" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c363a5301b8f153d80747126a04b3c82073b9fe3130571a9d170cacdeaf7912" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit" +version = "0.7.2" +source = "git+https://github.com/hermit-os/hermit-rs.git?rev=01df75880c9be03fe935c3faabd191082d8916a2#01df75880c9be03fe935c3faabd191082d8916a2" +dependencies = [ + "flate2", + "tar", + "ureq", +] + +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b" +dependencies = [ + "crypto-mac", + "digest 0.9.0", +] + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "idna" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed" +dependencies = [ + "icu_normalizer", + "icu_properties", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libredox" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" +dependencies = [ + "bitflags 2.5.0", + "libc", +] + +[[package]] +name = "libsecp256k1" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95b09eff1b35ed3b33b877ced3a691fc7a481919c7e29c53c906226fcf55e2a1" +dependencies = [ + "arrayref", + "base64 0.13.1", + "digest 0.9.0", + "libsecp256k1-core", + "libsecp256k1-gen-ecmult", + "libsecp256k1-gen-genmult", + "rand 0.8.5", + "serde", +] + +[[package]] +name = "libsecp256k1-core" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be9b9bb642d8522a44d533eab56c16c738301965504753b03ad1de3425d5451" +dependencies = [ + "crunchy", + "digest 0.9.0", + "subtle", +] + +[[package]] +name = "libsecp256k1-gen-ecmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3038c808c55c87e8a172643a7d87187fc6c4174468159cb3090659d55bcb4809" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "libsecp256k1-gen-genmult" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3db8d6ba2cec9eacc40e6e8ccc98931840301f1006e95647ceb2dd5c3aa06f7c" +dependencies = [ + "libsecp256k1-core", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + +[[package]] +name = "log" +version = "0.4.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" +dependencies = [ + "adler", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-bigint" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", + "serde", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" + +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "p256" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d053368e1bae4c8a672953397bd1bd7183dde1c72b0b7612a15719173148d186" +dependencies = [ + "ecdsa", + "elliptic-curve", + "sha2 0.9.9", +] + +[[package]] +name = "parse-display" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7271152b3c46c07c729698e7a5248e2744466b3446d222c97a0b1315925a97b1" +dependencies = [ + "once_cell", + "parse-display-derive", + "regex", +] + +[[package]] +name = "parse-display-derive" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6a9f3e41b237b77c99c09686481c235964ff5878229412b226c451f3e809f4f" +dependencies = [ + "once_cell", + "proc-macro2", + "quote", + "regex", + "regex-syntax 0.6.29", + "syn 1.0.109", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "proc-macro2" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "rand_chacha", + "rand_core 0.5.1", + "rand_hc", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core 0.5.1", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core 0.5.1", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_users" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd283d9651eeda4b2a83a43c1c91b266c40fd76ecd39a50a8c630ae69dc72891" +dependencies = [ + "getrandom", + "libredox", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax 0.7.5", +] + +[[package]] +name = "regex-automata" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.7.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.5.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "semver" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad977052201c6de01a8ef2aa3378c4bd23217a056337d1d6da40468d267a4fb0" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer 0.9.0", + "cfg-if", + "cpufeatures", + "digest 0.9.0", + "opaque-debug", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.7", +] + +[[package]] +name = "shellexpand" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da03fa3b94cc19e3ebfc88c4229c49d8f08cdbd1228870a45f0ffdf84988e14b" +dependencies = [ + "dirs", +] + +[[package]] +name = "signature" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2807892cfa58e081aa1f1111391c7a0649d4fa127a4ffbe34bcbfb35a1171a4" +dependencies = [ + "digest 0.9.0", + "rand_core 0.6.4", +] + +[[package]] +name = "signature" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e1788eed21689f9cf370582dfc467ef36ed9c707f073528ddafa8d83e3b8500" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "strum" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c" + +[[package]] +name = "strum_macros" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "subtle" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "tar" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +dependencies = [ + "filetime", + "libc", + "xattr", +] + +[[package]] +name = "tezos-smart-rollup" +version = "0.2.2" +dependencies = [ + "hermit", + "hex", + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-entrypoint", + "tezos-smart-rollup-host", + "tezos-smart-rollup-macros", + "tezos-smart-rollup-mock", + "tezos-smart-rollup-storage", + "tezos_crypto_rs", + "tezos_data_encoding", +] + +[[package]] +name = "tezos-smart-rollup-constants" +version = "0.2.2" + +[[package]] +name = "tezos-smart-rollup-core" +version = "0.2.2" +dependencies = [ + "tezos-smart-rollup-constants", +] + +[[package]] +name = "tezos-smart-rollup-debug" +version = "0.2.2" +dependencies = [ + "tezos-smart-rollup-core", + "tezos-smart-rollup-host", +] + +[[package]] +name = "tezos-smart-rollup-encoding" +version = "0.2.2" +dependencies = [ + "hex", + "nom", + "num-bigint", + "num-traits", + "paste", + "regex", + "tezos-smart-rollup-core", + "tezos-smart-rollup-host", + "tezos_crypto_rs", + "tezos_data_encoding", + "thiserror", + "time", +] + +[[package]] +name = "tezos-smart-rollup-entrypoint" +version = "0.2.2" +dependencies = [ + "cfg-if", + "dlmalloc", + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-host", + "tezos-smart-rollup-panic-hook", +] + +[[package]] +name = "tezos-smart-rollup-host" +version = "0.2.2" +dependencies = [ + "tezos-smart-rollup-core", + "tezos_crypto_rs", + "tezos_data_encoding", + "thiserror", +] + +[[package]] +name = "tezos-smart-rollup-macros" +version = "0.2.2" +dependencies = [ + "proc-macro-error2", + "quote", + "shellexpand", + "syn 2.0.66", +] + +[[package]] +name = "tezos-smart-rollup-mock" +version = "0.2.2" +dependencies = [ + "hex", + "tezos-smart-rollup-core", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-host", + "tezos_crypto_rs", + "tezos_data_encoding", +] + +[[package]] +name = "tezos-smart-rollup-panic-hook" +version = "0.2.2" +dependencies = [ + "tezos-smart-rollup-core", +] + +[[package]] +name = "tezos-smart-rollup-storage" +version = "0.2.2" +dependencies = [ + "tezos-smart-rollup-core", + "tezos-smart-rollup-debug", + "tezos-smart-rollup-encoding", + "tezos-smart-rollup-host", + "thiserror", +] + +[[package]] +name = "tezos_crypto_rs" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8954f27b00228b1fc669cddfa0e604a40adc5ee443002d3d31abdea0b911fcb6" +dependencies = [ + "anyhow", + "blst", + "bs58", + "byteorder", + "cryptoxide", + "ed25519-dalek", + "hex", + "libsecp256k1", + "nom", + "num-bigint", + "num-traits", + "p256", + "rand 0.7.3", + "serde", + "strum", + "strum_macros", + "tezos_data_encoding", + "thiserror", + "zeroize", +] + +[[package]] +name = "tezos_data_encoding" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1fff433d41c778d27df21b91e766e182b05d9a7c1331e1156ee081273d704a4" +dependencies = [ + "bit-vec", + "bitvec", + "hex", + "lazy_static", + "nom", + "num-bigint", + "num-traits", + "serde", + "tezos_data_encoding_derive", + "thiserror", +] + +[[package]] +name = "tezos_data_encoding_derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f614c81c10c1ac47fdb792ce23e928591fca685d534260e073f83bc5d5f080e0" +dependencies = [ + "lazy_static", + "once_cell", + "parse-display", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "threadpool" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" +dependencies = [ + "num_cpus", +] + +[[package]] +name = "time" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +dependencies = [ + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7300fbefb4dadc1af235a9cef3737cea692a9d97e1b9cbcd4ebdae6f8868e6fb" + +[[package]] +name = "time-macros" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ba15a897f3c86766b757e5ac7221554c6750054d74d5b28844fce5fb36a6c4" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "typenum" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cdd25c339e200129fe4de81451814e5228c9b771d57378817d6117cc2b3f97" +dependencies = [ + "base64 0.21.7", + "flate2", + "log", + "once_cell", + "rustls", + "rustls-webpki", + "url", + "webpki-roots", +] + +[[package]] +name = "url" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "webpki-roots" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f20c57d8d7db6d3b86154206ae5d8fba62dd39573114de97c2cb0578251f8e1" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "xattr" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da84f1a25939b27f6820d92aed108f83ff920fdf11a7b19366c27c4cda81d4f" +dependencies = [ + "libc", + "linux-raw-sys", + "rustix", +] + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a0956f1ba7c7909bfb66c2e9e4124ab6f6482560f6628b5aaeba39207c9aad9" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[package]] +name = "zerovec" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.66", +] + +[[patch.unused]] +name = "tezos_crypto_rs" +version = "0.5.2" +source = "git+https://github.com/trilitech/tezedge.git?rev=0468da39f3133dbe6355fa8d443d3aeee10e3c0b#0468da39f3133dbe6355fa8d443d3aeee10e3c0b" + +[[patch.unused]] +name = "tezos_data_encoding" +version = "0.5.2" +source = "git+https://github.com/trilitech/tezedge.git?rev=0468da39f3133dbe6355fa8d443d3aeee10e3c0b#0468da39f3133dbe6355fa8d443d3aeee10e3c0b" + +[[patch.unused]] +name = "tezos_data_encoding_derive" +version = "0.5.2" +source = "git+https://github.com/trilitech/tezedge.git?rev=0468da39f3133dbe6355fa8d443d3aeee10e3c0b#0468da39f3133dbe6355fa8d443d3aeee10e3c0b" diff --git a/src/kernel_adal_echo/Cargo.toml b/src/kernel_adal_echo/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..2ba18bdef1df96aebaaf8027dfc2337dbc81d26b --- /dev/null +++ b/src/kernel_adal_echo/Cargo.toml @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2023 Nomadic Labs +# SPDX-FileCopyrightText: 2023 Marigold +# +# SPDX-License-Identifier: MIT + +[workspace] + +members = ["kernel"] + +[workspace.dependencies] +tezos-smart-rollup = { path = "../kernel_sdk/sdk", features = ["proto-alpha"] } +tezos-smart-rollup-core = { path = "../kernel_sdk/core", features = [ + "proto-alpha", +] } +tezos-smart-rollup-host = { path = "../kernel_sdk/host", features = [ + "proto-alpha", +] } +tezos-smart-rollup-debug = { path = "../kernel_sdk/debug" } +tezos-smart-rollup-entrypoint = { path = "../kernel_sdk/entrypoint" } +tezos-smart-rollup-storage = { path = "../kernel_sdk/storage" } +tezos-smart-rollup-encoding = { path = "../kernel_sdk/encoding", default-features = false, features = [ + "alloc", + "tezos-encoding", + "crypto", +] } +tezos-smart-rollup-mock = { path = "../kernel_sdk/mock", features = [ + "proto-alpha", +] } + +[patch.crates-io] +tezos_crypto_rs = { git = "https://github.com/trilitech/tezedge.git", rev = "0468da39f3133dbe6355fa8d443d3aeee10e3c0b" } +tezos_data_encoding = { git = "https://github.com/trilitech/tezedge.git", rev = "0468da39f3133dbe6355fa8d443d3aeee10e3c0b" } +tezos_data_encoding_derive = { git = "https://github.com/trilitech/tezedge.git", rev = "0468da39f3133dbe6355fa8d443d3aeee10e3c0b" } diff --git a/src/kernel_adal_echo/Makefile b/src/kernel_adal_echo/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6c2d94467c666637f9da64b0bee7bdcf41e0ab3e --- /dev/null +++ b/src/kernel_adal_echo/Makefile @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2023 Marigold +# +# SPDX-License-Identifier: MIT + +NATIVE_TARGET ?= +ifneq ($(NATIVE_TARGET),) +NATIVE_OPT := --target "$(NATIVE_TARGET)" +endif + +.PHONY: all +all: build test check + +.PHONY: adal_echo_kernel +adal_echo_kernel: + @cargo build --target wasm32-unknown-unknown --release -p adal_echo_kernel + +.PHONY: build +build: adal_echo_kernel + +.PHONY: build-deps +build-deps: + @rustup target add wasm32-unknown-unknown $(NATIVE_TARGET) + +.PHONY: build-dev-deps +build-dev-deps: build-deps + @rustup component add rustfmt clippy + +.PHONY: test +test: + @cargo test --features testing + +.PHONY: check +check: + @cargo clippy --features testing --all-targets --locked -- --deny warnings + +.PHONY: clean +clean: + @cargo clean diff --git a/src/kernel_adal_echo/README.md b/src/kernel_adal_echo/README.md new file mode 100644 index 0000000000000000000000000000000000000000..59bfb0fa413497bd2f3fcc6dac4d3cdcb35f171e --- /dev/null +++ b/src/kernel_adal_echo/README.md @@ -0,0 +1,9 @@ +# DAL Echo Kernel + +A simple kernel for testing the DAL. At each level, it will download all pages published at `current_level - attestation_lag` at slot `0`, then store the downloaded content to `/output/slot-0` of the durable storage. + +## How to Build + +``` sh +make build +``` diff --git a/src/kernel_adal_echo/kernel/Cargo.toml b/src/kernel_adal_echo/kernel/Cargo.toml new file mode 100644 index 0000000000000000000000000000000000000000..0bbc701140c2e9b2e4e7402a91ac8cd73fbf3a18 --- /dev/null +++ b/src/kernel_adal_echo/kernel/Cargo.toml @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2022-2023 TriliTech +# +# SPDX-License-Identifier: MIT + +[package] +name = "adal_echo_kernel" +version = "0.1.0" +edition = "2021" +license = "MIT" + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +tezos-smart-rollup.workspace = true +tezos-smart-rollup-core.workspace = true +tezos-smart-rollup-host.workspace = true +tezos-smart-rollup-debug.workspace = true +tezos-smart-rollup-entrypoint.workspace = true +tezos-smart-rollup-storage.workspace = true +tezos-smart-rollup-encoding.workspace = true +tezos-smart-rollup-mock.workspace = true + +[features] +default = [] +testing = [] diff --git a/src/kernel_adal_echo/kernel/src/lib.rs b/src/kernel_adal_echo/kernel/src/lib.rs new file mode 100644 index 0000000000000000000000000000000000000000..5e7c511c787673ad3f38c17a9f4381ce1acab717 --- /dev/null +++ b/src/kernel_adal_echo/kernel/src/lib.rs @@ -0,0 +1,121 @@ +// SPDX-FileCopyrightText: 2023 Marigold +// SPDX-FileCopyrightText: 2023 Nomadic Labs +// +// SPDX-License-Identifier: MIT + +use tezos_smart_rollup::entrypoint; +use tezos_smart_rollup_debug::debug_msg; +use tezos_smart_rollup_host::dal_parameters::RollupDalParameters; +use tezos_smart_rollup_host::path::OwnedPath; +use tezos_smart_rollup_host::runtime::Runtime; + +fn process_slot( + host: &mut impl Runtime, + published_level: i32, + num_pages: usize, + page_size: usize, + slot_index: u8, +) { + let mut buffer = vec![0u8; page_size * num_pages]; + + for page_index in 0..num_pages { + let result = host.reveal_adal_page( + published_level, + slot_index, + page_index.try_into().unwrap(), + 210, + &mut buffer[page_index * page_size..(page_index + 1) * page_size], + ); + + match result { + Ok(num) if num == 0 => { + // Currently, we send empty pages to kernels for non-attested slots. + debug_msg!( + host, + "Slot {} not attested for level {}\n", + slot_index, + published_level + ); + return; + } + Ok(num) => { + debug_msg!( + host, + "Retrieved page {} for level {}, slot index {} successfully. {} bytes read\n", + page_index, + published_level, + slot_index, + num + ); + let slot_path = format!("/output/slot-{}", slot_index); + let path: OwnedPath = slot_path.as_bytes().to_vec().try_into().unwrap(); + host.store_write(&path, &buffer, 0) + .map_err(|_| "Error writing to storage".to_string()) + .unwrap_or_default(); + } + Err(err) => { + debug_msg!( + host, + "Failed to retrieve one of the pages. Slot {} not processed. Error: {}\n", + slot_index, + &err.to_string() + ); + // Stop fetching pages on error + return; + } + } + } +} + +fn get_slot_indexes_from_env() -> Vec { + // By default track slot index 0. + let default_slot_indexes = vec![0]; + + let slot_indexes = match option_env!("SLOT_INDEXES") { + None => default_slot_indexes, + Some(s) => s + .split(',') + .map(|s| s.parse::()) + .collect::, _>>() + .unwrap_or(default_slot_indexes), + }; + + slot_indexes +} + +#[entrypoint::main] +pub fn entry(host: &mut impl Runtime) { + let parameters = host.reveal_dal_parameters(); + debug_msg!(host, "Running kernel with parameters: {:?}\n", parameters); + let RollupDalParameters { + number_of_slots: _, + attestation_lag, + slot_size, + page_size, + } = parameters; + + let slot_indexes = get_slot_indexes_from_env(); + + match host.read_input() { + Ok(Some(message)) => { + let level = message.level; + let published_level = (level as i32) - (attestation_lag as i32); + let num_pages = (slot_size / page_size) as usize; + for slot_index in slot_indexes { + process_slot( + host, + published_level, + num_pages, + page_size as usize, + slot_index, + ); + } + } + Ok(None) => { + debug_msg!(host, "Input message was empty"); + } + Err(_) => { + debug_msg!(host, "Failed to read input message"); + } + } +} diff --git a/src/kernel_adal_echo/rust-toolchain b/src/kernel_adal_echo/rust-toolchain new file mode 100644 index 0000000000000000000000000000000000000000..b6148bc0a759fb63cac1548d340fa10ffc22396a --- /dev/null +++ b/src/kernel_adal_echo/rust-toolchain @@ -0,0 +1 @@ +1.66.0 diff --git a/src/kernel_dal_echo/kernel/src/lib.rs b/src/kernel_dal_echo/kernel/src/lib.rs index 5909041763d122f0420f18d9a526ce3cc50d31bf..9aebd1ed69989d5c4ad04731fbc3a4e13c660509 100644 --- a/src/kernel_dal_echo/kernel/src/lib.rs +++ b/src/kernel_dal_echo/kernel/src/lib.rs @@ -19,7 +19,7 @@ fn process_slot( let mut buffer = vec![0u8; page_size * num_pages]; for page_index in 0..num_pages { - let result = host.reveal_dal_page( + let result = host.reveal_dal_page2( published_level, slot_index, page_index.try_into().unwrap(), diff --git a/src/kernel_sdk/CHANGES.md b/src/kernel_sdk/CHANGES.md index 5a11d81450514dbdb6053f1cf8a2ec1aa648c42d..9e8a965e3ce8745fcfb95278b61866e1d61f03c6 100644 --- a/src/kernel_sdk/CHANGES.md +++ b/src/kernel_sdk/CHANGES.md @@ -3,6 +3,9 @@ ## Version next ### SDK +- Add `Runtime::reveal_dal_page2` to let a kernel request pages from Tezos’ Data + Availability Layer (DAL). +- Add Adaptive DAL reveal page - Add experimental support for compiling kernels to a Hermit RISC-V image behind the `proto-alpha` flag. - Add an experimental rollup host with an in-memory store behind the `experimental-host-in-memory-store` flag. - Add an `OutboxQueue` that can be used when more than 100 outbox messages are produced at a given level. @@ -36,7 +39,7 @@ - Add michelson `or` and `option`. - Add a feature flag `proto-alpha` to enable host functions introduced in unreleased protocols. -- Add `Runtime::reveal_dal_page` to let a kernel request pages from Tezos’ Data +- Add `Runtime::reveal_dal_page2` to let a kernel request pages from Tezos’ Data Availability Layer (DAL). - Add a new case `WhitelistUpdate(OutboxMessageWhitelistUpdate)` to the `OutboxMessage` encoding, behind the `proto-alpha` feature flag. diff --git a/src/kernel_sdk/host/src/runtime.rs b/src/kernel_sdk/host/src/runtime.rs index 269e5b21d31b8659f5337e2e0ea2436d29bd6eb1..a4d02392c7042406a81a8cdbddbad7b8180789c7 100644 --- a/src/kernel_sdk/host/src/runtime.rs +++ b/src/kernel_sdk/host/src/runtime.rs @@ -192,7 +192,7 @@ pub trait Runtime { /// Reveal a DAL page. #[cfg(feature = "alloc")] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, @@ -200,6 +200,17 @@ pub trait Runtime { destination: &mut [u8], ) -> Result; + /// Reveal a DAL page. + #[cfg(feature = "alloc")] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil: i16, + destination: &mut [u8], + ) -> Result; + /// Reveal the DAL parameters. fn reveal_dal_parameters(&self) -> RollupDalParameters; @@ -598,7 +609,7 @@ where } #[cfg(feature = "alloc")] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, @@ -630,6 +641,42 @@ where } } + #[cfg(feature = "alloc")] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil : i16, + destination: &mut [u8], + ) -> Result { + // This will match the encoding declared for a DAL page in the Tezos protocol. + // ADAL/FIXME: Handle this case for debug mode as well + let payload: &[u8] = &[ + &[4u8], // tag + published_level.to_be_bytes().as_ref(), + &[slot_index], + page_index.to_be_bytes().as_ref(), + attestation_threshold_per_mil.to_be_bytes().as_ref(), + ] + .concat(); + + let res = unsafe { + SmartRollupCore::reveal( + self, + payload.as_ptr(), + payload.len(), + destination.as_mut_ptr(), + destination.len(), + ) + }; + + match Error::wrap(res) { + Ok(size) => Ok(size), + Err(e) => Err(RuntimeError::HostErr(e)), + } + } + fn reveal_dal_parameters(&self) -> RollupDalParameters { let mut destination = [0u8; DAL_PARAMETERS_SIZE]; // This will match the encoding declared for revealing DAL parameters in the Tezos protocol. diff --git a/src/kernel_sdk/host/src/runtime/unwindable.rs b/src/kernel_sdk/host/src/runtime/unwindable.rs index 63e89b58c0c4c373d9be6bbf1ad4fa03e22766b2..4428bc61b7ed1dfb7b8ee2220406c97e2e56b545 100644 --- a/src/kernel_sdk/host/src/runtime/unwindable.rs +++ b/src/kernel_sdk/host/src/runtime/unwindable.rs @@ -176,14 +176,14 @@ impl Runtime for UnwindableRuntime { } #[cfg(feature = "alloc")] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, page_index: i16, destination: &mut [u8], ) -> Result { - self.runtime.read().unwrap().reveal_dal_page( + self.runtime.read().unwrap().reveal_dal_page2( published_level, slot_index, page_index, @@ -191,6 +191,24 @@ impl Runtime for UnwindableRuntime { ) } + #[cfg(feature = "alloc")] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil : i16, + destination: &mut [u8], + ) -> Result { + self.runtime.read().unwrap().reveal_adal_page( + published_level, + slot_index, + page_index, + attestation_threshold_per_mil, + destination, + ) + } + fn reveal_dal_parameters(&self) -> RollupDalParameters { self.runtime.read().unwrap().reveal_dal_parameters() } diff --git a/src/kernel_sdk/mock/src/host.rs b/src/kernel_sdk/mock/src/host.rs index 57010a3f1d60099ce6d00c28f7dc4a7611654196..1cd807c2996a453c80b8408c8a077c6852680db8 100644 --- a/src/kernel_sdk/mock/src/host.rs +++ b/src/kernel_sdk/mock/src/host.rs @@ -53,7 +53,7 @@ unsafe fn reveal_dal_parameters( len as i32 } -unsafe fn reveal_dal_page( +unsafe fn do_reveal_dal_page( host: &MockHost, published_level: i32, slot_index: u8, @@ -262,7 +262,7 @@ unsafe impl SmartRollupCore for MockHost { self.reveal_metadata(destination_addr, max_bytes) } 2 => { - // Reveal_dal_page + // do_reveal_dal_page const PAYLOAD_SIZE: usize = size_of::() + size_of::() + size_of::(); @@ -279,7 +279,7 @@ unsafe impl SmartRollupCore for MockHost { let slot_index = slot_index[0]; let page_index = i16::from_be_bytes(page_index.try_into().unwrap()); - reveal_dal_page( + do_reveal_dal_page( self, published_level, slot_index, @@ -519,7 +519,8 @@ mod tests { let mut offset = 0; for page_index in 0..number_of_pages { let page_len = mock - .reveal_dal_page( + // ADAL: no adaptive DAL version for tests currently + .reveal_dal_page2( published_level, slot_index, page_index, @@ -552,7 +553,8 @@ mod tests { mock.set_dal_slot(published_level, slot_index, &data); // The slot is in an attestable state, so we can read its content - mock.reveal_dal_page(published_level, slot_index, 0, page_buffer) + // ADAL: no adaptive DAL version for tests currently + mock.reveal_dal_page2(published_level, slot_index, 0, page_buffer) .expect("Reveal of attested slot shouldn't fail") } diff --git a/src/kernel_sdk/sdk/src/entrypoint/internal/static_input_host.rs b/src/kernel_sdk/sdk/src/entrypoint/internal/static_input_host.rs index c71c17013183249baca5b5f1c7c84ada85141a7e..aae2e6fcc0cf67aeefb65227df528e6b1b167348 100644 --- a/src/kernel_sdk/sdk/src/entrypoint/internal/static_input_host.rs +++ b/src/kernel_sdk/sdk/src/entrypoint/internal/static_input_host.rs @@ -205,7 +205,7 @@ impl<'runtime, R: Runtime> Runtime for StaticInputHost<'runtime, R> { } #[inline(always)] - fn reveal_dal_page( + fn reveal_dal_page2( &self, published_level: i32, slot_index: u8, @@ -213,7 +213,20 @@ impl<'runtime, R: Runtime> Runtime for StaticInputHost<'runtime, R> { destination: &mut [u8], ) -> Result { self.host - .reveal_dal_page(published_level, slot_index, page_index, destination) + .reveal_dal_page2(published_level, slot_index, page_index, destination) + } + + #[inline(always)] + fn reveal_adal_page( + &self, + published_level: i32, + slot_index: u8, + page_index: i16, + attestation_threshold_per_mil : i16, + destination: &mut [u8], + ) -> Result { + self.host + .reveal_adal_page(published_level, slot_index, page_index, attestation_threshold_per_mil, destination) } #[inline(always)] diff --git a/src/kernel_tx_demo/kernel/src/dal.rs b/src/kernel_tx_demo/kernel/src/dal.rs index ce0fe7cb9c4bcd1ec3dad6ae0aec6c03801a34e3..bb357d374d79ea96b94409e7b9d9fb3c98cd84ab 100644 --- a/src/kernel_tx_demo/kernel/src/dal.rs +++ b/src/kernel_tx_demo/kernel/src/dal.rs @@ -29,7 +29,7 @@ pub(crate) fn store_dal_slot( ) { let mut buffer = vec![0u8; page_size]; for page_index in 0..(num_pages as i16) { - let result = host.reveal_dal_page(published_level, slot_index, page_index, &mut buffer); + let result = host.reveal_dal_page2(published_level, slot_index, page_index, &mut buffer); match result { Ok(size) => { #[cfg(feature = "debug")] diff --git a/src/lib_dal_node/dal_plugin.ml b/src/lib_dal_node/dal_plugin.ml index b787d87db35956a5e64f626bfe4281e38d11c2fe..521f8606fc0afdf886b2b85f9dbce03c2938d7a8 100644 --- a/src/lib_dal_node/dal_plugin.ml +++ b/src/lib_dal_node/dal_plugin.ml @@ -170,9 +170,11 @@ module type T = sig (hash * cell) list tzresult Lwt.t end + (* module RPC : sig val directory : Skip_list_cells_store.t -> unit Tezos_rpc.Directory.t end + *) end let table : (module T) Protocol_hash.Table.t = Protocol_hash.Table.create 5 diff --git a/src/lib_dal_node/dal_plugin.mli b/src/lib_dal_node/dal_plugin.mli index df0422c7f255cb174f7eae8a75d93b11b19befd2..83023e3a1e1a11f02fabb0dfbfa170e13c57379d 100644 --- a/src/lib_dal_node/dal_plugin.mli +++ b/src/lib_dal_node/dal_plugin.mli @@ -155,10 +155,12 @@ module type T = sig (hash * cell) list tzresult Lwt.t end + (* module RPC : sig (** RPCs directory of the protocol-related part of the DAL node. *) val directory : Skip_list_cells_store.t -> unit Tezos_rpc.Directory.t end + *) end val register : (module T) -> unit diff --git a/src/lib_wasm_debugger/commands.ml b/src/lib_wasm_debugger/commands.ml index 876a0f349c659f231951abed2db0c3c2fabc535c..e718f1d08644a98555fb77abfec25f8bc80e0935 100644 --- a/src/lib_wasm_debugger/commands.ml +++ b/src/lib_wasm_debugger/commands.ml @@ -433,6 +433,9 @@ 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 : Handle this case for adaptive DAL. *) + assert false let write_debug_default config = if config.Config.kernel_debug then diff --git a/src/proto_alpha/lib_dal/RPC_directory.ml b/src/proto_alpha/lib_dal/RPC_directory.ml index 11f377b4fd688ee3f2e4708d8b72e81c0f32abbd..cdd2c8fddfd5ad903222c783b270ac8d3e84bf57 100644 --- a/src/proto_alpha/lib_dal/RPC_directory.ml +++ b/src/proto_alpha/lib_dal/RPC_directory.ml @@ -6,6 +6,7 @@ (* *) (*****************************************************************************) +(* module Dal_proto_services = Dal_services open Protocol @@ -38,3 +39,4 @@ let register_commitments_history ctxt directory = let directory (rpc_ctxt : Skip_list_cells_store.t) = register_commitments_history rpc_ctxt Tezos_rpc.Directory.empty +*) diff --git a/src/proto_alpha/lib_dal/RPC_directory.mli b/src/proto_alpha/lib_dal/RPC_directory.mli index 3e5940728daf092afc79ceb7d72256e43ff20e61..aa88084273d5d46e5351ceb86f4b3a248429db93 100644 --- a/src/proto_alpha/lib_dal/RPC_directory.mli +++ b/src/proto_alpha/lib_dal/RPC_directory.mli @@ -6,5 +6,7 @@ (* *) (*****************************************************************************) +(* (** The RPCs directory of the protocol part of DAL nodes. *) val directory : Skip_list_cells_store.t -> unit Environment.RPC_directory.t +*) diff --git a/src/proto_alpha/lib_dal/dal_plugin_registration.ml b/src/proto_alpha/lib_dal/dal_plugin_registration.ml index 5ecadaaae6b69b9b89aed88413195101d7da5276..3c1bc98785a00520ac1ed07046aa0d42a41c99cc 100644 --- a/src/proto_alpha/lib_dal/dal_plugin_registration.ml +++ b/src/proto_alpha/lib_dal/dal_plugin_registration.ml @@ -184,7 +184,8 @@ module Plugin = struct (* 1. There are no cells for [published_level = 0]. *) if published_level <= 0l then return [] else - let* feature_enable, prev_number_of_slots = + (* ADAL/TODO: Remove th dead code related to _feature_enable. *) + let* _feature_enable, prev_number_of_slots = if published_level = 1l then (* For this level, cannot retrieve the constants (as [pred publication_level = 0]), but dummy values will suffice. *) @@ -198,6 +199,14 @@ module Plugin = struct prev_constants.number_of_slots ) in let cpctxt = new Protocol_client_context.wrap_rpc_context ctxt in + + let* slot_headers_status = + Plugin.RPC.Dal.dal_published_slot_headers_status + cpctxt + (`Main, `Level attested_level) + () + in + (* 2. We retrieve the last cell of the DAL skip list from the context, if any. It's the one stored in the context at [attested_level - 1]. If no cell is stored yet, we return the genesis cell. *) @@ -212,48 +221,54 @@ module Plugin = struct return @@ Option.value previous_cell_opt ~default:Dal.Slots_history.genesis in - let* attested_slot_headers = - if not feature_enable then - (* There are no published headers, because the DAL was not enabled, - and therefore there are no attested headers. *) - return [] - else - (* 3. We retrieve the slot headers published at level [level - - attestation_lag] from the context. *) - let* published_slot_headers = - if published_level = 1l then return [] - else - Plugin.RPC.Dal.dal_published_slot_headers - cpctxt - (`Main, `Level published_level) - () - in - (* 4. We retrieve the bitset of attested slots at level [level]. *) - let* attested_slots = - let*? metadata = - Option.to_result - block_info.metadata - ~none: - (TzTrace.make - @@ Layer1_services.Cannot_read_block_metadata block_info.hash - ) - in - return metadata.protocol_data.dal_attestation - in - let is_slot_attested slot = - Dal.Attestation.is_attested - attested_slots - slot.Dal.Slot.Header.id.index - in - (* 5. We filter the list of slot headers published at [level - - attestation_lag] and keep only those attested at level [level]. *) - let attested_slot_headers, _attested_slots_bitset = - Dal.Slot.compute_attested_slot_headers - ~is_slot_attested - published_slot_headers - in - return attested_slot_headers - in + (* ADAL/TODO: Remove this dead code + let* attested_slot_headers = + if not feature_enable then + (* There are no published headers, because the DAL was not enabled, + and therefore there are no attested headers. *) + return [] + else + (* 3. We retrieve the slot headers published at level [level - + attestation_lag] from the context. *) + let* published_slot_headers = + if published_level = 1l then return [] + else + Plugin.RPC.Dal.dal_published_slot_headers + cpctxt + (`Main, `Level published_level) + () + in + (* 4. We retrieve the bitset of attested slots at level [level]. *) + let* attested_slots = + let*? metadata = + Option.to_result + block_info.metadata + ~none: + (TzTrace.make + @@ Layer1_services.Cannot_read_block_metadata block_info.hash + ) + in + return metadata.protocol_data.dal_attestation + in + let is_slot_attested slot = + let b = + Dal.Attestation.is_attested + attested_slots + slot.Dal.Slot.Header.id.index + in + (* ADAL/FIXME: We should probably read this info from blocks + metadata or from the context. *) + (b, (if b then 1 else 0), 1) + in + (* 5. We filter the list of slot headers published at [level - + attestation_lag] and keep only those attested at level [level]. *) + let attested_slot_headers, _attested_slots_bitset = + Dal.Slot.compute_attested_slot_headers + ~is_slot_attested + published_slot_headers + in + return attested_slot_headers + in*) let*? published_level = Raw_level.of_int32 published_level |> Environment.wrap_tzresult in @@ -275,7 +290,7 @@ module Plugin = struct Not resilient to DAL parameters change. *) ~number_of_slots:dal_constants.number_of_slots - attested_slot_headers + ~seen_slot_headers:slot_headers_status (*attested_slot_headers*) |> Environment.wrap_tzresult in (* 7. We finally export and return the cells alongside their hashes as a @@ -284,13 +299,17 @@ module Plugin = struct let open Dal.Slots_history.History_cache in view cache |> Map.bindings in - return last_cells + (* ADAL/FIXME: don't index skip list cells anymore *) + ignore last_cells ; + return [] (* last_cells *) end + (* module RPC = struct let directory skip_list_cells_store = RPC_directory.directory skip_list_cells_store end + *) end let () = Dal_plugin.register (module Plugin) diff --git a/src/proto_alpha/lib_dal/dal_proto_client.ml b/src/proto_alpha/lib_dal/dal_proto_client.ml index 48ab4668bc55eed9f4684e3b718e6489e524b8bb..bf74092e8adaba86e9359ed6924c090fe41ad82d 100644 --- a/src/proto_alpha/lib_dal/dal_proto_client.ml +++ b/src/proto_alpha/lib_dal/dal_proto_client.ml @@ -24,6 +24,7 @@ (* *) (*****************************************************************************) +(* type cctxt = Dal_node_client.cctxt let get_commitments_history_hash_content (cctxt : cctxt) hash = @@ -35,3 +36,4 @@ let get_commitments_history_hash_content (cctxt : cctxt) hash = ((), hash) () () +*) diff --git a/src/proto_alpha/lib_dal/dal_proto_client.mli b/src/proto_alpha/lib_dal/dal_proto_client.mli index 96c2cd4ffe428f412839ea5ad06843ebc3d848cd..a2493a7c7e16268b1796156007956ee9616d989e 100644 --- a/src/proto_alpha/lib_dal/dal_proto_client.mli +++ b/src/proto_alpha/lib_dal/dal_proto_client.mli @@ -24,7 +24,9 @@ (* *) (*****************************************************************************) +(* val get_commitments_history_hash_content : Dal_node_client.cctxt -> Dal_plugin_registration.Plugin.Skip_list.hash -> Dal_plugin_registration.Plugin.Skip_list.cell tzresult Lwt.t +*) diff --git a/src/proto_alpha/lib_dal/dal_services.ml b/src/proto_alpha/lib_dal/dal_services.ml index 0fae899bf1cab8543721aa5faaa6938a7e0cdd70..23dc6f21c7bc8a25431a9bd9358a0834a54a94db 100644 --- a/src/proto_alpha/lib_dal/dal_services.ml +++ b/src/proto_alpha/lib_dal/dal_services.ml @@ -6,6 +6,7 @@ (* *) (*****************************************************************************) +(* open Protocol.Alpha_context open Tezos_rpc @@ -21,6 +22,7 @@ type 'rpc service = ; output : 'output > module Commitments_history = struct + let cell_hash_arg : Dal.Slots_history.Pointer_hash.t Arg.t = Arg.make ~descr:"The hash of a DAL skip list cell" @@ -49,3 +51,4 @@ module Commitments_history = struct / Protocol_hash.to_b58check Protocol.hash / "commitments_history" / "hash" /: cell_hash_arg) end + *) diff --git a/src/proto_alpha/lib_dal/dal_services.mli b/src/proto_alpha/lib_dal/dal_services.mli index 61f8ae00466c1b3d24da4a8cd6513d7777ecc8a5..eecdeb013641594ce7060865f17041de3eacaf41 100644 --- a/src/proto_alpha/lib_dal/dal_services.mli +++ b/src/proto_alpha/lib_dal/dal_services.mli @@ -6,6 +6,7 @@ (* *) (*****************************************************************************) +(* open Protocol.Alpha_context type 'rpc service = @@ -30,3 +31,4 @@ module Commitments_history : sig ; query : unit > service end +*) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index 36d24f1b9ec0d3837f336f0a850281dcab8ac543..e8ee0206e1a1329b63ffb56abcf36338c8b1d0bb 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -3032,6 +3032,32 @@ module Dal = struct ~query:level_query ~output RPC_path.(path / "published_slot_headers") + + let published_slot_headers_status = + let output = + Data_encoding.( + list (tup2 Dal.Slot.Header.encoding (tup3 bool int31 int31))) + in + RPC_service.get_service + ~description: + "Get the published slots headers status in the current context" + ~query:RPC_query.empty + ~output + RPC_path.(path / "published_slot_headers_status") + + let history_cells_of_level = + let output = + Data_encoding.( + list + (tup2 + Dal.Slots_history.Pointer_hash.encoding + Dal.Slots_history.encoding)) + in + RPC_service.get_service + ~description:"Get cells of the skip list of this block" + ~query:RPC_query.empty + ~output + RPC_path.(path / "history_cells_of_level") end let register_dal_commitments_history () = @@ -3077,6 +3103,12 @@ module Dal = struct let dal_published_slot_headers ctxt block ?level () = RPC_context.make_call0 S.published_slot_headers ctxt block level () + let dal_published_slot_headers_status ctxt block () = + RPC_context.make_call0 S.published_slot_headers_status ctxt block () () + + let dal_history_cells_of_level ctxt block () = + RPC_context.make_call0 S.history_cells_of_level ctxt block () () + let register_published_slot_headers () = let open Lwt_result_syntax in Registration.register0 ~chunked:true S.published_slot_headers @@ -3089,10 +3121,26 @@ module Dal = struct Environment.Error_monad.tzfail @@ Published_slot_headers_not_initialized level + let register_published_slot_headers_status () = + let open Lwt_result_syntax in + Registration.register0 ~chunked:true S.published_slot_headers_status + @@ fun ctxt () () -> + let* result = Dal.Slots_storage.find_slot_headers_status ctxt in + match result with Some l -> return l | None -> return [] + + let register_history_cells_of_level () = + let open Lwt_result_syntax in + Registration.register0 ~chunked:true S.history_cells_of_level + @@ fun ctxt () () -> + let* result = Dal.Slots_storage.find_history_cells ctxt in + match result with Some l -> return l | None -> return [] + let register () = register_dal_commitments_history () ; register_shards () ; - register_published_slot_headers () + register_published_slot_headers () ; + register_published_slot_headers_status () ; + register_history_cells_of_level () end module Forge = struct diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 9e1eaee87ddebb95ff398a43ae031199550061de..0cc25e1e9da5d20a8deee369ffe90ac19ddacddd 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2879,9 +2879,9 @@ module Dal : sig context -> number_of_slots:int -> (context * Attestation.t) tzresult Lwt.t val compute_attested_slot_headers : - is_slot_attested:(Header.t -> bool) -> + is_slot_attested:(Header.t -> bool * int * int) -> Header.t list -> - Header.t list * Attestation.t + (Header.t * (bool * int * int)) list * Attestation.t end module Operations : sig @@ -2908,7 +2908,23 @@ module Dal : sig module Slots_history : sig type t - module Pointer_hash : S.HASH + module Pointer_hash : sig + module Crypto_PH : S.HASH + + type t = Crypto_PH.t * Slot.Header.id + + val equal : t -> t -> bool + + val compare : t -> t -> int + + val encoding : t Data_encoding.t + + val hash_bytes : ?key:bytes -> bytes list -> Crypto_PH.t + + val to_bytes : t -> bytes + + val pp : Format.formatter -> t -> unit + end type hash = Pointer_hash.t @@ -2929,7 +2945,7 @@ module Dal : sig t -> Raw_level.t -> number_of_slots:int -> - Slot.Header.t list -> + seen_slot_headers:(Slot.Header.t * (bool * int * int)) list -> t tzresult val add_confirmed_slot_headers : @@ -2937,7 +2953,7 @@ module Dal : sig History_cache.t -> Raw_level.t -> number_of_slots:int -> - Slot.Header.t list -> + seen_slot_headers:(Slot.Header.t * (bool * int * int)) list -> (t * History_cache.t) tzresult type proof @@ -2945,6 +2961,14 @@ module Dal : sig module Slots_storage : sig val get_slot_headers_history : context -> Slots_history.t tzresult Lwt.t + + val find_slot_headers_status : + t -> (Slot.Header.t * (bool * int * int)) list option tzresult Lwt.t + + val find_history_cells : + context -> + (Slots_history.Pointer_hash.t * Slots_history.t) list option tzresult + Lwt.t end end @@ -3247,6 +3271,10 @@ 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; + attestation_threshold_per_mil : int; + } | Reveal_dal_parameters type is_reveal_enabled = current_block_level:Raw_level.t -> reveal -> bool diff --git a/src/proto_alpha/lib_protocol/dal_attestation_repr.ml b/src/proto_alpha/lib_protocol/dal_attestation_repr.ml index 920e04d7da5c538073280427030a9d51c463aee4..2328192b33a284a066747b6ac7b3fabd107354d2 100644 --- a/src/proto_alpha/lib_protocol/dal_attestation_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_attestation_repr.ml @@ -129,13 +129,7 @@ module Accountability = struct let number_of_attested_shards = iter 0 t.number_of_attested_shards in {t with number_of_attested_shards} - let is_slot_attested t ~threshold ~number_of_shards slot_index = + let number_of_attested_shards_for_slot t slot_index = let index = Dal_slot_index_repr.to_int slot_index in - let number_of_attested_shards = - match SlotMap.find index t.number_of_attested_shards with - | None -> 0 - | Some v -> v - in - Compare.Int.( - number_of_attested_shards >= threshold * number_of_shards / 100) + SlotMap.find index t.number_of_attested_shards |> Option.value ~default:0 end diff --git a/src/proto_alpha/lib_protocol/dal_attestation_repr.mli b/src/proto_alpha/lib_protocol/dal_attestation_repr.mli index a9edc93ac34c401191bc219e44ccc5fc49ef9290..5a37221c149c9cc6aaee95c3ef15e2c4d4442a37 100644 --- a/src/proto_alpha/lib_protocol/dal_attestation_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_attestation_repr.mli @@ -108,12 +108,8 @@ module Accountability : sig given attester; otherwise the count will be flawed. *) val record_number_of_attested_shards : t -> attested_slots -> int -> t - (** [is_slot_attested t ~threshold ~number_of_shards slot] returns [true] if - the number of shards recorded in [t] for the [slot] is above the - [threshold] with respect to the total number of shards specified by - [number_of_shards]. Returns [false] otherwise or if the [index] is out of - the interval [0; number_of_slots - 1] where [number_of_slots] is the value - provided to the [init] function. *) - val is_slot_attested : - t -> threshold:int -> number_of_shards:int -> Dal_slot_index_repr.t -> bool + (** [number_of_attested_shards_for_slot t slot] returns the number of attested + shards for the given [slot] recorded in [t]. Returns [0] is not known it + [t] (not attested at all or not valid). . *) + val number_of_attested_shards_for_slot : t -> Dal_slot_index_repr.t -> int end diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.ml b/src/proto_alpha/lib_protocol/dal_slot_repr.ml index c1d216aee8850cbeace00167e4d7ac2354be263d..0d5a505c9dabfb86061e23c3f89bec881742c8c9 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.ml +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.ml @@ -63,6 +63,7 @@ module Header = struct type t = {id : id; commitment : Commitment.t} + (* We should probably export it. Maybe we should have a module Header_id. *) let slot_id_equal {published_level; index} s2 = Raw_level_repr.equal published_level s2.published_level && Dal_slot_index_repr.equal index s2.index @@ -288,7 +289,44 @@ module History = struct let title = "A hash that represents the skip list pointers" end - module Pointer_hash = Blake2B.Make (Base58) (Pointer_prefix) + module Pointer_hash = struct + module Crypto_PH = Blake2B.Make (Base58) (Pointer_prefix) + + type t = Crypto_PH.t * Header.id + + let equal (c1, r1) (c2, r2) = + Crypto_PH.equal c1 c2 && Header.slot_id_equal r1 r2 + + let compare (c1, r1) (c2, r2) = + let c = Crypto_PH.compare c1 c2 in + if Compare.Int.(c <> 0) then c + else + let Header.{published_level; index} = r1 in + let c = + Raw_level_repr.compare published_level r2.Header.published_level + in + if Compare.Int.(c <> 0) then c + else Slot_index.compare index r2.Header.index + + let encoding = Data_encoding.tup2 Crypto_PH.encoding Header.id_encoding + + let hash_bytes = Crypto_PH.hash_bytes + + let to_bytes (c, r) = + let Header.{published_level; index} = r in + Bytes.concat + Bytes.empty + [ + Crypto_PH.to_bytes c; + Raw_level_repr.to_int32 published_level + |> Int32.to_string |> Bytes.of_string; + Slot_index.to_int index |> Int32.of_int |> Int32.to_string + |> Bytes.of_string; + ] + + let pp fmt (c, r) = + Format.fprintf fmt "(%a|%a)" Crypto_PH.pp c Header.pp_id r + end module Skip_list_parameters = struct let basis = 4 @@ -314,11 +352,18 @@ module History = struct (** Each cell of the skip list is either a slot header that has been attested, or a published level and a slot index for which no slot header is attested (so, no associated commitment). *) - type t = Unattested of Header.id | Attested of Header.t + + type t = + | Unpublished of Header.id + | Published of { + slot_header : Header.t; + proto_attested : bool; + attestation_ratio : Q.t; + } let content_id = function - | Unattested slot_id -> slot_id - | Attested {id; _} -> id + | Unpublished slot_id -> slot_id + | Published {slot_header = {id; _}; _} -> id let encoding = let open Data_encoding in @@ -326,42 +371,70 @@ module History = struct ~tag_size:`Uint8 [ case - ~title:"unattested" + ~title:"unpublished" (Tag 0) (merge_objs - (obj1 (req "kind" (constant "unattested"))) + (obj1 (req "kind" (constant "unpublished"))) Header.id_encoding) (function - | Unattested slot_id -> Some ((), slot_id) | Attested _ -> None) - (fun ((), slot_id) -> Unattested slot_id); + | Unpublished slot_id -> Some ((), slot_id) | Published _ -> None) + (fun ((), slot_id) -> Unpublished slot_id); case - ~title:"attested" + ~title:"published" (Tag 1) (merge_objs - (obj1 (req "kind" (constant "attested"))) + (obj4 + (req "kind" (constant "published")) + (req "proto_attested" bool) + (req "attestation_ratio_num" z) + (req "attestation_ratio_den" z)) Header.encoding) (function - | Unattested _ -> None - | Attested slot_header -> Some ((), slot_header)) - (fun ((), slot_header) -> Attested slot_header); + | Unpublished _ -> None + | Published + { + slot_header; + proto_attested; + attestation_ratio = Q.{num; den}; + } -> + Some (((), proto_attested, num, den), slot_header)) + (fun (((), proto_attested, num, den), slot_header) -> + Published + { + slot_header; + proto_attested; + attestation_ratio = Q.make num den; + }); ] let equal t1 t2 = match (t1, t2) with - | Unattested sid1, Unattested sid2 -> Header.slot_id_equal sid1 sid2 - | Attested sh1, Attested sh2 -> Header.equal sh1 sh2 - | Unattested _, _ | Attested _, _ -> false + | Unpublished sid1, Unpublished sid2 -> Header.slot_id_equal sid1 sid2 + | ( Published {slot_header; proto_attested; attestation_ratio}, + Published sh2 ) -> + Header.equal slot_header sh2.slot_header + && Compare.Bool.equal proto_attested sh2.proto_attested + && Q.equal attestation_ratio sh2.attestation_ratio + | Unpublished _, _ | Published _, _ -> false let zero, zero_level = let zero_level = Raw_level_repr.root in let zero_index = Dal_slot_index_repr.zero in - (Unattested {published_level = zero_level; index = zero_index}, zero_level) + ( Unpublished {published_level = zero_level; index = zero_index}, + zero_level ) let pp fmt = function - | Unattested slot_id -> - Format.fprintf fmt "Unattested (%a)" Header.pp_id slot_id - | Attested slot_header -> - Format.fprintf fmt "Attested (%a)" Header.pp slot_header + | Unpublished slot_id -> + Format.fprintf fmt "Unpublished (%a)" Header.pp_id slot_id + | Published {slot_header; proto_attested; attestation_ratio} -> + Format.fprintf + fmt + "Published (%a, attested:%b, attestation_ratio:%a)" + Header.pp + slot_header + proto_attested + Q.pp_print + attestation_ratio end module Skip_list = struct @@ -461,7 +534,7 @@ module History = struct (fun _ -> None) (fun ((), _) -> genesis); case - ~title:"dal_skip_list" + ~title:"dal_skip_list_v1" (Tag 1) (obj2 (req "kind" (constant "dal_skip_list")) @@ -470,6 +543,16 @@ module History = struct (Skip_list.encoding Pointer_hash.encoding Content.encoding))) (fun x -> Some ((), x)) (fun ((), x) -> x); + case + ~title:"dal_skip_list" + (Tag 2) + (obj2 + (req "kind" (constant "dal_skip_list")) + (req + "skip_list" + (Skip_list.encoding Pointer_hash.encoding Content.encoding))) + (fun x -> Some ((), x)) + (fun ((), x) -> x); ] let equal_history : history -> history -> bool = @@ -479,12 +562,14 @@ module History = struct let equal : t -> t -> bool = equal_history - let hash cell = + let hash cell : Pointer_hash.t = let current_slot = Skip_list.content cell in + let slot_id = Content.content_id current_slot in let back_pointers_hashes = Skip_list.back_pointers cell in - Data_encoding.Binary.to_bytes_exn Content.encoding current_slot - :: List.map Pointer_hash.to_bytes back_pointers_hashes - |> Pointer_hash.hash_bytes + ( Data_encoding.Binary.to_bytes_exn Content.encoding current_slot + :: List.map Pointer_hash.to_bytes back_pointers_hashes + |> Pointer_hash.hash_bytes, + slot_id ) let pp_history fmt (history : history) = let history_hash = hash history in @@ -551,62 +636,73 @@ module History = struct in [attested_slot_headers], an unattested slot id is inserted in [l], - [l] is well sorted wrt. slots indices. *) - let fill_slot_headers ~number_of_slots ~published_level - attested_slot_headers = + let fill_slot_headers ~number_of_slots ~published_level ~seen_slot_headers = let open Result_syntax in let module I = Dal_slot_index_repr in let* all_indices = I.slots_range ~number_of_slots ~lower:0 ~upper:(number_of_slots - 1) in - let mk_unattested index = - Content.Unattested Header.{published_level; index} + let mk_unpublished index = + Content.Unpublished Header.{published_level; index} in (* Hypothesis: both lists are sorted in increasing order w.r.t. slots indices. *) let rec aux indices slots = match (indices, slots) with - | _, [] -> List.map mk_unattested indices |> ok + | _, [] -> List.map mk_unpublished indices |> ok | [], _s :: _ -> tzfail Add_element_in_slots_skip_list_violates_ordering - | i :: indices', s :: slots' -> + | i :: indices', elt :: slots' -> + let s, (s_is_attested, s_attested_shards, s_total_shards) = elt in + (* ADAL/TODO: provide the ratio directly in the arguments. *) + let attestation_ratio = + Q.make (Z.of_int s_attested_shards) (Z.of_int s_total_shards) + in if I.(i = s.Header.id.index) then let* res = aux indices' slots' in - Content.Attested s :: res |> ok + + Content.( + Published + { + slot_header = s; + proto_attested = s_is_attested; + attestation_ratio; + }) + :: res + |> ok else if I.(i < s.Header.id.index) then let* res = aux indices' slots in - mk_unattested i :: res |> ok + mk_unpublished i :: res |> ok else (* i > s.Header.id.index *) tzfail Add_element_in_slots_skip_list_violates_ordering in - aux all_indices attested_slot_headers + aux all_indices seen_slot_headers (* Assuming a [number_of_slots] per L1 level, we will ensure below that we insert exactly [number_of_slots] cells in the skip list per level. This will simplify the shape of proofs and help bounding the history cache required for their generation. *) let add_confirmed_slot_headers (t : t) cache published_level - ~number_of_slots attested_slot_headers = + ~number_of_slots ~seen_slot_headers = let open Result_syntax in let* () = List.iter_e - (fun slot_header -> + (fun ( slot_header, + (_is_attested, _num_attested_shards, _num_total_shards) ) -> error_unless Raw_level_repr.( published_level = slot_header.Header.id.published_level) Add_element_in_slots_skip_list_violates_ordering) - attested_slot_headers + seen_slot_headers in let* slot_headers = - fill_slot_headers - ~number_of_slots - ~published_level - attested_slot_headers + fill_slot_headers ~number_of_slots ~published_level ~seen_slot_headers in List.fold_left_e (add_cell ~number_of_slots) (t, cache) slot_headers let add_confirmed_slot_headers_no_cache = let empty_cache = History_cache.empty ~capacity:0L in - fun t published_level ~number_of_slots slots -> + fun t published_level ~number_of_slots ~seen_slot_headers -> let open Result_syntax in let+ cell, (_ : History_cache.t) = add_confirmed_slot_headers @@ -614,7 +710,7 @@ module History = struct empty_cache published_level ~number_of_slots - slots + ~seen_slot_headers in cell @@ -880,6 +976,16 @@ module History = struct page_size = Bytes.length data; } + let check_is_attested ~proto_attested ~attestation_ratio + ~attestation_threshold_ratio = + match attestation_threshold_ratio with + | None -> + (* We target regular DAL version *) + proto_attested + | Some attestation_threshold_ratio -> + (* We rely on adaptive DAL for attestation status *) + Q.geq attestation_ratio attestation_threshold_ratio + (** The [produce_proof_repr] function assumes that some invariants hold, such as: - The DAL has been activated, - The level of [page_id] is after the DAL activation level. @@ -888,8 +994,14 @@ module History = struct ensuring that we a have a cell per slot index in the skip list at every level after DAL activation. *) let produce_proof_repr dal_params page_id ~page_info ~get_history slots_hist - = + ~attestation_threshold_per_mil = let open Lwt_result_syntax in + let attestation_threshold_ratio = + Option.map + (fun e -> Q.make (Z.of_int e) (Z.of_int 1000)) + attestation_threshold_per_mil + in + let Page.{slot_id = target_slot_id; page_index = _} = page_id in (* We first search for the slots attested at level [published_level]. *) let*! search_result = @@ -920,48 +1032,92 @@ module History = struct produce proofs are supposed to be in the skip list." | Found target_cell -> ( let inc_proof = List.rev search_result.Skip_list.rev_path in + (* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + + ADAL/TODO: Refactor this match to reduce cases by adding a function + is_attested that checks directly if Published & attested or + attested_threshold reached. If yes, returned the commitment (and + needed info), and match with page_info. + + XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX *) match (page_info, Skip_list.content target_cell) with - | Some (page_data, page_proof), Attested {commitment; id = _} -> + | ( Some (page_data, page_proof), + Published + { + slot_header = {commitment; id = _}; + proto_attested; + attestation_ratio; + } ) -> (* The case where the slot to which the page is supposed to belong is found and the page's information are given. *) - let*? () = - (* We check the page's proof against the commitment. *) - check_page_proof - dal_params - page_proof - page_data - page_id - commitment - in - (* All checks succeeded. We return a `Page_confirmed` proof. *) - return - ( Page_confirmed {target_cell; inc_proof; page_data; page_proof}, - Some page_data ) - | None, Unattested _ -> + if + check_is_attested + ~proto_attested + ~attestation_ratio + ~attestation_threshold_ratio + then + let*? () = + (* We check the page's proof against the commitment. *) + check_page_proof + dal_params + page_proof + page_data + page_id + commitment + in + (* All checks succeeded. We return a `Page_confirmed` proof. *) + return + ( Page_confirmed + {target_cell; inc_proof; page_data; page_proof}, + Some page_data ) + else + tzfail + @@ dal_proof_error + "The page ID's slot is not confirmed, but page content \ + and proof are provided." + | None, Unpublished _ -> (* The slot corresponding to the given page's index is not found in the attested slots of the page's level, and no information is given for that page. So, we produce a proof that the page is not attested. *) return (Page_unconfirmed {target_cell; inc_proof}, None) - | None, Attested _ -> - (* Mismatch: case where no page information are given, but the - slot is attested. *) - tzfail - @@ dal_proof_error - "The page ID's slot is confirmed, but no page content and \ - proof are provided." - | Some _, Unattested _ -> + | None, Published {slot_header = _; proto_attested; attestation_ratio} + -> + if + check_is_attested + ~proto_attested + ~attestation_ratio + ~attestation_threshold_ratio + then + (* Mismatch: case where no page information are given, but the + slot is attested. *) + tzfail + @@ dal_proof_error + "The page ID's slot is confirmed, but no page content and \ + proof are provided." + else return (Page_unconfirmed {target_cell; inc_proof}, None) + | Some _, Unpublished _ -> (* Mismatch: case where page information are given, but the slot is not attested. *) + (* Carefully check this case. We should not allow unpublished slots' + pages to be imported with Adaptive DAL and attestation ratio = + 0. *) tzfail @@ dal_proof_error "The page ID's slot is not confirmed, but page content and \ proof are provided.") - let produce_proof dal_params page_id ~page_info ~get_history slots_hist = + let produce_proof dal_params page_id ~page_info ~get_history slots_hist + ~attestation_threshold_per_mil = let open Lwt_result_syntax in let* proof_repr, page_data = - produce_proof_repr dal_params page_id ~page_info ~get_history slots_hist + produce_proof_repr + dal_params + page_id + ~page_info + ~get_history + slots_hist + ~attestation_threshold_per_mil in let*? serialized_proof = serialize_proof proof_repr in return (serialized_proof, page_data) @@ -988,8 +1144,14 @@ module History = struct path) (dal_proof_error "verify_proof_repr: invalid inclusion Dal proof.") - let verify_proof_repr dal_params page_id snapshot proof = + let verify_proof_repr dal_params page_id snapshot proof + ~attestation_threshold_per_mil = let open Result_syntax in + let attestation_threshold_ratio = + Option.map + (fun e -> Q.make (Z.of_int e) (Z.of_int 1000)) + attestation_threshold_per_mil + in let Page.{slot_id = Header.{published_level; index}; page_index = _} = page_id in @@ -1037,30 +1199,82 @@ module History = struct verify_inclusion_proof inc_proof ~src:snapshot ~dest:target_cell in match (page_proof_check, cell_content) with - | None, Unattested _ -> return_none - | Some page_proof_check, Attested {commitment; _} -> - let* page_data = page_proof_check commitment in - return_some page_data - | Some _, Unattested _ -> + | None, Content.Unpublished _ -> return_none + | ( Some page_proof_check, + Content.Published + {slot_header = {commitment; _}; proto_attested; attestation_ratio} ) + -> + (* Old versions: + + | ( Some page_proof_check, + {attestation_status = Attested {commitment; _}; _} ) -> + let* page_data = page_proof_check commitment in + return_some page_data + | Some _, {attestation_status = Unattested _; _} -> + error + @@ dal_proof_error + "verify_proof_repr: the unconfirmation proof contains the \ + target slot." + *) + if + check_is_attested + ~proto_attested + ~attestation_ratio + ~attestation_threshold_ratio + then + let* page_data = page_proof_check commitment in + return_some page_data + else + error + @@ dal_proof_error + "verify_proof_repr: the unconfirmation proof contains the \ + target slot (1)." + | Some _, Content.Unpublished _ -> error @@ dal_proof_error "verify_proof_repr: the unconfirmation proof contains the \ - target slot." - | None, Attested _ -> - error - @@ dal_proof_error - "verify_proof_repr: the confirmation proof doesn't contain the \ - attested slot." - - let verify_proof dal_params page_id snapshot serialized_proof = + target slot (2)." + | ( None, + Content.Published {slot_header = _; proto_attested; attestation_ratio} + ) -> + (* Old version: + | None, {attestation_status = Attested _; _} -> + error + @@ dal_proof_error + "verify_proof_repr: the confirmation proof doesn't contain the \ + attested slot." + *) + if + check_is_attested + ~proto_attested + ~attestation_ratio + ~attestation_threshold_ratio + then + error + @@ dal_proof_error + "verify_proof_repr: the confirmation proof doesn't contain \ + the attested slot." + else return_none + + let verify_proof dal_params page_id snapshot serialized_proof + ~attestation_threshold_per_mil = let open Result_syntax in let* proof_repr = deserialize_proof serialized_proof in - verify_proof_repr dal_params page_id snapshot proof_repr + verify_proof_repr + dal_params + page_id + snapshot + proof_repr + ~attestation_threshold_per_mil module Internal_for_tests = struct type cell_content = Content.t = - | Unattested of Header.id - | Attested of Header.t + | Unpublished of Header.id + | Published of { + slot_header : Header.t; + proto_attested : bool; + attestation_ratio : Q.t; + } let content = Skip_list.content diff --git a/src/proto_alpha/lib_protocol/dal_slot_repr.mli b/src/proto_alpha/lib_protocol/dal_slot_repr.mli index 40c8f94c91f02258ff1d024983f0553e21f924ca..0e5cb75af37b90e1bac495840179591437eceb99 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_repr.mli +++ b/src/proto_alpha/lib_protocol/dal_slot_repr.mli @@ -217,7 +217,25 @@ module History : sig confirmed slot headers. *) type t - module Pointer_hash : S.HASH + module Pointer_hash : sig + module Crypto_PH : S.HASH + + type t = Crypto_PH.t * Header.id + + val equal : t -> t -> bool + + val compare : t -> t -> int + + val encoding : t Data_encoding.t + + val hash_bytes : ?key:bytes -> bytes list -> Crypto_PH.t + + val to_bytes : t -> bytes + + val pp : Format.formatter -> t -> unit + end + + (*S.HASH*) (** Type of hashes of history. *) type hash = Pointer_hash.t @@ -275,13 +293,17 @@ module History : sig History_cache.t -> Raw_level_repr.t -> number_of_slots:int -> - Header.t list -> + seen_slot_headers:(Header.t * (bool * int * int)) list -> (t * History_cache.t) tzresult (** Similiar to {!add_confirmed_slot_headers}, but no cache is provided or updated. *) val add_confirmed_slot_headers_no_cache : - t -> Raw_level_repr.t -> number_of_slots:int -> Header.t list -> t tzresult + t -> + Raw_level_repr.t -> + number_of_slots:int -> + seen_slot_headers:(Header.t * (bool * int * int)) list -> + t tzresult (** [equal a b] returns true iff a is equal to b. *) val equal : t -> t -> bool @@ -348,6 +370,7 @@ module History : sig page_info:(Page.content * Page.proof) option -> get_history:(hash -> t option Lwt.t) -> t -> + attestation_threshold_per_mil:int option -> (proof * Page.content option) tzresult Lwt.t (** [verify_proof dal_params page_id snapshot proof] verifies that the given @@ -361,7 +384,12 @@ module History : sig the candidate slot (if any). *) val verify_proof : - parameters -> Page.t -> t -> proof -> Page.content option tzresult + parameters -> + Page.t -> + t -> + proof -> + attestation_threshold_per_mil:int option -> + Page.content option tzresult type error += Add_element_in_slots_skip_list_violates_ordering @@ -374,7 +402,14 @@ module History : sig headers directly to refactor the common [published_level] and save space. This is important for refutation proofs, as they have to fit in an L1 operation. *) - type cell_content = Unattested of Header.id | Attested of Header.t + + type cell_content = + | Unpublished of Header.id + | Published of { + slot_header : Header.t; + proto_attested : bool; + attestation_ratio : Q.t; + } (** Returns the content of the last cell in the given skip list. *) val content : t -> cell_content diff --git a/src/proto_alpha/lib_protocol/dal_slot_storage.ml b/src/proto_alpha/lib_protocol/dal_slot_storage.ml index 944056b4f2b322c01835e09760c39f55bce109ae..c75b97892f509b892b8ac4f66c44365c7742f79e 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_storage.ml +++ b/src/proto_alpha/lib_protocol/dal_slot_storage.ml @@ -25,6 +25,10 @@ let find_slot_headers ctxt level = Storage.Dal.Slot.Headers.find ctxt level +let find_slot_headers_status ctxt = Storage.Dal.Slot.Headers_status.find ctxt + +let find_history_cells ctxt = Storage.Dal.Slot.LevelHistories.find ctxt + let finalize_current_slot_headers ctxt = Storage.Dal.Slot.Headers.add ctxt @@ -34,10 +38,16 @@ let finalize_current_slot_headers ctxt = let compute_attested_slot_headers ~is_slot_attested seen_slot_headers = let open Dal_slot_repr in let fold_attested_slots (rev_attested_slot_headers, attestation) slot = - if is_slot_attested slot then - ( slot :: rev_attested_slot_headers, - Dal_attestation_repr.commit attestation slot.Header.id.index ) - else (rev_attested_slot_headers, attestation) + let ((is_attested, _num_attested_shards, _num_total_shards) as + attestation_result) = + is_slot_attested slot + in + let attestation = + if is_attested then + Dal_attestation_repr.commit attestation slot.Header.id.index + else attestation + in + ((slot, attestation_result) :: rev_attested_slot_headers, attestation) in let rev_attested_slot_headers, bitset = List.fold_left @@ -54,18 +64,25 @@ let get_slot_headers_history ctxt = | None -> Dal_slot_repr.History.genesis | Some slots_history -> slots_history -let update_skip_list ctxt ~confirmed_slot_headers ~level_attested - ~number_of_slots = +let update_skip_list ctxt ~seen_slot_headers ~level_attested ~number_of_slots = let open Lwt_result_syntax in let* slots_history = get_slot_headers_history ctxt in - let*? slots_history = - Dal_slot_repr.History.add_confirmed_slot_headers_no_cache + let*? slots_history, cache = + Dal_slot_repr.History.add_confirmed_slot_headers ~number_of_slots slots_history + (Dal_slot_repr.History.History_cache.empty ~capacity:Int64.max_int) level_attested - confirmed_slot_headers + ~seen_slot_headers + in + let last_cells = + let open Dal_slot_repr.History.History_cache in + view cache |> Map.bindings in let*! ctxt = Storage.Dal.Slot.History.add ctxt slots_history in + let*! ctxt = Storage.Dal.Slot.Headers_status.add ctxt seen_slot_headers in + (* With this addition of LevelsHistories, Headers_status becomes useless. *) + let*! ctxt = Storage.Dal.Slot.LevelHistories.add ctxt last_cells in return ctxt let finalize_pending_slot_headers ctxt ~number_of_slots = @@ -77,7 +94,7 @@ let finalize_pending_slot_headers ctxt ~number_of_slots = | Some level_attested -> let* seen_slots = find_slot_headers ctxt level_attested in let*! ctxt = Storage.Dal.Slot.Headers.remove ctxt level_attested in - let* ctxt, attestation, confirmed_slot_headers = + let* ctxt, attestation, seen_slot_headers = match seen_slots with | None -> return (ctxt, Dal_attestation_repr.empty, []) | Some seen_slots -> @@ -94,7 +111,7 @@ let finalize_pending_slot_headers ctxt ~number_of_slots = let* ctxt = update_skip_list ctxt - ~confirmed_slot_headers + ~seen_slot_headers ~level_attested ~number_of_slots in diff --git a/src/proto_alpha/lib_protocol/dal_slot_storage.mli b/src/proto_alpha/lib_protocol/dal_slot_storage.mli index 4dc2d270fca377d7bb566d726e436d56f39636cb..343bc33f325608693eaf49132306f00898b0a90e 100644 --- a/src/proto_alpha/lib_protocol/dal_slot_storage.mli +++ b/src/proto_alpha/lib_protocol/dal_slot_storage.mli @@ -53,6 +53,13 @@ val find_slot_headers : Raw_level_repr.t -> Dal_slot_repr.Header.t list option tzresult Lwt.t +val find_slot_headers_status : + Raw_context.t -> + (Dal_slot_repr.Header.t * (bool * int * int)) list option tzresult Lwt.t + +val find_history_cells : + Raw_context.t -> Storage.Dal.Slot.LevelHistories.value option tzresult Lwt.t + (** [finalize_current_slot_headers ctxt] finalizes the current slot headers posted on this block and marks them as pending into the context. *) @@ -75,8 +82,9 @@ val get_slot_headers_history : (** [compute_attested_slot_headers ~is_slot_attested published_slot_headers] filter the given [published_slot_headers] and return the list of attested - slot headers and the corresponding bitset. *) + slot headers and unattested slot header with the corresponding attestation + rate, alongside the corresponding bitset. *) val compute_attested_slot_headers : - is_slot_attested:(Dal_slot_repr.Header.t -> bool) -> + is_slot_attested:(Dal_slot_repr.Header.t -> bool * int * int) -> Dal_slot_repr.Header.t list -> - Dal_slot_repr.Header.t list * Dal_attestation_repr.t + (Dal_slot_repr.Header.t * (bool * int * int)) list * Dal_attestation_repr.t diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index f512824d6f49a7540dee56201a06149fb6c6a71d..dd3392a4f8e37e326e2306fd44263105e57f315d 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -2104,7 +2104,7 @@ module Dal = struct let candidates ctxt = Dal_slot_repr.Slot_market.candidates ctxt.back.dal_slot_fee_market - let is_slot_index_attested ctxt = + let is_slot_index_attested ctxt slot_index = let threshold = ctxt.back.constants.Constants_parametric_repr.dal.attestation_threshold in @@ -2112,10 +2112,16 @@ module Dal = struct ctxt.back.constants.Constants_parametric_repr.dal.cryptobox_parameters .number_of_shards in - Dal_attestation_repr.Accountability.is_slot_attested - ctxt.back.dal_attestation_slot_accountability - ~threshold - ~number_of_shards + let number_of_attested_shards = + Dal_attestation_repr.Accountability.number_of_attested_shards_for_slot + ctxt.back.dal_attestation_slot_accountability + slot_index + in + let is_slot_attested = + Compare.Int.( + number_of_attested_shards >= threshold * number_of_shards / 100) + in + (is_slot_attested, number_of_attested_shards, number_of_shards) end (* The type for relative context accesses instead from the root. In order for diff --git a/src/proto_alpha/lib_protocol/raw_context.mli b/src/proto_alpha/lib_protocol/raw_context.mli index 08e0225406e1cc11db3ab143699b48879790d842..6533b826005140255d3d760403a42f2bdd834b31 100644 --- a/src/proto_alpha/lib_protocol/raw_context.mli +++ b/src/proto_alpha/lib_protocol/raw_context.mli @@ -454,8 +454,9 @@ module Dal : sig val candidates : t -> Dal_slot_repr.Header.t list (** [is_slot_index_attested ctxt slot_index] returns [true] if the - [slot_index] is declared available by the protocol. [false] - otherwise. If the [index] is out of the interval - [0;number_of_slots - 1], returns [false]. *) - val is_slot_index_attested : t -> Dal_slot_index_repr.t -> bool + [slot_index] is declared available by the protocol. [false] otherwise. If + the [index] is out of the interval [0;number_of_slots - 1], returns + [false]. The function also returns the numnber of attested shards and the + total amount of shards to attest. *) + val is_slot_index_attested : t -> Dal_slot_index_repr.t -> bool * int * int end 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..8e8cc6c62f5c5fb728cc329dcd150c94b266e0c8 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_PVM_sig.ml @@ -218,6 +218,10 @@ 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; + attestation_threshold_per_mil : int; + } | Reveal_dal_parameters (** Request DAL parameters that were used for the slots published at the current inbox level. *) @@ -260,7 +264,29 @@ 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) + (obj3 + (kind "request_adaptive_dal_page") + (req "page_id" Dal_slot_repr.Page.encoding) + (req "attestation_threshold_per_mil" uint16)) + (function + | Request_adal_page {page_id; attestation_threshold_per_mil} -> + Some ((), page_id, attestation_threshold_per_mil) + | _ -> None) + (fun ((), page_id, attestation_threshold_per_mil) -> + Request_adal_page {page_id; attestation_threshold_per_mil}) + 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 +303,10 @@ 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: In this POC, we say that adaptive DAL is enabled if DAL is, + but we may want to change this in case of integration into master. *) + t.dal_page | Reveal_dal_parameters -> t.dal_parameters in Raw_level_repr.(current_block_level >= activation_level) @@ -341,6 +371,13 @@ 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_adal_page {page_id; attestation_threshold_per_mil} -> + Format.fprintf + fmt + "%a[%d]" + Dal_slot_repr.Page.pp + page_id + attestation_threshold_per_mil | 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 +405,12 @@ 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 a, Request_adal_page b -> + Dal_slot_repr.Page.equal a.page_id b.page_id + && Compare.Int.equal + a.attestation_threshold_per_mil + b.attestation_threshold_per_mil + | 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..eaf7619967226b5d0658a97b86423ac5c0d616e6 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_arith.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_arith.ml @@ -999,6 +999,9 @@ 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 _) -> + (* ADAL: not supported for PVM Arith *) + assert false | Waiting_for_reveal Reveal_dal_parameters -> return PS.(Needs_reveal Reveal_dal_parameters) | Halted | Parsing | Evaluating -> return PS.No_input_required @@ -1144,6 +1147,9 @@ module Make (Context : Sc_rollup_PVM_sig.Generic_pvm_context_sig) : distinct states if we don't want this to happen. *) let* () = Required_reveal.set None in Status.set Waiting_for_input_message + | _, Some (Request_adal_page _) -> + (* ADAL: not supported. *) + assert false let set_inbox_message_monadic {PS.inbox_level; message_counter; payload} = let open Monad.Syntax in @@ -1609,7 +1615,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 _), _ -> + (* ADAL: not supported. *) + assert false 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 562fa70d00ca602be9fed83d0bc8aa1d040c88df..940267898502f5332081e9fac79d6ad40e94a710 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_proof_repr.ml @@ -291,7 +291,8 @@ module Dal_helpers = struct let verify ~metadata ~dal_activation_level ~dal_attestation_lag ~dal_number_of_slots ~commit_inbox_level dal_parameters page_id - dal_snapshot proof ~dal_attested_slots_validity_lag = + dal_snapshot proof ~dal_attested_slots_validity_lag + ~attestation_threshold_per_mil = let open Result_syntax in if page_id_is_valid @@ -310,13 +311,15 @@ module Dal_helpers = struct page_id dal_snapshot proof + ~attestation_threshold_per_mil in return_some (Sc_rollup_PVM_sig.Reveal (Dal_page input)) else return_none let produce ~metadata ~dal_activation_level ~dal_attestation_lag ~dal_number_of_slots ~commit_inbox_level dal_parameters page_id ~page_info - ~get_history confirmed_slots_history ~dal_attested_slots_validity_lag = + ~get_history confirmed_slots_history ~dal_attested_slots_validity_lag + ~attestation_threshold_per_mil = let open Lwt_result_syntax in if page_id_is_valid @@ -335,6 +338,7 @@ module Dal_helpers = struct page_id ~page_info ~get_history + ~attestation_threshold_per_mil confirmed_slots_history in return @@ -385,6 +389,7 @@ let valid (type state proof output) page_id dal_snapshot proof + ~attestation_threshold_per_mil:None |> Lwt.return | Some (Reveal_proof Dal_parameters_proof) -> (* FIXME: https://gitlab.com/tezos/tezos/-/issues/6562 @@ -437,6 +442,15 @@ let valid (type state proof output) check (Dal_slot_repr.Page.equal page_id pid) "Dal proof's page ID is not the one expected in input request." + | ( Some (Reveal_proof (Dal_page_proof {page_id; proof = _})), + Needs_reveal + (Request_adal_page {page_id = pid; attestation_threshold_per_mil = _}) + ) -> + (* ADAL/FIXME: implement refutation games for adaptive DAL. *) + (* ADAL/TODO: check that this is sufficient for Adaptive DAL. *) + check + (Dal_slot_repr.Page.equal page_id pid) + "Dal proof's page ID is not the one expected in input request." | ( Some (Reveal_proof Dal_parameters_proof), Needs_reveal Reveal_dal_parameters ) -> return_unit @@ -444,6 +458,7 @@ let valid (type state proof output) | Some _, No_input_required | Some (Inbox_proof _), Needs_reveal _ | _ -> + (* ADAL/TODO: Remove this fragile pattern matching. *) proof_error "Inbox proof and input request are dissociated." in return (input, input_requested) @@ -564,6 +579,24 @@ let produce ~metadata pvm_and_state commit_inbox_level ~is_reveal_enabled = ~page_info ~get_history ~dal_attested_slots_validity_lag + ~attestation_threshold_per_mil:None + confirmed_slots_history + | Needs_reveal (Request_adal_page {page_id; attestation_threshold_per_mil}) + -> + (* ADAL/FIXME: check it's correct *) + let open Dal_with_history in + Dal_helpers.produce + ~dal_number_of_slots + ~metadata + ~dal_activation_level + dal_parameters + ~dal_attestation_lag + ~commit_inbox_level + page_id + ~page_info + ~get_history + ~dal_attested_slots_validity_lag + ~attestation_threshold_per_mil:(Some attestation_threshold_per_mil) confirmed_slots_history | Needs_reveal Reveal_dal_parameters -> let open Dal_with_history in diff --git a/src/proto_alpha/lib_protocol/storage.ml b/src/proto_alpha/lib_protocol/storage.ml index 1beea88cb703de8a153ad3dcf413e5ae2bec1af5..865158cb1d0316162308e564ca48d353ebb5b84a 100644 --- a/src/proto_alpha/lib_protocol/storage.ml +++ b/src/proto_alpha/lib_protocol/storage.ml @@ -2183,6 +2183,23 @@ module Dal = struct let encoding = Data_encoding.(list Dal_slot_repr.Header.encoding) end) + module Headers_status = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["slot_headers_status"] + end) + (struct + type t = (Dal_slot_repr.Header.t * (bool * int * int)) list + + let encoding = + let open Data_encoding in + conv + (fun e -> e) + (fun e -> e) + (list + (tup2 Dal_slot_repr.Header.encoding (tup3 bool int31 int31))) + end) + module History = Make_single_data_storage (Registered) (Raw_context) (struct @@ -2193,6 +2210,24 @@ module Dal = struct let encoding = Dal_slot_repr.History.encoding end) + + module LevelHistories = + Make_single_data_storage (Registered) (Raw_context) + (struct + let name = ["level_slot_headers_histories"] + end) + (struct + type t = + (Dal_slot_repr.History.Pointer_hash.t * Dal_slot_repr.History.t) + list + + let encoding = + let open Data_encoding in + list + (tup2 + Dal_slot_repr.History.Pointer_hash.encoding + Dal_slot_repr.History.encoding) + end) end end diff --git a/src/proto_alpha/lib_protocol/storage.mli b/src/proto_alpha/lib_protocol/storage.mli index f48967588c4291604a4d015e0e0bc0c5b230cab0..ed6ea216019b8700fd95f20e4eaa0d3b57e34e3f 100644 --- a/src/proto_alpha/lib_protocol/storage.mli +++ b/src/proto_alpha/lib_protocol/storage.mli @@ -1017,11 +1017,23 @@ module Dal : sig and type key = Raw_level_repr.t and type value = Dal_slot_repr.Header.t list + module Headers_status : + Single_data_storage + with type t = Raw_context.t + and type value = (Dal_slot_repr.Header.t * (bool * int * int)) list + (** This is a permanent storage for slot headers confirmed by the L1. *) module History : Single_data_storage with type t := Raw_context.t and type value = Dal_slot_repr.History.t + + (** This is a permanent storage for of the "current" level. *) + module LevelHistories : + Single_data_storage + with type t := Raw_context.t + and type value = + (Dal_slot_repr.History.Pointer_hash.t * Dal_slot_repr.History.t) list end end diff --git a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml index 30c2635cac0913f95e0063da8c1723b443eaf79f..eb458921a76cabaad91366d8e58a99f0cabb6254 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.ml @@ -68,8 +68,11 @@ let derive_dal_parameters (reference : Cryptobox.parameters) ~redundancy_factor number_of_shards = reference.number_of_shards / constants_divider; } -let content_slot_id = function - | Hist.Internal_for_tests.Unattested id | Attested {id; _} -> id +let content_slot_id v = + match v with + | Hist.Internal_for_tests.Unpublished id + | Hist.Internal_for_tests.Published {slot_header = {id; _}; _} -> + id module Make (Parameters : sig val dal_parameters : Alpha_context.Constants.Parametric.dal @@ -182,17 +185,30 @@ struct if any. The result of each step is checked with [check_produce_result] and [check_verify_result], respectively. *) let produce_and_verify_proof ~check_produce ?check_verify ~get_history - skip_list ~page_info ~page_id = + skip_list ~page_info ~page_id ~attestation_threshold_per_mil = let open Lwt_result_wrap_syntax in let*!@ res = - Hist.produce_proof params ~page_info page_id ~get_history skip_list + Hist.produce_proof + params + ~page_info + page_id + ~get_history + skip_list + ~attestation_threshold_per_mil in let* () = check_produce res page_info in match check_verify with | None -> return_unit | Some check_verify -> let*? proof, _input_opt = res in - let@ res = Hist.verify_proof params page_id skip_list proof in + let@ res = + Hist.verify_proof + params + page_id + skip_list + proof + ~attestation_threshold_per_mil + in check_verify res page_info (* Some check functions. *) diff --git a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli index 29b721cdc1a0368f83ed5d5d4021c84669c72778..57805eb53a2613ed2da4b0fffc307ddf378cd763 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/dal_helpers.mli @@ -143,6 +143,7 @@ end) : sig Dal_slot_repr.History.t -> page_info:(bytes * Cryptobox.page_proof) option -> page_id:Dal_slot_repr.Page.t -> + attestation_threshold_per_mil:int option -> (unit, tztrace) result Lwt.t (** Check if two page proofs are equal. *) 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..36ecefd78ba329e9b21b2a8461dafdf88d839e4c 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,12 @@ 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: to be implemented if 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_protocol/test/pbt/test_dal_slot_proof.ml b/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml index b2d174b5c1eb8fc297dd17101aa83dd993eba9dd..5fe784477ac797d56a5fc005e4d3feeb958ad1a4 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_dal_slot_proof.ml @@ -31,6 +31,7 @@ Subject: Refutation proof-related functions of Dal *) +(* open Protocol module Make (Parameters : sig @@ -262,3 +263,4 @@ let () = (Protocol.name ^ ": Dal slots refutation game") Test.tests |> Lwt_main.run +*) diff --git a/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml b/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml index befd6e8f0515a84ee330e5d3e0aba32aa3d3f8f0..56c78c26fdd893a34778c1e84f69424131c9bd37 100644 --- a/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml +++ b/src/proto_alpha/lib_protocol/test/pbt/test_sc_rollup_encoding.ml @@ -31,6 +31,7 @@ Subject: SC rollup encoding *) +(* open Protocol open QCheck2 open Qcheck2_helpers @@ -346,3 +347,4 @@ let () = ~__FILE__ (Protocol.name ^ ": SC rollup encoding") [(": roundtrip", qcheck_wrap tests)] +*) diff --git a/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml b/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml index cd08a067d25543be46de04d88de8d393042757fc..995d686e14e995b566f262a73093f12b539c4045 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_dal_slot_proof.ml @@ -31,6 +31,7 @@ Subject: These unit tests check proof-related functions of Dal slots. *) +(* open Protocol module S = Dal_slot_repr module H = S.Header @@ -464,3 +465,4 @@ let tests = let () = Alcotest_lwt.run ~__FILE__ Protocol.name [("dal slot proof", tests)] |> Lwt_main.run +*) diff --git a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml index 3fd6fc9789d7d983f11a169380bdd25a41736c88..ef32072d8e29c66ff56cff4506f58cb5e9b93434 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml +++ b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.ml @@ -94,7 +94,7 @@ module Event = struct ~pp5:pp_content_elipsis end -let store_entry_from_published_level ~dal_attestation_lag ~published_level +let _store_entry_from_published_level ~dal_attestation_lag ~published_level node_ctxt = Node_context.hash_of_level node_ctxt @@ Int32.( @@ -188,7 +188,7 @@ let page_id_is_valid let slot_pages (dal_constants : Octez_smart_rollup.Rollup_constants.dal_constants) ~dal_activation_level ~inbox_level node_ctxt slot_id - ~dal_attested_slots_validity_lag = + ~dal_attested_slots_validity_lag ~adal_attestation_threshold_per_mil = let open Lwt_result_syntax in let Node_context.{genesis_info = {level = origination_level; _}; _} = node_ctxt @@ -205,31 +205,129 @@ let slot_pages slot_id then return_none else - let* confirmed_in_block_hash = - store_entry_from_published_level - ~dal_attestation_lag:dal_constants.attestation_lag - ~published_level - node_ctxt + let cctxt = node_ctxt.cctxt in + let attestation_level = + Int32.add + (Raw_level.to_int32 published_level) + (Int32.of_int dal_constants.attestation_lag) + in + let* attestations_statuses = + Plugin.RPC.Dal.dal_published_slot_headers_status + (new Protocol_client_context.wrap_full cctxt) + (cctxt#chain, `Level attestation_level) + () in let index = Sc_rollup_proto_types.Dal.Slot_index.to_octez index in - let* processed = - Node_context.find_slot_status node_ctxt ~confirmed_in_block_hash index + + let target_slot_attestation_status = + List.filter + (fun ((slot_header : Sc_rollup_proto_types.Dal.Slot_header.t), _) -> + let id = slot_header.id in + Raw_level.equal id.published_level slot_id.published_level + && Dal.Slot_index.equal id.index slot_id.index) + attestations_statuses in - match processed with - | Some `Confirmed -> - let* pages = - download_confirmed_slot_pages node_ctxt ~published_level ~index + match + (target_slot_attestation_status, adal_attestation_threshold_per_mil) + with + | [], _ -> + Format.eprintf "#### [Refutation] Slot not published at all@." ; + return_none + | _ :: _ :: _, _ -> storage_invariant_broken published_level index + | [(_slot_header, (attested, _num_attested_shards, _total_shards))], None -> + if attested then + let () = + Format.eprintf "#### [Refutation] DAL Slot published and attested@." + in + let+ res = + download_confirmed_slot_pages node_ctxt ~published_level ~index + in + Some res + else + let () = + Format.eprintf + "#### [Refutation] DAL Slot published not NOT attested@." + in + return_none + | ( [(_slot_header, (_attested, num_attested_shards, total_shards))], + Some attestation_threshold_per_mil ) -> + let threshold = + Q.make (Z.of_int attestation_threshold_per_mil) (Z.of_int 1000) in - return (Some pages) - | Some `Unconfirmed -> return_none - | None -> storage_invariant_broken published_level index + let current = + Q.make (Z.of_int num_attested_shards) (Z.of_int total_shards) + in + let is_accepted = Q.compare current threshold >= 0 in + if is_accepted then + let () = + Format.eprintf + "#### [Refutation] Adaptive DAL Slot published and sufficiently \ + attested. Threshold:%a, Current:%a@." + Q.pp_print + threshold + Q.pp_print + current + in + let+ res = + download_confirmed_slot_pages node_ctxt ~published_level ~index + in + Some res + else + let () = + Format.eprintf + "#### [Refutation] DAL Slot published but NOT sufficiently \ + attested@." + in + return_none + +(* + let* confirmed_in_block_hash = + store_entry_from_published_level + ~dal_attestation_lag:dal_constants.attestation_lag + ~published_level + node_ctxt + in + let index = Sc_rollup_proto_types.Dal.Slot_index.to_octez index in + let* processed = + Node_context.find_slot_status node_ctxt ~confirmed_in_block_hash index + in + match processed with + | Some `Confirmed -> + let* pages = + download_confirmed_slot_pages node_ctxt ~published_level ~index + in + return (Some pages) + | Some `Unconfirmed -> return_none + | None -> storage_invariant_broken published_level index +*) + +let get_page node_ctxt ~inbox_level page_id = + let open Lwt_result_syntax in + let Dal.Page.{slot_id; page_index} = page_id in + let Dal.Slot.Header.{published_level; index} = slot_id in + let index = Sc_rollup_proto_types.Dal.Slot_index.to_octez index in + let* pages = + download_confirmed_slot_pages node_ctxt ~published_level ~index + in + match List.nth_opt pages page_index with + | Some page -> + let*! () = + Event.(emit page_reveal) + ( index, + page_index, + Raw_level.to_int32 published_level, + inbox_level, + page ) + in + return @@ Some page + | None -> tzfail @@ Dal_invalid_page_for_slot page_id let page_content (dal_constants : Octez_smart_rollup.Rollup_constants.dal_constants) ~dal_activation_level ~inbox_level node_ctxt page_id - ~dal_attested_slots_validity_lag = + ~dal_attested_slots_validity_lag ~adal_attestation_threshold_per_mil = let open Lwt_result_syntax in - let Dal.Page.{slot_id; page_index} = page_id in + let Dal.Page.{slot_id; page_index = _} = page_id in let Dal.Slot.Header.{published_level; index} = slot_id in let Node_context.{genesis_info = {level = origination_level; _}; _} = node_ctxt @@ -245,13 +343,28 @@ let page_content page_id then return_none else + let cctxt = node_ctxt.cctxt in + let attestation_level = + Int32.add + (Raw_level.to_int32 published_level) + (Int32.of_int dal_constants.attestation_lag) + in + let* attestations_statuses = + Plugin.RPC.Dal.dal_published_slot_headers_status + (new Protocol_client_context.wrap_full cctxt) + (cctxt#chain, `Level attestation_level) + () + in + let index = Sc_rollup_proto_types.Dal.Slot_index.to_octez index in + (* ADAL/TODO: If the new design is adopted, DAL slots statuses in the rollup + node are not needed anymore. *) + (* let* confirmed_in_block_hash = store_entry_from_published_level ~dal_attestation_lag:dal_constants.attestation_lag ~published_level node_ctxt in - let index = Sc_rollup_proto_types.Dal.Slot_index.to_octez index in let* processed = Node_context.find_slot_status node_ctxt ~confirmed_in_block_hash index in @@ -274,3 +387,54 @@ let page_content | None -> tzfail @@ Dal_invalid_page_for_slot page_id) | Some `Unconfirmed -> return_none | None -> storage_invariant_broken published_level index +*) + let target_slot_attestation_status = + List.filter + (fun ((slot_header : Sc_rollup_proto_types.Dal.Slot_header.t), _) -> + let id = slot_header.id in + Raw_level.equal id.published_level slot_id.published_level + && Dal.Slot_index.equal id.index slot_id.index) + attestations_statuses + in + match + (target_slot_attestation_status, adal_attestation_threshold_per_mil) + with + | [], _ -> + Format.eprintf "#### Slot not published at all@." ; + return_none + | _ :: _ :: _, _ -> storage_invariant_broken published_level index + | [(_slot_header, (attested, _num_attested_shards, _total_shards))], None -> + if attested then + let () = Format.eprintf "#### DAL Slot published and attested@." in + get_page node_ctxt ~inbox_level page_id + else + let () = + Format.eprintf "#### DAL Slot published not NOT attested@." + in + return_none + | ( [(_slot_header, (_attested, num_attested_shards, total_shards))], + Some attestation_threshold_per_mil ) -> + let threshold = + Q.make (Z.of_int attestation_threshold_per_mil) (Z.of_int 1000) + in + let current = + Q.make (Z.of_int num_attested_shards) (Z.of_int total_shards) + in + let is_accepted = Q.compare current threshold >= 0 in + if is_accepted then + let () = + Format.eprintf + "#### Adaptive DAL Slot published and sufficiently attested. \ + Threshold:%a, Current:%a@." + Q.pp_print + threshold + Q.pp_print + current + in + get_page node_ctxt ~inbox_level page_id + else + let () = + Format.eprintf + "#### DAL Slot published but NOT sufficiently attested@." + in + return_none diff --git a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli index 17d384fed0c2f8d24c757918828c7a506d81b981..71d67aecfa574b0656118704496586bb777b0cd6 100644 --- a/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli +++ b/src/proto_alpha/lib_sc_rollup_node/dal_pages_request.mli @@ -64,6 +64,7 @@ val slot_pages : _ Node_context.t -> Dal.slot_id -> dal_attested_slots_validity_lag:int -> + adal_attestation_threshold_per_mil:int option -> Dal.Page.content list option tzresult Lwt.t (** Retrieve the content of the page identified by the given ID from the store. @@ -75,6 +76,7 @@ val slot_pages : which the content has already been downloaded and saved to the store. [dal_attestation_lag] is used to retrieve the correct entry in [store]. + TODO: Extend doc-string *) val page_content : Octez_smart_rollup.Rollup_constants.dal_constants -> @@ -83,4 +85,5 @@ val page_content : _ Node_context.t -> Dal.Page.t -> dal_attested_slots_validity_lag:int -> + adal_attestation_threshold_per_mil:int option -> Dal.Page.content option tzresult Lwt.t 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 83a9d80d547b70de74596bedcea91d16f05ace3f..97201b25eecce2ee1fb39d855af62c5a3e2bd946 100644 --- a/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml +++ b/src/proto_alpha/lib_sc_rollup_node/fueled_pvm.ml @@ -153,6 +153,7 @@ module Make_fueled (F : Fuel.S) : FUELED_PVM with type fuel = F.t = struct ~dal_activation_level ~dal_attested_slots_validity_lag ~inbox_level:(Int32.of_int level) + ~adal_attestation_threshold_per_mil:None node_ctxt dal_page in @@ -174,7 +175,35 @@ 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 {page_id = dal_page; attestation_threshold_per_mil} + -> ( + Format.eprintf + "### Page:(?, ?), attestation_threshold_per_mil:%d@." + attestation_threshold_per_mil ; + let*! content = + Dal_pages_request.page_content + constants.dal + ~dal_activation_level + ~dal_attested_slots_validity_lag + ~inbox_level:(Int32.of_int level) + ~adal_attestation_threshold_per_mil: + (Some attestation_threshold_per_mil) + node_ctxt + dal_page + in + match content with + | Error error -> + (* The [Error_wrapper] must be caught upstream and converted into + a tzresult. *) + (* This happens when, for example, the kernel requests a page from a future level. *) + Lwt.fail (Error_wrapper error) + | Ok None -> + (* The page was not confirmed by L1. + We return empty string in this case, as done in the slow executon. *) + Lwt.return "" + | Ok (Some b) -> Lwt.return (Bytes.to_string b)) in + let eval_tick_consume_fuel fuel failing_ticks state = let max_steps = F.max_ticks fuel in let normal_eval ?(max_steps = max_steps) state fuel = @@ -299,6 +328,27 @@ module Make_fueled (F : Fuel.S) : FUELED_PVM with type fuel = F.t = struct ~inbox_level:(Int32.of_int level) ~dal_activation_level ~dal_attested_slots_validity_lag + ~adal_attestation_threshold_per_mil:None + node_ctxt + page_id + in + let*! next_state = + PVM.set_input (Reveal (Dal_page content_opt)) state + in + go fuel (Int64.succ current_tick) failing_ticks next_state) + | Needs_reveal + (Request_adal_page {page_id; attestation_threshold_per_mil}) -> ( + match F.consume F.one_tick_consumption fuel with + | None -> abort state fuel current_tick + | Some fuel -> + let* content_opt = + Dal_pages_request.page_content + constants.dal + ~inbox_level:(Int32.of_int level) + ~dal_activation_level + ~dal_attested_slots_validity_lag + ~adal_attestation_threshold_per_mil: + (Some attestation_threshold_per_mil) node_ctxt page_id in diff --git a/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml b/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml index 7ea4b3650dc3b1a420b52a343cd403cab3a5ee4e..9e5496cf62f5b0b797f5730a56b2ea3bf42f8f1b 100644 --- a/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml +++ b/src/proto_alpha/lib_sc_rollup_node/refutation_game_helpers.ml @@ -28,6 +28,54 @@ open Protocol open Alpha_context +let do_it constants (node_ctxt : _ Node_context.t) ~inbox_level + (dal_params : Dal.parameters) ~dal_activation_level + ~dal_attested_slots_validity_lag ~adal_attestation_threshold_per_mil page_id + = + let open Lwt_result_syntax in + let Dal.Page.{slot_id; page_index} = page_id in + let* pages = + Dal_pages_request.slot_pages + constants.Rollup_constants.dal + ~dal_activation_level + ~dal_attested_slots_validity_lag + ~inbox_level + node_ctxt + ~adal_attestation_threshold_per_mil + slot_id + in + match pages with + | None -> return_none (* The slot is not confirmed. *) + | Some pages -> ( + let pages_per_slot = dal_params.slot_size / dal_params.page_size in + (* check invariant that pages' length is correct. *) + (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/4031 + It's better to do the check when the slots are saved into disk. *) + (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3997 + This check is not resilient to dal parameters change. *) + match List.nth_opt pages page_index with + | Some content -> + let* page_proof = + let dal_cctxt = + WithExceptions.Option.get ~loc:__LOC__ node_ctxt.dal_cctxt + in + let Dal.Slot.Header.{published_level; index} = slot_id in + Dal_node_client.get_slot_page_proof + dal_cctxt + { + slot_level = published_level |> Raw_level.to_int32; + slot_index = index |> Alpha_context.Dal.Slot_index.to_int; + } + page_index + in + return_some (content, page_proof) + | None -> + failwith + "Page index %d too big or negative.\n\ + Number of pages in a slot is %d." + page_index + pages_per_slot) + (** When the PVM is waiting for a Dal page input, this function attempts to retrieve the page's content from the store, the data of its slot. Then it computes the proof that the page is part of the slot and returns the @@ -71,48 +119,28 @@ let page_info_from_pvm_state constants (node_ctxt : _ Node_context.t) (Ctxt_wrapper.of_node_pvmstate start_state) in match input_request with - | Sc_rollup.(Needs_reveal (Request_dal_page page_id)) -> ( - let Dal.Page.{slot_id; page_index} = page_id in - let* pages = - Dal_pages_request.slot_pages - constants.Rollup_constants.dal - ~dal_activation_level - ~dal_attested_slots_validity_lag - ~inbox_level - node_ctxt - slot_id - in - match pages with - | None -> return_none (* The slot is not confirmed. *) - | Some pages -> ( - let pages_per_slot = dal_params.slot_size / dal_params.page_size in - (* check invariant that pages' length is correct. *) - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/4031 - It's better to do the check when the slots are saved into disk. *) - (* FIXME/DAL: https://gitlab.com/tezos/tezos/-/issues/3997 - This check is not resilient to dal parameters change. *) - match List.nth_opt pages page_index with - | Some content -> - let* page_proof = - let dal_cctxt = - WithExceptions.Option.get ~loc:__LOC__ node_ctxt.dal_cctxt - in - let Dal.Slot.Header.{published_level; index} = slot_id in - Dal_node_client.get_slot_page_proof - dal_cctxt - { - slot_level = published_level |> Raw_level.to_int32; - slot_index = index |> Alpha_context.Dal.Slot_index.to_int; - } - page_index - in - return_some (content, page_proof) - | None -> - failwith - "Page index %d too big or negative.\n\ - Number of pages in a slot is %d." - page_index - pages_per_slot)) + | Sc_rollup.(Needs_reveal (Request_dal_page page_id)) -> + do_it + constants + (node_ctxt : _ Node_context.t) + ~inbox_level + (dal_params : Dal.parameters) + ~dal_activation_level + ~dal_attested_slots_validity_lag + ~adal_attestation_threshold_per_mil:None + page_id + | Sc_rollup.( + Needs_reveal (Request_adal_page {page_id; attestation_threshold_per_mil})) + -> + do_it + constants + node_ctxt + ~inbox_level + dal_params + ~dal_activation_level + ~dal_attested_slots_validity_lag + ~adal_attestation_threshold_per_mil:(Some attestation_threshold_per_mil) + page_id | _ -> return_none let metadata (node_ctxt : _ Node_context.t) = @@ -141,16 +169,52 @@ let generate_proof (node_ctxt : _ Node_context.t) (* Similarly to what's done for inbox snapshot above. *) Sc_rollup_proto_types.Dal.Slot_history.of_octez game.dal_snapshot in - let get_cell_from_hash hash = - (* each time a DAL skip list cell is requested by hash, we retrieve it from the DAL node. *) + let get_cell_from_hash ~dal_attestation_lag + ((hash, (header_id : Dal.Slot.Header.id)) : Dal.Slots_history.hash) = + (* TODO: update this comment -> each time a DAL skip list cell is requested + by hash, we retrieve it from the DAL node. *) (* TODO: We may want to have a local cache here. *) let open Lwt_syntax in - let dal_cctxt = node_ctxt.dal_cctxt in - let dal_cctxt = WithExceptions.Option.get ~loc:__LOC__ dal_cctxt in - let+ res = - Dal_proto_client.get_commitments_history_hash_content dal_cctxt hash + let attested_level = + Int32.add + (Int32.of_int dal_attestation_lag) + (Raw_level.to_int32 header_id.Dal.Slot.Header.published_level) + in + let* cells_of_level = + let cctxt = node_ctxt.cctxt in + Plugin.RPC.Dal.dal_history_cells_of_level + (new Protocol_client_context.wrap_full cctxt) + (cctxt#chain, `Level attested_level) + () in - Result.to_option res + let slot_id_equal Dal.Slot.Header.{published_level; index} s2 = + Raw_level.equal published_level s2.Dal.Slot.Header.published_level + && Dal.Slot_index.equal index s2.Dal.Slot.Header.index + in + match cells_of_level with + | Error _ -> Lwt.return_none + | Ok l -> ( + let l = + List.filter_map + (fun ((cell_hash, cell_slot_id), cell) -> + if + slot_id_equal cell_slot_id header_id + && Dal.Slots_history.Pointer_hash.Crypto_PH.equal cell_hash hash + then Some cell + else None) + l + in + match l with + | [] | _ :: _ :: _ -> assert false (* Should not be reachable *) + | [cell] -> + let Dal.Slot.Header.{published_level; index} = header_id in + Format.eprintf + "#### Got cell of slot (%a, %a) from L1 node ...@." + Raw_level.pp + published_level + Dal.Slot_index.pp + index ; + return_some cell) in (* We fetch the value of protocol constants at block snapshot level where the game started. *) @@ -237,7 +301,8 @@ let generate_proof (node_ctxt : _ Node_context.t) module Dal_with_history = struct let confirmed_slots_history = dal_slots_history - let get_history = get_cell_from_hash + let get_history x : Dal.Slots_history.t option Lwt.t = + get_cell_from_hash ~dal_attestation_lag x let dal_attestation_lag = dal_attestation_lag diff --git a/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml b/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml index d8f5db8cac625da9b4ec6fc815545ecc86fef542..20fa34f06543aea6c4fce89d73f9530bbad85d15 100644 --- a/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml +++ b/src/proto_alpha/lib_sc_rollup_node/test/test_octez_conversions.ml @@ -32,6 +32,7 @@ protocol ones are bijective. *) +(* open Qcheck2_helpers open Octez_smart_rollup @@ -488,3 +489,4 @@ let () = ~__FILE__ (Protocol.name ^ ": Smart rollup types octez conversions") [("roundtrip", qcheck_wrap tests)] +*) 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 b2d5d76c669315142af73bcbe850933e77b556aa..ce6efc33d19860add22629a5c6afd97f3642bd7b 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,9 @@ 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: to be implemented. *) + assert false let eval_many ~reveal_builtins ~write_debug ~is_reveal_enabled:_ = Backend.compute_step_many diff --git a/tezt/lib_tezos/constant.ml b/tezt/lib_tezos/constant.ml index 9c4425d73cb2c7fd4a883b412aa46065c600cec3..4ac607a8376f06ccac67576c8edc7b767b0dd6e5 100644 --- a/tezt/lib_tezos/constant.ml +++ b/tezt/lib_tezos/constant.ml @@ -81,7 +81,18 @@ let teztale_server = module WASM = struct let dal_echo_kernel = - Uses.make ~tag:"dal_echo_kernel" ~path:"dal_echo_kernel.wasm" () + Uses.make + ~tag:"dal_echo_kernel" + ~path: + "src/kernel_dal_echo/target/wasm32-unknown-unknown/release/dal_echo_kernel.wasm" + () + + let adal_echo_kernel = + Uses.make + ~tag:"adal_echo_kernel" + ~path: + "src/kernel_adal_echo/target/wasm32-unknown-unknown/release/adal_echo_kernel.wasm" + () let debug_kernel = Uses.make diff --git a/tezt/tests/dal.ml b/tezt/tests/dal.ml index 0179fb95927d2f3ae162b031f3a2aeb5b981f002..fa0cccc50a7efa7f435ecbd4f0bef65bf7804de2 100644 --- a/tezt/tests/dal.ml +++ b/tezt/tests/dal.ml @@ -4997,7 +4997,7 @@ module History_rpcs = struct node dal_node - let test_commitments_history_rpcs_with_migration ~migrate_from ~migrate_to = + let _test_commitments_history_rpcs_with_migration ~migrate_from ~migrate_to = let tags = ["rpc"; "skip_list"; Tag.memory_3k] in let description = "test commitments history with migration" in let slot_index = 3 in @@ -6743,6 +6743,80 @@ module Tx_kernel_e2e = struct (String.sub value 0 (String.length payload)) in Test.fail "%s" message + + let test_adal_echo_kernel_e2e _protocol parameters dal_node sc_rollup_node + _sc_rollup_address node client pvm_name = + Log.info "Originate the ADAL echo kernel." ; + let* {boot_sector; _} = + Sc_rollup_helpers.prepare_installer_kernel + ~preimages_dir: + (Filename.concat (Sc_rollup_node.data_dir sc_rollup_node) pvm_name) + Constant.WASM.adal_echo_kernel + in + let* sc_rollup_address = + Client.Sc_rollup.originate + ~burn_cap:Tez.(of_int 9999999) + ~alias:"adal_echo_kernel" + ~src:Constant.bootstrap1.public_key_hash + ~kind:pvm_name + ~boot_sector + ~parameters_ty:"unit" + client + in + let* () = bake_for client in + let* () = + Sc_rollup_node.run sc_rollup_node sc_rollup_address [Log_kernel_debug] + in + let* current_level = Node.get_level node in + let target_level = + current_level + parameters.Dal.Parameters.attestation_lag + 1 + in + let payload = "hello" in + let* () = + publish_store_and_attest_slot + client + node + dal_node + Constant.bootstrap1 + ~index:0 + ~content: + (Helpers.make_slot + ~slot_size:parameters.Dal.Parameters.cryptobox.slot_size + payload) + ~attestation_lag:parameters.attestation_lag + ~number_of_slots:parameters.number_of_slots + in + Log.info "Wait for the rollup node to catch up." ; + let* _level = + Sc_rollup_node.wait_for_level ~timeout:30. sc_rollup_node target_level + in + let key = "/output/slot-0" in + let* value_written = + Sc_rollup_node.RPC.call sc_rollup_node ~rpc_hooks + @@ Sc_rollup_rpc.get_global_block_durable_state_value + ~pvm_kind:pvm_name + ~operation:Sc_rollup_rpc.Value + ~key + () + in + match value_written with + | None -> Test.fail "Expected a value to be found. But none was found." + | Some value -> + let value = `Hex value |> Hex.to_string in + Check.( + (String.length value = parameters.Dal.Parameters.cryptobox.slot_size) + int + ~error_msg:"Expected a value of size %R. Got $L") ; + if String.starts_with ~prefix:payload value then unit + else + let message = + Format.asprintf + "Expected the payload '%s' to be a prefix of the value written. \ + Instead found: %s" + payload + (String.sub value 0 (String.length payload)) + in + Test.fail "%s" message end module Profiler = Tezos_base.Profiler @@ -7287,7 +7361,7 @@ module Refutations = struct - Initializes two DAL nodes, one honest and one faulty. - Initializes two rollup nodes, one for each DAL node. - Prepares and provides the kernel code for both rollup nodes. - - Originates the dal_echo_kernel smart rollup. + - Originates the xdal_echo_kernel smart rollup. - Publishes DAL slots at indices 0 and 1 of the same level. - Attest the two slots. - Stops the faulty DAL node and alters its shards store to make it return @@ -7303,7 +7377,7 @@ module Refutations = struct *) let scenario_with_two_rollups_a_faulty_dal_node_and_a_correct_one ~refute_operations_priority _protocol parameters _dal_node _sc_rollup_node - _sc_rollup_address node client pvm_name = + _sc_rollup_address node client pvm_name ~xdal_echo_kernel = (* Initializing the real SRS. *) let faulty_operator_key = Constant.bootstrap4.public_key_hash in let honest_operator_key = Constant.bootstrap5.public_key_hash in @@ -7348,7 +7422,7 @@ module Refutations = struct Sc_rollup_helpers.prepare_installer_kernel ~preimages_dir: (Filename.concat (Sc_rollup_node.data_dir sc_rollup) pvm_name) - Constant.WASM.dal_echo_kernel + xdal_echo_kernel in return boot_sector) "" @@ -7362,11 +7436,11 @@ module Refutations = struct bake_for ~count:parameters.Dal.Parameters.attestation_lag client in - (* Originate the dal_echo_kernel smart rollup *) + (* Originate the xdal_echo_kernel smart rollup *) let* sc_rollup_address = Client.Sc_rollup.originate ~burn_cap:Tez.(of_int 9999999) - ~alias:"dal_echo_kernel" + ~alias:"xdal_echo_kernel" ~src:Constant.bootstrap1.public_key_hash ~kind:pvm_name ~boot_sector @@ -8364,6 +8438,18 @@ let register ~protocols = Tx_kernel_e2e.test_echo_kernel_e2e protocols ; + scenario_with_all_nodes + "test adaptive DAL echo_kernel" + ~uses:(fun _protocol -> + [Constant.smart_rollup_installer; Constant.WASM.adal_echo_kernel]) + ~pvm_name:"wasm_2_0_0" + ~slot_size:2048 + ~page_size:256 + ~number_of_shards:64 + ~producer_profiles:[0] + Tx_kernel_e2e.test_adal_echo_kernel_e2e + protocols ; + (* Register tutorial test *) scenario_tutorial_dal_baker protocols ; @@ -8375,9 +8461,10 @@ let register ~protocols = ~pvm_name:"wasm_2_0_0" ~commitment_period:5 (Refutations.scenario_with_two_rollups_a_faulty_dal_node_and_a_correct_one - ~refute_operations_priority:`Faulty_first) - ~smart_rollup_timeout_period_in_blocks:20 - ~l1_history_mode:Default_with_refutation + ~refute_operations_priority:`Faulty_first + ~xdal_echo_kernel:Constant.WASM.dal_echo_kernel) + ~smart_rollup_timeout_period_in_blocks:400 + ~l1_history_mode:(Custom Archive) ~tags:[Tag.slow] protocols ; @@ -8389,9 +8476,40 @@ let register ~protocols = ~pvm_name:"wasm_2_0_0" ~commitment_period:5 (Refutations.scenario_with_two_rollups_a_faulty_dal_node_and_a_correct_one - ~refute_operations_priority:`Honest_first) - ~smart_rollup_timeout_period_in_blocks:20 - ~l1_history_mode:Default_with_refutation + ~refute_operations_priority:`Honest_first + ~xdal_echo_kernel:Constant.WASM.dal_echo_kernel) + ~smart_rollup_timeout_period_in_blocks:400 + ~l1_history_mode:(Custom Archive) + ~tags:[Tag.slow] + protocols ; + + scenario_with_all_nodes + "Adaptive DAL refutation where the faulty node timeouts" + ~regression:false + ~uses:(fun _protocol -> + [Constant.smart_rollup_installer; Constant.WASM.adal_echo_kernel]) + ~pvm_name:"wasm_2_0_0" + ~commitment_period:5 + (Refutations.scenario_with_two_rollups_a_faulty_dal_node_and_a_correct_one + ~refute_operations_priority:`Faulty_first + ~xdal_echo_kernel:Constant.WASM.adal_echo_kernel) + ~smart_rollup_timeout_period_in_blocks:400 + ~l1_history_mode:(Custom Archive) + ~tags:[Tag.slow] + protocols ; + + scenario_with_all_nodes + "Adaptive DAL refutation where the honest node makes final move" + ~regression:false + ~uses:(fun _protocol -> + [Constant.smart_rollup_installer; Constant.WASM.adal_echo_kernel]) + ~pvm_name:"wasm_2_0_0" + ~commitment_period:5 + (Refutations.scenario_with_two_rollups_a_faulty_dal_node_and_a_correct_one + ~refute_operations_priority:`Honest_first + ~xdal_echo_kernel:Constant.WASM.adal_echo_kernel) + ~smart_rollup_timeout_period_in_blocks:400 + ~l1_history_mode:(Custom Archive) ~tags:[Tag.slow] protocols ; @@ -8440,9 +8558,11 @@ let tests_start_dal_node_around_migration ~migrate_from ~migrate_to = tests ~migrate_from ~migrate_to ~check_rpc:true let register_migration ~migrate_from ~migrate_to = - test_migration_plugin ~migration_level:4 ~migrate_from ~migrate_to ; + test_migration_plugin ~migration_level:4 ~migrate_from ~migrate_to +(* History_rpcs.test_commitments_history_rpcs_with_migration ~migration_level:10 ~migrate_from ~migrate_to ; tests_start_dal_node_around_migration ~migrate_from ~migrate_to +*) diff --git a/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (test adaptive DAL echo_kernel).out b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (test adaptive DAL echo_kernel).out new file mode 100644 index 0000000000000000000000000000000000000000..2f6f670223d3a0063297aee21135fb3286b828ac --- /dev/null +++ b/tezt/tests/expected/dal.ml/Alpha- Testing DAL rollup and node with L1 (test adaptive DAL echo_kernel).out @@ -0,0 +1,39 @@ + +./octez-client --wait none originate smart rollup rollup from '[PUBLIC_KEY_HASH]' of kind wasm_2_0_0 of type string with kernel --burn-cap 9999999 +Node is bootstrapped. +Estimated gas: 1930.030 units (will add 100 for safety) +Estimated storage: 6552 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 + octez-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.000441 + Expected counter: 1 + Gas limit: 2031 + Storage limit: 6572 bytes + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ0.000441 + payload fees(the block proposer) ....... +ꜩ0.000441 + Smart rollup origination: + Kind: wasm_2_0_0 + Parameter type: string + Kernel Blake2B hash: '0e5751c026e543b2e8ab2eb06099daa1d1e5df47778f7787faab45cdf12fe3a8' + This smart rollup origination was successfully applied + Consumed gas: 1929.997 + Storage size: 6552 bytes + Address: [SMART_ROLLUP_HASH] + Genesis commitment hash: [SC_ROLLUP_COMMITMENT_HASH] + Balance updates: + [PUBLIC_KEY_HASH] ... -ꜩ1.638 + storage fees ........................... +ꜩ1.638 + +Smart rollup [SMART_ROLLUP_HASH] memorized as "rollup" +GET http://[HOST]:[PORT]/global/block/head/durable/wasm_2_0_0/value?key=/output/slot-0 +200 OK +"68656c6c6f000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + diff --git a/tezt/tests/main.ml b/tezt/tests/main.ml index d0613f803eb04f688e4495be3dfc46c2468c354f..f04954dc0610994bcb66d8f1c4c62b05ad4f6903 100644 --- a/tezt/tests/main.ml +++ b/tezt/tests/main.ml @@ -223,7 +223,7 @@ let register_protocol_tests_that_use_supports_correctly () = Tx_sc_rollup.register ~protocols ; Timelock.register ~protocols ; Tzt_regression.register ~protocols ; - Dal.register ~protocols ; + Dal.register ~protocols:[Alpha] ; Yes_crypto.register ~protocols (* Regression tests are not easy to maintain for multiple protocols because one needs