Skip to content

Commit

Permalink
fix: tracing (#1099)
Browse files Browse the repository at this point in the history
* fix toml version

* set tracing block gas limit to u64::MAX

* revert change

* add check in send_raw_transaction
  • Loading branch information
greged93 authored May 22, 2024
1 parent 2d2fb05 commit da635cd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kakarot-rpc"
version = "0.1.0"
version = "0.6.12"
edition = "2021"
authors = [
"Abdelhamid Bakhta <@abdelhamidbakhta>",
Expand Down
9 changes: 9 additions & 0 deletions src/eth_provider/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = Result<T, EthApiError>;
Expand Down Expand Up @@ -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?;
Expand Down
2 changes: 1 addition & 1 deletion src/tracing/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct TracerBuilder<P: EthereumProvider + Send + Sync, Status = Floating> {
/// 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: <https://github.com/kkrt-labs/kakarot/blob/98b26fda32c36f09880ed0c7f44dba7f4d669b61/src/kakarot/accounts/library.cairo#L245>
/// 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<P: EthereumProvider + Send + Sync + Clone> TracerBuilder<P, Floating> {
pub async fn new(eth_provider: P) -> TracerResult<Self> {
Expand Down

0 comments on commit da635cd

Please sign in to comment.