diff --git a/README.md b/README.md index 38d0a0b7..0d7ed9de 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,18 @@ Alternatively, if you have [nix](https://nixos.org/) installed, you can get the full development environment `nix develop`. +- Also you need installed python, so we can compile cairo0 programs in benchmarks/integration tests, to insatll them just run: + ```bash + make deps + ``` + if u got macos: + ```bash + make deps-macos + ``` +- After you need compile all cairo0 programs, to use test or benchmarks: + ```bash + make compile-cairo-programs + ``` ## ⚡ Wanna get up to speed fast?
@@ -64,9 +76,19 @@ You can display the help message by running: ### Run a cairo program +Without proof mode: ```bash +./zig-out/bin/ziggy-starkdust execute --filename cairo_programs/fibonacci.json +``` -./zig-out/bin/ziggy-starkdust execute --filename cairo_programs/fibonacci.json --proof-mode=false +With proof mode: +```bash +./zig-out/bin/ziggy-starkdust execute --filename cairo_programs/fibonacci.json --proof-mode +``` + +With memory layout, trace, proof mode and custom layout: +```bash +./zig-out/bin/ziggy-starkdust execute --filename cairo_programs/fibonacci.json --memory-file=/dev/null --trace-file=/dev/null --proof-mode=true --layout all_cairo ``` diff --git a/build.zig b/build.zig index 3b3dc594..463e5232 100644 --- a/build.zig +++ b/build.zig @@ -114,7 +114,6 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, - .link_libc = false, .omit_frame_pointer = if (optimize == .ReleaseFast) null else false, .strip = if (optimize == .ReleaseFast) true else null, diff --git a/src/cmd/cmd.zig b/src/cmd/cmd.zig index 2139fe22..71158950 100644 --- a/src/cmd/cmd.zig +++ b/src/cmd/cmd.zig @@ -248,7 +248,7 @@ const UsageError = error{ /// Returns a `UsageError` if there's a misuse of the CLI, specifically if tracing is attempted /// while it's disabled in the build. fn execute() anyerror!void { - var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); + var arena = std.heap.ArenaAllocator.init(global_allocator); defer arena.deinit(); try runProgram(arena.allocator(), cfg); diff --git a/src/hint_processor/math_hints.zig b/src/hint_processor/math_hints.zig index 3b52f374..07c834cc 100644 --- a/src/hint_processor/math_hints.zig +++ b/src/hint_processor/math_hints.zig @@ -65,15 +65,14 @@ pub fn isPositive(allocator: Allocator, vm: *CairoVM, ids_data: std.StringHashMa ), vm, ids_data, ap_tracking); } -// Implements hint:from starkware.cairo.common.math.cairo +//Implements hint:from starkware.cairo.common.math.cairo // -// %{ -// from starkware.cairo.common.math_utils import assert_integer -// assert_integer(ids.value) -// assert ids.value % PRIME != 0, f'assert_not_zero failed: {ids.value} = 0.' +//%{ +// from starkware.cairo.common.math_utils import assert_integer +// assert_integer(ids.value) +// assert ids.value % PRIME != 0, f'assert_not_zero failed: {ids.value} = 0.' // // %} - pub fn assertNonZero( vm: *CairoVM, ids_data: std.StringHashMap(HintReference), diff --git a/src/vm/core.zig b/src/vm/core.zig index 0b2798ce..623f793e 100644 --- a/src/vm/core.zig +++ b/src/vm/core.zig @@ -470,7 +470,7 @@ pub const CairoVM = struct { ) !void { // Check if tracing is disabled and log the current state if not. if (self.trace) |*trace| { - if (trace.capacity < trace.items.len + 1) + if (trace.capacity <= trace.items.len) try trace.ensureTotalCapacityPrecise(trace.capacity * 2); trace.appendAssumeCapacity( diff --git a/src/vm/memory/memory.zig b/src/vm/memory/memory.zig index 64b72e1e..7e70f0bf 100644 --- a/src/vm/memory/memory.zig +++ b/src/vm/memory/memory.zig @@ -370,7 +370,7 @@ pub const Memory = struct { /// - `MemoryError.DuplicatedRelocation` if there is an attempt to overwrite existing memory. /// # Safety /// This function assumes proper initialization and management of the VM memory. - pub fn set( + pub inline fn set( self: *Self, allocator: Allocator, address: Relocatable, @@ -380,9 +380,6 @@ pub const Memory = struct { var data = self.getDataFromSegmentIndex(address.segment_index); const insert_segment_index = address.getAdjustedSegmentIndex(); - // if (address.segment_index == 0 and value.isFelt()) - // std.debug.panic("set {any}, value {any}", .{ address, value }); - // Check if the data segment is allocated for the given segment index. if (data.len <= insert_segment_index) return MemoryError.UnallocatedSegment; @@ -902,7 +899,7 @@ pub const Memory = struct { return value; } - pub fn relAddress(self: *const Self, address: Relocatable) !MaybeRelocatable { + pub inline fn relAddress(self: *const Self, address: Relocatable) !MaybeRelocatable { // Attempt to retrieve relocation rules for the given segment index. if (address.segment_index < 0) if (self.relocation_rules.get(address.getAdjustedSegmentIndex())) |x|