diff --git a/etherlink/CHANGES_KERNEL.md b/etherlink/CHANGES_KERNEL.md index 67eb5d5986a6e6308e4a9b1ddf5eed9993b361e1..c9153694db818a68814e7df2b3f66c74e4d9b866 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 diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index 69f0f459df99821abfe4d71ec66e4d56fbeea442..135c58a56d179c9825371af03a026a171848443a 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.