Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Sep 11, 2024
1 parent b4c7e64 commit 25699d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
11 changes: 9 additions & 2 deletions crates/contracts/src/account_contract.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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]
}
}
Expand Down
16 changes: 7 additions & 9 deletions crates/evm/src/backend/validation.cairo
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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');
}

0 comments on commit 25699d2

Please sign in to comment.