From da635cd93990e0a4af5f9f0f039d11b83ba02456 Mon Sep 17 00:00:00 2001 From: greged93 <82421016+greged93@users.noreply.github.com> Date: Wed, 22 May 2024 12:40:15 +0200 Subject: [PATCH] fix: tracing (#1099) * fix toml version * set tracing block gas limit to u64::MAX * revert change * add check in send_raw_transaction --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/eth_provider/provider.rs | 9 +++++++++ src/tracing/builder.rs | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84bad642d..a46db8c20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8000,7 +8000,7 @@ dependencies = [ [[package]] name = "kakarot-rpc" -version = "0.1.0" +version = "0.6.12" dependencies = [ "alloy-primitives 0.7.2", "alloy-rlp", diff --git a/Cargo.toml b/Cargo.toml index a60fe0be0..346d6d839 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kakarot-rpc" -version = "0.1.0" +version = "0.6.12" edition = "2021" authors = [ "Abdelhamid Bakhta <@abdelhamidbakhta>", diff --git a/src/eth_provider/provider.rs b/src/eth_provider/provider.rs index 3c60e4c65..01c8d6708 100644 --- a/src/eth_provider/provider.rs +++ b/src/eth_provider/provider.rs @@ -43,6 +43,7 @@ use super::utils::{contract_not_found, entrypoint_not_found, into_filter, split_ use crate::eth_provider::utils::format_hex; use crate::models::block::{EthBlockId, EthBlockNumberOrTag}; use crate::models::felt::Felt252Wrapper; +use crate::tracing::builder::TRACING_BLOCK_GAS_LIMIT; use crate::{into_via_try_wrapper, into_via_wrapper}; pub type EthProviderResult = Result; @@ -537,6 +538,14 @@ where max_fee.saturating_sub(eth_fees) }; + // If the transaction gas limit is higher than the tracing + // block gas limit, prevent the transaction from being sent + // (it will revert anyway on the Starknet side). This assures + // that all transactions are traceable. + if transaction_signed.gas_limit() > TRACING_BLOCK_GAS_LIMIT { + return Err(TransactionError::GasOverflow.into()); + } + // Deploy EVM transaction signer if Hive feature is enabled #[cfg(feature = "hive")] self.deploy_evm_transaction_signer(signer).await?; diff --git a/src/tracing/builder.rs b/src/tracing/builder.rs index ea4006d2b..9902bb45b 100644 --- a/src/tracing/builder.rs +++ b/src/tracing/builder.rs @@ -25,7 +25,7 @@ pub struct TracerBuilder { /// Block gas limit for tracing. Set to an arbitrarily high value to never run out. /// Block gas limit is only partially enforced in Cairo EVM layer: /// Remove when block gas limit is enforced consistently (i.e. when we check that a transaction's gas limit is lower than the block gas limit as well as the current block's cumulative gas) -const TRACING_BLOCK_GAS_LIMIT: u64 = 1_000_000_000; +pub const TRACING_BLOCK_GAS_LIMIT: u64 = 1_000_000_000; impl TracerBuilder { pub async fn new(eth_provider: P) -> TracerResult {