From abcdba6bf1f7f8e4f61c41ac1dbdadd65374d11f Mon Sep 17 00:00:00 2001 From: enitrat Date: Wed, 11 Sep 2024 16:37:39 +0200 Subject: [PATCH] fmt --- crates/contracts/src/account_contract.cairo | 11 +++++-- crates/evm/src/backend/validation.cairo | 16 ++++----- crates/evm/src/environment.cairo | 36 --------------------- 3 files changed, 16 insertions(+), 47 deletions(-) delete mode 100644 crates/evm/src/environment.cairo diff --git a/crates/contracts/src/account_contract.cairo b/crates/contracts/src/account_contract.cairo index 1e136892b..a59dd0160 100644 --- a/crates/contracts/src/account_contract.cairo +++ b/crates/contracts/src/account_contract.cairo @@ -52,6 +52,7 @@ pub mod AccountContract { use contracts::errors::{KAKAROT_VALIDATION_FAILED, KAKAROT_REENTRANCY}; use contracts::kakarot_core::interface::{IKakarotCoreDispatcher, IKakarotCoreDispatcherTrait}; use contracts::storage::StorageBytecode; + use core::cmp::min; use core::num::traits::Bounded; use core::num::traits::zero::Zero; use core::panic_with_felt252; @@ -74,7 +75,6 @@ pub mod AccountContract { use utils::eth_transaction::validation::validate_eth_tx; use utils::eth_transaction::{TransactionMetadata}; use utils::serialization::{deserialize_signature, deserialize_bytes, serialize_bytes}; - use core::cmp::min; use utils::traits::DefaultSignature; // Add ownable component @@ -271,7 +271,14 @@ pub mod AccountContract { // https://github.com/starkware-libs/blockifier/blob/9bfb3d4c8bf1b68a0c744d1249b32747c75a4d87/crates/blockifier/resources/versioned_constants.json // The whole data_len should be less than 300, so it's the return_data should be less // than 297 (+3 for return_data_len, success, gas_used) - self.emit(TransactionExecuted { response: return_data.slice(0, min(297, return_data.len())), success: success, gas_used }); + self + .emit( + TransactionExecuted { + response: return_data.slice(0, min(297, return_data.len())), + success: success, + gas_used + } + ); array![return_data] } } diff --git a/crates/evm/src/backend/validation.cairo b/crates/evm/src/backend/validation.cairo index 25b28360a..d82c8b2d5 100644 --- a/crates/evm/src/backend/validation.cairo +++ b/crates/evm/src/backend/validation.cairo @@ -1,16 +1,16 @@ use contracts::IKakarotCore; -use starknet::storage::StorageTrait; -use core::ops::SnapshotDeref; -use contracts::kakarot_core::KakarotCore; -use utils::eth_transaction::transaction::{Transaction, TransactionTrait}; use contracts::account_contract::{IAccountDispatcher, IAccountDispatcherTrait}; +use contracts::kakarot_core::KakarotCore; +use core::ops::SnapshotDeref; +use core::starknet::storage::{StoragePointerReadAccess}; use core::starknet::{get_caller_address, get_tx_info}; use openzeppelin::token::erc20::interface::{IERC20CamelDispatcher, IERC20CamelDispatcherTrait}; +use starknet::storage::StorageTrait; use utils::constants::POW_2_32; -use core::starknet::storage::{StoragePointerReadAccess}; use utils::eth_transaction::get_effective_gas_price; +use utils::eth_transaction::transaction::{Transaction, TransactionTrait}; -pub fn validate_eth_tx(kakarot_state: @KakarotCore::ContractState, tx: Transaction){ +pub fn validate_eth_tx(kakarot_state: @KakarotCore::ContractState, tx: Transaction) { let kakarot_storage = kakarot_state.snapshot_deref().storage(); // Validate transaction @@ -51,9 +51,7 @@ pub fn validate_eth_tx(kakarot_state: @KakarotCore::ContractState, tx: Transacti assert(tx_cost <= balance, 'Not enough ETH'); let effective_gas_price = get_effective_gas_price( - Option::Some(tx.max_fee_per_gas()), - tx.max_priority_fee_per_gas(), - block_base_fee.into() + Option::Some(tx.max_fee_per_gas()), tx.max_priority_fee_per_gas(), block_base_fee.into() ); assert(effective_gas_price.is_ok(), 'Invalid effective gas price'); } diff --git a/crates/evm/src/environment.cairo b/crates/evm/src/environment.cairo deleted file mode 100644 index d7bc4b183..000000000 --- a/crates/evm/src/environment.cairo +++ /dev/null @@ -1,36 +0,0 @@ -/// The transaction environment. -#[derive(Copy, Drop, Debug, PartialEq)] -pub struct TxEnv { - /// Transaction signer - pub origin: EthAddress, - /// The gas limit of the transaction. - pub gas_limit: u64, - /// The gas price of the transaction. - pub gas_price: u128, - /// The destination of the transaction. - pub transact_to: TransactTo, - /// The value sent to `transact_to`. - pub value: u256, - /// The data of the transaction. - pub data: Span, - /// The nonce of the transaction. - pub nonce: u64, - /// The chain ID of the transaction. If set to `None`, no checks are performed. - /// - /// Incorporated as part of the Spurious Dragon upgrade via [EIP-155]. - /// - /// [EIP-155]: https://eips.ethereum.org/EIPS/eip-155 - pub chain_id: Option, - /// A list of addresses and storage keys that the transaction plans to access. - /// - /// Added in [EIP-2930]. - /// - /// [EIP-2930]: https://eips.ethereum.org/EIPS/eip-2930 - pub access_list: Span, - /// The priority fee per gas. - /// - /// Incorporated as part of the London upgrade via [EIP-1559]. - /// - /// [EIP-1559]: https://eips.ethereum.org/EIPS/eip-1559 - pub gas_priority_fee: Option, -}