diff --git a/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs b/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs index a2973b4fa14fb0bd32b7bc1cd3b56b9bd0e15d71..1f9a1ce045e96359a097ac76a4be92a246ba04a3 100644 --- a/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs +++ b/etherlink/kernel_evm/evm_evaluation/src/evalhost.rs @@ -171,6 +171,24 @@ impl SdkRuntime for EvalHost { .reveal_dal_page(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/runtime/src/runtime.rs b/etherlink/kernel_evm/runtime/src/runtime.rs index 64a24c9fe51a3be7c49cce6f00daac636d5d9c07..6dc7d9ba76dc7d85b3597b5170202158de75384c 100644 --- a/etherlink/kernel_evm/runtime/src/runtime.rs +++ b/etherlink/kernel_evm/runtime/src/runtime.rs @@ -211,6 +211,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 d55feb706e33759acb9859300ae784e4abe16905..0a1190554c3569c33a7205547ca7cc68c3c87858 100644 --- a/etherlink/kernel_evm/runtime/src/safe_storage.rs +++ b/etherlink/kernel_evm/runtime/src/safe_storage.rs @@ -197,6 +197,24 @@ impl SdkRuntime for SafeStorage<&mut Host> { .reveal_dal_page(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/src/kernel_sdk/CHANGES.md b/src/kernel_sdk/CHANGES.md index cefd8de2f97fcc8514f7ced6aecc308e35420f61..617aa6ed24ff0be1fcbd3fe61fa0c7a8f1e62369 100644 --- a/src/kernel_sdk/CHANGES.md +++ b/src/kernel_sdk/CHANGES.md @@ -3,6 +3,7 @@ ## Version next ### SDK +- Add Experimental support for Adjustable 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 for RISC-V 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. diff --git a/src/kernel_sdk/host/src/runtime.rs b/src/kernel_sdk/host/src/runtime.rs index 269e5b21d31b8659f5337e2e0ea2436d29bd6eb1..e3db4eb5d19a6e85962e91439c2aea52c1a24596 100644 --- a/src/kernel_sdk/host/src/runtime.rs +++ b/src/kernel_sdk/host/src/runtime.rs @@ -200,6 +200,17 @@ pub trait Runtime { destination: &mut [u8], ) -> Result; + /// Reveal a Adjustable 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; @@ -630,6 +641,43 @@ where } } + /// Reveal Adjustable 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 { + // 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..a55b87ec1d388e353ee8260d7d9b7f05f1fe0426 100644 --- a/src/kernel_sdk/host/src/runtime/unwindable.rs +++ b/src/kernel_sdk/host/src/runtime/unwindable.rs @@ -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/sdk/src/entrypoint/internal/static_input_host.rs b/src/kernel_sdk/sdk/src/entrypoint/internal/static_input_host.rs index c71c17013183249baca5b5f1c7c84ada85141a7e..f949c39b3e2c3e97a259c8471996156ae10c01d0 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 @@ -216,6 +216,24 @@ impl<'runtime, R: Runtime> Runtime for StaticInputHost<'runtime, R> { .reveal_dal_page(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()