diff --git a/etherlink/kernel_latest/kernel/src/block.rs b/etherlink/kernel_latest/kernel/src/block.rs index f513f222f257a0e6f4bc3de9db6f7f0088191022..f6a38a84a1ad394a98199235895b859c8fade102 100644 --- a/etherlink/kernel_latest/kernel/src/block.rs +++ b/etherlink/kernel_latest/kernel/src/block.rs @@ -11,11 +11,9 @@ use crate::apply::{ use crate::blueprint::Blueprint; use crate::blueprint_storage::{ drop_blueprint, read_blueprint, read_current_block_header, - store_current_block_header, BlockHeader, ChainHeader, EVMBlockHeader, -}; -use crate::chains::{ - BlockInProgressTrait, ChainConfigTrait, ChainHeaderTrait, EvmChainConfig, EvmLimits, + store_current_block_header, BlockHeader, ChainHeader, }; +use crate::chains::{ChainConfigTrait, ChainHeaderTrait, EvmLimits, TransactionTrait}; use crate::configuration::ConfigurationMode; use crate::delayed_inbox::DelayedInbox; use crate::error::Error; @@ -28,12 +26,12 @@ use crate::upgrade::KernelUpgrade; use crate::Configuration; use crate::{block_in_progress, tick_model}; use anyhow::Context; -use block_in_progress::EthBlockInProgress; +use block_in_progress::BlockInProgress; use primitive_types::{H160, H256, U256}; use revm::primitives::hardfork::SpecId; use revm_etherlink::inspectors::TracerInput; use tezos_ethereum::block::BlockConstants; -use tezos_ethereum::transaction::TransactionHash; +use tezos_ethereum::transaction::{TransactionHash, TransactionReceipt}; use tezos_evm_logging::{__trace_kernel, log, Level::*, Verbosity}; use tezos_evm_runtime::runtime::{IsEvmNode, Runtime}; use tezos_evm_runtime::safe_storage::SafeStorage; @@ -92,14 +90,14 @@ enum BlockInProgressProvenance { Blueprint, } -fn on_invalid_transaction( +fn on_invalid_transaction( host: &mut Host, - transaction: &Transaction, - block_in_progress: &mut EthBlockInProgress, + transaction: &Tx, + block_in_progress: &mut BlockInProgress, data_size: u64, ) { if transaction.is_delayed() { - block_in_progress.register_delayed_transaction(transaction.tx_hash); + block_in_progress.register_delayed_transaction(transaction.tx_hash()); } block_in_progress.account_for_invalid_transaction(data_size); @@ -131,7 +129,7 @@ fn can_fit_in_reboot( fn compute( host: &mut Host, outbox_queue: &OutboxQueue<'_, impl Path>, - block_in_progress: &mut EthBlockInProgress, + block_in_progress: &mut BlockInProgress, block_constants: &BlockConstants, sequencer_pool_address: Option, limits: &EvmLimits, @@ -224,24 +222,20 @@ enum BlueprintParsing { None, } -pub fn eth_bip_from_blueprint( +pub fn bip_from_blueprint( host: &Host, - chain_config: &EvmChainConfig, + chain_config: &ChainConfig, tick_counter: &TickCounter, next_bip_number: U256, - header: EVMBlockHeader, - blueprint: Blueprint, -) -> EthBlockInProgress { - let gas_price = crate::gas_price::base_fee_per_gas( - host, - blueprint.timestamp, - chain_config.get_limits().minimum_base_fee_per_gas, - ); + hash: H256, + blueprint: Blueprint, +) -> BlockInProgress { + let gas_price = chain_config.base_fee_per_gas(host, blueprint.timestamp); - let bip = EthBlockInProgress::from_blueprint( + let bip = BlockInProgress::from_blueprint( blueprint, next_bip_number, - header.hash, + hash, tick_counter.c, gas_price, ); @@ -257,7 +251,11 @@ fn next_bip_from_blueprints( chain_config: &ChainConfig, config: &mut Configuration, kernel_upgrade: &Option, -) -> Result, anyhow::Error> { +) -> anyhow::Result< + BlueprintParsing< + BlockInProgress, + >, +> { let (next_bip_number, timestamp, chain_header) = match read_current_block_header(host) { Err(_) => ( @@ -293,14 +291,17 @@ fn next_bip_from_blueprints( return Ok(BlueprintParsing::None); } } - let bip: ChainConfig::BlockInProgress = chain_config - .block_in_progress_from_blueprint( - host, - tick_counter, - next_bip_number, - chain_header, - blueprint, - )?; + let bip: BlockInProgress< + ChainConfig::Transaction, + ChainConfig::TransactionReceipt, + > = bip_from_blueprint( + host, + chain_config, + tick_counter, + next_bip_number, + chain_header.hash(), + blueprint, + ); Ok(BlueprintParsing::Next(Box::new(bip))) } None => Ok(BlueprintParsing::None), @@ -311,7 +312,7 @@ fn next_bip_from_blueprints( pub fn compute_bip( host: &mut Host, outbox_queue: &OutboxQueue<'_, impl Path>, - mut block_in_progress: EthBlockInProgress, + mut block_in_progress: BlockInProgress, tick_counter: &mut TickCounter, sequencer_pool_address: Option, limits: &EvmLimits, @@ -510,7 +511,7 @@ pub fn produce( } }; - let processed_blueprint = block_in_progress.number(); + let processed_blueprint = block_in_progress.number; let computation_result = chain_config.compute_bip( &mut safe_host, &outbox_queue, @@ -1722,7 +1723,7 @@ mod tests { let transactions = vec![valid_tx].into(); // init block in progress - let mut block_in_progress = EthBlockInProgress::new( + let mut block_in_progress = BlockInProgress::new( U256::from(1), transactions, block_constants.block_fees.base_fee_per_gas(), diff --git a/etherlink/kernel_latest/kernel/src/block_in_progress.rs b/etherlink/kernel_latest/kernel/src/block_in_progress.rs index 0748a191b313f49b14d0a656dcc80036af7b4d28..f062f7175950d5ea0538be0c9dc86f2179b36044 100644 --- a/etherlink/kernel_latest/kernel/src/block_in_progress.rs +++ b/etherlink/kernel_latest/kernel/src/block_in_progress.rs @@ -7,7 +7,7 @@ use crate::apply::{TransactionObjectInfo, TransactionReceiptInfo}; use crate::block_storage; -use crate::chains::ETHERLINK_SAFE_STORAGE_ROOT_PATH; +use crate::chains::{TransactionTrait, ETHERLINK_SAFE_STORAGE_ROOT_PATH}; use crate::error::Error; use crate::error::TransferError::CumulativeGasUsedOverflow; use crate::gas_price::base_fee_per_gas; @@ -36,7 +36,7 @@ use tezos_smart_rollup_host::path::RefPath; #[derive(Debug, PartialEq, Clone)] /// Container for all data needed during block computation -pub struct EthBlockInProgress { +pub struct BlockInProgress { /// block number pub number: U256, /// queue containing the transactions to execute @@ -71,9 +71,9 @@ pub struct EthBlockInProgress { pub cumulative_tx_objects: Vec, } -impl Encodable for EthBlockInProgress { +impl Encodable for BlockInProgress { fn rlp_append(&self, stream: &mut rlp::RlpStream) { - let EthBlockInProgress { + let BlockInProgress { number, tx_queue, valid_txs, @@ -110,7 +110,7 @@ impl Encodable for EthBlockInProgress { } } -fn append_queue(stream: &mut rlp::RlpStream, queue: &VecDeque) { +fn append_queue(stream: &mut rlp::RlpStream, queue: &VecDeque) { stream.begin_list(queue.len()); for transaction in queue { stream.append(transaction); @@ -124,7 +124,10 @@ fn append_txs(stream: &mut rlp::RlpStream, valid_txs: &[[u8; TRANSACTION_HASH_SI }) } -fn append_receipts(stream: &mut rlp::RlpStream, receipts: &[TransactionReceipt]) { +fn append_receipts( + stream: &mut rlp::RlpStream, + receipts: &[Receipt], +) { stream.begin_list(receipts.len()); receipts.iter().for_each(|receipt| { stream.append(receipt); @@ -138,8 +141,8 @@ fn append_tx_objects(stream: &mut rlp::RlpStream, objects: &[TransactionObject]) }) } -impl Decodable for EthBlockInProgress { - fn decode(decoder: &rlp::Rlp<'_>) -> Result { +impl Decodable for BlockInProgress { + fn decode(decoder: &rlp::Rlp<'_>) -> Result { if !decoder.is_list() { return Err(DecoderError::RlpExpectedToBeList); } @@ -149,7 +152,7 @@ impl Decodable for EthBlockInProgress { let mut it = decoder.iter(); let number: U256 = decode_field(&next(&mut it)?, "number")?; - let tx_queue: VecDeque = decode_queue(&next(&mut it)?)?; + let tx_queue: VecDeque = decode_queue(&next(&mut it)?)?; let valid_txs: Vec = decode_valid_txs(&next(&mut it)?)?; let delayed_txs: Vec = decode_valid_txs(&next(&mut it)?)?; let cumulative_gas: U256 = decode_field(&next(&mut it)?, "cumulative_gas")?; @@ -163,8 +166,7 @@ impl Decodable for EthBlockInProgress { let base_fee_per_gas = decode_field(&next(&mut it)?, "base_fee_per_gas")?; let cumulative_execution_gas: U256 = decode_field(&next(&mut it)?, "cumulative_execution_gas")?; - let cumulative_receipts: Vec = - decode_receipts(&next(&mut it)?)?; + let cumulative_receipts: Vec = decode_receipts(&next(&mut it)?)?; let cumulative_tx_objects: Vec = decode_tx_objects(&next(&mut it)?)?; @@ -204,27 +206,29 @@ fn decode_valid_txs( Ok(valid_txs) } -fn decode_queue(decoder: &rlp::Rlp<'_>) -> Result, DecoderError> { +fn decode_queue( + decoder: &rlp::Rlp<'_>, +) -> Result, DecoderError> { if !decoder.is_list() { return Err(DecoderError::RlpExpectedToBeList); } let mut queue = VecDeque::with_capacity(decoder.item_count()?); for item in decoder.iter() { - let tx: Transaction = item.as_val()?; + let tx: Tx = item.as_val()?; queue.push_back(tx); } Ok(queue) } -fn decode_receipts( +fn decode_receipts( decoder: &rlp::Rlp<'_>, -) -> Result, DecoderError> { +) -> Result, DecoderError> { if !decoder.is_list() { return Err(DecoderError::RlpExpectedToBeList); } let mut receipts = Vec::with_capacity(decoder.item_count()?); for item in decoder.iter() { - let receipt: TransactionReceipt = item.as_val()?; + let receipt: Receipt = item.as_val()?; receipts.push(receipt); } Ok(receipts) @@ -244,7 +248,7 @@ fn decode_tx_objects( Ok(objects) } -impl EthBlockInProgress { +impl BlockInProgress { pub fn queue_length(&self) -> usize { self.tx_queue.len() } @@ -253,7 +257,7 @@ impl EthBlockInProgress { pub fn new_with_ticks( number: U256, parent_hash: H256, - transactions: VecDeque, + transactions: VecDeque, estimated_ticks_in_run: u64, timestamp: Timestamp, base_fee_per_gas: U256, @@ -280,11 +284,7 @@ impl EthBlockInProgress { // constructor of raw structure, used in tests #[cfg(test)] - pub fn new( - number: U256, - transactions: VecDeque, - base_fee_per_gas: U256, - ) -> EthBlockInProgress { + pub fn new(number: U256, transactions: VecDeque, base_fee_per_gas: U256) -> Self { Self::new_with_ticks( number, H256::zero(), @@ -325,15 +325,15 @@ impl EthBlockInProgress { } pub fn from_blueprint( - blueprint: crate::blueprint::Blueprint, + blueprint: crate::blueprint::Blueprint, number: U256, parent_hash: H256, tick_counter: u64, base_fee_per_gas: U256, - ) -> EthBlockInProgress { + ) -> Self { // blueprint is turn into a ring to allow popping from the front let ring = blueprint.transactions.into(); - EthBlockInProgress::new_with_ticks( + Self::new_with_ticks( number, parent_hash, ring, @@ -360,6 +360,20 @@ impl EthBlockInProgress { self.delayed_txs.push(hash); } + pub fn account_for_invalid_transaction(&mut self, tx_data_size: u64) { + self.add_ticks(tick_model::ticks_of_invalid_transaction(tx_data_size)); + } + + pub fn pop_tx(&mut self) -> Option { + self.tx_queue.pop_front() + } + + pub fn has_tx(&self) -> bool { + !self.tx_queue.is_empty() + } +} + +impl BlockInProgress { #[instrument(skip_all)] pub fn register_valid_transaction( &mut self, @@ -402,10 +416,6 @@ impl EthBlockInProgress { Ok(()) } - pub fn account_for_invalid_transaction(&mut self, tx_data_size: u64) { - self.add_ticks(tick_model::ticks_of_invalid_transaction(tx_data_size)); - } - fn safe_store_get_hash( host: &mut Host, path: &RefPath, @@ -485,18 +495,10 @@ impl EthBlockInProgress { Ok(new_block) } - pub fn pop_tx(&mut self) -> Option { - self.tx_queue.pop_front() - } - pub fn repush_tx(&mut self, tx: Transaction) { self.tx_queue.push_front(tx) } - pub fn has_tx(&self) -> bool { - !self.tx_queue.is_empty() - } - pub fn make_receipt( &mut self, receipt_info: TransactionReceiptInfo, @@ -579,7 +581,7 @@ impl EthBlockInProgress { #[cfg(test)] mod tests { - use super::EthBlockInProgress; + use super::BlockInProgress; use crate::bridge::Deposit; use crate::transaction::{Transaction, TransactionContent}; use primitive_types::{H160, H256, U256}; @@ -592,6 +594,9 @@ mod tests { }; use tezos_smart_rollup_encoding::timestamp::Timestamp; + type EthBlockInProgress = + BlockInProgress; + fn new_sig_unsafe(v: u64, r: H256, s: H256) -> TxSignature { TxSignature::new(U256::from(v), r, s).unwrap() } diff --git a/etherlink/kernel_latest/kernel/src/chains.rs b/etherlink/kernel_latest/kernel/src/chains.rs index 23a7af79fcb7fad24478e610874f01abcabe0da6..7e5073bb28d3b11534ec0e0ad90b90109eab318f 100644 --- a/etherlink/kernel_latest/kernel/src/chains.rs +++ b/etherlink/kernel_latest/kernel/src/chains.rs @@ -3,9 +3,8 @@ // SPDX-License-Identifier: MIT use crate::{ - block::{eth_bip_from_blueprint, BlockComputationResult, TickCounter}, - block_in_progress::EthBlockInProgress, - blueprint::Blueprint, + block::{BlockComputationResult, TickCounter}, + block_in_progress::BlockInProgress, blueprint_storage::{ read_current_blueprint_header, BlueprintHeader, DelayedTransactionFetchingResult, EVMBlockHeader, TezBlockHeader, @@ -26,10 +25,7 @@ use primitive_types::{H160, H256, U256}; use revm::primitives::hardfork::SpecId; use revm_etherlink::inspectors::TracerInput; use rlp::{Decodable, DecoderError, Encodable}; -use std::{ - collections::VecDeque, - fmt::{Debug, Display}, -}; +use std::fmt::{Debug, Display}; use tezos_crypto_rs::hash::{ChainId, UnknownSignature}; use tezos_data_encoding::{enc::BinWriter, nom::NomReader}; use tezos_ethereum::{ @@ -43,7 +39,6 @@ use tezos_smart_rollup::{outbox::OutboxQueue, types::Timestamp}; use tezos_smart_rollup_host::path::{Path, RefPath}; use tezos_tezlink::{ block::{AppliedOperation, TezBlock}, - enc_wrappers::BlockNumber, operation::{ManagerOperation, ManagerOperationContent, Operation}, operation_result::{ OperationBatchWithMetadata, OperationDataAndMetadata, OperationError, @@ -116,30 +111,6 @@ pub struct MichelsonChainConfig { chain_id: ChainId, } -pub trait BlockInProgressTrait { - fn number(&self) -> U256; -} - -impl BlockInProgressTrait for EthBlockInProgress { - fn number(&self) -> U256 { - self.number - } -} - -pub struct TezBlockInProgress { - number: BlockNumber, - timestamp: Timestamp, - previous_hash: H256, - applied: Vec, - operations: VecDeque, -} - -impl BlockInProgressTrait for TezBlockInProgress { - fn number(&self) -> U256 { - self.number.into() - } -} - pub enum ChainConfig { Evm(Box), Michelson(MichelsonChainConfig), @@ -227,6 +198,35 @@ impl Decodable for TezlinkContent { } } +pub trait TransactionTrait { + fn is_delayed(&self) -> bool; + + fn tx_hash(&self) -> TransactionHash; +} + +impl TransactionTrait for crate::transaction::Transaction { + fn is_delayed(&self) -> bool { + self.is_delayed() + } + + fn tx_hash(&self) -> TransactionHash { + self.tx_hash + } +} + +impl TransactionTrait for TezlinkOperation { + fn is_delayed(&self) -> bool { + match self.content { + TezlinkContent::Tezos(_) => false, + TezlinkContent::Deposit(_) => true, + } + } + + fn tx_hash(&self) -> TransactionHash { + self.tx_hash + } +} + pub trait ChainHeaderTrait { fn hash(&self) -> H256; @@ -259,9 +259,9 @@ impl ChainHeaderTrait for crate::blueprint_storage::TezBlockHeader { } pub trait ChainConfigTrait: Debug { - type Transaction: Encodable + Decodable + Debug; + type Transaction: TransactionTrait + Encodable + Decodable + Debug; - type BlockInProgress: BlockInProgressTrait; + type TransactionReceipt: Debug; type ChainHeader: ChainHeaderTrait + Decodable; @@ -287,25 +287,20 @@ pub trait ChainConfigTrait: Debug { bytes: Vec>, ) -> anyhow::Result>; - fn block_in_progress_from_blueprint( - &self, - host: &impl Runtime, - tick_counter: &crate::block::TickCounter, - current_block_number: U256, - previous_chain_header: Self::ChainHeader, - blueprint: Blueprint, - ) -> anyhow::Result; + fn base_fee_per_gas(&self, host: &impl Runtime, timestamp: Timestamp) -> U256; fn read_block_in_progress( host: &impl Runtime, - ) -> anyhow::Result>; + ) -> anyhow::Result< + Option>, + >; #[allow(clippy::too_many_arguments)] fn compute_bip( &self, host: &mut Host, outbox_queue: &OutboxQueue<'_, impl Path>, - block_in_progress: Self::BlockInProgress, + block_in_progress: BlockInProgress, tick_counter: &mut TickCounter, sequencer_pool_address: Option, maximum_allowed_ticks: u64, @@ -320,7 +315,7 @@ pub trait ChainConfigTrait: Debug { impl ChainConfigTrait for EvmChainConfig { type Transaction = crate::transaction::Transaction; - type BlockInProgress = crate::block_in_progress::EthBlockInProgress; + type TransactionReceipt = tezos_ethereum::transaction::TransactionReceipt; type ChainHeader = crate::blueprint_storage::EVMBlockHeader; @@ -332,22 +327,12 @@ impl ChainConfigTrait for EvmChainConfig { ChainFamily::Evm } - fn block_in_progress_from_blueprint( - &self, - host: &impl Runtime, - tick_counter: &crate::block::TickCounter, - current_block_number: U256, - header: Self::ChainHeader, - blueprint: Blueprint, - ) -> anyhow::Result { - Ok(eth_bip_from_blueprint( + fn base_fee_per_gas(&self, host: &impl Runtime, timestamp: Timestamp) -> U256 { + crate::gas_price::base_fee_per_gas( host, - self, - tick_counter, - current_block_number, - header, - blueprint, - )) + timestamp, + self.get_limits().minimum_base_fee_per_gas, + ) } fn transactions_from_bytes( @@ -373,7 +358,9 @@ impl ChainConfigTrait for EvmChainConfig { fn read_block_in_progress( host: &impl Runtime, - ) -> anyhow::Result> { + ) -> anyhow::Result< + Option>, + > { crate::storage::read_block_in_progress(host) } @@ -381,7 +368,7 @@ impl ChainConfigTrait for EvmChainConfig { &self, host: &mut Host, outbox_queue: &OutboxQueue<'_, impl Path>, - block_in_progress: Self::BlockInProgress, + block_in_progress: BlockInProgress, tick_counter: &mut TickCounter, sequencer_pool_address: Option, _maximum_allowed_ticks: u64, @@ -449,7 +436,7 @@ const TEZLINK_SIMULATION_RESULT_PATH: RefPath = impl ChainConfigTrait for MichelsonChainConfig { type Transaction = TezlinkOperation; - type BlockInProgress = TezBlockInProgress; + type TransactionReceipt = AppliedOperation; type ChainHeader = TezBlockHeader; fn get_chain_id(&self) -> U256 { @@ -460,23 +447,8 @@ impl ChainConfigTrait for MichelsonChainConfig { ChainFamily::Michelson } - fn block_in_progress_from_blueprint( - &self, - _host: &impl Runtime, - _tick_counter: &crate::block::TickCounter, - current_block_number: U256, - header: Self::ChainHeader, - blueprint: Blueprint, - ) -> anyhow::Result { - let operations = blueprint.transactions; - let current_block_number: BlockNumber = current_block_number.try_into()?; - Ok(TezBlockInProgress { - number: current_block_number, - timestamp: blueprint.timestamp, - previous_hash: header.hash, - applied: vec![], - operations: VecDeque::from(operations), - }) + fn base_fee_per_gas(&self, _host: &impl Runtime, _timestamp: Timestamp) -> U256 { + U256::zero() } fn fetch_hashes_from_delayed_inbox( @@ -545,7 +517,9 @@ impl ChainConfigTrait for MichelsonChainConfig { fn read_block_in_progress( _host: &impl Runtime, - ) -> anyhow::Result> { + ) -> anyhow::Result< + Option>, + > { Ok(None) } @@ -553,7 +527,10 @@ impl ChainConfigTrait for MichelsonChainConfig { &self, host: &mut Host, _outbox_queue: &OutboxQueue<'_, impl Path>, - block_in_progress: Self::BlockInProgress, + mut block_in_progress: BlockInProgress< + Self::Transaction, + Self::TransactionReceipt, + >, _tick_counter: &mut TickCounter, _sequencer_pool_address: Option, _maximum_allowed_ticks: u64, @@ -561,33 +538,27 @@ impl ChainConfigTrait for MichelsonChainConfig { _da_fee_per_byte: U256, _coinbase: H160, ) -> anyhow::Result { - let TezBlockInProgress { - number, - timestamp, - previous_hash, - mut applied, - mut operations, - } = block_in_progress; log!( host, Debug, "Computing the BlockInProgress for Tezlink at level {}", - number + block_in_progress.number ); let context = context::Context::from(&self.storage_root_path())?; + let level = block_in_progress.number.try_into()?; + let now = block_in_progress.timestamp; let block_ctx = BlockCtx { - level: &number, - now: ×tamp, + level: &level, + now: &now, chain_id: &self.chain_id, }; let mut included_delayed_transactions = vec![]; // Compute operations that are in the block in progress - while !operations.is_empty() { - // Retrieve the next operation in the VecDequeue - let operation = operations.pop_front().ok_or(error::Error::Reboot)?; + while block_in_progress.has_tx() { + let operation = block_in_progress.pop_tx().ok_or(error::Error::Reboot)?; match operation.content { TezlinkContent::Tezos(operation) => { @@ -636,7 +607,9 @@ impl ChainConfigTrait for MichelsonChainConfig { }, ), }; - applied.push(applied_operation); + block_in_progress + .cumulative_receipts + .push(applied_operation); } TezlinkContent::Deposit(deposit) => { log!(host, Debug, "Execute Tezlink deposit: {deposit:?}"); @@ -649,7 +622,7 @@ impl ChainConfigTrait for MichelsonChainConfig { let applied_operation = AppliedOperation { hash: H256::from_slice(&operation.tx_hash).into(), - branch: block_in_progress.previous_hash.into(), + branch: block_in_progress.parent_hash.into(), op_and_receipt: OperationDataAndMetadata::OperationWithMetadata( OperationBatchWithMetadata { operations: vec![OperationWithMetadata { @@ -676,14 +649,21 @@ impl ChainConfigTrait for MichelsonChainConfig { }, ), }; - applied.push(applied_operation); + block_in_progress + .cumulative_receipts + .push(applied_operation); included_delayed_transactions.push(operation.tx_hash); } }; } // Create a Tezos block from the block in progress - let tezblock = TezBlock::new(number, timestamp, previous_hash, applied)?; + let tezblock = TezBlock::new( + level, + block_in_progress.timestamp, + block_in_progress.parent_hash, + block_in_progress.cumulative_receipts, + )?; let new_block = L2Block::Tezlink(tezblock); let root = self.storage_root_path(); crate::block_storage::store_current(host, &root, &new_block) diff --git a/etherlink/kernel_latest/kernel/src/gas_price.rs b/etherlink/kernel_latest/kernel/src/gas_price.rs index 0d69b769c1b0c8d38668fa51b404cf82bc039a2e..873110cb85a75e9fb368789d259bdb2fe7cfcd4b 100644 --- a/etherlink/kernel_latest/kernel/src/gas_price.rs +++ b/etherlink/kernel_latest/kernel/src/gas_price.rs @@ -4,10 +4,11 @@ //! Adjustments of the gas price (a.k.a `base_fee_per_gas`), in response to load. -use crate::block_in_progress::EthBlockInProgress; - +use crate::block_in_progress::BlockInProgress; +use crate::transaction::Transaction; use primitive_types::U256; use softfloat::F64; +use tezos_ethereum::transaction::TransactionReceipt; use tezos_evm_runtime::runtime::Runtime; use tezos_smart_rollup_encoding::timestamp::Timestamp; @@ -22,7 +23,7 @@ const ALPHA: F64 = softfloat::f64!(0.000_000_000_99); /// Register a completed block into the tick backlog pub fn register_block( host: &mut impl Runtime, - bip: &EthBlockInProgress, + bip: &BlockInProgress, ) -> anyhow::Result<()> { if bip.queue_length() > 0 { anyhow::bail!("update_gas_price on non-empty block"); @@ -205,7 +206,7 @@ mod test { H160::zero(), ); - let mut bip = EthBlockInProgress::new_with_ticks( + let mut bip = BlockInProgress::new_with_ticks( U256::zero(), Default::default(), VecDeque::new(), diff --git a/etherlink/kernel_latest/kernel/src/storage.rs b/etherlink/kernel_latest/kernel/src/storage.rs index 4ff5f2e64b9afa5cbc3db76f734238450a7d1001..eb46b9fec223ccd7ebf91afc16b158891aeac717 100644 --- a/etherlink/kernel_latest/kernel/src/storage.rs +++ b/etherlink/kernel_latest/kernel/src/storage.rs @@ -5,7 +5,7 @@ // // SPDX-License-Identifier: MIT -use crate::block_in_progress::EthBlockInProgress; +use crate::block_in_progress::BlockInProgress; use crate::chains::ChainFamily; use crate::event::Event; use crate::simulation::SimulationResult; @@ -665,9 +665,9 @@ pub fn store_kernel_version( // Never inlined when the kernel is compiled for benchmarks, to ensure the // function is visible in the profiling results. #[cfg_attr(feature = "benchmark", inline(never))] -pub fn store_block_in_progress( +pub fn store_block_in_progress( host: &mut Host, - bip: &EthBlockInProgress, + bip: &BlockInProgress, ) -> anyhow::Result<()> { let path = OwnedPath::from(EVM_BLOCK_IN_PROGRESS); let bytes = &bip.rlp_bytes(); @@ -685,9 +685,9 @@ pub fn store_block_in_progress( // Never inlined when the kernel is compiled for benchmarks, to ensure the // function is visible in the profiling results. #[cfg_attr(feature = "benchmark", inline(never))] -pub fn read_block_in_progress( +pub fn read_block_in_progress( host: &Host, -) -> anyhow::Result> { +) -> anyhow::Result>> { let path = OwnedPath::from(EVM_BLOCK_IN_PROGRESS); if let Some(ValueType::Value) = host.store_has(&path)? { let bytes = host @@ -700,7 +700,7 @@ pub fn read_block_in_progress( bytes.len() ); let decoder = Rlp::new(bytes.as_slice()); - let bip = EthBlockInProgress::decode(&decoder) + let bip = BlockInProgress::decode(&decoder) .context("Failed to decode current block in progress")?; Ok(Some(bip)) } else {