Skip to content

Commit

Permalink
Solve post-merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Mar 7, 2023
1 parent cef4153 commit a9e0051
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/vm/runners/builtin_runner/poseidon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,19 @@ impl PoseidonBuiltinRunner {
if let Some(felt) = self.cache.borrow().get(&address) {
return Ok(Some(felt.into()));
}
// index will always be less than address.offset, so we can safely unwrap here
let first_input_addr = address.sub_usize(index).unwrap();
let first_output_addr = first_input_addr + self.n_input_cells as usize;
let first_input_addr = (address - index)?;
let first_output_addr = (first_input_addr + self.n_input_cells as usize)?;

let mut input_felts = Vec::<FieldElement>::new();

for i in 0..self.n_input_cells as usize {
let val = match memory.get(&(first_input_addr + i)) {
let val = match memory.get(&(first_input_addr + i)?) {
Some(value) => {
let num = value
.get_int_ref()
.ok_or(RunnerError::BuiltinExpectedInteger(
POSEIDON_BUILTIN_NAME,
first_input_addr + i,
(first_input_addr + i)?,
))?;
FieldElement::from_dec_str(&num.to_str_radix(10))
.map_err(|_| RunnerError::FailedStringConversion)?
Expand All @@ -103,7 +102,7 @@ impl PoseidonBuiltinRunner {
permute_comp(&mut poseidon_state);
for (i, elem) in poseidon_state.iter().enumerate() {
self.cache.borrow_mut().insert(
first_output_addr + i,
(first_output_addr + i)?,
Felt::from_bytes_be(&elem.to_bytes_be()),
);
}
Expand Down Expand Up @@ -132,7 +131,7 @@ impl PoseidonBuiltinRunner {
vm: &VirtualMachine,
) -> Result<(usize, usize), MemoryError> {
let ratio = self.ratio as usize;
let min_step = ratio * 1_usize /* TODO: Override with change */;
let min_step = ratio /* TODO: Override with change */;
if vm.current_step < min_step {
Err(
InsufficientAllocatedCellsError::MinStepNotReached(min_step, POSEIDON_BUILTIN_NAME)
Expand Down Expand Up @@ -174,9 +173,8 @@ impl PoseidonBuiltinRunner {
pointer: Relocatable,
) -> Result<Relocatable, RunnerError> {
if self.included {
let stop_pointer_addr = pointer
.sub_usize(1)
.map_err(|_| RunnerError::NoStopPointer(POSEIDON_BUILTIN_NAME))?;
let stop_pointer_addr =
(pointer - 1).map_err(|_| RunnerError::NoStopPointer(POSEIDON_BUILTIN_NAME))?;
let stop_pointer = segments
.memory
.get_relocatable(stop_pointer_addr)
Expand Down

1 comment on commit a9e0051

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.30.

Benchmark suite Current: a9e0051 Previous: 91bd6b0 Ratio
cairo_run(cairo_programs/benchmarks/linear_search.json) 117648237 ns/iter (± 3257904) 90466462 ns/iter (± 446225) 1.30
cairo_run(cairo_programs/benchmarks/secp_integration_benchmark.json) 2044716327 ns/iter (± 26831695) 1518159929 ns/iter (± 2752559) 1.35
cairo_run(cairo_programs/benchmarks/blake2s_integration_benchmark.json) 1641492380 ns/iter (± 24244837) 1233087060 ns/iter (± 2610574) 1.33
cairo_run(cairo_programs/benchmarks/dict_integration_benchmark.json) 1102654958 ns/iter (± 22050824) 839120883 ns/iter (± 2317066) 1.31
cairo_run(cairo_programs/benchmarks/operations_with_data_structures_benchmarks.json) 2408508565 ns/iter (± 42023005) 1810785028 ns/iter (± 18730341) 1.33
cairo_run(cairo_programs/benchmarks/uint256_integration_benchmark.json) 1626185893 ns/iter (± 26534145) 1222491940 ns/iter (± 3372193) 1.33

This comment was automatically generated by workflow using github-action-benchmark.

CC: @unbalancedparentheses

Please sign in to comment.