Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit d579f6f

Browse files
committed
invoke
1 parent f52e045 commit d579f6f

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

src/execution/execution_entry_point.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ impl ExecutionEntryPoint {
430430
class_hash: [u8; 32],
431431
support_reverted: bool,
432432
) -> Result<CallInfo, TransactionError> {
433+
dbg!("called");
433434
let previous_cairo_usage = resources_manager.cairo_usage.clone();
434435

435436
// fetch selected entry point
@@ -559,6 +560,8 @@ impl ExecutionEntryPoint {
559560
resources_manager.cairo_usage += &runner.get_execution_resources()?;
560561

561562
let call_result = runner.get_call_result(self.initial_gas)?;
563+
dbg!(&call_result.is_success);
564+
dbg!(&call_result.retdata);
562565
self.build_call_info::<S>(
563566
previous_cairo_usage,
564567
resources_manager,

src/syscalls/business_logic_syscall_handler.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ impl<'a, S: StateReader> BusinessLogicSyscallHandler<'a, S> {
451451
remaining_gas: u128,
452452
vm: &mut VirtualMachine,
453453
) -> Result<SyscallResponse, SyscallHandlerError> {
454+
dbg!(&request);
454455
match request {
455456
SyscallRequest::LibraryCall(req) => self.library_call(vm, req, remaining_gas),
456457
SyscallRequest::CallContract(req) => self.call_contract(vm, req, remaining_gas),

tests/account_panic.rs

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use starknet_in_rust::{
1313
cached_state::CachedState, in_memory_state_reader::InMemoryStateReader, state_api::State,
1414
ExecutionResourcesManager,
1515
},
16-
transaction::{DeclareV2, Deploy, DeployAccount, Transaction},
16+
transaction::{DeclareV2, Deploy, DeployAccount, InvokeFunction, Transaction},
1717
utils::{Address, ClassHash},
1818
CasmContractClass, EntryPointType,
1919
};
@@ -65,47 +65,32 @@ fn account_panic() {
6565
let mut state = CachedState::new(Arc::new(state_reader), contract_class_cache);
6666

6767
let entrypoints = contract_class.entry_points_by_type;
68+
6869
let entrypoint_selector = &entrypoints.external.get(0).unwrap().selector;
6970

7071
// arguments of contract_a contract
7172
let calldata: Vec<_> = [2.into()].to_vec();
7273

7374
// set up remaining structures
7475

75-
let entry_point_type = EntryPointType::External;
76-
77-
let exec_entry_point = ExecutionEntryPoint::new(
76+
let invoke = InvokeFunction::new(
7877
contract_address,
79-
calldata,
8078
Felt252::new(entrypoint_selector.clone()),
81-
account_address.clone(),
82-
entry_point_type,
83-
Some(CallType::Delegate),
84-
Some(contract_class_hash),
85-
100_000_000,
86-
);
87-
88-
let mut tx_execution_context = TransactionExecutionContext::new(
89-
account_address,
90-
Felt252::zero(),
91-
Vec::new(),
9279
0,
93-
10.into(),
94-
block_context.invoke_tx_max_n_steps(),
9580
TRANSACTION_VERSION.clone(),
96-
);
97-
let mut resources_manager = ExecutionResourcesManager::default();
98-
99-
let call_info = exec_entry_point
100-
.execute(
101-
&mut state,
102-
&block_context,
103-
&mut resources_manager,
104-
&mut tx_execution_context,
105-
false,
106-
block_context.invoke_tx_max_n_steps(),
107-
)
108-
.expect("failed");
109-
110-
dbg!(call_info);
81+
calldata,
82+
vec![],
83+
block_context.starknet_os_config().chain_id().clone(),
84+
Some(1.into()),
85+
)
86+
.unwrap();
87+
88+
let tx = Transaction::InvokeFunction(invoke);
89+
let call_info = tx
90+
.execute(&mut state, &block_context, 0)
91+
.expect("failed to invoke");
92+
93+
dbg!(call_info.revert_error);
94+
//dbg!(call_info);
95+
panic!()
11196
}

0 commit comments

Comments
 (0)