From 2d891bd1f53e2dffe65fe06e14057fb5002af894 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Thu, 6 Feb 2025 15:48:47 +0100 Subject: [PATCH 1/3] Etherlink/Kernel: split the read_next_blueprint function Small refactoring to prepare next commit which will replace the single non-test call to `read_next_blueprint` by a call to `read_blueprint` without reading the storage. --- etherlink/kernel_evm/kernel/src/blueprint_storage.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index fc94fdf31f45..82b6470bf2b1 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -423,11 +423,11 @@ fn read_all_chunks_and_validate( } } -pub fn read_next_blueprint( +fn read_blueprint( host: &mut Host, config: &mut Configuration, + number: U256, ) -> anyhow::Result<(Option, usize)> { - let number = read_next_blueprint_number(host)?; let blueprint_path = blueprint_path(number)?; let exists = host.store_has(&blueprint_path)?.is_some(); if exists { @@ -468,6 +468,14 @@ pub fn read_next_blueprint( } } +pub fn read_next_blueprint( + host: &mut Host, + config: &mut Configuration, +) -> anyhow::Result<(Option, usize)> { + let number = read_next_blueprint_number(host)?; + read_blueprint(host, config, number) +} + pub fn drop_blueprint(host: &mut Host, number: U256) -> Result<(), Error> { let path = blueprint_path(number)?; host.store_delete(&path).map_err(Error::from) -- GitLab From f1916241fbd3b889ed0d4522845b07ead476a638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Thu, 6 Feb 2025 09:58:49 +0100 Subject: [PATCH 2/3] Etherlink/Kernel/Stage 2: avoid rereading the BP number --- etherlink/kernel_evm/kernel/src/block.rs | 5 +++-- etherlink/kernel_evm/kernel/src/blueprint_storage.rs | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index 9e0fbf9f52c6..acfa7c92d6c8 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -9,7 +9,7 @@ use crate::apply::{ apply_transaction, ExecutionInfo, ExecutionResult, Validity, WITHDRAWAL_OUTBOX_QUEUE, }; use crate::block_storage; -use crate::blueprint_storage::{drop_blueprint, read_next_blueprint}; +use crate::blueprint_storage::{drop_blueprint, read_blueprint}; use crate::configuration::ConfigurationMode; use crate::configuration::Limits; use crate::delayed_inbox::DelayedInbox; @@ -254,7 +254,7 @@ fn next_bip_from_blueprints( kernel_upgrade: &Option, minimum_base_fee_per_gas: U256, ) -> Result { - let (blueprint, size) = read_next_blueprint(host, config)?; + let (blueprint, size) = read_blueprint(host, config, current_block_number)?; log!(host, Benchmarking, "Size of blueprint: {}", size); match blueprint { Some(blueprint) => { @@ -593,6 +593,7 @@ mod tests { use super::*; use crate::block_storage; use crate::blueprint::Blueprint; + use crate::blueprint_storage::read_next_blueprint; use crate::blueprint_storage::store_inbox_blueprint; use crate::blueprint_storage::store_inbox_blueprint_by_number; use crate::fees::DA_FEE_PER_BYTE; diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index 82b6470bf2b1..0548f72af084 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -423,7 +423,7 @@ fn read_all_chunks_and_validate( } } -fn read_blueprint( +pub fn read_blueprint( host: &mut Host, config: &mut Configuration, number: U256, @@ -468,6 +468,7 @@ fn read_blueprint( } } +#[cfg(test)] pub fn read_next_blueprint( host: &mut Host, config: &mut Configuration, -- GitLab From 3aa4722e5b70f5e02267fa83c874aa69b5be4bc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Tue, 11 Feb 2025 12:01:49 +0100 Subject: [PATCH 3/3] Etherlink/Kernel: update changelog --- etherlink/CHANGES_KERNEL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etherlink/CHANGES_KERNEL.md b/etherlink/CHANGES_KERNEL.md index 1592db6cbf37..a19dd84a6178 100644 --- a/etherlink/CHANGES_KERNEL.md +++ b/etherlink/CHANGES_KERNEL.md @@ -9,7 +9,7 @@ ### Internal - Rework block production to simplify data flow and remove unnecessary - IO. (!16661 !16684 !16685) + IO. (!16661 !16684 !16685 !16618) ## Next proposal -- GitLab