From 75f452a5e38a84ebc22b3fbdc56e8e98a13637cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 17 Jan 2025 10:23:19 +0100 Subject: [PATCH 1/2] Etherlink/Kernel/Stage 2: reboot between blocks This commit simplifies block production in Etherlink's kernel by adding a reboot between blocks. --- etherlink/kernel_evm/kernel/src/block.rs | 35 ++++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index 69f0f459df99..135c58a56d17 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -501,6 +501,8 @@ pub fn produce( )?; if at_most_one_block { return Ok(ComputationResult::Finished); + } else { + return Ok(ComputationResult::RebootNeeded); } } Ok(BlockComputationResult::RebootNeeded) => { @@ -523,11 +525,8 @@ pub fn produce( // because the sequencer pool address is located outside of `/evm/world_state`. upgrade::possible_sequencer_upgrade(safe_host.host)?; - // Execute stored blueprints - // - // The loop will eventually stop until there is no more blueprint, or no - // more ticks. - loop { + // Execute at most one of the stored blueprints + { let block_in_progress = match next_bip_from_blueprints( safe_host.host, current_block_number, @@ -586,7 +585,9 @@ pub fn produce( included_delayed_transactions, )?; if at_most_one_block { - return Ok(ComputationResult::Finished); + Ok(ComputationResult::Finished) + } else { + Ok(ComputationResult::RebootNeeded) } } Ok(BlockComputationResult::RebootNeeded) => { @@ -598,7 +599,7 @@ pub fn produce( "Estimated ticks: {}", tick_counter.c ); - return Ok(ComputationResult::RebootNeeded); + Ok(ComputationResult::RebootNeeded) } Err(err) => { revert_block(&mut safe_host, false, processed_blueprint, err)?; @@ -612,7 +613,7 @@ pub fn produce( "Estimated ticks: {}", tick_counter.c ); - return Ok(ComputationResult::RebootNeeded); + Ok(ComputationResult::RebootNeeded) } } } @@ -1083,6 +1084,16 @@ mod tests { ); store_block_fees(&mut host, &dummy_block_fees()).unwrap(); + // Produce block for blueprint containing transaction_0 + produce( + &mut host, + DUMMY_CHAIN_ID, + &mut Configuration::default(), + None, + None, + ) + .expect("The block production failed."); + // Produce block for blueprint containing transaction_1 produce( &mut host, DUMMY_CHAIN_ID, @@ -1704,6 +1715,12 @@ mod tests { ..Configuration::default() }; store_block_fees(&mut host, &dummy_block_fees()).unwrap(); + let computation_result = + produce(&mut host, DUMMY_CHAIN_ID, &mut configuration, None, None) + .expect("Should have produced"); + // test reboot is set + matches!(computation_result, ComputationResult::RebootNeeded); + let computation_result = produce(&mut host, DUMMY_CHAIN_ID, &mut configuration, None, None) .expect("Should have produced"); @@ -1716,7 +1733,7 @@ mod tests { "There should have been one block registered" ); - // test reboot is set + // test reboot is set again matches!(computation_result, ComputationResult::RebootNeeded); // The block is in progress, therefore it is in the safe storage. -- GitLab From 661ac9a7f3da676124b15dd7126156050408b856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Fri, 17 Jan 2025 11:00:42 +0100 Subject: [PATCH 2/2] Etherlink/Kernel/Changelog: mention !16274 --- etherlink/CHANGES_KERNEL.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/etherlink/CHANGES_KERNEL.md b/etherlink/CHANGES_KERNEL.md index 67eb5d5986a6..c9153694db81 100644 --- a/etherlink/CHANGES_KERNEL.md +++ b/etherlink/CHANGES_KERNEL.md @@ -25,6 +25,8 @@ - Current block's gas price is not stored on its own anymore but the information is still available as part of the current block. (!15609) +- The kernel always reboots between the application of + blocks. (!16274) ### Bug fixes -- GitLab