From af7d47da5c7161d8afd7d6264129fdad7a51f4a7 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 20 Feb 2025 14:43:26 +0100 Subject: [PATCH 1/8] Etherlink/Kernel/Renaming: Rename L2Block in EthBlock The kernel of etherlink will soon have a structure to represent tezlink block. In the multichain kernel, L2Block notion represent both ethereum block and tezos block. --- etherlink/kernel_evm/ethereum/src/block.rs | 32 +++++++++---------- etherlink/kernel_evm/kernel/src/block.rs | 6 ++-- .../kernel/src/block_in_progress.rs | 6 ++-- .../kernel_evm/kernel/src/block_storage.rs | 14 ++++---- .../kernel/src/blueprint_storage.rs | 6 ++-- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/etherlink/kernel_evm/ethereum/src/block.rs b/etherlink/kernel_evm/ethereum/src/block.rs index fa5f117e032f..9831cef6f294 100644 --- a/etherlink/kernel_evm/ethereum/src/block.rs +++ b/etherlink/kernel_evm/ethereum/src/block.rs @@ -128,7 +128,7 @@ impl BlockConstants { } #[derive(Debug, PartialEq, Eq, Clone)] -pub struct L2Block { +pub struct EthBlock { // This choice of a L2 block representation is totally // arbitrarily based on what is an Ethereum block and is // subject to change. @@ -153,7 +153,7 @@ pub struct L2Block { pub mix_hash: H256, } -impl L2Block { +impl EthBlock { #[allow(clippy::too_many_arguments)] pub fn new( number: U256, @@ -181,7 +181,7 @@ impl L2Block { timestamp, &None, ); - L2Block { + EthBlock { number, hash, parent_hash, @@ -231,7 +231,7 @@ impl L2Block { H256(Keccak256::digest(bytes).into()) } - pub fn from_bytes(bytes: &[u8]) -> Result { + pub fn from_bytes(bytes: &[u8]) -> Result { let first = *bytes.first().ok_or(DecoderError::Custom("Empty bytes"))?; if first == 0x01 { let decoder = Rlp::new(&bytes[1..]); @@ -242,7 +242,7 @@ impl L2Block { } } - fn rlp_decode_v0(decoder: &Rlp) -> Result { + fn rlp_decode_v0(decoder: &Rlp) -> Result { if decoder.is_list() { if Ok(13) == decoder.item_count() { let mut it = decoder.iter(); @@ -264,7 +264,7 @@ impl L2Block { decode_transaction_hash_list(&next(&mut it)?, "transactions")?; let gas_used: U256 = decode_field_u256_le(&next(&mut it)?, "gas_used")?; let timestamp = decode_timestamp(&next(&mut it)?)?; - Ok(L2Block { + Ok(EthBlock { number, hash, parent_hash, @@ -289,7 +289,7 @@ impl L2Block { } } - fn rlp_decode_v1(decoder: &Rlp) -> Result { + fn rlp_decode_v1(decoder: &Rlp) -> Result { if decoder.is_list() { if Ok(15) == decoder.item_count() { let mut it = decoder.iter(); @@ -314,7 +314,7 @@ impl L2Block { let base_fee_per_gas: U256 = decode_field_u256_le(&next(&mut it)?, "base_fee_per_gas")?; let mix_hash: H256 = decode_field(&next(&mut it)?, "mix_hash")?; - Ok(L2Block { + Ok(EthBlock { number, hash, parent_hash, @@ -339,7 +339,7 @@ impl L2Block { } } - fn rlp_encode(self: &L2Block, s: &mut RlpStream) { + fn rlp_encode(self: &EthBlock, s: &mut RlpStream) { s.begin_list(15); append_u256_le(s, &self.number); s.append(&self.hash); @@ -361,7 +361,7 @@ impl L2Block { } } -impl VersionedEncoding for L2Block { +impl VersionedEncoding for EthBlock { const VERSION: u8 = 1; fn unversionned_encode(&self) -> bytes::BytesMut { @@ -378,7 +378,7 @@ impl VersionedEncoding for L2Block { #[cfg(test)] mod tests { - use super::L2Block; + use super::EthBlock; use crate::eth_gen::OwnedHash; use crate::rlp_helpers::VersionedEncoding; use crate::transaction::TRANSACTION_HASH_SIZE; @@ -386,9 +386,9 @@ mod tests { use primitive_types::{H256, U256}; use tezos_smart_rollup_encoding::timestamp::Timestamp; - fn block_encoding_roundtrip(v: L2Block) { + fn block_encoding_roundtrip(v: EthBlock) { let bytes = v.to_bytes(); - let v2 = L2Block::from_bytes(&bytes).expect("L2Block should be decodable"); + let v2 = EthBlock::from_bytes(&bytes).expect("EthBlock should be decodable"); assert_eq!(v, v2, "Roundtrip failed on {:?}", v) } @@ -397,8 +397,8 @@ mod tests { pub fn dummy_hash() -> OwnedHash { DUMMY_HASH.into() } - fn dummy_block(tx_length: usize) -> L2Block { - L2Block { + fn dummy_block(tx_length: usize) -> EthBlock { + EthBlock { number: U256::from(42), hash: H256::from([3u8; 32]), parent_hash: H256::from([2u8; 32]), @@ -420,7 +420,7 @@ mod tests { #[test] fn roundtrip_rlp() { for tx_length in 0..3 { - let v: L2Block = dummy_block(tx_length); + let v: EthBlock = dummy_block(tx_length); block_encoding_roundtrip(v); } } diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index a0b4a4e7b901..311be157aa20 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -32,7 +32,7 @@ use evm_execution::precompiles::PrecompileBTreeMap; use evm_execution::trace::TracerInput; use primitive_types::{H160, H256, U256}; use tezos_ethereum::block::BlockConstants; -use tezos_ethereum::block::L2Block; +use tezos_ethereum::block::EthBlock; use tezos_ethereum::transaction::TransactionHash; use tezos_evm_logging::{log, Level::*, Verbosity}; use tezos_evm_runtime::runtime::Runtime; @@ -76,7 +76,7 @@ pub enum BlockComputationResult { RebootNeeded, Finished { included_delayed_transactions: Vec, - block: Box, + block: Box, }, } @@ -438,7 +438,7 @@ fn promote_block( safe_host: &mut SafeStorage<&mut Host>, outbox_queue: &OutboxQueue<'_, impl Path>, block_in_progress_provenance: &BlockInProgressProvenance, - block: L2Block, + block: EthBlock, config: &mut Configuration, delayed_txs: Vec, ) -> anyhow::Result<()> { diff --git a/etherlink/kernel_evm/kernel/src/block_in_progress.rs b/etherlink/kernel_evm/kernel/src/block_in_progress.rs index 0726000fa5d1..12a0e3ff898c 100644 --- a/etherlink/kernel_evm/kernel/src/block_in_progress.rs +++ b/etherlink/kernel_evm/kernel/src/block_in_progress.rs @@ -18,7 +18,7 @@ use evm_execution::account_storage::EVM_ACCOUNTS_PATH; use primitive_types::{H160, H256, U256}; use rlp::{Decodable, DecoderError, Encodable}; use std::collections::VecDeque; -use tezos_ethereum::block::{BlockConstants, BlockFees, L2Block}; +use tezos_ethereum::block::{BlockConstants, BlockFees, EthBlock}; use tezos_ethereum::eth_gen::OwnedHash; use tezos_ethereum::rlp_helpers::*; use tezos_ethereum::transaction::{ @@ -442,7 +442,7 @@ impl BlockInProgress { self, host: &mut Host, block_constants: &BlockConstants, - ) -> Result { + ) -> Result { let state_root = Self::safe_store_get_hash(host, &EVM_ACCOUNTS_PATH)?; let receipts_root = self.receipts_root(host, &self.previous_receipts_root)?; let transactions_root = @@ -452,7 +452,7 @@ impl BlockInProgress { self.timestamp, block_constants.block_fees.minimum_base_fee_per_gas(), ); - let new_block = L2Block::new( + let new_block = EthBlock::new( self.number, self.valid_txs, self.timestamp, diff --git a/etherlink/kernel_evm/kernel/src/block_storage.rs b/etherlink/kernel_evm/kernel/src/block_storage.rs index f090c86b40f9..22586cbdd07d 100644 --- a/etherlink/kernel_evm/kernel/src/block_storage.rs +++ b/etherlink/kernel_evm/kernel/src/block_storage.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use primitive_types::{H256, U256}; -use tezos_ethereum::block::L2Block; +use tezos_ethereum::block::EthBlock; use tezos_ethereum::rlp_helpers::VersionedEncoding; use tezos_evm_logging::{ log, @@ -52,7 +52,7 @@ fn store_current_hash(host: &mut impl Runtime, hash: H256) -> anyhow::Result<()> fn store_block( host: &mut impl Runtime, - block: &L2Block, + block: &EthBlock, index_block: bool, ) -> anyhow::Result<()> { if index_block { @@ -68,7 +68,7 @@ fn store_block( fn store_current_index_or_not( host: &mut impl Runtime, - block: &L2Block, + block: &EthBlock, index_block: bool, ) -> anyhow::Result<()> { store_current_number(host, block.number)?; @@ -86,11 +86,11 @@ fn store_current_index_or_not( Ok(()) } -pub fn store_current(host: &mut impl Runtime, block: &L2Block) -> anyhow::Result<()> { +pub fn store_current(host: &mut impl Runtime, block: &EthBlock) -> anyhow::Result<()> { store_current_index_or_not(host, block, true) } -pub fn restore_current(host: &mut impl Runtime, block: &L2Block) -> anyhow::Result<()> { +pub fn restore_current(host: &mut impl Runtime, block: &EthBlock) -> anyhow::Result<()> { store_current_index_or_not(host, block, false) } @@ -102,11 +102,11 @@ pub fn read_current_hash(host: &impl Runtime) -> anyhow::Result { read_h256_be(host, &path::CURRENT_HASH) } -pub fn read_current(host: &mut impl Runtime) -> anyhow::Result { +pub fn read_current(host: &mut impl Runtime) -> anyhow::Result { let hash = read_current_hash(host)?; let block_path = path::path(hash)?; let bytes = &host.store_read_all(&block_path)?; - let block_from_bytes = L2Block::from_bytes(bytes)?; + let block_from_bytes = EthBlock::from_bytes(bytes)?; Ok(block_from_bytes) } diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index 71b469061a2f..d45ec5c70594 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -16,7 +16,7 @@ use primitive_types::{H256, U256}; use rlp::{Decodable, DecoderError, Encodable}; use sha3::{Digest, Keccak256}; use std::fmt::Debug; -use tezos_ethereum::block::L2Block; +use tezos_ethereum::block::EthBlock; use tezos_ethereum::eth_gen::OwnedHash; use tezos_ethereum::rlp_helpers::{ self, append_timestamp, append_u256_le, decode_field_u256_le, decode_timestamp, @@ -116,8 +116,8 @@ pub struct BlockHeader { pub evm_block_header: H, } -impl From for BlockHeader { - fn from(block: L2Block) -> Self { +impl From for BlockHeader { + fn from(block: EthBlock) -> Self { Self { blueprint_header: BlueprintHeader { number: block.number, -- GitLab From bbeb238b9f4bce8281f49a97d029e7a1f30354fd Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 20 Feb 2025 15:18:42 +0100 Subject: [PATCH 2/8] Etherlink/Kernel/Refacto: Move evm storage initialisation in compute_bip As the etherlink kernel will also support tezlink, code will be shared between the two chains. The deeper we put the apparition of evm notion in the code, the longer etherlink and tezlink can share code. --- etherlink/kernel_evm/kernel/src/block.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index 311be157aa20..01e23f58a4b6 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -338,7 +338,6 @@ fn compute_bip( outbox_queue: &OutboxQueue<'_, impl Path>, mut block_in_progress: BlockInProgress, precompiles: &PrecompileBTreeMap, - evm_account_storage: &mut EthereumAccountStorage, tick_counter: &mut TickCounter, sequencer_pool_address: Option, limits: &Limits, @@ -349,6 +348,8 @@ fn compute_bip( coinbase: H160, evm_configuration: &Config, ) -> anyhow::Result { + let mut evm_account_storage = + init_account_storage().context("Failed to initialize EVM account storage")?; let constants: BlockConstants = block_in_progress.constants( chain_id, minimum_base_fee_per_gas, @@ -362,7 +363,7 @@ fn compute_bip( &mut block_in_progress, &constants, precompiles, - evm_account_storage, + &mut evm_account_storage, sequencer_pool_address, limits, tracer_input, @@ -490,8 +491,6 @@ pub fn produce( // in blocks is set to the pool address. let coinbase = sequencer_pool_address.unwrap_or_default(); - let mut evm_account_storage = - init_account_storage().context("Failed to initialize EVM account storage")?; let mut tick_counter = TickCounter::new(0u64); let mut safe_host = SafeStorage { host }; @@ -542,7 +541,6 @@ pub fn produce( &outbox_queue, block_in_progress, &precompiles, - &mut evm_account_storage, &mut tick_counter, sequencer_pool_address, &config.limits, -- GitLab From 4c983788f3833652b2c1224aad3bbee01d498ef0 Mon Sep 17 00:00:00 2001 From: arnaud Date: Wed, 26 Feb 2025 13:46:09 +0100 Subject: [PATCH 3/8] Etherlink/Kernel: Add minimum_base_fee_per_gas in configuration limits --- etherlink/kernel_evm/kernel/src/block.rs | 9 ++------- etherlink/kernel_evm/kernel/src/configuration.rs | 8 ++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index 01e23f58a4b6..b2d358a42caa 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -255,7 +255,6 @@ fn next_bip_from_blueprints( tick_counter: &TickCounter, config: &mut Configuration, kernel_upgrade: &Option, - minimum_base_fee_per_gas: U256, ) -> Result { let ( current_block_number, @@ -308,7 +307,7 @@ fn next_bip_from_blueprints( let gas_price = crate::gas_price::base_fee_per_gas( host, blueprint.timestamp, - minimum_base_fee_per_gas, + config.limits.minimum_base_fee_per_gas, ); let bip = block_in_progress::BlockInProgress::from_blueprint( @@ -343,7 +342,6 @@ fn compute_bip( limits: &Limits, tracer_input: Option, chain_id: U256, - minimum_base_fee_per_gas: U256, da_fee_per_byte: U256, coinbase: H160, evm_configuration: &Config, @@ -352,7 +350,7 @@ fn compute_bip( init_account_storage().context("Failed to initialize EVM account storage")?; let constants: BlockConstants = block_in_progress.constants( chain_id, - minimum_base_fee_per_gas, + limits.minimum_base_fee_per_gas, da_fee_per_byte, GAS_LIMIT, coinbase, @@ -482,7 +480,6 @@ pub fn produce( tracer_input: Option, ) -> Result { let chain_id = config.chain_config.chain_id; - let minimum_base_fee_per_gas = crate::retrieve_minimum_base_fee_per_gas(host)?; let da_fee_per_byte = crate::retrieve_da_fee(host)?; let kernel_upgrade = upgrade::read_kernel_upgrade(host)?; @@ -515,7 +512,6 @@ pub fn produce( &tick_counter, config, &kernel_upgrade, - minimum_base_fee_per_gas, )? { BlueprintParsing::Next(bip) => bip, BlueprintParsing::None => { @@ -546,7 +542,6 @@ pub fn produce( &config.limits, tracer_input, chain_id, - minimum_base_fee_per_gas, da_fee_per_byte, coinbase, &config.chain_config.evm_configuration, diff --git a/etherlink/kernel_evm/kernel/src/configuration.rs b/etherlink/kernel_evm/kernel/src/configuration.rs index a44e1b2f7f5c..e9dadbdbf637 100644 --- a/etherlink/kernel_evm/kernel/src/configuration.rs +++ b/etherlink/kernel_evm/kernel/src/configuration.rs @@ -7,6 +7,8 @@ use crate::{ blueprint_storage::DEFAULT_MAX_BLUEPRINT_LOOKAHEAD_IN_SECONDS, chains::ChainFamily, delayed_inbox::DelayedInbox, + fees::MINIMUM_BASE_FEE_PER_GAS, + retrieve_minimum_base_fee_per_gas, storage::{ dal_slots, enable_dal, evm_node_flag, is_enable_fa_bridge, max_blueprint_lookahead_in_seconds, read_admin, read_delayed_transaction_bridge, @@ -107,6 +109,7 @@ impl ChainConfig { pub struct Limits { pub maximum_allowed_ticks: u64, pub maximum_gas_limit: u64, + pub minimum_base_fee_per_gas: U256, } impl Default for Limits { @@ -114,6 +117,7 @@ impl Default for Limits { Self { maximum_allowed_ticks: MAX_ALLOWED_TICKS, maximum_gas_limit: MAXIMUM_GAS_LIMIT, + minimum_base_fee_per_gas: MINIMUM_BASE_FEE_PER_GAS.into(), } } } @@ -231,9 +235,13 @@ pub fn fetch_limits(host: &mut impl Runtime) -> Limits { let maximum_gas_limit = read_or_set_maximum_gas_per_transaction(host).unwrap_or(MAXIMUM_GAS_LIMIT); + let minimum_base_fee_per_gas = retrieve_minimum_base_fee_per_gas(host) + .unwrap_or(MINIMUM_BASE_FEE_PER_GAS.into()); + Limits { maximum_allowed_ticks, maximum_gas_limit, + minimum_base_fee_per_gas, } } -- GitLab From ee70020c8747c4382ac02a38e6ffae8aeee3cca3 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 27 Feb 2025 11:08:10 +0100 Subject: [PATCH 4/8] Etherlink/kernel: Extract maximum allocated ticks of the Limits structure --- etherlink/kernel_evm/kernel/src/block.rs | 34 +++++++------------ .../kernel/src/blueprint_storage.rs | 2 ++ .../kernel_evm/kernel/src/configuration.rs | 12 +++---- etherlink/kernel_evm/kernel/src/inbox.rs | 17 ++++------ etherlink/kernel_evm/kernel/src/lib.rs | 9 ++--- etherlink/kernel_evm/kernel/src/simulation.rs | 11 +++--- etherlink/kernel_evm/kernel/src/stage_one.rs | 6 ++++ 7 files changed, 41 insertions(+), 50 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index b2d358a42caa..da35f7b19e5e 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -120,6 +120,7 @@ fn compute( precompiles: &PrecompileBTreeMap, evm_account_storage: &mut EthereumAccountStorage, sequencer_pool_address: Option, + maximum_allowed_ticks: u64, limits: &Limits, tracer_input: Option, evm_configuration: &Config, @@ -139,7 +140,7 @@ fn compute( log!(host, Benchmarking, "Transaction data size: {}", data_size); // The current number of ticks remaining for the current `kernel_run` is allocated for the transaction. let allocated_ticks = estimate_remaining_ticks_for_transaction_execution( - limits.maximum_allowed_ticks, + maximum_allowed_ticks, block_in_progress.estimated_ticks_in_run, data_size, ); @@ -340,6 +341,7 @@ fn compute_bip( tick_counter: &mut TickCounter, sequencer_pool_address: Option, limits: &Limits, + maximum_allowed_ticks: u64, tracer_input: Option, chain_id: U256, da_fee_per_byte: U256, @@ -363,6 +365,7 @@ fn compute_bip( precompiles, &mut evm_account_storage, sequencer_pool_address, + maximum_allowed_ticks, limits, tracer_input, evm_configuration, @@ -540,6 +543,7 @@ pub fn produce( &mut tick_counter, sequencer_pool_address, &config.limits, + config.maximum_allowed_ticks, tracer_input, chain_id, da_fee_per_byte, @@ -615,6 +619,7 @@ mod tests { use crate::storage::read_block_in_progress; use crate::storage::read_last_info_per_level_timestamp; use crate::storage::{read_transaction_receipt, read_transaction_receipt_status}; + use crate::tick_model::constants::MAX_ALLOWED_TICKS; use crate::{retrieve_block_fees, retrieve_chain_id}; use evm_execution::account_storage::{ account_path, init_account_storage, EthereumAccountStorage, @@ -1317,8 +1322,7 @@ mod tests { vec![0; 32], ); // run is almost full wrt ticks - let limits = Limits::default(); - block_in_progress.estimated_ticks_in_run = limits.maximum_allowed_ticks - 1000; + block_in_progress.estimated_ticks_in_run = MAX_ALLOWED_TICKS - 1000; // act let result = compute( @@ -1329,7 +1333,8 @@ mod tests { &precompiles, &mut evm_account_storage, None, - &limits, + MAX_ALLOWED_TICKS, + &Limits::default(), None, &EVMVersion::current_test_config(), ) @@ -1602,13 +1607,8 @@ mod tests { host.reboot_left().expect("should be some reboot left"); // Set the tick limit to 11bn ticks - 2bn, which is the old limit minus the safety margin. - let limits = Limits { - maximum_allowed_ticks: 9_000_000_000, - ..Limits::default() - }; - let mut configuration = Configuration { - limits, + maximum_allowed_ticks: 9_000_000_000, ..dummy_configuration(EVMVersion::current_test_config()) }; @@ -1682,13 +1682,8 @@ mod tests { store_blueprints(&mut host, proposals); // Set the tick limit to 11bn ticks - 2bn, which is the old limit minus the safety margin. - let limits = Limits { - maximum_allowed_ticks: 9_000_000_000, - ..Limits::default() - }; - let mut configuration = Configuration { - limits, + maximum_allowed_ticks: 9_000_000_000, ..dummy_configuration(EVMVersion::current_test_config()) }; store_block_fees(&mut host, &dummy_block_fees()).unwrap(); @@ -1839,13 +1834,8 @@ mod tests { store_inbox_blueprint(&mut host, blueprint(proposals_first_reboot)).unwrap(); // Set the tick limit to 11bn ticks - 2bn, which is the old limit minus the safety margin. - let limits = Limits { - maximum_allowed_ticks: 9_000_000_000, - ..Limits::default() - }; - let mut configuration = Configuration { - limits, + maximum_allowed_ticks: 9_000_000_000, ..dummy_configuration(EVMVersion::current_test_config()) }; // sanity check: no current block diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index d45ec5c70594..1605af2b562b 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -644,6 +644,7 @@ mod tests { use crate::delayed_inbox::Hash; use crate::sequencer_blueprint::rlp_roundtrip; use crate::storage::store_last_info_per_level_timestamp; + use crate::tick_model::constants::MAX_ALLOWED_TICKS; use primitive_types::H256; use tezos_crypto_rs::hash::ContractKt1Hash; use tezos_ethereum::transaction::TRANSACTION_HASH_SIZE; @@ -679,6 +680,7 @@ mod tests { evm_node_flag: false, max_blueprint_lookahead_in_seconds: 100_000i64, }, + maximum_allowed_ticks: MAX_ALLOWED_TICKS, limits: Limits::default(), enable_fa_bridge: false, chain_config: ChainConfig::default(), diff --git a/etherlink/kernel_evm/kernel/src/configuration.rs b/etherlink/kernel_evm/kernel/src/configuration.rs index e9dadbdbf637..9c7f41b0afec 100644 --- a/etherlink/kernel_evm/kernel/src/configuration.rs +++ b/etherlink/kernel_evm/kernel/src/configuration.rs @@ -107,7 +107,6 @@ impl ChainConfig { } pub struct Limits { - pub maximum_allowed_ticks: u64, pub maximum_gas_limit: u64, pub minimum_base_fee_per_gas: U256, } @@ -115,7 +114,6 @@ pub struct Limits { impl Default for Limits { fn default() -> Self { Self { - maximum_allowed_ticks: MAX_ALLOWED_TICKS, maximum_gas_limit: MAXIMUM_GAS_LIMIT, minimum_base_fee_per_gas: MINIMUM_BASE_FEE_PER_GAS.into(), } @@ -126,6 +124,7 @@ pub struct Configuration { pub tezos_contracts: TezosContracts, pub mode: ConfigurationMode, pub limits: Limits, + pub maximum_allowed_ticks: u64, pub enable_fa_bridge: bool, pub chain_config: ChainConfig, pub garbage_collect_blocks: bool, @@ -137,6 +136,7 @@ impl Default for Configuration { tezos_contracts: TezosContracts::default(), mode: ConfigurationMode::Proxy, limits: Limits::default(), + maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), garbage_collect_blocks: false, @@ -229,9 +229,6 @@ fn fetch_tezos_contracts(host: &mut impl Runtime) -> TezosContracts { } pub fn fetch_limits(host: &mut impl Runtime) -> Limits { - let maximum_allowed_ticks = - read_maximum_allowed_ticks(host).unwrap_or(MAX_ALLOWED_TICKS); - let maximum_gas_limit = read_or_set_maximum_gas_per_transaction(host).unwrap_or(MAXIMUM_GAS_LIMIT); @@ -239,7 +236,6 @@ pub fn fetch_limits(host: &mut impl Runtime) -> Limits { .unwrap_or(MINIMUM_BASE_FEE_PER_GAS.into()); Limits { - maximum_allowed_ticks, maximum_gas_limit, minimum_base_fee_per_gas, } @@ -260,6 +256,8 @@ pub fn fetch_configuration( chain_id: U256, ) -> Configuration { let tezos_contracts = fetch_tezos_contracts(host); + let maximum_allowed_ticks = + read_maximum_allowed_ticks(host).unwrap_or(MAX_ALLOWED_TICKS); let limits = fetch_limits(host); let sequencer = sequencer(host).unwrap_or_default(); let enable_fa_bridge = is_enable_fa_bridge(host).unwrap_or_default(); @@ -293,6 +291,7 @@ pub fn fetch_configuration( evm_node_flag, max_blueprint_lookahead_in_seconds, }, + maximum_allowed_ticks, limits, enable_fa_bridge, chain_config, @@ -310,6 +309,7 @@ pub fn fetch_configuration( None => Configuration { tezos_contracts, mode: ConfigurationMode::Proxy, + maximum_allowed_ticks, limits, enable_fa_bridge, chain_config, diff --git a/etherlink/kernel_evm/kernel/src/inbox.rs b/etherlink/kernel_evm/kernel/src/inbox.rs index 7c80f4a37cd7..4aeddab4c99d 100644 --- a/etherlink/kernel_evm/kernel/src/inbox.rs +++ b/etherlink/kernel_evm/kernel/src/inbox.rs @@ -7,7 +7,7 @@ use crate::blueprint_storage::store_sequencer_blueprint; use crate::bridge::Deposit; -use crate::configuration::{fetch_limits, DalConfiguration, TezosContracts}; +use crate::configuration::{DalConfiguration, TezosContracts}; use crate::dal::fetch_and_parse_sequencer_blueprint_from_dal; use crate::dal_slot_import_signal::DalSlotImportSignals; use crate::delayed_inbox::DelayedInbox; @@ -687,6 +687,7 @@ pub fn read_sequencer_inbox( sequencer: PublicKey, delayed_inbox: &mut DelayedInbox, enable_fa_bridge: bool, + maximum_allowed_ticks: u64, dal: Option, garbage_collect_blocks: bool, evm_configuration: &Config, @@ -696,14 +697,12 @@ pub fn read_sequencer_inbox( // variable remains true, that means that the inbox was already consumed // during this kernel run. let mut inbox_is_empty = true; - let limits = fetch_limits(host); let next_blueprint_number: U256 = crate::blueprint_storage::read_next_blueprint_number(host)?; let mut parsing_context = SequencerParsingContext { sequencer, delayed_bridge, - allocated_ticks: limits - .maximum_allowed_ticks + allocated_ticks: maximum_allowed_ticks .saturating_sub(TICKS_FOR_BLUEPRINT_INTERCEPT), dal_configuration: dal, buffer_transaction_chunks: None, @@ -717,9 +716,7 @@ pub fn read_sequencer_inbox( host, Benchmarking, "Estimated ticks: {}", - limits - .maximum_allowed_ticks - .saturating_sub(parsing_context.allocated_ticks) + maximum_allowed_ticks.saturating_sub(parsing_context.allocated_ticks) ); return Ok(StageOneStatus::Reboot); }; @@ -753,9 +750,7 @@ pub fn read_sequencer_inbox( host, Benchmarking, "Estimated ticks: {}", - limits - .maximum_allowed_ticks - .saturating_sub(parsing_context.allocated_ticks) + maximum_allowed_ticks.saturating_sub(parsing_context.allocated_ticks) ); return Ok(StageOneStatus::Done); } @@ -778,6 +773,7 @@ mod tests { use crate::inbox::TransactionContent::Ethereum; use crate::parsing::RollupType; use crate::storage::*; + use crate::tick_model::constants::MAX_ALLOWED_TICKS; use evm_execution::configuration::EVMVersion; use primitive_types::U256; use std::fmt::Write; @@ -1435,6 +1431,7 @@ mod tests { pk.clone(), &mut delayed_inbox, false, + MAX_ALLOWED_TICKS, None, false, &EVMVersion::current_test_config(), diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index 436caee611fc..27f6ca1d4ba7 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -362,7 +362,7 @@ mod tests { use crate::block_storage; use crate::blueprint_storage::store_inbox_blueprint_by_number; - use crate::configuration::{ChainConfig, Configuration, Limits}; + use crate::configuration::{ChainConfig, Configuration}; use crate::fees; use crate::main; use crate::parsing::RollupType; @@ -588,13 +588,8 @@ mod tests { let block_fees = dummy_block_fees(); // Set the tick limit to 11bn ticks - 2bn, which is the old limit minus the safety margin. - let limits = Limits { - maximum_allowed_ticks: 9_000_000_000, - ..Limits::default() - }; - let mut configuration = Configuration { - limits, + maximum_allowed_ticks: 9_000_000_000, ..dummy_configuration(EVMVersion::current_test_config()) }; diff --git a/etherlink/kernel_evm/kernel/src/simulation.rs b/etherlink/kernel_evm/kernel/src/simulation.rs index 8e0f4af3e277..4e7708724635 100644 --- a/etherlink/kernel_evm/kernel/src/simulation.rs +++ b/etherlink/kernel_evm/kernel/src/simulation.rs @@ -9,12 +9,12 @@ // when the proxy node simulates directly use crate::block_storage; -use crate::configuration::fetch_limits; use crate::fees::simulation_add_gas_for_fees; use crate::storage::{ - read_last_info_per_level_timestamp, read_sequencer_pool_address, read_tracer_input, + read_last_info_per_level_timestamp, read_maximum_allowed_ticks, + read_sequencer_pool_address, read_tracer_input, }; -use crate::tick_model::constants::MAXIMUM_GAS_LIMIT; +use crate::tick_model::constants::{MAXIMUM_GAS_LIMIT, MAX_ALLOWED_TICKS}; use crate::{error::Error, error::StorageError, storage}; use crate::{parsable, parsing, retrieve_chain_id, tick_model}; @@ -450,10 +450,11 @@ impl Evaluation { let precompiles = precompiles::precompile_set::(enable_fa_withdrawals); let tx_data_size = self.data.len() as u64; - let limits = fetch_limits(host); + let maximum_allowed_ticks = + read_maximum_allowed_ticks(host).unwrap_or(MAX_ALLOWED_TICKS); let allocated_ticks = tick_model::estimate_remaining_ticks_for_transaction_execution( - limits.maximum_allowed_ticks, + maximum_allowed_ticks, 0, tx_data_size, ); diff --git a/etherlink/kernel_evm/kernel/src/stage_one.rs b/etherlink/kernel_evm/kernel/src/stage_one.rs index 4d5c4b433396..f5721a3419ca 100644 --- a/etherlink/kernel_evm/kernel/src/stage_one.rs +++ b/etherlink/kernel_evm/kernel/src/stage_one.rs @@ -124,6 +124,7 @@ fn fetch_sequencer_blueprints( delayed_inbox: &mut DelayedInbox, sequencer: PublicKey, dal: Option, + maximum_allowed_ticks: u64, enable_fa_bridge: bool, garbage_collect_blocks: bool, evm_configuration: &Config, @@ -136,6 +137,7 @@ fn fetch_sequencer_blueprints( sequencer, delayed_inbox, enable_fa_bridge, + maximum_allowed_ticks, dal, garbage_collect_blocks, evm_configuration, @@ -179,6 +181,7 @@ pub fn fetch_blueprints( delayed_inbox, sequencer.clone(), dal.clone(), + config.maximum_allowed_ticks, config.enable_fa_bridge, config.garbage_collect_blocks, &config.chain_config.evm_configuration, @@ -203,6 +206,7 @@ mod tests { UnsignedDalSlotSignals, }, parsing::DAL_SLOT_IMPORT_SIGNAL_TAG, + tick_model::constants::MAX_ALLOWED_TICKS, }; use evm_execution::configuration::EVMVersion; use primitive_types::U256; @@ -275,6 +279,7 @@ mod tests { max_blueprint_lookahead_in_seconds: 100_000i64, }, limits: Limits::default(), + maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), garbage_collect_blocks: false, @@ -290,6 +295,7 @@ mod tests { }, mode: ConfigurationMode::Proxy, limits: Limits::default(), + maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), garbage_collect_blocks: false, -- GitLab From a9edd5d802363dcc78ac05fff7fb90c282a31227 Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 27 Feb 2025 11:13:16 +0100 Subject: [PATCH 5/8] Etherlink/Kernel/Renaming: Rename Limits in EvmLimits --- etherlink/kernel_evm/kernel/src/block.rs | 8 ++++---- etherlink/kernel_evm/kernel/src/blueprint_storage.rs | 6 ++++-- etherlink/kernel_evm/kernel/src/configuration.rs | 12 ++++++------ etherlink/kernel_evm/kernel/src/stage_one.rs | 6 +++--- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index da35f7b19e5e..190c3ff64f73 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -13,7 +13,7 @@ use crate::blueprint_storage::{ store_current_block_header, BlockHeader, BlueprintHeader, EVMBlockHeader, }; use crate::configuration::ConfigurationMode; -use crate::configuration::Limits; +use crate::configuration::EvmLimits; use crate::delayed_inbox::DelayedInbox; use crate::error::Error; use crate::event::Event; @@ -121,7 +121,7 @@ fn compute( evm_account_storage: &mut EthereumAccountStorage, sequencer_pool_address: Option, maximum_allowed_ticks: u64, - limits: &Limits, + limits: &EvmLimits, tracer_input: Option, evm_configuration: &Config, ) -> Result { @@ -340,7 +340,7 @@ fn compute_bip( precompiles: &PrecompileBTreeMap, tick_counter: &mut TickCounter, sequencer_pool_address: Option, - limits: &Limits, + limits: &EvmLimits, maximum_allowed_ticks: u64, tracer_input: Option, chain_id: U256, @@ -1334,7 +1334,7 @@ mod tests { &mut evm_account_storage, None, MAX_ALLOWED_TICKS, - &Limits::default(), + &EvmLimits::default(), None, &EVMVersion::current_test_config(), ) diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index 1605af2b562b..ae6c151f13d0 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -640,7 +640,9 @@ mod tests { use super::*; use crate::block::GENESIS_PARENT_HASH; - use crate::configuration::{ChainConfig, DalConfiguration, Limits, TezosContracts}; + use crate::configuration::{ + ChainConfig, DalConfiguration, EvmLimits, TezosContracts, + }; use crate::delayed_inbox::Hash; use crate::sequencer_blueprint::rlp_roundtrip; use crate::storage::store_last_info_per_level_timestamp; @@ -681,7 +683,7 @@ mod tests { max_blueprint_lookahead_in_seconds: 100_000i64, }, maximum_allowed_ticks: MAX_ALLOWED_TICKS, - limits: Limits::default(), + limits: EvmLimits::default(), enable_fa_bridge: false, chain_config: ChainConfig::default(), garbage_collect_blocks: false, diff --git a/etherlink/kernel_evm/kernel/src/configuration.rs b/etherlink/kernel_evm/kernel/src/configuration.rs index 9c7f41b0afec..365f8856e6e3 100644 --- a/etherlink/kernel_evm/kernel/src/configuration.rs +++ b/etherlink/kernel_evm/kernel/src/configuration.rs @@ -106,12 +106,12 @@ impl ChainConfig { } } -pub struct Limits { +pub struct EvmLimits { pub maximum_gas_limit: u64, pub minimum_base_fee_per_gas: U256, } -impl Default for Limits { +impl Default for EvmLimits { fn default() -> Self { Self { maximum_gas_limit: MAXIMUM_GAS_LIMIT, @@ -123,7 +123,7 @@ impl Default for Limits { pub struct Configuration { pub tezos_contracts: TezosContracts, pub mode: ConfigurationMode, - pub limits: Limits, + pub limits: EvmLimits, pub maximum_allowed_ticks: u64, pub enable_fa_bridge: bool, pub chain_config: ChainConfig, @@ -135,7 +135,7 @@ impl Default for Configuration { Self { tezos_contracts: TezosContracts::default(), mode: ConfigurationMode::Proxy, - limits: Limits::default(), + limits: EvmLimits::default(), maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), @@ -228,14 +228,14 @@ fn fetch_tezos_contracts(host: &mut impl Runtime) -> TezosContracts { } } -pub fn fetch_limits(host: &mut impl Runtime) -> Limits { +pub fn fetch_limits(host: &mut impl Runtime) -> EvmLimits { let maximum_gas_limit = read_or_set_maximum_gas_per_transaction(host).unwrap_or(MAXIMUM_GAS_LIMIT); let minimum_base_fee_per_gas = retrieve_minimum_base_fee_per_gas(host) .unwrap_or(MINIMUM_BASE_FEE_PER_GAS.into()); - Limits { + EvmLimits { maximum_gas_limit, minimum_base_fee_per_gas, } diff --git a/etherlink/kernel_evm/kernel/src/stage_one.rs b/etherlink/kernel_evm/kernel/src/stage_one.rs index f5721a3419ca..e188651c8b25 100644 --- a/etherlink/kernel_evm/kernel/src/stage_one.rs +++ b/etherlink/kernel_evm/kernel/src/stage_one.rs @@ -200,7 +200,7 @@ pub fn fetch_blueprints( #[cfg(test)] mod tests { use crate::{ - configuration::{ChainConfig, Limits}, + configuration::{ChainConfig, EvmLimits}, dal_slot_import_signal::{ DalSlotImportSignals, DalSlotIndicesList, DalSlotIndicesOfLevel, UnsignedDalSlotSignals, @@ -278,7 +278,7 @@ mod tests { evm_node_flag: false, max_blueprint_lookahead_in_seconds: 100_000i64, }, - limits: Limits::default(), + limits: EvmLimits::default(), maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), @@ -294,7 +294,7 @@ mod tests { ..contracts }, mode: ConfigurationMode::Proxy, - limits: Limits::default(), + limits: EvmLimits::default(), maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), -- GitLab From c4bea62a650bc126dda5294a603b696ce7c3d29e Mon Sep 17 00:00:00 2001 From: arnaud Date: Thu, 27 Feb 2025 11:40:56 +0100 Subject: [PATCH 6/8] Etherlink/Kernel: Move EvmLimits in chains.rs as these are limits specific to Ethereum --- etherlink/kernel_evm/kernel/src/block.rs | 2 +- .../kernel/src/blueprint_storage.rs | 5 ++--- etherlink/kernel_evm/kernel/src/chains.rs | 19 +++++++++++++++++++ .../kernel_evm/kernel/src/configuration.rs | 16 +--------------- etherlink/kernel_evm/kernel/src/stage_one.rs | 3 ++- 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index 190c3ff64f73..dca425d1ca0a 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -12,8 +12,8 @@ use crate::blueprint_storage::{ drop_blueprint, read_blueprint, read_current_block_header, store_current_block_header, BlockHeader, BlueprintHeader, EVMBlockHeader, }; +use crate::chains::EvmLimits; use crate::configuration::ConfigurationMode; -use crate::configuration::EvmLimits; use crate::delayed_inbox::DelayedInbox; use crate::error::Error; use crate::event::Event; diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index ae6c151f13d0..3b32f6cd363b 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -640,9 +640,8 @@ mod tests { use super::*; use crate::block::GENESIS_PARENT_HASH; - use crate::configuration::{ - ChainConfig, DalConfiguration, EvmLimits, TezosContracts, - }; + use crate::chains::EvmLimits; + use crate::configuration::{ChainConfig, DalConfiguration, TezosContracts}; use crate::delayed_inbox::Hash; use crate::sequencer_blueprint::rlp_roundtrip; use crate::storage::store_last_info_per_level_timestamp; diff --git a/etherlink/kernel_evm/kernel/src/chains.rs b/etherlink/kernel_evm/kernel/src/chains.rs index 54ee5fa7d406..daf255b2096e 100644 --- a/etherlink/kernel_evm/kernel/src/chains.rs +++ b/etherlink/kernel_evm/kernel/src/chains.rs @@ -2,6 +2,10 @@ // // SPDX-License-Identifier: MIT +use primitive_types::U256; + +use crate::{fees::MINIMUM_BASE_FEE_PER_GAS, tick_model::constants::MAXIMUM_GAS_LIMIT}; + #[derive(Clone, Copy, Debug)] pub enum ChainFamily { Evm, @@ -16,3 +20,18 @@ impl std::fmt::Display for ChainFamily { } } } + +#[derive(Clone, Copy, Debug)] +pub struct EvmLimits { + pub maximum_gas_limit: u64, + pub minimum_base_fee_per_gas: U256, +} + +impl Default for EvmLimits { + fn default() -> Self { + Self { + maximum_gas_limit: MAXIMUM_GAS_LIMIT, + minimum_base_fee_per_gas: MINIMUM_BASE_FEE_PER_GAS.into(), + } + } +} diff --git a/etherlink/kernel_evm/kernel/src/configuration.rs b/etherlink/kernel_evm/kernel/src/configuration.rs index 365f8856e6e3..375cde5975f7 100644 --- a/etherlink/kernel_evm/kernel/src/configuration.rs +++ b/etherlink/kernel_evm/kernel/src/configuration.rs @@ -5,7 +5,7 @@ use crate::{ blueprint_storage::DEFAULT_MAX_BLUEPRINT_LOOKAHEAD_IN_SECONDS, - chains::ChainFamily, + chains::{ChainFamily, EvmLimits}, delayed_inbox::DelayedInbox, fees::MINIMUM_BASE_FEE_PER_GAS, retrieve_minimum_base_fee_per_gas, @@ -106,20 +106,6 @@ impl ChainConfig { } } -pub struct EvmLimits { - pub maximum_gas_limit: u64, - pub minimum_base_fee_per_gas: U256, -} - -impl Default for EvmLimits { - fn default() -> Self { - Self { - maximum_gas_limit: MAXIMUM_GAS_LIMIT, - minimum_base_fee_per_gas: MINIMUM_BASE_FEE_PER_GAS.into(), - } - } -} - pub struct Configuration { pub tezos_contracts: TezosContracts, pub mode: ConfigurationMode, diff --git a/etherlink/kernel_evm/kernel/src/stage_one.rs b/etherlink/kernel_evm/kernel/src/stage_one.rs index e188651c8b25..3b0eb32cf671 100644 --- a/etherlink/kernel_evm/kernel/src/stage_one.rs +++ b/etherlink/kernel_evm/kernel/src/stage_one.rs @@ -200,7 +200,8 @@ pub fn fetch_blueprints( #[cfg(test)] mod tests { use crate::{ - configuration::{ChainConfig, EvmLimits}, + chains::EvmLimits, + configuration::ChainConfig, dal_slot_import_signal::{ DalSlotImportSignals, DalSlotIndicesList, DalSlotIndicesOfLevel, UnsignedDalSlotSignals, -- GitLab From d39fea4239fc747da5c4da3aebf81dcbc2be4c84 Mon Sep 17 00:00:00 2001 From: arnaud Date: Tue, 18 Mar 2025 14:48:18 +0100 Subject: [PATCH 7/8] Etherlink/Kernel: Don't use MINIMUM_BASE_FEE_PER_GAS in configuration.rs The fact that the function retrieve_minimum_base_fee can fail doesn't affect the kernel as the error is catch in configuration.rs, one call is in the simulation and the other is in a test function. --- .../kernel_evm/kernel/src/configuration.rs | 4 +--- etherlink/kernel_evm/kernel/src/lib.rs | 21 ++++++++++++------- etherlink/kernel_evm/kernel/src/simulation.rs | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/configuration.rs b/etherlink/kernel_evm/kernel/src/configuration.rs index 375cde5975f7..0ccd7629d8d5 100644 --- a/etherlink/kernel_evm/kernel/src/configuration.rs +++ b/etherlink/kernel_evm/kernel/src/configuration.rs @@ -7,7 +7,6 @@ use crate::{ blueprint_storage::DEFAULT_MAX_BLUEPRINT_LOOKAHEAD_IN_SECONDS, chains::{ChainFamily, EvmLimits}, delayed_inbox::DelayedInbox, - fees::MINIMUM_BASE_FEE_PER_GAS, retrieve_minimum_base_fee_per_gas, storage::{ dal_slots, enable_dal, evm_node_flag, is_enable_fa_bridge, @@ -218,8 +217,7 @@ pub fn fetch_limits(host: &mut impl Runtime) -> EvmLimits { let maximum_gas_limit = read_or_set_maximum_gas_per_transaction(host).unwrap_or(MAXIMUM_GAS_LIMIT); - let minimum_base_fee_per_gas = retrieve_minimum_base_fee_per_gas(host) - .unwrap_or(MINIMUM_BASE_FEE_PER_GAS.into()); + let minimum_base_fee_per_gas = retrieve_minimum_base_fee_per_gas(host); EvmLimits { maximum_gas_limit, diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index 27f6ca1d4ba7..ce72ec3c9d24 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -142,15 +142,22 @@ fn retrieve_chain_id(host: &mut Host) -> Result { } } -fn retrieve_minimum_base_fee_per_gas( - host: &mut Host, -) -> Result { +fn retrieve_minimum_base_fee_per_gas(host: &mut Host) -> U256 { match read_minimum_base_fee_per_gas(host) { - Ok(minimum_base_fee_per_gas) => Ok(minimum_base_fee_per_gas), + Ok(minimum_base_fee_per_gas) => minimum_base_fee_per_gas, Err(_) => { let minimum_base_fee_per_gas = crate::fees::MINIMUM_BASE_FEE_PER_GAS.into(); - store_minimum_base_fee_per_gas(host, minimum_base_fee_per_gas)?; - Ok(minimum_base_fee_per_gas) + if let Err(err) = + store_minimum_base_fee_per_gas(host, minimum_base_fee_per_gas) + { + log!( + host, + Error, + "Can't store the default minimum_base_fee: {:?}", + err + ); + } + minimum_base_fee_per_gas } } } @@ -188,7 +195,7 @@ fn retrieve_da_fee(host: &mut Host) -> Result { fn retrieve_block_fees( host: &mut Host, ) -> Result { - let minimum_base_fee_per_gas = retrieve_minimum_base_fee_per_gas(host)?; + let minimum_base_fee_per_gas = retrieve_minimum_base_fee_per_gas(host); let base_fee_per_gas = retrieve_base_fee_per_gas(host, minimum_base_fee_per_gas); let da_fee = retrieve_da_fee(host)?; let block_fees = tezos_ethereum::block::BlockFees::new( diff --git a/etherlink/kernel_evm/kernel/src/simulation.rs b/etherlink/kernel_evm/kernel/src/simulation.rs index 4e7708724635..af6dc6b30e51 100644 --- a/etherlink/kernel_evm/kernel/src/simulation.rs +++ b/etherlink/kernel_evm/kernel/src/simulation.rs @@ -373,7 +373,7 @@ impl Evaluation { evm_configuration: &Config, ) -> Result, Error> { let chain_id = retrieve_chain_id(host)?; - let minimum_base_fee_per_gas = crate::retrieve_minimum_base_fee_per_gas(host)?; + let minimum_base_fee_per_gas = crate::retrieve_minimum_base_fee_per_gas(host); let da_fee = crate::retrieve_da_fee(host)?; let coinbase = read_sequencer_pool_address(host).unwrap_or_default(); let mut evm_account_storage = account_storage::init_account_storage() -- GitLab From 75759354955dce28828e1a994d3fb1a947c95906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?= Date: Sat, 1 Mar 2025 13:12:03 +0100 Subject: [PATCH 8/8] Etherlink/Kernel: Introduce Chain Configuration for Ethereum and for Tezos --- etherlink/kernel_evm/kernel/src/block.rs | 94 +++++++++------- .../kernel/src/blueprint_storage.rs | 5 +- etherlink/kernel_evm/kernel/src/chains.rs | 104 +++++++++++++++++- .../kernel_evm/kernel/src/configuration.rs | 57 ++-------- etherlink/kernel_evm/kernel/src/inbox.rs | 47 ++++---- etherlink/kernel_evm/kernel/src/lib.rs | 9 +- etherlink/kernel_evm/kernel/src/stage_one.rs | 26 ++--- 7 files changed, 210 insertions(+), 132 deletions(-) diff --git a/etherlink/kernel_evm/kernel/src/block.rs b/etherlink/kernel_evm/kernel/src/block.rs index dca425d1ca0a..1555f0bad979 100644 --- a/etherlink/kernel_evm/kernel/src/block.rs +++ b/etherlink/kernel_evm/kernel/src/block.rs @@ -12,7 +12,7 @@ use crate::blueprint_storage::{ drop_blueprint, read_blueprint, read_current_block_header, store_current_block_header, BlockHeader, BlueprintHeader, EVMBlockHeader, }; -use crate::chains::EvmLimits; +use crate::chains::{ChainConfig, EvmLimits}; use crate::configuration::ConfigurationMode; use crate::delayed_inbox::DelayedInbox; use crate::error::Error; @@ -305,28 +305,33 @@ fn next_bip_from_blueprints( return Ok(BlueprintParsing::None); } } - let gas_price = crate::gas_price::base_fee_per_gas( - host, - blueprint.timestamp, - config.limits.minimum_base_fee_per_gas, - ); - - let bip = block_in_progress::BlockInProgress::from_blueprint( - blueprint, - current_block_number, - current_block_parent_hash, - tick_counter.c, - gas_price, - receipts_root, - transactions_root, - ); - - tezos_evm_logging::log!( - host, - tezos_evm_logging::Level::Debug, - "bip: {bip:?}" - ); - Ok(BlueprintParsing::Next(Box::new(bip))) + match &config.chain_config { + ChainConfig::Evm(chain_config) => { + let gas_price = crate::gas_price::base_fee_per_gas( + host, + blueprint.timestamp, + chain_config.limits.minimum_base_fee_per_gas, + ); + + let bip = block_in_progress::BlockInProgress::from_blueprint( + blueprint, + current_block_number, + current_block_parent_hash, + tick_counter.c, + gas_price, + receipts_root, + transactions_root, + ); + + tezos_evm_logging::log!( + host, + tezos_evm_logging::Level::Debug, + "bip: {bip:?}" + ); + Ok(BlueprintParsing::Next(Box::new(bip))) + } + ChainConfig::Michelson(_) => panic!("Implement Tezlink"), + } } None => Ok(BlueprintParsing::None), } @@ -482,7 +487,7 @@ pub fn produce( sequencer_pool_address: Option, tracer_input: Option, ) -> Result { - let chain_id = config.chain_config.chain_id; + let chain_id = config.chain_config.get_chain_id(); let da_fee_per_byte = crate::retrieve_da_fee(host)?; let kernel_upgrade = upgrade::read_kernel_upgrade(host)?; @@ -535,21 +540,25 @@ pub fn produce( }; let processed_blueprint = block_in_progress.number; - match compute_bip( - &mut safe_host, - &outbox_queue, - block_in_progress, - &precompiles, - &mut tick_counter, - sequencer_pool_address, - &config.limits, - config.maximum_allowed_ticks, - tracer_input, - chain_id, - da_fee_per_byte, - coinbase, - &config.chain_config.evm_configuration, - ) { + let computation_result = match &config.chain_config { + ChainConfig::Evm(chain_config) => compute_bip( + &mut safe_host, + &outbox_queue, + block_in_progress, + &precompiles, + &mut tick_counter, + sequencer_pool_address, + &chain_config.limits, + config.maximum_allowed_ticks, + tracer_input, + chain_id, + da_fee_per_byte, + coinbase, + &chain_config.evm_config, + ), + ChainConfig::Michelson(_) => panic!("Implement Tezlink"), + }; + match computation_result { Ok(BlockComputationResult::Finished { included_delayed_transactions, block, @@ -609,7 +618,6 @@ mod tests { 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::configuration::ChainConfig; use crate::fees::DA_FEE_PER_BYTE; use crate::fees::MINIMUM_BASE_FEE_PER_GAS; use crate::inbox::Transaction; @@ -687,7 +695,11 @@ mod tests { fn dummy_configuration(evm_configuration: Config) -> Configuration { Configuration { - chain_config: ChainConfig::new_evm_config(DUMMY_CHAIN_ID, evm_configuration), + chain_config: ChainConfig::new_evm_config( + DUMMY_CHAIN_ID, + EvmLimits::default(), + evm_configuration, + ), ..Configuration::default() } } diff --git a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs index 3b32f6cd363b..1df6f8bef9c0 100644 --- a/etherlink/kernel_evm/kernel/src/blueprint_storage.rs +++ b/etherlink/kernel_evm/kernel/src/blueprint_storage.rs @@ -640,8 +640,8 @@ mod tests { use super::*; use crate::block::GENESIS_PARENT_HASH; - use crate::chains::EvmLimits; - use crate::configuration::{ChainConfig, DalConfiguration, TezosContracts}; + use crate::chains::ChainConfig; + use crate::configuration::{DalConfiguration, TezosContracts}; use crate::delayed_inbox::Hash; use crate::sequencer_blueprint::rlp_roundtrip; use crate::storage::store_last_info_per_level_timestamp; @@ -682,7 +682,6 @@ mod tests { max_blueprint_lookahead_in_seconds: 100_000i64, }, maximum_allowed_ticks: MAX_ALLOWED_TICKS, - limits: EvmLimits::default(), enable_fa_bridge: false, chain_config: ChainConfig::default(), garbage_collect_blocks: false, diff --git a/etherlink/kernel_evm/kernel/src/chains.rs b/etherlink/kernel_evm/kernel/src/chains.rs index daf255b2096e..7906077b5938 100644 --- a/etherlink/kernel_evm/kernel/src/chains.rs +++ b/etherlink/kernel_evm/kernel/src/chains.rs @@ -2,9 +2,13 @@ // // SPDX-License-Identifier: MIT +use evm_execution::configuration::EVMVersion; use primitive_types::U256; -use crate::{fees::MINIMUM_BASE_FEE_PER_GAS, tick_model::constants::MAXIMUM_GAS_LIMIT}; +use crate::{ + configuration::CHAIN_ID, fees::MINIMUM_BASE_FEE_PER_GAS, + tick_model::constants::MAXIMUM_GAS_LIMIT, +}; #[derive(Clone, Copy, Debug)] pub enum ChainFamily { @@ -12,6 +16,62 @@ pub enum ChainFamily { Michelson, } +pub struct EvmChainConfig { + pub chain_id: U256, + pub limits: EvmLimits, + pub evm_config: evm_execution::Config, +} + +impl EvmChainConfig { + pub fn create_config( + chain_id: U256, + limits: EvmLimits, + evm_config: evm_execution::Config, + ) -> Self { + Self { + chain_id, + limits, + evm_config, + } + } +} + +pub struct MichelsonChainConfig { + pub chain_id: U256, +} + +#[allow(clippy::large_enum_variant)] +pub enum ChainConfig { + Evm(EvmChainConfig), + Michelson(MichelsonChainConfig), +} + +impl ChainConfig { + pub fn new_evm_config( + chain_id: U256, + limits: EvmLimits, + evm_config: evm_execution::Config, + ) -> Self { + ChainConfig::Evm(EvmChainConfig::create_config(chain_id, limits, evm_config)) + } + + pub fn get_chain_family(&self) -> ChainFamily { + match self { + ChainConfig::Evm(_) => ChainFamily::Evm, + ChainConfig::Michelson(_) => ChainFamily::Michelson, + } + } + + pub fn get_chain_id(&self) -> U256 { + match self { + ChainConfig::Evm(evm_chain_config) => evm_chain_config.chain_id, + ChainConfig::Michelson(michelson_chain_config) => { + michelson_chain_config.chain_id + } + } + } +} + impl std::fmt::Display for ChainFamily { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -35,3 +95,45 @@ impl Default for EvmLimits { } } } + +impl std::fmt::Display for ChainConfig { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ChainConfig::Evm(chain_config) => write!( + f, + "{{Chain id: {}, Chain family: {}, Limits: {:?}, VMConfig: {:?}}}", + chain_config.chain_id, + ChainFamily::Evm, + chain_config.limits, + chain_config.evm_config + ), + ChainConfig::Michelson(chain_config) => { + write!( + f, + "{{Chain id: {}, Chain family: {}", + chain_config.chain_id, + ChainFamily::Michelson + ) + } + } + } +} + +impl Default for ChainConfig { + fn default() -> Self { + Self::Evm(EvmChainConfig::create_config( + U256::from(CHAIN_ID), + EvmLimits::default(), + EVMVersion::to_config(&EVMVersion::default()), + )) + } +} + +#[cfg(test)] +pub fn test_chain_config() -> ChainConfig { + ChainConfig::new_evm_config( + U256::from(CHAIN_ID), + EvmLimits::default(), + EVMVersion::current_test_config(), + ) +} diff --git a/etherlink/kernel_evm/kernel/src/configuration.rs b/etherlink/kernel_evm/kernel/src/configuration.rs index 0ccd7629d8d5..f2d0ac9192d6 100644 --- a/etherlink/kernel_evm/kernel/src/configuration.rs +++ b/etherlink/kernel_evm/kernel/src/configuration.rs @@ -5,7 +5,7 @@ use crate::{ blueprint_storage::DEFAULT_MAX_BLUEPRINT_LOOKAHEAD_IN_SECONDS, - chains::{ChainFamily, EvmLimits}, + chains::{ChainConfig, EvmLimits}, delayed_inbox::DelayedInbox, retrieve_minimum_base_fee_per_gas, storage::{ @@ -17,11 +17,7 @@ use crate::{ }, tick_model::constants::{MAXIMUM_GAS_LIMIT, MAX_ALLOWED_TICKS}, }; -use evm::Config; -use evm_execution::{ - configuration::{fetch_evm_configuration, EVMVersion}, - read_ticketer, -}; +use evm_execution::{configuration::fetch_evm_configuration, read_ticketer}; use primitive_types::U256; use tezos_crypto_rs::hash::ContractKt1Hash; use tezos_evm_logging::{log, Level::*}; @@ -69,46 +65,9 @@ impl std::fmt::Display for ConfigurationMode { } } -pub struct ChainConfig { - pub chain_id: U256, - pub chain_family: ChainFamily, - pub evm_configuration: Config, -} - -impl Default for ChainConfig { - fn default() -> Self { - Self { - chain_id: U256::from(CHAIN_ID), - chain_family: ChainFamily::Evm, - evm_configuration: EVMVersion::to_config(&EVMVersion::default()), - } - } -} - -impl std::fmt::Display for ChainConfig { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!( - f, - "{{Chain id: {}, Chain informations: {}}}", - self.chain_id, self.chain_family - ) - } -} - -impl ChainConfig { - pub fn new_evm_config(chain_id: U256, evm_configuration: Config) -> Self { - ChainConfig { - chain_id, - chain_family: ChainFamily::Evm, - evm_configuration, - } - } -} - pub struct Configuration { pub tezos_contracts: TezosContracts, pub mode: ConfigurationMode, - pub limits: EvmLimits, pub maximum_allowed_ticks: u64, pub enable_fa_bridge: bool, pub chain_config: ChainConfig, @@ -120,7 +79,6 @@ impl Default for Configuration { Self { tezos_contracts: TezosContracts::default(), mode: ConfigurationMode::Proxy, - limits: EvmLimits::default(), maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, chain_config: ChainConfig::default(), @@ -213,7 +171,7 @@ fn fetch_tezos_contracts(host: &mut impl Runtime) -> TezosContracts { } } -pub fn fetch_limits(host: &mut impl Runtime) -> EvmLimits { +pub fn fetch_evm_limits(host: &mut impl Runtime) -> EvmLimits { let maximum_gas_limit = read_or_set_maximum_gas_per_transaction(host).unwrap_or(MAXIMUM_GAS_LIMIT); @@ -242,13 +200,14 @@ pub fn fetch_configuration( let tezos_contracts = fetch_tezos_contracts(host); let maximum_allowed_ticks = read_maximum_allowed_ticks(host).unwrap_or(MAX_ALLOWED_TICKS); - let limits = fetch_limits(host); + let evm_limits = fetch_evm_limits(host); let sequencer = sequencer(host).unwrap_or_default(); let enable_fa_bridge = is_enable_fa_bridge(host).unwrap_or_default(); let evm_configuration = fetch_evm_configuration(host); let dal: Option = fetch_dal_configuration(host); let evm_node_flag = evm_node_flag(host).unwrap_or(false); - let chain_config = ChainConfig::new_evm_config(chain_id, evm_configuration); + let chain_config = + ChainConfig::new_evm_config(chain_id, evm_limits, evm_configuration); match sequencer { Some(sequencer) => { let delayed_bridge = read_delayed_transaction_bridge(host) @@ -276,7 +235,6 @@ pub fn fetch_configuration( max_blueprint_lookahead_in_seconds, }, maximum_allowed_ticks, - limits, enable_fa_bridge, chain_config, garbage_collect_blocks: !evm_node_flag, @@ -284,7 +242,7 @@ pub fn fetch_configuration( Err(err) => { log!(host, Fatal, "The kernel failed to created the delayed inbox, reverting configuration to proxy ({:?})", err); Configuration { - limits, + chain_config, ..Configuration::default() } } @@ -294,7 +252,6 @@ pub fn fetch_configuration( tezos_contracts, mode: ConfigurationMode::Proxy, maximum_allowed_ticks, - limits, enable_fa_bridge, chain_config, garbage_collect_blocks: false, diff --git a/etherlink/kernel_evm/kernel/src/inbox.rs b/etherlink/kernel_evm/kernel/src/inbox.rs index 4aeddab4c99d..608add59a3d4 100644 --- a/etherlink/kernel_evm/kernel/src/inbox.rs +++ b/etherlink/kernel_evm/kernel/src/inbox.rs @@ -7,6 +7,7 @@ use crate::blueprint_storage::store_sequencer_blueprint; use crate::bridge::Deposit; +use crate::chains::ChainConfig; use crate::configuration::{DalConfiguration, TezosContracts}; use crate::dal::fetch_and_parse_sequencer_blueprint_from_dal; use crate::dal_slot_import_signal::DalSlotImportSignals; @@ -29,7 +30,6 @@ use crate::tick_model::maximum_ticks_for_sequencer_chunk; use crate::upgrade::*; use crate::Error; use crate::{simulation, upgrade}; -use evm::Config; use evm_execution::fa_bridge::{deposit::FaDeposit, FA_DEPOSIT_PROXY_GAS_LIMIT}; use evm_execution::EthereumError; use primitive_types::U256; @@ -573,7 +573,7 @@ fn read_and_dispatch_input( res: &mut Mode::Inbox, enable_fa_bridge: bool, garbage_collect_blocks: bool, - evm_configuration: &Config, + chain_configuration: &ChainConfig, ) -> anyhow::Result { let input: InputResult = read_input( host, @@ -601,7 +601,14 @@ fn read_and_dispatch_input( // kernel enters in simulation mode, reading will be done by the // simulation and all the previous and next transactions are // discarded. - simulation::start_simulation_mode(host, enable_fa_bridge, evm_configuration)?; + match chain_configuration { + ChainConfig::Evm(evm) => simulation::start_simulation_mode( + host, + enable_fa_bridge, + &evm.evm_config, + ), + ChainConfig::Michelson(_) => Ok(()), + }?; Ok(ReadStatus::FinishedIgnore) } InputResult::Input(input) => { @@ -617,7 +624,7 @@ pub fn read_proxy_inbox( tezos_contracts: &TezosContracts, enable_fa_bridge: bool, garbage_collect_blocks: bool, - evm_configuration: &Config, + chain_configuration: &ChainConfig, ) -> Result, anyhow::Error> { let mut res = ProxyInboxContent { transactions: vec![], @@ -637,7 +644,7 @@ pub fn read_proxy_inbox( &mut res, enable_fa_bridge, garbage_collect_blocks, - evm_configuration, + chain_configuration, ) { Err(err) => // If we failed to read or dispatch the input. @@ -690,7 +697,7 @@ pub fn read_sequencer_inbox( maximum_allowed_ticks: u64, dal: Option, garbage_collect_blocks: bool, - evm_configuration: &Config, + chain_configuration: &ChainConfig, ) -> Result { // The mutable variable is used to retrieve the information of whether the // inbox was empty or not. As we consume all the inbox in one go, if the @@ -729,7 +736,7 @@ pub fn read_sequencer_inbox( delayed_inbox, enable_fa_bridge, garbage_collect_blocks, - evm_configuration, + chain_configuration, ) { Err(err) => // If we failed to read or dispatch the input. @@ -766,6 +773,7 @@ mod tests { blueprint_path, store_current_block_header, BlockHeader, BlueprintHeader, EVMBlockHeader, }; + use crate::chains::test_chain_config; use crate::configuration::TezosContracts; use crate::dal_slot_import_signal::{ DalSlotIndicesList, DalSlotIndicesOfLevel, UnsignedDalSlotSignals, @@ -774,7 +782,6 @@ mod tests { use crate::parsing::RollupType; use crate::storage::*; use crate::tick_model::constants::MAX_ALLOWED_TICKS; - use evm_execution::configuration::EVMVersion; use primitive_types::U256; use std::fmt::Write; use tezos_crypto_rs::hash::SmartRollupHash; @@ -921,7 +928,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap() .unwrap(); @@ -953,7 +960,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap() .unwrap(); @@ -1010,7 +1017,7 @@ mod tests { }, false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap() .unwrap(); @@ -1057,7 +1064,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap(); @@ -1109,7 +1116,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap(); @@ -1149,7 +1156,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap(); @@ -1206,7 +1213,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap() .unwrap(); @@ -1228,7 +1235,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap() .unwrap(); @@ -1291,7 +1298,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap() .unwrap(); @@ -1316,7 +1323,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap(); assert!(inbox_content.is_some()); @@ -1328,7 +1335,7 @@ mod tests { &TezosContracts::default(), false, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap(); assert!(inbox_content.is_none()); @@ -1434,7 +1441,7 @@ mod tests { MAX_ALLOWED_TICKS, None, false, - &EVMVersion::current_test_config(), + &test_chain_config(), ) .unwrap(); diff --git a/etherlink/kernel_evm/kernel/src/lib.rs b/etherlink/kernel_evm/kernel/src/lib.rs index ce72ec3c9d24..6eefbba8977a 100644 --- a/etherlink/kernel_evm/kernel/src/lib.rs +++ b/etherlink/kernel_evm/kernel/src/lib.rs @@ -369,7 +369,8 @@ mod tests { use crate::block_storage; use crate::blueprint_storage::store_inbox_blueprint_by_number; - use crate::configuration::{ChainConfig, Configuration}; + use crate::chains::{ChainConfig, EvmLimits}; + use crate::configuration::Configuration; use crate::fees; use crate::main; use crate::parsing::RollupType; @@ -426,7 +427,11 @@ mod tests { fn dummy_configuration(evm_configuration: Config) -> Configuration { Configuration { - chain_config: ChainConfig::new_evm_config(DUMMY_CHAIN_ID, evm_configuration), + chain_config: ChainConfig::new_evm_config( + DUMMY_CHAIN_ID, + EvmLimits::default(), + evm_configuration, + ), ..Configuration::default() } } diff --git a/etherlink/kernel_evm/kernel/src/stage_one.rs b/etherlink/kernel_evm/kernel/src/stage_one.rs index 3b0eb32cf671..86f89e6a8033 100644 --- a/etherlink/kernel_evm/kernel/src/stage_one.rs +++ b/etherlink/kernel_evm/kernel/src/stage_one.rs @@ -8,6 +8,7 @@ use crate::blueprint_storage::{ clear_all_blueprints, read_current_blueprint_header, store_forced_blueprint, store_inbox_blueprint, }; +use crate::chains::ChainConfig; use crate::configuration::{ Configuration, ConfigurationMode, DalConfiguration, TezosContracts, }; @@ -17,7 +18,6 @@ use crate::inbox::{read_proxy_inbox, read_sequencer_inbox}; use crate::inbox::{ProxyInboxContent, StageOneStatus}; use crate::storage::read_last_info_per_level_timestamp; use anyhow::Ok; -use evm::Config; use std::ops::Add; use tezos_crypto_rs::hash::ContractKt1Hash; use tezos_evm_logging::{log, Level::*}; @@ -32,7 +32,7 @@ pub fn fetch_proxy_blueprints( tezos_contracts: &TezosContracts, enable_fa_bridge: bool, garbage_collect_blocks: bool, - evm_configuration: &Config, + chain_configuration: &ChainConfig, ) -> Result { if let Some(ProxyInboxContent { transactions }) = read_proxy_inbox( host, @@ -40,7 +40,7 @@ pub fn fetch_proxy_blueprints( tezos_contracts, enable_fa_bridge, garbage_collect_blocks, - evm_configuration, + chain_configuration, )? { let timestamp = read_last_info_per_level_timestamp(host).unwrap_or(Timestamp::from(0)); @@ -127,7 +127,7 @@ fn fetch_sequencer_blueprints( maximum_allowed_ticks: u64, enable_fa_bridge: bool, garbage_collect_blocks: bool, - evm_configuration: &Config, + chain_configuration: &ChainConfig, ) -> Result { match read_sequencer_inbox( host, @@ -140,7 +140,7 @@ fn fetch_sequencer_blueprints( maximum_allowed_ticks, dal, garbage_collect_blocks, - evm_configuration, + chain_configuration, )? { StageOneStatus::Done => { // Check if there are timed-out transactions in the delayed inbox @@ -184,7 +184,7 @@ pub fn fetch_blueprints( config.maximum_allowed_ticks, config.enable_fa_bridge, config.garbage_collect_blocks, - &config.chain_config.evm_configuration, + &config.chain_config, ), ConfigurationMode::Proxy => fetch_proxy_blueprints( host, @@ -192,7 +192,7 @@ pub fn fetch_blueprints( &config.tezos_contracts, config.enable_fa_bridge, config.garbage_collect_blocks, - &config.chain_config.evm_configuration, + &config.chain_config, ), } } @@ -200,8 +200,7 @@ pub fn fetch_blueprints( #[cfg(test)] mod tests { use crate::{ - chains::EvmLimits, - configuration::ChainConfig, + chains::test_chain_config, dal_slot_import_signal::{ DalSlotImportSignals, DalSlotIndicesList, DalSlotIndicesOfLevel, UnsignedDalSlotSignals, @@ -209,7 +208,6 @@ mod tests { parsing::DAL_SLOT_IMPORT_SIGNAL_TAG, tick_model::constants::MAX_ALLOWED_TICKS, }; - use evm_execution::configuration::EVMVersion; use primitive_types::U256; use rlp::Encodable; use tezos_crypto_rs::hash::{HashTrait, SecretKeyEd25519, UnknownSignature}; @@ -279,10 +277,9 @@ mod tests { evm_node_flag: false, max_blueprint_lookahead_in_seconds: 100_000i64, }, - limits: EvmLimits::default(), maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, - chain_config: ChainConfig::default(), + chain_config: test_chain_config(), garbage_collect_blocks: false, } } @@ -295,10 +292,9 @@ mod tests { ..contracts }, mode: ConfigurationMode::Proxy, - limits: EvmLimits::default(), maximum_allowed_ticks: MAX_ALLOWED_TICKS, enable_fa_bridge: false, - chain_config: ChainConfig::default(), + chain_config: test_chain_config(), garbage_collect_blocks: false, } } @@ -571,7 +567,7 @@ mod tests { &conf.tezos_contracts, false, false, - &EVMVersion::current_test_config(), + &conf.chain_config, ) .unwrap() { -- GitLab