-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from HerodotusDev/dryrun_syscall_handler
dryrun syscall handler & hdp_cairo scarb package
- Loading branch information
Showing
19 changed files
with
101 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[workspace] | ||
name = "hdp_cairo" | ||
version = "0.1.0" | ||
edition = "2023_11" | ||
|
||
members = [ | ||
"cairo", | ||
"src/contracts/simple_linear_regression" | ||
] | ||
|
||
[workspace.dependencies] | ||
hdp_cairo = { path = "cairo" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "hdp_cairo" | ||
version = "0.1.0" | ||
edition = "2023_11" | ||
|
||
# See more keys and their definitions at https://docs.swmansion.com/scarb/docs/reference/manifest.html | ||
|
||
[dependencies] | ||
starknet = "2.6.3" |
2 changes: 1 addition & 1 deletion
2
...near_regression/src/slr/hdp_context.cairo → cairo/src/lib.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub mod header_memorizer; | ||
pub mod memorizer; | ||
|
||
#[derive(Serde, Drop)] | ||
pub struct HDP { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod header_memorizer; |
3 changes: 1 addition & 2 deletions
3
...rc/slr/hdp_context/header_memorizer.cairo → cairo/src/memorizer/header_memorizer.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from rlp import decode | ||
from typing import ( | ||
Dict, | ||
Iterable, | ||
) | ||
from tools.py.utils import little_8_bytes_chunks_to_bytes | ||
from starkware.cairo.lang.vm.relocatable import RelocatableValue, MaybeRelocatable | ||
from starkware.cairo.lang.vm.memory_segments import MemorySegmentManager | ||
from contract_bootloader.syscall_handler_base import SyscallHandlerBase | ||
from starkware.cairo.common.dict import DictManager | ||
from starkware.cairo.common.structs import CairoStructProxy | ||
from tools.py.block_header import BlockHeaderDencun as Block | ||
from starkware.cairo.lang.vm.crypto import poseidon_hash_many | ||
from starkware.starknet.business_logic.execution.objects import ( | ||
CallResult, | ||
) | ||
|
||
|
||
class SyscallHandler(SyscallHandlerBase): | ||
""" | ||
A handler for system calls; used by the BusinessLogic entry point execution. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
dict_manager: DictManager, | ||
segments: MemorySegmentManager, | ||
): | ||
super().__init__(segments=segments, initial_syscall_ptr=None) | ||
self.syscall_counter: Dict[str, int] = {} | ||
self.dict_manager = dict_manager | ||
|
||
def set_syscall_ptr(self, syscall_ptr: RelocatableValue): | ||
assert self._syscall_ptr is None, "syscall_ptr is already set." | ||
self._syscall_ptr = syscall_ptr | ||
|
||
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, retdata: Iterable[int]) -> RelocatableValue: | ||
return self.allocate_segment(data=retdata) | ||
|
||
def _call_contract_helper( | ||
self, request: CairoStructProxy, syscall_name: str | ||
) -> CallResult: | ||
calldata = self._get_felt_range( | ||
start_addr=request.calldata_start, end_addr=request.calldata_end | ||
) | ||
|
||
return CallResult( | ||
gas_consumed=0, | ||
failure_flag=0, | ||
retdata=[], | ||
) |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters