From 9ddadcb2987c93c1bce66579802f5985b4e04b2c Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 09:27:26 +0200 Subject: [PATCH 1/9] Tezlink/Kernel/Transfer: FailedToFetchAccount is ValidityError --- etherlink/kernel_latest/tezos/src/operation_result.rs | 1 + etherlink/kernel_latest/tezos_execution/src/validate.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index 3bfee9f081f3..ed2ee4e5b134 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -38,6 +38,7 @@ pub enum ValidityError { GasLimitTooHigh, StorageLimitTooHigh, InvalidSignature, + FailedToFetchAccount, } #[derive(Debug, PartialEq, Eq, NomReader, BinWriter)] diff --git a/etherlink/kernel_latest/tezos_execution/src/validate.rs b/etherlink/kernel_latest/tezos_execution/src/validate.rs index 646997c2d4eb..c7c64e2659bb 100644 --- a/etherlink/kernel_latest/tezos_execution/src/validate.rs +++ b/etherlink/kernel_latest/tezos_execution/src/validate.rs @@ -130,7 +130,11 @@ pub fn validate_operation( let branch = &operation.branch; let content: ManagerOperation = operation.content.clone().into(); let signature = &operation.signature; - let account = TezlinkImplicitAccount::from_public_key_hash(context, &content.source)?; + let account = + match TezlinkImplicitAccount::from_public_key_hash(context, &content.source) { + Err(_) => return Ok(Err(ValidityError::FailedToFetchAccount)), + Ok(account) => account, + }; // Account must exist in the durable storage if !account.allocated(host)? { -- GitLab From 51a8ce7f6ece21e29878aa1a13ce40cc659d120a Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 10:03:42 +0200 Subject: [PATCH 2/9] Tezlink/Kernel/Transfer: BigIntError is ValidityError --- etherlink/kernel_latest/tezos/src/operation_result.rs | 1 + etherlink/kernel_latest/tezos_execution/src/validate.rs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index ed2ee4e5b134..669ecd12a6a1 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -39,6 +39,7 @@ pub enum ValidityError { StorageLimitTooHigh, InvalidSignature, FailedToFetchAccount, + FailedToComputeFeeBalanceUpdate, } #[derive(Debug, PartialEq, Eq, NomReader, BinWriter)] diff --git a/etherlink/kernel_latest/tezos_execution/src/validate.rs b/etherlink/kernel_latest/tezos_execution/src/validate.rs index c7c64e2659bb..1cbdb9a47b3e 100644 --- a/etherlink/kernel_latest/tezos_execution/src/validate.rs +++ b/etherlink/kernel_latest/tezos_execution/src/validate.rs @@ -206,8 +206,10 @@ pub fn validate_operation( } let (src_delta, block_fees) = - crate::compute_fees_balance_updates(&content.source, &content.fee) - .map_err(ApplyKernelError::BigIntError)?; + match crate::compute_fees_balance_updates(&content.source, &content.fee) { + Err(_) => return Ok(Err(ValidityError::FailedToComputeFeeBalanceUpdate)), + Ok(v) => v, + }; Ok(Ok(ValidationInfo { new_source_balance: new_balance, -- GitLab From 93926baa939b3e43d9efe4d97f37b70525d9345b Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 08:44:12 +0200 Subject: [PATCH 3/9] Tezlink/Kernel/Transfer: remove nested results in check_counter_increment --- .../kernel_latest/tezos/src/operation_result.rs | 1 + .../kernel_latest/tezos_execution/src/validate.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index 669ecd12a6a1..2cba8935dfe9 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -40,6 +40,7 @@ pub enum ValidityError { InvalidSignature, FailedToFetchAccount, FailedToComputeFeeBalanceUpdate, + FailedToFetchCounter, } #[derive(Debug, PartialEq, Eq, NomReader, BinWriter)] diff --git a/etherlink/kernel_latest/tezos_execution/src/validate.rs b/etherlink/kernel_latest/tezos_execution/src/validate.rs index 1cbdb9a47b3e..6d9d794d889d 100644 --- a/etherlink/kernel_latest/tezos_execution/src/validate.rs +++ b/etherlink/kernel_latest/tezos_execution/src/validate.rs @@ -28,13 +28,15 @@ impl TezlinkImplicitAccount { &self, host: &impl Runtime, counter: &Narith, - ) -> Result, tezos_storage::error::Error> { - let contract_counter = self.counter(host)?; + ) -> Result<(), ValidityError> { + let contract_counter = self + .counter(host) + .map_err(|_| ValidityError::FailedToFetchCounter)?; // The provided counter value must be the successor of the manager's counter. let expected_counter = Narith(&contract_counter.0 + 1_u64); if &expected_counter == counter { - Ok(Ok(())) + Ok(()) } else if expected_counter.0 > counter.0 { let error = CounterError { expected: expected_counter, @@ -45,7 +47,7 @@ impl TezlinkImplicitAccount { tezos_evm_logging::Level::Debug, "Invalid operation: Source counter is in the past" ); - Ok(Err(ValidityError::CounterInThePast(error))) + Err(ValidityError::CounterInThePast(error)) } else { let error = CounterError { expected: expected_counter, @@ -56,7 +58,7 @@ impl TezlinkImplicitAccount { tezos_evm_logging::Level::Debug, "Invalid operation: Source counter is in the future" ); - Ok(Err(ValidityError::CounterInTheFuture(error))) + Err(ValidityError::CounterInTheFuture(error)) } } @@ -146,7 +148,7 @@ pub fn validate_operation( return Ok(Err(ValidityError::EmptyImplicitContract)); } - if let Err(err) = account.check_counter_increment(host, &content.counter)? { + if let Err(err) = account.check_counter_increment(host, &content.counter) { // Counter verification failed, return the error return Ok(Err(err)); } -- GitLab From 79fe74b5a3529c7efd6fee67bb3b6d11683620e6 Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 09:04:52 +0200 Subject: [PATCH 4/9] Tezlink/Kernel/Transfer: remove nested results in get_manager_key --- etherlink/kernel_latest/tezos/src/operation_result.rs | 1 + .../kernel_latest/tezos_execution/src/validate.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index 2cba8935dfe9..99a4bafc42e8 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -41,6 +41,7 @@ pub enum ValidityError { FailedToFetchAccount, FailedToComputeFeeBalanceUpdate, FailedToFetchCounter, + FailedToFetchManagerKey, } #[derive(Debug, PartialEq, Eq, NomReader, BinWriter)] diff --git a/etherlink/kernel_latest/tezos_execution/src/validate.rs b/etherlink/kernel_latest/tezos_execution/src/validate.rs index 6d9d794d889d..b4f8da0e46d6 100644 --- a/etherlink/kernel_latest/tezos_execution/src/validate.rs +++ b/etherlink/kernel_latest/tezos_execution/src/validate.rs @@ -87,10 +87,12 @@ fn get_revealed_key( host: &Host, account: &TezlinkImplicitAccount, content: &OperationContent, -) -> Result, ApplyKernelError> { +) -> Result { match content { - OperationContent::Reveal(RevealContent { pk, proof: _ }) => Ok(Ok(pk.clone())), - _ => Ok(account.get_manager_key(host)?), + OperationContent::Reveal(RevealContent { pk, proof: _ }) => Ok(pk.clone()), + _ => account + .get_manager_key(host) + .map_err(|_| ValidityError::FailedToFetchManagerKey)?, } } @@ -153,7 +155,7 @@ pub fn validate_operation( return Ok(Err(err)); } - let pk = match get_revealed_key(host, &account, &content.operation)? { + let pk = match get_revealed_key(host, &account, &content.operation) { Err(err) => { // Retrieve public key failed, return the error return Ok(Err(err)); -- GitLab From 56a4cc032aef966b423bc3e90323c9c3201d5391 Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 09:17:43 +0200 Subject: [PATCH 5/9] Tezlink/Kernel/Transfer: remove nested results in simulate_spending --- etherlink/kernel_latest/tezos/src/operation_result.rs | 1 + etherlink/kernel_latest/tezos_execution/src/validate.rs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index 99a4bafc42e8..44f4c5b8893a 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -42,6 +42,7 @@ pub enum ValidityError { FailedToComputeFeeBalanceUpdate, FailedToFetchCounter, FailedToFetchManagerKey, + FailedToFetchBalance, } #[derive(Debug, PartialEq, Eq, NomReader, BinWriter)] diff --git a/etherlink/kernel_latest/tezos_execution/src/validate.rs b/etherlink/kernel_latest/tezos_execution/src/validate.rs index b4f8da0e46d6..710adfc9689a 100644 --- a/etherlink/kernel_latest/tezos_execution/src/validate.rs +++ b/etherlink/kernel_latest/tezos_execution/src/validate.rs @@ -186,9 +186,9 @@ pub fn validate_operation( } // The manager account must be solvent to pay the announced fees. - let new_balance = match account.simulate_spending(host, &content.fee)? { - Some(new_balance) => new_balance, - None => { + let new_balance = match account.simulate_spending(host, &content.fee) { + Ok(Some(new_balance)) => new_balance, + Ok(None) => { log!( host, tezos_evm_logging::Level::Debug, @@ -196,6 +196,7 @@ pub fn validate_operation( ); return Ok(Err(ValidityError::CantPayFees(content.fee))); } + Err(_) => return Ok(Err(ValidityError::FailedToFetchBalance)), }; let verify = verify_signature(&pk, branch, &operation.content, signature.clone())?; -- GitLab From 6465aae6e2754a7f1714b09f5c23572048bb67e6 Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 09:56:34 +0200 Subject: [PATCH 6/9] Tezlink/Kernel/Transfer: remove nested results in validate_operation --- .../kernel_latest/tezos_execution/src/lib.rs | 8 +- .../tezos_execution/src/validate.rs | 82 +++++-------------- 2 files changed, 24 insertions(+), 66 deletions(-) diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index 40deaf51793f..778bbe6258de 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -518,14 +518,10 @@ pub fn validate_and_apply_operation( log!(safe_host, Debug, "Verifying that the operation is valid"); let mut validation_info = - match validate::validate_operation(&safe_host, context, &operation)? { + match validate::validate_operation(&safe_host, context, &operation) { Ok(validation_info) => validation_info, Err(validity_err) => { - log!( - safe_host, - Debug, - "Operation is invalid, exiting apply_operation" - ); + log!(safe_host, Debug, "Operation is invalid: {:?}", validity_err); // TODO: Don't force the receipt to a reveal receipt let receipt = produce_operation_result::( vec![], diff --git a/etherlink/kernel_latest/tezos_execution/src/validate.rs b/etherlink/kernel_latest/tezos_execution/src/validate.rs index 710adfc9689a..888eae39a654 100644 --- a/etherlink/kernel_latest/tezos_execution/src/validate.rs +++ b/etherlink/kernel_latest/tezos_execution/src/validate.rs @@ -16,7 +16,7 @@ use tezos_tezlink::{ use crate::{ account_storage::{Manager, TezlinkImplicitAccount}, context::Context, - ApplyKernelError, BalanceUpdate, + BalanceUpdate, }; impl TezlinkImplicitAccount { @@ -130,60 +130,30 @@ pub fn validate_operation( host: &Host, context: &Context, operation: &Operation, -) -> Result, ApplyKernelError> { +) -> Result { let branch = &operation.branch; let content: ManagerOperation = operation.content.clone().into(); let signature = &operation.signature; - let account = - match TezlinkImplicitAccount::from_public_key_hash(context, &content.source) { - Err(_) => return Ok(Err(ValidityError::FailedToFetchAccount)), - Ok(account) => account, - }; + let account = TezlinkImplicitAccount::from_public_key_hash(context, &content.source) + .map_err(|_| ValidityError::FailedToFetchAccount)?; // Account must exist in the durable storage - if !account.allocated(host)? { - log!( - host, - tezos_evm_logging::Level::Debug, - "Invalid operation: Source is not allocated" - ); - return Ok(Err(ValidityError::EmptyImplicitContract)); + if !account + .allocated(host) + .map_err(|_| ValidityError::FailedToFetchBalance)? + { + return Err(ValidityError::EmptyImplicitContract); } - if let Err(err) = account.check_counter_increment(host, &content.counter) { - // Counter verification failed, return the error - return Ok(Err(err)); - } + account.check_counter_increment(host, &content.counter)?; - let pk = match get_revealed_key(host, &account, &content.operation) { - Err(err) => { - // Retrieve public key failed, return the error - return Ok(Err(err)); - } - Ok(pk) => pk, - }; + let pk = get_revealed_key(host, &account, &content.operation)?; // TODO: hard gas limit per operation is a Tezos constant, for now we took the one from ghostnet - if let Err(err) = check_gas_limit(&1040000_u64.into(), &content.gas_limit) { - // Gas limit verification failed, return the error - log!( - host, - tezos_evm_logging::Level::Debug, - "Invalid operation: Gas limit is too high" - ); - return Ok(Err(err)); - } + check_gas_limit(&1040000_u64.into(), &content.gas_limit)?; // TODO: hard storage limit per operation is a Tezos constant, for now we took the one from ghostnet - if let Err(err) = check_storage_limit(&60000_u64.into(), &content.storage_limit) { - // Storage limit verification failed, return the error - log!( - host, - tezos_evm_logging::Level::Debug, - "Invalid operation: Storage limit is too high" - ); - return Ok(Err(err)); - } + check_storage_limit(&60000_u64.into(), &content.storage_limit)?; // The manager account must be solvent to pay the announced fees. let new_balance = match account.simulate_spending(host, &content.fee) { @@ -194,31 +164,23 @@ pub fn validate_operation( tezos_evm_logging::Level::Debug, "Invalid operation: Can't pay the fees" ); - return Ok(Err(ValidityError::CantPayFees(content.fee))); + return Err(ValidityError::CantPayFees(content.fee)); } - Err(_) => return Ok(Err(ValidityError::FailedToFetchBalance)), + Err(_) => return Err(ValidityError::FailedToFetchBalance), }; - let verify = verify_signature(&pk, branch, &operation.content, signature.clone())?; - - if !verify { - log!( - host, - tezos_evm_logging::Level::Debug, - "Invalid operation: Signature is invalid" - ); - return Ok(Err(ValidityError::InvalidSignature)); + match verify_signature(&pk, branch, &operation.content, signature.clone()) { + Ok(true) => (), + _ => return Err(ValidityError::InvalidSignature), } let (src_delta, block_fees) = - match crate::compute_fees_balance_updates(&content.source, &content.fee) { - Err(_) => return Ok(Err(ValidityError::FailedToComputeFeeBalanceUpdate)), - Ok(v) => v, - }; + crate::compute_fees_balance_updates(&content.source, &content.fee) + .map_err(|_| ValidityError::FailedToComputeFeeBalanceUpdate)?; - Ok(Ok(ValidationInfo { + Ok(ValidationInfo { new_source_balance: new_balance, source_account: account, balance_updates: vec![src_delta, block_fees], - })) + }) } -- GitLab From 543e81449e09837e177f513d74d55b5f6e7df473 Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 11:00:24 +0200 Subject: [PATCH 7/9] Tezlink/Kernel/Transfer: only revert BIP with RuntimeError --- .../tezos/src/operation_result.rs | 1 + .../kernel_latest/tezos_execution/src/lib.rs | 20 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index 44f4c5b8893a..aea9cf93b233 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -43,6 +43,7 @@ pub enum ValidityError { FailedToFetchCounter, FailedToFetchManagerKey, FailedToFetchBalance, + FailedToUpdateBalance, } #[derive(Debug, PartialEq, Eq, NomReader, BinWriter)] diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index 778bbe6258de..a398e7dd32d2 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -19,6 +19,7 @@ use tezos_data_encoding::types::Narith; use tezos_evm_logging::{log, Level::*, Verbosity}; use tezos_evm_runtime::{runtime::Runtime, safe_storage::SafeStorage}; use tezos_smart_rollup::types::{Contract, PublicKey, PublicKeyHash}; +use tezos_smart_rollup_host::runtime::RuntimeError; use tezos_tezlink::operation::Operation; use tezos_tezlink::operation_result::TransferTarget; use tezos_tezlink::{ @@ -28,7 +29,7 @@ use tezos_tezlink::{ operation_result::{ is_applied, produce_operation_result, Balance, BalanceTooLow, BalanceUpdate, OperationError, OperationResultSum, Reveal, RevealError, RevealSuccess, - TransferError, TransferSuccess, UpdateOrigin, + TransferError, TransferSuccess, UpdateOrigin, ValidityError, }, }; use thiserror::Error; @@ -495,7 +496,7 @@ pub fn validate_and_apply_operation( host: &mut Host, context: &context::Context, operation: Operation, -) -> Result { +) -> Result { let manager_operation: ManagerOperation = operation.content.clone().into(); @@ -535,9 +536,20 @@ pub fn validate_and_apply_operation( log!(safe_host, Debug, "Operation is valid"); log!(safe_host, Debug, "Updates balance to pay fees"); - validation_info + if validation_info .source_account - .set_balance(&mut safe_host, &validation_info.new_source_balance)?; + .set_balance(&mut safe_host, &validation_info.new_source_balance) + .is_err() + { + log!(safe_host, Debug, "Could not update balance!"); + // TODO: Don't force the receipt to a reveal receipt + let receipt = produce_operation_result::( + vec![], + Err(ValidityError::FailedToUpdateBalance.into()), + ); + safe_host.revert()?; + return Ok(OperationResultSum::Reveal(receipt)); + }; safe_host.promote()?; safe_host.promote_trace()?; -- GitLab From 770095b03e82d0bdfeb93bebb0b66d769f24421c Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 11:16:05 +0200 Subject: [PATCH 8/9] Tezlink/Kernel/Transfer: UnsupportedMirAddress is TransferError --- etherlink/kernel_latest/tezos/src/operation_result.rs | 2 ++ etherlink/kernel_latest/tezos_execution/src/lib.rs | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/etherlink/kernel_latest/tezos/src/operation_result.rs b/etherlink/kernel_latest/tezos/src/operation_result.rs index aea9cf93b233..2b6c819578ca 100644 --- a/etherlink/kernel_latest/tezos/src/operation_result.rs +++ b/etherlink/kernel_latest/tezos/src/operation_result.rs @@ -103,6 +103,8 @@ pub enum TransferError { FailedToApplyInternalOperation(String), #[error("Failed to increment counter")] FailedToIncrementCounter, + #[error("Apply operation failed because of an unsupported address error")] + MirAddressUnsupportedError, } impl From for TransferError { diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index a398e7dd32d2..4aeda813f7e9 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -52,8 +52,6 @@ pub enum ApplyKernelError { BigIntError(num_bigint::TryFromBigIntError), #[error("Serialization failed because of {0}")] BinaryError(String), - #[error("Apply operation failed because of an unsupported address error")] - MirAddressUnsupportedError, } // 'FromBase58CheckError' doesn't implement PartialEq and Eq @@ -119,11 +117,11 @@ fn reveal( }) } -fn contract_from_address(address: AddressHash) -> Result { +fn contract_from_address(address: AddressHash) -> Result { match address { AddressHash::Kt1(kt1) => Ok(Contract::Originated(kt1)), AddressHash::Implicit(pkh) => Ok(Contract::Implicit(pkh)), - AddressHash::Sr1(_) => Err(ApplyKernelError::MirAddressUnsupportedError), + AddressHash::Sr1(_) => Err(TransferError::MirAddressUnsupportedError), } } @@ -196,8 +194,7 @@ pub fn execute_internal_operations<'a, Host: Runtime>( amount, }) => { let amount = Narith(amount.try_into().unwrap_or(BigUint::ZERO)); - let dest_contract = contract_from_address(destination_address.hash) - .map_err(|_| TransferError::FailedToFetchDestinationAccount)?; + let dest_contract = contract_from_address(destination_address.hash)?; transfer( host, context, -- GitLab From df140e1d910e90c23def0be35601122d0b60f47b Mon Sep 17 00:00:00 2001 From: Luciano Freitas Date: Thu, 31 Jul 2025 11:02:46 +0200 Subject: [PATCH 9/9] Tezlink/Kernel: delete unnecessary ApplyKernelError --- etherlink/kernel_latest/kernel/src/error.rs | 3 -- .../kernel_latest/tezos_execution/src/lib.rs | 38 +------------------ 2 files changed, 1 insertion(+), 40 deletions(-) diff --git a/etherlink/kernel_latest/kernel/src/error.rs b/etherlink/kernel_latest/kernel/src/error.rs index eb31590f1569..bdf8d7ea9a8b 100644 --- a/etherlink/kernel_latest/kernel/src/error.rs +++ b/etherlink/kernel_latest/kernel/src/error.rs @@ -11,7 +11,6 @@ use primitive_types::U256; use rlp::DecoderError; use tezos_data_encoding::enc::BinError; use tezos_ethereum::tx_common::SigError; -use tezos_execution::ApplyKernelError; use tezos_indexable_storage::IndexableStorageError; use tezos_smart_rollup_encoding::entrypoint::EntrypointError; use tezos_smart_rollup_encoding::michelson::ticket::TicketError; @@ -91,8 +90,6 @@ pub enum Error { #[error(transparent)] Transfer(TransferError), #[error(transparent)] - Operation(ApplyKernelError), - #[error(transparent)] Storage(StorageError), #[error("Invalid conversion")] InvalidConversion, diff --git a/etherlink/kernel_latest/tezos_execution/src/lib.rs b/etherlink/kernel_latest/tezos_execution/src/lib.rs index 4aeda813f7e9..a80e6e1f8dab 100644 --- a/etherlink/kernel_latest/tezos_execution/src/lib.rs +++ b/etherlink/kernel_latest/tezos_execution/src/lib.rs @@ -13,8 +13,7 @@ use mir::{ }; use num_bigint::{BigInt, BigUint}; use num_traits::ops::checked::CheckedSub; -use tezos_crypto_rs::{base58::FromBase58CheckError, PublicKeyWithHash}; -use tezos_data_encoding::enc::BinError; +use tezos_crypto_rs::PublicKeyWithHash; use tezos_data_encoding::types::Narith; use tezos_evm_logging::{log, Level::*, Verbosity}; use tezos_evm_runtime::{runtime::Runtime, safe_storage::SafeStorage}; @@ -32,7 +31,6 @@ use tezos_tezlink::{ TransferError, TransferSuccess, UpdateOrigin, ValidityError, }, }; -use thiserror::Error; use validate::ValidationInfo; extern crate alloc; @@ -40,40 +38,6 @@ pub mod account_storage; pub mod context; mod validate; -#[derive(Error, Debug, PartialEq, Eq)] -pub enum ApplyKernelError { - #[error("Host failed with a runtime error {0}")] - HostRuntimeError(#[from] tezos_smart_rollup_host::runtime::RuntimeError), - #[error("Apply operation failed on a storage manipulation {0}")] - StorageError(tezos_storage::error::Error), - #[error("Apply operation failed because of a b58 conversion {0}")] - Base58Error(String), - #[error("Apply operation failed because of a big integer conversion error {0}")] - BigIntError(num_bigint::TryFromBigIntError), - #[error("Serialization failed because of {0}")] - BinaryError(String), -} - -// 'FromBase58CheckError' doesn't implement PartialEq and Eq -// Use the String representation instead -impl From for ApplyKernelError { - fn from(err: FromBase58CheckError) -> Self { - Self::Base58Error(err.to_string()) - } -} - -impl From for ApplyKernelError { - fn from(value: tezos_storage::error::Error) -> Self { - Self::StorageError(value) - } -} - -impl From for ApplyKernelError { - fn from(value: BinError) -> Self { - Self::BinaryError(format!("{:?}", value)) - } -} - fn reveal( host: &mut Host, provided_hash: &PublicKeyHash, -- GitLab