Skip to content

Commit

Permalink
change add_int implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrigada committed Mar 7, 2023
1 parent 6205fdf commit 25f4782
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
38 changes: 17 additions & 21 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov

# - name: Set up cargo cache
# uses: Swatinem/rust-cache@v2
- name: Set up cargo cache
uses: Swatinem/rust-cache@v2

- name: Install test dependencies
run: pip install ecdsa fastecdsa sympy cairo-lang
Expand All @@ -39,27 +39,23 @@ jobs:
fetch-depth: 0
- name: Format
run: cargo fmt --all -- --check
- name: cat
run: cat src/types/relocatable.rs
- name: git log
run: git log
- name: Build
run: make build
# - name: Populate cache
# uses: actions/cache@v3
# id: cache-cairo-programs
# with:
# path: |
# cairo_programs/*.json
# cairo_programs/*.memory
# cairo_programs/*.trace
# !cairo_programs/*.rs.*
# cairo_programs/*/*.json
# cairo_programs/*/*.memory
# cairo_programs/*/*.trace
# !cairo_programs/*/*.rs.*
# key: cairo-cache-${{ hashFiles( 'cairo_programs/*.cairo', 'cairo_programs/*/*.cairo' ) }}
# restore-keys: cairo-cache-
- name: Populate cache
uses: actions/cache@v3
id: cache-cairo-programs
with:
path: |
cairo_programs/*.json
cairo_programs/*.memory
cairo_programs/*.trace
!cairo_programs/*.rs.*
cairo_programs/*/*.json
cairo_programs/*/*.memory
cairo_programs/*/*.trace
!cairo_programs/*/*.rs.*
key: cairo-cache-${{ hashFiles( 'cairo_programs/*.cairo', 'cairo_programs/*/*.cairo' ) }}
restore-keys: cairo-cache-
- name: Restore timestamps
uses: chetan/git-restore-mtime-action@v1
- name: Install dependencies
Expand Down
11 changes: 6 additions & 5 deletions src/vm/runners/builtin_runner/ec_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ impl EcOpBuiltinRunner {
return Ok(None);
}
let instance = Relocatable::from((address.segment_index, address.offset - index));
let x_addr = instance
.add_int(&Felt::new(INPUT_CELLS_PER_EC_OP))
let x_addr = (instance + (&Felt::new(INPUT_CELLS_PER_EC_OP)))
.map_err(|_| RunnerError::Memory(MemoryError::ExpectedInteger(instance)))?;

if let Some(number) = self.cache.borrow().get(&address).cloned() {
Expand Down Expand Up @@ -220,9 +219,11 @@ impl EcOpBuiltinRunner {
self.cache
.borrow_mut()
.insert(x_addr, result.0.clone().into());
self.cache
.borrow_mut()
.insert(x_addr + 1, result.1.clone().into());
self.cache.borrow_mut().insert(
(x_addr + 1usize)
.map_err(|_| RunnerError::Memory(MemoryError::ExpectedInteger(x_addr)))?,
result.1.clone().into(),
);
match index - self.n_input_cells as usize {
0 => Ok(Some(MaybeRelocatable::Int(Felt::new(result.0)))),
_ => Ok(Some(MaybeRelocatable::Int(Felt::new(result.1)))),
Expand Down

0 comments on commit 25f4782

Please sign in to comment.