Skip to content

Commit

Permalink
some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oxlime committed Nov 7, 2023
1 parent 54edcac commit c57896f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 11 additions & 5 deletions src/vm/builtins/builtin_runner/range_check.zig
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,18 @@ pub const RangeCheckBuiltinRunner = struct {
///
/// An `ArrayList(Relocatable)` containing the rules address
/// verification fails.
pub fn rangeCheckValidationRule(memory: *Memory, address: Relocatable) std.ArrayList(!Relocatable) {
const addr = memory.get(address);
if (addr.bits <= N_PARTS * INNER_RC_BOUND_SHIFT) {
return std.ArrayList.append(address);
pub fn rangeCheckValidationRule(memory: *Memory, address: Relocatable, allocator: Allocator) !std.ArrayList(Relocatable) {
var result = ArrayList(Relocatable).init(allocator);
const num = (memory.get(address) catch {
return null;
}).tryIntoFelt() catch {
return RunnerError.BuiltinExpectedInteger;
};

if (num.Mask <= N_PARTS * INNER_RC_BOUND_SHIFT) {
return result.append(address);
} else {
return std.ArrayList.append(Error.MemoryOutOfBounds);
return result.append(Error.MemoryOutOfBounds);
}
}

Expand Down
7 changes: 1 addition & 6 deletions src/vm/types/range_check_instance_def.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ pub const RangeCheckInstanceDef = struct {
/// For example, n_parts=8 defines the range [0, 2^128).
n_parts: u32,

/// Number of cells per built in
pub fn cellsPerBuiltin() u32 {
return CELLS_PER_RANGE_CHECK;
}

/// Number of units per builtin
pub fn rangeCheckUnitsPerBuiltin(self: *Self) u32 {
return self.n_parts;
}

pub fn default() !Self {
pub fn default() Self {
return .{
.ratio = 8,
.n_parts = 8,
Expand Down

0 comments on commit c57896f

Please sign in to comment.