Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Okm165 committed May 27, 2024
1 parent 94c366c commit 3c15fda
Show file tree
Hide file tree
Showing 22 changed files with 87 additions and 94 deletions.
19 changes: 4 additions & 15 deletions cairo0-bootloader/bootloader/contract/execute_entry_point.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ from starkware.starknet.core.os.constants import (
ENTRY_POINT_TYPE_L1_HANDLER,
NOP_ENTRY_POINT_OFFSET,
)
from contract_class.compiled_class import (
CompiledClass,
CompiledClassEntryPoint,
CompiledClassFact,
)
from contract_class.compiled_class import CompiledClass, CompiledClassEntryPoint, CompiledClassFact
from starkware.starknet.core.os.output import OsCarriedOutputs

struct BuiltinData {
Expand Down Expand Up @@ -88,9 +84,7 @@ func call_execute_syscalls{
contract_class_changes: DictAccess*,
outputs: OsCarriedOutputs*,
}(block_context: BlockContext*, execution_context: ExecutionContext*, syscall_ptr_end: felt*) {
%{
print("call_execute_syscalls")
%}
%{ print("call_execute_syscalls") %}
}

// Returns the CompiledClassEntryPoint, based on 'compiled_class' and 'execution_context'.
Expand Down Expand Up @@ -148,9 +142,7 @@ func get_entry_point{range_check_ptr}(
// block_context - a global context that is fixed throughout the block.
// execution_context - The context for the current execution.
func execute_entry_point{
range_check_ptr,
builtin_ptrs: BuiltinPointers*,
builtin_encodings: BuiltinData*,
range_check_ptr, builtin_ptrs: BuiltinPointers*, builtin_encodings: BuiltinData*
}(compiled_class: CompiledClass*, execution_context: ExecutionContext*) -> (
retdata_size: felt, retdata: felt*
) {
Expand All @@ -173,9 +165,7 @@ func execute_entry_point{

local syscall_ptr: felt*;

%{
ids.syscall_ptr = segments.add()
%}
%{ ids.syscall_ptr = segments.add() %}

let builtin_ptrs: BuiltinPointers* = prepare_builtin_ptrs_for_execute(builtin_ptrs);

Expand Down Expand Up @@ -215,7 +205,6 @@ func execute_entry_point{
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.
Expand Down
25 changes: 15 additions & 10 deletions cairo0-bootloader/bootloader/contract/run_contract_bootloader.cairo
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from starkware.cairo.common.cairo_builtins import HashBuiltin, PoseidonBuiltin, BitwiseBuiltin, KeccakBuiltin
from starkware.cairo.common.cairo_builtins import (
HashBuiltin,
PoseidonBuiltin,
BitwiseBuiltin,
KeccakBuiltin,
)
from starkware.cairo.common.registers import get_fp_and_pc
from contract_class.compiled_class import CompiledClass
from starkware.starknet.builtins.segment_arena.segment_arena import new_arena
Expand All @@ -7,7 +12,12 @@ from starkware.starknet.core.os.builtins import (
NonSelectableBuiltins,
SelectableBuiltins,
)
from bootloader.contract.execute_entry_point import execute_entry_point, ExecutionContext, ExecutionInfo, BuiltinData
from bootloader.contract.execute_entry_point import (
execute_entry_point,
ExecutionContext,
ExecutionInfo,
BuiltinData,
)

// Loads the programs and executes them.
//
Expand Down Expand Up @@ -60,13 +70,9 @@ func run_contract_bootloader{
let builtin_encodings = &local_builtin_encodings;

local calldata: felt*;
%{
ids.calldata = segments.add()
%}
%{ ids.calldata = segments.add() %}

local execution_info: ExecutionInfo = ExecutionInfo(
selector=0,
);
local execution_info: ExecutionInfo = ExecutionInfo(selector=0);

from starkware.starknet.core.os.constants import (
DEFAULT_ENTRY_POINT_SELECTOR,
Expand All @@ -81,7 +87,6 @@ func run_contract_bootloader{
entry_point_type=ENTRY_POINT_TYPE_EXTERNAL,
calldata_size=0,
calldata=calldata,
// Additional information about the execution.
execution_info=&execution_info,
);

Expand All @@ -90,4 +95,4 @@ func run_contract_bootloader{
}

return ();
}
}
11 changes: 7 additions & 4 deletions cairo0-bootloader/bootloader/contract/simple_bootloader.cairo
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
%builtins output pedersen range_check ecdsa bitwise ec_op keccak poseidon

from bootloader.contract.run_contract_bootloader import (
run_contract_bootloader,
from bootloader.contract.run_contract_bootloader import run_contract_bootloader
from starkware.cairo.common.cairo_builtins import (
HashBuiltin,
PoseidonBuiltin,
BitwiseBuiltin,
KeccakBuiltin,
)
from starkware.cairo.common.cairo_builtins import HashBuiltin, PoseidonBuiltin, BitwiseBuiltin, KeccakBuiltin
from starkware.cairo.common.registers import get_fp_and_pc
from contract_class.compiled_class import CompiledClass

Expand Down Expand Up @@ -46,4 +49,4 @@ func main{
run_contract_bootloader(compiled_class);

return ();
}
}
10 changes: 7 additions & 3 deletions cairo0-bootloader/bootloader/contract/syscall_handler.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
from typing import Iterable
from starkware.starknet.core.os.syscall_handler import SyscallHandlerBase, OsExecutionHelper
from starkware.starknet.core.os.syscall_handler import (
SyscallHandlerBase,
OsExecutionHelper,
)
from starkware.cairo.lang.vm.relocatable import RelocatableValue, MaybeRelocatable
from starkware.cairo.lang.vm.memory_segments import MemorySegmentManager


class SyscallHandler(SyscallHandlerBase):
"""
A handler for system calls; used by the BusinessLogic entry point execution.
Expand All @@ -22,7 +26,7 @@ def allocate_segment(self, data: Iterable[MaybeRelocatable]) -> RelocatableValue
segment_start = self.segments.add()
self.segments.write_arg(ptr=segment_start, arg=data)
return segment_start

def _allocate_segment_for_retdata(self):
# Implementation here
pass
Expand Down Expand Up @@ -73,4 +77,4 @@ def _storage_write(self):

def current_block_number(self):
# Implementation here
pass
pass
2 changes: 1 addition & 1 deletion cairo0-bootloader/bootloader/recursive/execute_task.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,4 @@ func execute_task{builtin_ptrs: BuiltinData*, self_range_check_ptr}(

let builtin_ptrs = &return_builtin_ptrs;
return ();
}
}
17 changes: 4 additions & 13 deletions cairo0-bootloader/bootloader/recursive/run_simple_bootloader.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ from common.registers import get_fp_and_pc
// Updated builtin pointers after executing all programs.
// fact_topologies - that corresponds to the tasks (hint variable).
func run_simple_bootloader{
output_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr,
bitwise_ptr,
output_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr, bitwise_ptr
}() {
alloc_locals;
local task_range_check_ptr;
Expand Down Expand Up @@ -45,17 +42,11 @@ func run_simple_bootloader{

// A struct containing the encoding of each builtin.
local builtin_encodings: BuiltinData = BuiltinData(
output='output',
pedersen='pedersen',
range_check='range_check',
bitwise='bitwise',
output='output', pedersen='pedersen', range_check='range_check', bitwise='bitwise'
);

local builtin_instance_sizes: BuiltinData = BuiltinData(
output=1,
pedersen=3,
range_check=1,
bitwise=5,
output=1, pedersen=3, range_check=1, bitwise=5
);

// Call execute_tasks.
Expand Down Expand Up @@ -152,4 +143,4 @@ func execute_tasks{builtin_ptrs: BuiltinData*, self_range_check_ptr}(
builtin_instance_sizes=builtin_instance_sizes,
n_tasks=n_tasks - 1,
);
}
}
13 changes: 3 additions & 10 deletions cairo0-bootloader/bootloader/recursive/simple_bootloader.cairo
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
%builtins output pedersen range_check bitwise

from bootloader.recursive.run_simple_bootloader import (
run_simple_bootloader,
)
from bootloader.recursive.run_simple_bootloader import run_simple_bootloader
from common.cairo_builtins import HashBuiltin
from common.registers import get_fp_and_pc

func main{
output_ptr: felt*,
pedersen_ptr: HashBuiltin*,
range_check_ptr,
bitwise_ptr,
}() {
func main{output_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr, bitwise_ptr}() {
%{
from bootloader.objects import SimpleBootloaderInput
simple_bootloader_input = SimpleBootloaderInput.Schema().load(program_input)
Expand Down Expand Up @@ -44,4 +37,4 @@ func main{
)
%}
return ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,4 @@ func execute_task{builtin_ptrs: BuiltinData*, self_range_check_ptr}(

let builtin_ptrs = &return_builtin_ptrs;
return ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@ func run_simple_bootloader{
);

local builtin_instance_sizes: BuiltinData = BuiltinData(
output=1,
pedersen=3,
range_check=1,
bitwise=5,
poseidon=6,
output=1, pedersen=3, range_check=1, bitwise=5, poseidon=6
);

// Call execute_tasks.
Expand Down Expand Up @@ -153,11 +149,7 @@ func execute_tasks{builtin_ptrs: BuiltinData*, self_range_check_ptr}(
}

local input_size = Input.SIZE;
local input: Input = Input(
a=3,
b=4,
c=5,
);
local input: Input = Input(a=3, b=4, c=5);

%{
from bootloader.objects import Task
Expand Down Expand Up @@ -188,4 +180,4 @@ func execute_tasks{builtin_ptrs: BuiltinData*, self_range_check_ptr}(
builtin_instance_sizes=builtin_instance_sizes,
n_tasks=n_tasks - 1,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
%builtins output pedersen range_check bitwise poseidon

from bootloader.recursive_with_poseidon.run_simple_bootloader import (
run_simple_bootloader,
)
from bootloader.recursive_with_poseidon.run_simple_bootloader import run_simple_bootloader
from common.cairo_builtins import HashBuiltin, PoseidonBuiltin
from common.registers import get_fp_and_pc

Expand Down Expand Up @@ -45,4 +43,4 @@ func main{
)
%}
return ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,4 @@ func execute_task{builtin_ptrs: BuiltinData*, self_range_check_ptr}(

let builtin_ptrs = &return_builtin_ptrs;
return ();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,7 @@ func run_simple_bootloader{
);

local builtin_instance_sizes: BuiltinData = BuiltinData(
output=1,
pedersen=3,
range_check=1,
ecdsa=2,
bitwise=5,
ec_op=7,
keccak=16,
poseidon=6,
output=1, pedersen=3, range_check=1, ecdsa=2, bitwise=5, ec_op=7, keccak=16, poseidon=6
);

// Call execute_tasks.
Expand Down Expand Up @@ -172,4 +165,4 @@ func execute_tasks{builtin_ptrs: BuiltinData*, self_range_check_ptr}(
builtin_instance_sizes=builtin_instance_sizes,
n_tasks=n_tasks - 1,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
%builtins output pedersen range_check ecdsa bitwise ec_op keccak poseidon

from bootloader.starknet_with_keccak.run_simple_bootloader import (
run_simple_bootloader,
)
from bootloader.starknet_with_keccak.run_simple_bootloader import run_simple_bootloader
from common.cairo_builtins import HashBuiltin, PoseidonBuiltin
from common.registers import get_fp_and_pc

Expand Down Expand Up @@ -48,4 +46,4 @@ func main{
)
%}
return ();
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/builtin_poseidon/poseidon.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ func poseidon_hash_many{poseidon_ptr: PoseidonBuiltin*}(n: felt, elements: felt*
let res = poseidon_ptr.output.s0;
let poseidon_ptr = poseidon_ptr + PoseidonBuiltin.SIZE;
return (res=res);
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/cairo_builtins.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ struct KeccakBuiltin {
struct PoseidonBuiltin {
input: PoseidonBuiltinState,
output: PoseidonBuiltinState,
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/ec_point.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
struct EcPoint {
x: felt,
y: felt,
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/hash_chain.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ func hash_chain{hash_ptr: HashBuiltin*}(data_ptr: felt*) -> (hash: felt) {
// Set the hash_ptr implicit argument and return the result.
let hash_ptr = next_frame.hash_ptr;
return (hash=next_frame.cur_hash);
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/keccak_state.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ struct KeccakBuiltinState {
s5: felt,
s6: felt,
s7: felt,
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/poseidon_state.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ struct PoseidonBuiltinState {
s0: felt,
s1: felt,
s2: felt,
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/common/registers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ func get_label_location(label_value: codeoffset) -> (res: felt*) {
ret_pc_label:
return (res=pc_val + (label_value - ret_pc_label));
}
}
2 changes: 1 addition & 1 deletion cairo0-bootloader/lang/compiler/lib/registers.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ func get_ap() -> (ap_val: felt*) {
// Hence, the desired ap value is fp - 2.
let (fp_val, pc_val) = get_fp_and_pc();
return (ap_val=fp_val - 2);
}
}
Loading

0 comments on commit 3c15fda

Please sign in to comment.