Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed May 24, 2024
1 parent 74973ad commit 9513718
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,19 @@ func run_contract_bootloader{
);
let builtin_encodings = &local_builtin_encodings;

local calldata = nondet %{ segments.add() %};
local calldata = 0x0;
local execution_info: ExecutionInfo = ExecutionInfo(
selector=0
block_info=0,
tx_info=0,

// Entry-point-specific info.

caller_address=0,
// The execution is done in the context of the contract at this address.
// It controls the storage being used, messages sent to L1, calling contracts, etc.
contract_address=0,
// The entry point selector.
selector=0,
);

from starkware.starknet.core.os.constants import (
Expand All @@ -74,10 +84,15 @@ func run_contract_bootloader{
)

local execution_context: ExecutionContext = ExecutionContext(
entry_point_type = ENTRY_POINT_TYPE_EXTERNAL,
calldata_size = 0,
calldata = &calldata,
execution_info=&execution_info
entry_point_type=ENTRY_POINT_TYPE_EXTERNAL,
// The hash of the contract class to execute.
class_hash=0,
calldata_size=0,
calldata=0,
// Additional information about the execution.
execution_info=&execution_info,
// Information about the transaction that triggered the execution.
deprecated_tx_info=0,
);

with builtin_ptrs, builtin_encodings {
Expand Down
38 changes: 23 additions & 15 deletions cairo0-bootloader/execution/execute_entry_point.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,25 @@ struct BuiltinData {
}

struct ExecutionInfo {
caller_address: felt,
// The execution is done in the context of the contract at this address.
// It controls the storage being used, messages sent to L1, calling contracts, etc.
contract_address: felt,
// The entry point selector.
selector: felt,
}

// Represents the execution context during the execution of contract code.
struct ExecutionContext {
entry_point_type: felt,
// The hash of the contract class to execute.
class_hash: felt,
calldata_size: felt,
calldata: felt*,
// Additional information about the execution.
execution_info: ExecutionInfo*,
// Information about the transaction that triggered the execution.
deprecated_tx_info: DeprecatedTxInfo*,
}

// Represents the arguments pushed to the stack before calling an entry point.
Expand Down Expand Up @@ -172,14 +180,11 @@ func execute_entry_point{
local range_check_ptr = range_check_ptr;
local contract_entry_point: felt* = compiled_class.bytecode_ptr + entry_point_offset;

local os_context: felt*;
local syscall_ptr: felt*;

%{
ids.os_context = segments.add()
ids.syscall_ptr = segments.add()
%}
assert [os_context] = cast(syscall_ptr, felt);

let builtin_ptrs: BuiltinPointers* = prepare_builtin_ptrs_for_execute(builtin_ptrs);

Expand All @@ -197,34 +202,37 @@ func execute_entry_point{
n_selected_builtins=entry_point_n_builtins,
);

%{
print(ids.compiled_class_entry_point.n_builtins)
%}

// Use tempvar to pass the rest of the arguments to contract_entry_point().
let current_ap = ap;
tempvar args = EntryPointCallArguments(
gas_builtin=1000000000,
gas_builtin=10000000000,
syscall_ptr=syscall_ptr,
calldata_start=calldata_start,
calldata_end=calldata_end,
);
static_assert ap == current_ap + EntryPointCallArguments.SIZE;

%{
print(ids.compiled_class_entry_point.n_builtins)
print(ids.calldata_start)
print(ids.calldata_end)
print(ids.contract_entry_point)
print(ids.syscall_ptr)
%}

%{ vm_enter_scope() %}
call abs contract_entry_point;
%{ vm_exit_scope() %}

// Retrieve returned_builtin_ptrs_subset.
// Note that returned_builtin_ptrs_subset cannot be set in a hint because doing so will allow a
// malicious prover to lie about the storage changes of a valid contract.
let (ap_val) = get_ap();
local return_values_ptr: felt* = ap_val - EntryPointReturnValues.SIZE;
local returned_builtin_ptrs_subset: felt* = return_values_ptr - entry_point_n_builtins;
local entry_point_return_values: EntryPointReturnValues* = cast(
return_values_ptr, EntryPointReturnValues*
);
// let (ap_val) = get_ap();
// local return_values_ptr: felt* = ap_val - EntryPointReturnValues.SIZE;
// local returned_builtin_ptrs_subset: felt* = return_values_ptr - entry_point_n_builtins;
// local entry_point_return_values: EntryPointReturnValues* = cast(
// return_values_ptr, EntryPointReturnValues*
// );

return (retdata_size=0, retdata=cast(0, felt*));
}
Expand Down

0 comments on commit 9513718

Please sign in to comment.