Skip to content

Commit 5ff337e

Browse files
feat(starknet_os): implement deploy syscall (#6771)
1 parent 5dce449 commit 5ff337e

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

crates/starknet_os/src/hint_processor/snos_syscall_executor.rs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,34 @@ impl<S: StateReader> SyscallExecutor for SnosHintProcessor<'_, S> {
147147
syscall_handler: &mut Self,
148148
remaining_gas: &mut u64,
149149
) -> SyscallResult<DeployResponse> {
150-
todo!()
150+
// TODO(Nimrod): Handle errors correctly.
151+
let call_info_tracker = syscall_handler
152+
.execution_helpers_manager
153+
.get_mut_current_execution_helper()
154+
.unwrap()
155+
.tx_execution_iter
156+
.tx_execution_info_ref
157+
.as_mut()
158+
.unwrap()
159+
.call_info_tracker
160+
.as_mut()
161+
.unwrap();
162+
163+
let deployed_contract_address =
164+
call_info_tracker.deployed_contracts_iterator.next().unwrap();
165+
let execution = &call_info_tracker.inner_calls_iterator.next().unwrap().execution;
166+
167+
*remaining_gas -= execution.gas_consumed;
168+
let retdata: Vec<_> = execution.retdata.0.iter().map(MaybeRelocatable::from).collect();
169+
let retdata_base = vm.add_temporary_segment();
170+
vm.load_data(retdata_base, &retdata).unwrap();
171+
if execution.failed {
172+
return Err(SyscallExecutionError::Revert { error_data: execution.retdata.0.clone() });
173+
};
174+
Ok(DeployResponse {
175+
contract_address: deployed_contract_address,
176+
constructor_retdata: ReadOnlySegment { start_ptr: retdata_base, length: retdata.len() },
177+
})
151178
}
152179

153180
fn emit_event(

0 commit comments

Comments
 (0)