lambdaclass / cairo-vm_in_go

cairo-vm_in_go is a Go implementation of the Cairo VM. Cairo (CPU Algebraic Intermediate Representation) is a programming language for writing provable programs, where one party can prove to another that a certain computation was executed correctly without the need for this party to re-execute the same program.
Apache License 2.0
56 stars 13 forks source link

Fix `math_utils.DivCeil` #284

Closed fmoletta closed 1 year ago

fmoletta commented 1 year ago

The current implementation yields incorrect values when x is zero. As this function is used when calculating the instances used by a builtin, when running a cairo program with a builtin who's segment used size is zero, the vm would throw an invalid stop ptr error, as the used cells (calculated from used_size.div_ceil(cells_per_instance) * cells_per_instance) would not be zero

codecov-commenter commented 1 year ago

Codecov Report

Merging #284 (b4312d7) into main (102682a) will decrease coverage by 0.05%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #284      +/-   ##
==========================================
- Coverage   58.75%   58.71%   -0.05%     
==========================================
  Files          42       42              
  Lines        5383     5387       +4     
==========================================
  Hits         3163     3163              
- Misses       1947     1951       +4     
  Partials      273      273              
Files Changed Coverage Δ
pkg/utils/math_utils.go 0.00% <0.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more