Skip to content

Commit c032030

Browse files
cptarturksew1
authored andcommitted
Some lints
1 parent 7c9dec5 commit c032030

File tree

6 files changed

+40
-17
lines changed

6 files changed

+40
-17
lines changed

crates/cheatnet/src/runtime_extensions/call_to_blockifier_runtime_extension/execution/entry_point.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ pub fn execute_call_entry_point(
189189
// } else {
190190
println!("Executing native entry point");
191191
execute_entry_point_call_native(
192-
entry_point.clone(),
193-
native_compiled_class_v1,
192+
&entry_point,
193+
&native_compiled_class_v1,
194194
state,
195195
cheatnet_state,
196196
context,

crates/cheatnet/src/runtime_extensions/native/call.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1+
use crate::runtime_extensions::call_to_blockifier_runtime_extension::execution::entry_point::execute_call_entry_point;
2+
use crate::runtime_extensions::native::native_syscall_handler::BaseSyscallResult;
3+
use crate::state::CheatnetState;
14
use blockifier::execution::call_info::CallInfo;
25
use blockifier::execution::entry_point::CallEntryPoint;
36
use blockifier::execution::execution_utils::update_remaining_gas;
4-
use blockifier::execution::syscalls::hint_processor::{SyscallExecutionError, ENTRYPOINT_FAILED_ERROR};
7+
use blockifier::execution::syscalls::hint_processor::{
8+
ENTRYPOINT_FAILED_ERROR, SyscallExecutionError,
9+
};
510
use blockifier::execution::syscalls::syscall_base::SyscallHandlerBase;
611
use starknet_types_core::felt::Felt;
7-
use crate::runtime_extensions::call_to_blockifier_runtime_extension::execution::entry_point::execute_call_entry_point;
8-
use crate::runtime_extensions::native::native_syscall_handler::BaseSyscallResult;
9-
use crate::state::CheatnetState;
1012

13+
#[expect(clippy::mut_mut)]
1114
#[allow(clippy::result_large_err)]
1215
pub fn execute_inner_call(
1316
syscall_handler_base: &mut SyscallHandlerBase,
@@ -61,4 +64,4 @@ pub fn execute_inner_call(
6164
}
6265

6366
Ok(raw_retdata)
64-
}
67+
}

crates/cheatnet/src/runtime_extensions/native/deploy.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,14 @@ use starknet_api::contract_class::EntryPointType;
1515
use starknet_api::core::{ClassHash, ContractAddress, calculate_contract_address};
1616
use starknet_api::transaction::fields::{Calldata, ContractAddressSalt};
1717

18+
// Copied from blockifer/src/execution/entry_point.rs
1819
#[allow(clippy::result_large_err)]
20+
#[expect(clippy::needless_pass_by_value)]
1921
pub fn execute_constructor_entry_point(
2022
state: &mut dyn State,
23+
// region: Modified blockifer code
2124
cheatnet_state: &mut CheatnetState,
25+
// endregion
2226
context: &mut EntryPointExecutionContext,
2327
ctor_context: ConstructorContext,
2428
calldata: Calldata,
@@ -54,6 +58,7 @@ pub fn execute_constructor_entry_point(
5458
initial_gas: *remaining_gas,
5559
};
5660

61+
// region: Modified blockifer code
5762
let call_info =
5863
execute_call_entry_point(&mut constructor_call, state, cheatnet_state, context, false)
5964
.map_err(|error| {
@@ -65,8 +70,11 @@ pub fn execute_constructor_entry_point(
6570
})?;
6671

6772
Ok(call_info)
73+
// endregion
6874
}
6975

76+
#[expect(clippy::result_large_err)]
77+
// Copied from blockifer/src/execution/execution_utils.rs
7078
fn execute_deployment(
7179
state: &mut dyn State,
7280
cheatnet_state: &mut CheatnetState,
@@ -108,6 +116,8 @@ fn execute_deployment(
108116
)
109117
}
110118

119+
#[expect(clippy::match_bool, clippy::result_large_err)]
120+
// Copied from blockifer/src/execution/syscalls/syscall_base.rs
111121
pub fn deploy(
112122
syscall_handler_base: &mut SyscallHandlerBase,
113123
cheatnet_state: &mut CheatnetState,
@@ -150,6 +160,7 @@ pub fn deploy(
150160
storage_address: deployed_contract_address,
151161
caller_address: deployer_address,
152162
};
163+
// region: Modified blockifer code
153164
let call_info = execute_deployment(
154165
syscall_handler_base.state,
155166
cheatnet_state,
@@ -158,5 +169,6 @@ pub fn deploy(
158169
constructor_calldata,
159170
remaining_gas,
160171
)?;
172+
// endregion
161173
Ok((deployed_contract_address, call_info))
162174
}

crates/cheatnet/src/runtime_extensions/native/execution.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ use blockifier::utils::add_maps;
1919
use cairo_native::execution_result::{BuiltinStats, ContractExecutionResult};
2020
use cairo_native::utils::BuiltinCosts;
2121
use cairo_vm::types::builtin_name::BuiltinName;
22+
use std::collections::HashMap;
2223
use std::default::Default;
2324

25+
#[expect(clippy::result_large_err)]
2426
pub(crate) fn execute_entry_point_call_native(
25-
call: ExecutableCallEntryPoint,
26-
native_compiled_class_v1: NativeCompiledClassV1,
27+
call: &ExecutableCallEntryPoint,
28+
native_compiled_class_v1: &NativeCompiledClassV1,
2729
state: &mut dyn State,
2830
cheatnet_state: &mut CheatnetState, // Added parameter
2931
context: &mut EntryPointExecutionContext,
@@ -39,8 +41,8 @@ pub(crate) fn execute_entry_point_call_native(
3941

4042
Ok(CallInfoWithExecutionData {
4143
call_info,
42-
syscall_usage_vm_resources: Default::default(),
43-
syscall_usage_sierra_gas: Default::default(),
44+
syscall_usage_vm_resources: HashMap::default(),
45+
syscall_usage_sierra_gas: HashMap::default(),
4446
vm_trace: None,
4547
})
4648
}
@@ -49,8 +51,8 @@ pub(crate) fn execute_entry_point_call_native(
4951
// todo(rodrigo): add an `entry point not found` test for Native
5052
#[allow(clippy::result_large_err)]
5153
pub fn execute_entry_point_call(
52-
call: ExecutableCallEntryPoint,
53-
compiled_class: NativeCompiledClassV1,
54+
call: &ExecutableCallEntryPoint,
55+
compiled_class: &NativeCompiledClassV1,
5456
// state: &mut dyn State,
5557
// context: &mut EntryPointExecutionContext,
5658
mut syscall_handler: CheatableNativeSyscallHandler,
@@ -124,6 +126,7 @@ pub fn execute_entry_point_call(
124126

125127
// Copied from blockifier
126128
#[allow(clippy::result_large_err)]
129+
#[expect(clippy::needless_pass_by_value)]
127130
fn create_callinfo(
128131
call_result: ContractExecutionResult,
129132
syscall_handler: CheatableNativeSyscallHandler<'_>,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1+
mod call;
2+
mod deploy;
13
pub mod execution;
24
pub mod native_syscall_handler;
3-
mod deploy;
4-
mod call;

crates/cheatnet/src/runtime_extensions/native/native_syscall_handler.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ impl CheatableNativeSyscallHandler<'_> {
9696
Ok(())
9797
}
9898

99+
// Copied from blockifer/src/exection/native/syscall_handler.rs
99100
#[allow(clippy::result_large_err)]
100101
fn execute_inner_call(
101102
&mut self,
@@ -110,9 +111,10 @@ impl CheatableNativeSyscallHandler<'_> {
110111
) -> SyscallExecutionError,
111112
) -> SyscallResult<Retdata> {
112113
let entry_point_clone = entry_point.clone();
114+
// region: Modified blockifier code
113115
let raw_data = execute_inner_call(
114116
&mut self.native_syscall_handler.base,
115-
&mut self.cheatnet_state,
117+
self.cheatnet_state,
116118
entry_point,
117119
remaining_gas,
118120
)
@@ -131,6 +133,7 @@ impl CheatableNativeSyscallHandler<'_> {
131133
)),
132134
)
133135
})?;
136+
// endregion
134137
Ok(Retdata(raw_data))
135138
}
136139

@@ -359,7 +362,7 @@ impl StarknetSyscallHandler for &mut CheatableNativeSyscallHandler<'_> {
359362

360363
let (deployed_contract_address, call_info) = deploy(
361364
&mut self.native_syscall_handler.base,
362-
&mut self.cheatnet_state,
365+
self.cheatnet_state,
363366
ClassHash(class_hash),
364367
ContractAddressSalt(contract_address_salt),
365368
Calldata(Arc::new(calldata.to_vec())),
@@ -379,6 +382,7 @@ impl StarknetSyscallHandler for &mut CheatableNativeSyscallHandler<'_> {
379382
.replace_class(class_hash, remaining_gas)
380383
}
381384

385+
// Copied from blockifier/src/execution/native/syscall_handler.rs
382386
fn library_call(
383387
&mut self,
384388
class_hash: Felt,
@@ -433,6 +437,7 @@ impl StarknetSyscallHandler for &mut CheatableNativeSyscallHandler<'_> {
433437
.0)
434438
}
435439

440+
// Copied from blockifier/src/execution/native/syscall_handler.rs
436441
fn call_contract(
437442
&mut self,
438443
address: Felt,

0 commit comments

Comments
 (0)