Skip to content

Commit 3957406

Browse files
committed
fmt
1 parent efb33c5 commit 3957406

File tree

6 files changed

+44
-36
lines changed

6 files changed

+44
-36
lines changed

crates/vm/src/metrics/cycle_tracker/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ impl CycleTracker {
2323
pub fn top(&self) -> Option<&String> {
2424
match self.stack.last() {
2525
Some(span) => Some(&span.tag),
26-
_ => None
26+
_ => None,
2727
}
2828
}
2929

3030
/// Starts a new cycle tracker span for the given name.
31-
/// If a span already exists for the given name, it ends the existing span and pushes a new one to the vec.
31+
/// If a span already exists for the given name, it ends the existing span and pushes a new one
32+
/// to the vec.
3233
pub fn start(&mut self, mut name: String, cycles_count: usize) {
3334
// hack to remove "CT-" prefix
3435
if name.starts_with("CT-") {

extensions/native/circuit/src/poseidon2/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ fn tester_with_random_poseidon2_ops(num_ops: usize) -> VmChipTester<BabyBearBlak
467467
PERM_POS2 => {
468468
tester.write(e, lhs, data_left);
469469
tester.write(e, lhs + CHUNK, data_right);
470-
},
470+
}
471471
MULTI_OBSERVE => {}
472472
}
473473

extensions/native/compiler/src/asm/compiler.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,10 +491,15 @@ impl<F: PrimeField32 + TwoAdicField, EF: ExtensionField<F> + TwoAdicField> AsmCo
491491
}
492492
DslIr::Poseidon2MultiObserve(dst, init_pos, arr_ptr, len) => {
493493
self.push(
494-
AsmInstruction::Poseidon2MultiObserve(dst.fp(), init_pos.fp(), arr_ptr.fp(), len.get_var().fp()),
494+
AsmInstruction::Poseidon2MultiObserve(
495+
dst.fp(),
496+
init_pos.fp(),
497+
arr_ptr.fp(),
498+
len.get_var().fp(),
499+
),
495500
debug_info,
496501
);
497-
},
502+
}
498503
DslIr::Poseidon2PermuteBabyBear(dst, src) => match (dst, src) {
499504
(Array::Dyn(dst, _), Array::Dyn(src, _)) => self.push(
500505
AsmInstruction::Poseidon2Permute(dst.fp(), src.fp()),

extensions/native/compiler/src/asm/instruction.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,11 @@ impl<F: PrimeField32, EF: ExtensionField<F>> AsmInstruction<F, EF> {
340340
AsmInstruction::Halt => write!(f, "halt"),
341341
AsmInstruction::HintBits(src, len) => write!(f, "hint_bits ({})fp, {}", src, len),
342342
AsmInstruction::Poseidon2MultiObserve(dst, init_pos, arr, len) => {
343-
write!(f, "poseidon2_multi_observe ({})fp, ({})fp ({})fp ({})fp", dst, init_pos, arr, len)
343+
write!(
344+
f,
345+
"poseidon2_multi_observe ({})fp, ({})fp ({})fp ({})fp",
346+
dst, init_pos, arr, len
347+
)
344348
}
345349
AsmInstruction::Poseidon2Permute(dst, lhs) => {
346350
write!(f, "poseidon2_permute ({})fp, ({})fp", dst, lhs)

extensions/native/compiler/src/ir/instructions.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,13 @@ pub enum DslIr<C: Config> {
208208
/// Permutes an array of Bn254 elements using Poseidon2 (output = p2_permute(array)). Should
209209
/// only be used when target is a circuit.
210210
CircuitPoseidon2Permute([Var<C::N>; 3]),
211-
/// Absorbs an array of baby bear elements into a duplex transcript with Poseidon2 permutations (output = p2_multi_observe(array, els)).
211+
/// Absorbs an array of baby bear elements into a duplex transcript with Poseidon2 permutations
212+
/// (output = p2_multi_observe(array, els)).
212213
Poseidon2MultiObserve(
213-
Ptr<C::N>, // sponge_state
214-
Var<C::N>, // initial input_ptr position
215-
Ptr<C::N>, // input array (base elements)
216-
Usize<C::N>, // len of els
214+
Ptr<C::N>, // sponge_state
215+
Var<C::N>, // initial input_ptr position
216+
Ptr<C::N>, // input array (base elements)
217+
Usize<C::N>, // len of els
217218
),
218219

219220
// Miscellaneous instructions.

extensions/native/compiler/src/ir/poseidon.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
use openvm_native_compiler_derive::iter_zip;
22
use openvm_stark_backend::p3_field::FieldAlgebra;
33

4-
use crate::ir::Variable;
5-
64
use super::{Array, ArrayLike, Builder, Config, DslIr, Ext, Felt, MemIndex, Ptr, Usize, Var};
5+
use crate::ir::Variable;
76

87
pub const DIGEST_SIZE: usize = 8;
98
pub const HASH_RATE: usize = 8;
109
pub const PERMUTATION_WIDTH: usize = 16;
1110

1211
impl<C: Config> Builder<C> {
1312
/// Extends native VM ability to observe multiple base elements in one opcode operation
14-
/// Absorbs elements sequentially at the RATE portion of sponge state and performs as many permutations as necessary.
15-
/// Returns the index position of the next input_ptr.
16-
///
13+
/// Absorbs elements sequentially at the RATE portion of sponge state and performs as many
14+
/// permutations as necessary. Returns the index position of the next input_ptr.
15+
///
1716
/// [Reference](https://docs.rs/p3-poseidon2/latest/p3_poseidon2/struct.Poseidon2.html)
1817
pub fn poseidon2_multi_observe(
1918
&mut self,
20-
sponge_state: &Array<C, Felt<C::F>>,
19+
sponge_state: &Array<C, Felt<C::F>>,
2120
input_ptr: Ptr<C::N>,
2221
arr: &Array<C, Felt<C::F>>,
2322
) -> Usize<C::N> {
@@ -28,26 +27,24 @@ impl<C: Config> Builder<C> {
2827
Array::Fixed(_) => {
2928
panic!("Poseidon2 permutation is not allowed on fixed arrays");
3029
}
31-
Array::Dyn(sponge_ptr, _) => {
32-
match arr {
33-
Array::Fixed(_) => {
34-
panic!("Base elements input must be dynamic");
35-
}
36-
Array::Dyn(ptr, len) => {
37-
let init_pos: Var<C::N> = Var::uninit(self);
38-
self.assign(&init_pos, input_ptr.address - sponge_ptr.address);
39-
40-
self.operations.push(DslIr::Poseidon2MultiObserve(
41-
*sponge_ptr,
42-
init_pos,
43-
*ptr,
44-
len.clone(),
45-
));
46-
47-
Usize::Var(init_pos)
48-
}
30+
Array::Dyn(sponge_ptr, _) => match arr {
31+
Array::Fixed(_) => {
32+
panic!("Base elements input must be dynamic");
4933
}
50-
}
34+
Array::Dyn(ptr, len) => {
35+
let init_pos: Var<C::N> = Var::uninit(self);
36+
self.assign(&init_pos, input_ptr.address - sponge_ptr.address);
37+
38+
self.operations.push(DslIr::Poseidon2MultiObserve(
39+
*sponge_ptr,
40+
init_pos,
41+
*ptr,
42+
len.clone(),
43+
));
44+
45+
Usize::Var(init_pos)
46+
}
47+
},
5148
}
5249
}
5350

0 commit comments

Comments
 (0)