Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/execution/execution_entry_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ pub struct ExecutionEntryPoint {
pub(crate) caller_address: Address,
pub(crate) entry_point_selector: Felt252,
pub(crate) entry_point_type: EntryPointType,
#[allow(unused)]
pub(crate) initial_gas: u128,
}
#[allow(clippy::too_many_arguments)]
Expand Down
15 changes: 4 additions & 11 deletions src/execution/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ impl TransactionExecutionInfo {
}
}

pub fn create_concurrent_stage_execution_info(
pub fn new_without_fee_info(
validate_info: Option<CallInfo>,
call_info: Option<CallInfo>,
actual_resources: HashMap<String, usize>,
Expand All @@ -506,16 +506,9 @@ impl TransactionExecutionInfo {
}
}

pub fn from_concurrent_state_execution_info(
concurrent_execution_info: TransactionExecutionInfo,
actual_fee: u128,
fee_transfer_info: Option<CallInfo>,
) -> Self {
TransactionExecutionInfo {
actual_fee,
fee_transfer_info,
..concurrent_execution_info
}
pub fn set_fee_info(&mut self, actual_fee: u128, fee_transfer_call_info: Option<CallInfo>) {
self.actual_fee = actual_fee;
self.fee_transfer_info = fee_transfer_call_info;
}

pub fn get_visited_storage_entries_of_many(
Expand Down
3 changes: 0 additions & 3 deletions src/syscalls/business_logic_syscall_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ lazy_static! {
};
}

//TODO Remove allow dead_code after merging to 0.11
#[allow(dead_code)]
#[derive(Debug)]

pub struct BusinessLogicSyscallHandler<'a, T: State + StateReader> {
pub(crate) events: Vec<OrderedEvent>,
pub(crate) expected_syscall_ptr: Relocatable,
Expand Down
2 changes: 0 additions & 2 deletions src/syscalls/syscall_response.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use cairo_vm::felt::Felt252;
use cairo_vm::types::relocatable::{MaybeRelocatable, Relocatable};

// TODO: remove once used.
#[allow(dead_code)]
pub(crate) enum ResponseBody {
StorageReadResponse { value: Option<Felt252> },
GetBlockNumber { number: Felt252 },
Expand Down
27 changes: 10 additions & 17 deletions src/transaction/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,12 @@ impl Declare {
)
.map_err(|_| TransactionError::ResourcesCalculation)?;

Ok(
TransactionExecutionInfo::create_concurrent_stage_execution_info(
validate_info,
None,
actual_resources,
Some(self.tx_type),
),
)
Ok(TransactionExecutionInfo::new_without_fee_info(
validate_info,
None,
actual_resources,
Some(self.tx_type),
))
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -271,7 +269,7 @@ impl Declare {
state: &mut S,
block_context: &BlockContext,
) -> Result<TransactionExecutionInfo, TransactionError> {
let concurrent_exec_info = self.apply(state, block_context)?;
let mut tx_exec_info = self.apply(state, block_context)?;
self.handle_nonce(state)?;
// Set contract class
match state.get_contract_class(&self.class_hash) {
Expand All @@ -287,15 +285,10 @@ impl Declare {
}

let (fee_transfer_info, actual_fee) =
self.charge_fee(state, &concurrent_exec_info.actual_resources, block_context)?;
self.charge_fee(state, &tx_exec_info.actual_resources, block_context)?;
tx_exec_info.set_fee_info(actual_fee, fee_transfer_info);

Ok(
TransactionExecutionInfo::from_concurrent_state_execution_info(
concurrent_exec_info,
actual_fee,
fee_transfer_info,
),
)
Ok(tx_exec_info)
}

pub(crate) fn create_for_simulation(
Expand Down
11 changes: 3 additions & 8 deletions src/transaction/declare_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,15 @@ impl DeclareV2 {
let (fee_transfer_info, actual_fee) =
self.charge_fee(state, &actual_resources, block_context)?;

let concurrent_exec_info = TransactionExecutionInfo::create_concurrent_stage_execution_info(
let mut tx_exec_info = TransactionExecutionInfo::new_without_fee_info(
validate_info,
None,
actual_resources,
Some(self.tx_type),
);
tx_exec_info.set_fee_info(actual_fee, fee_transfer_info);

Ok(
TransactionExecutionInfo::from_concurrent_state_execution_info(
concurrent_exec_info,
actual_fee,
fee_transfer_info,
),
)
Ok(tx_exec_info)
}

pub(crate) fn compile_and_store_casm_class<S: State + StateReader>(
Expand Down
39 changes: 15 additions & 24 deletions src/transaction/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,12 @@ impl Deploy {
None,
)?;

Ok(
TransactionExecutionInfo::create_concurrent_stage_execution_info(
None,
Some(call_info),
actual_resources,
Some(self.tx_type),
),
)
Ok(TransactionExecutionInfo::new_without_fee_info(
None,
Some(call_info),
actual_resources,
Some(self.tx_type),
))
}

pub fn invoke_constructor<S: State + StateReader>(
Expand Down Expand Up @@ -203,14 +201,12 @@ impl Deploy {
None,
)?;

Ok(
TransactionExecutionInfo::create_concurrent_stage_execution_info(
None,
Some(call_info),
actual_resources,
Some(self.tx_type),
),
)
Ok(TransactionExecutionInfo::new_without_fee_info(
None,
Some(call_info),
actual_resources,
Some(self.tx_type),
))
}

/// Calculates actual fee used by the transaction using the execution
Expand All @@ -220,16 +216,11 @@ impl Deploy {
state: &mut S,
block_context: &BlockContext,
) -> Result<TransactionExecutionInfo, TransactionError> {
let concurrent_exec_info = self.apply(state, block_context)?;
let mut tx_exec_info = self.apply(state, block_context)?;
let (fee_transfer_info, actual_fee) = (None, 0);
tx_exec_info.set_fee_info(actual_fee, fee_transfer_info);

Ok(
TransactionExecutionInfo::from_concurrent_state_execution_info(
concurrent_exec_info,
actual_fee,
fee_transfer_info,
),
)
Ok(tx_exec_info)
}

// ---------------
Expand Down
25 changes: 9 additions & 16 deletions src/transaction/deploy_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,14 @@ impl DeployAccount {
where
S: State + StateReader,
{
let tx_info = self.apply(state, block_context)?;
let mut tx_info = self.apply(state, block_context)?;

self.handle_nonce(state)?;
let (fee_transfer_info, actual_fee) =
self.charge_fee(state, &tx_info.actual_resources, block_context)?;
tx_info.set_fee_info(actual_fee, fee_transfer_info);

Ok(
TransactionExecutionInfo::from_concurrent_state_execution_info(
tx_info,
actual_fee,
fee_transfer_info,
),
)
Ok(tx_info)
}

fn constructor_entry_points_empty(
Expand Down Expand Up @@ -190,14 +185,12 @@ impl DeployAccount {
)
.map_err::<TransactionError, _>(|_| TransactionError::ResourcesCalculation)?;

Ok(
TransactionExecutionInfo::create_concurrent_stage_execution_info(
validate_info,
Some(constructor_call_info),
actual_resources,
Some(TransactionType::DeployAccount),
),
)
Ok(TransactionExecutionInfo::new_without_fee_info(
validate_info,
Some(constructor_call_info),
actual_resources,
Some(TransactionType::DeployAccount),
))
}

pub fn handle_constructor<S>(
Expand Down
30 changes: 12 additions & 18 deletions src/transaction/invoke_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,12 @@ impl InvokeFunction {
changes,
None,
)?;
let transaction_execution_info =
TransactionExecutionInfo::create_concurrent_stage_execution_info(
validate_info,
call_info,
actual_resources,
Some(self.tx_type),
);
let transaction_execution_info = TransactionExecutionInfo::new_without_fee_info(
validate_info,
call_info,
actual_resources,
Some(self.tx_type),
);
Ok(transaction_execution_info)
}

Expand Down Expand Up @@ -279,19 +278,14 @@ impl InvokeFunction {
block_context: &BlockContext,
remaining_gas: u128,
) -> Result<TransactionExecutionInfo, TransactionError> {
let concurrent_exec_info = self.apply(state, block_context, remaining_gas)?;
let mut tx_exec_info = self.apply(state, block_context, remaining_gas)?;
self.handle_nonce(state)?;

let (fee_transfer_info, actual_fee) =
self.charge_fee(state, &concurrent_exec_info.actual_resources, block_context)?;
self.charge_fee(state, &tx_exec_info.actual_resources, block_context)?;
tx_exec_info.set_fee_info(actual_fee, fee_transfer_info);

Ok(
TransactionExecutionInfo::from_concurrent_state_execution_info(
concurrent_exec_info,
actual_fee,
fee_transfer_info,
),
)
Ok(tx_exec_info)
}

fn handle_nonce<S: State + StateReader>(&self, state: &mut S) -> Result<(), TransactionError> {
Expand Down Expand Up @@ -397,7 +391,7 @@ mod tests {
use std::{collections::HashMap, path::PathBuf};

#[test]
fn test_apply_specific_concurrent_changes() {
fn test_invoke_apply_without_fees() {
let internal_invoke_function = InvokeFunction {
contract_address: Address(0.into()),
entry_point_selector: Felt252::from_str_radix(
Expand Down Expand Up @@ -466,7 +460,7 @@ mod tests {
}

#[test]
fn test_execute_specific_concurrent_changes() {
fn test_invoke_execute() {
let internal_invoke_function = InvokeFunction {
contract_address: Address(0.into()),
entry_point_selector: Felt252::from_str_radix(
Expand Down
14 changes: 6 additions & 8 deletions src/transaction/l1_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,12 @@ impl L1Handler {
}
}

Ok(
TransactionExecutionInfo::create_concurrent_stage_execution_info(
None,
call_info,
actual_resources,
Some(TransactionType::L1Handler),
),
)
Ok(TransactionExecutionInfo::new_without_fee_info(
None,
call_info,
actual_resources,
Some(TransactionType::L1Handler),
))
}

/// Returns the payload size of the corresponding L1-to-L2 message.
Expand Down