Skip to content

Commit ab2c19d

Browse files
cargo make fmt-all
1 parent 74956b3 commit ab2c19d

File tree

131 files changed

+1053
-1231
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+1053
-1231
lines changed

ceno_emul/src/elf.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ extern crate alloc;
1919
use alloc::collections::BTreeMap;
2020

2121
use crate::addr::WORD_SIZE;
22-
use anyhow::{anyhow, bail, Context, Result};
23-
use elf::{endian::LittleEndian, file::Class, ElfBytes};
22+
use anyhow::{Context, Result, anyhow, bail};
23+
use elf::{ElfBytes, endian::LittleEndian, file::Class};
2424

2525
/// A RISC Zero program
2626
pub struct Program {

ceno_emul/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod addr;
22
pub use addr::*;
33

44
mod platform;
5-
pub use platform::{Platform, CENO_PLATFORM};
5+
pub use platform::{CENO_PLATFORM, Platform};
66

77
mod tracer;
88
pub use tracer::{Change, MemOp, ReadOp, StepRecord, Tracer, WriteOp};

ceno_emul/src/rv32im.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
// See the License for the specific language governing permissions and
1515
// limitations under the License.
1616

17-
use anyhow::{anyhow, Result};
17+
use anyhow::{Result, anyhow};
1818
use std::sync::OnceLock;
1919
use strum_macros::EnumIter;
2020

21-
use super::addr::{ByteAddr, RegIdx, Word, WordAddr, WORD_SIZE};
21+
use super::addr::{ByteAddr, RegIdx, WORD_SIZE, Word, WordAddr};
2222

2323
pub trait EmuContext {
2424
// Handle environment call

ceno_emul/src/tracer.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use std::{collections::HashMap, fmt, mem};
22

33
use crate::{
4+
CENO_PLATFORM, PC_STEP_SIZE,
45
addr::{ByteAddr, Cycle, RegIdx, Word, WordAddr},
56
rv32im::DecodedInstruction,
6-
CENO_PLATFORM, PC_STEP_SIZE,
77
};
88

99
/// An instruction and its context in an execution trace. That is concrete values of registers and memory.
@@ -214,13 +214,10 @@ impl Tracer {
214214
/// Return the completed step and advance to the next cycle.
215215
pub fn advance(&mut self) -> StepRecord {
216216
let next_cycle = self.record.cycle + Self::SUBCYCLES_PER_INSN;
217-
mem::replace(
218-
&mut self.record,
219-
StepRecord {
220-
cycle: next_cycle,
221-
..StepRecord::default()
222-
},
223-
)
217+
mem::replace(&mut self.record, StepRecord {
218+
cycle: next_cycle,
219+
..StepRecord::default()
220+
})
224221
}
225222

226223
pub fn store_pc(&mut self, pc: ByteAddr) {

ceno_emul/src/vm_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ use std::collections::HashMap;
22

33
use super::rv32im::EmuContext;
44
use crate::{
5+
Program,
56
addr::{ByteAddr, RegIdx, Word, WordAddr},
67
platform::Platform,
78
rv32im::{DecodedInstruction, Emulator, TrapCause},
89
tracer::{Change, StepRecord, Tracer},
9-
Program,
1010
};
11-
use anyhow::{anyhow, Result};
11+
use anyhow::{Result, anyhow};
1212
use std::iter::from_fn;
1313

1414
/// An implementation of the machine state and of the side-effects of operations.

ceno_emul/tests/test_elf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::Result;
2-
use ceno_emul::{ByteAddr, EmuContext, InsnKind, StepRecord, VMState, CENO_PLATFORM};
2+
use ceno_emul::{ByteAddr, CENO_PLATFORM, EmuContext, InsnKind, StepRecord, VMState};
33

44
#[test]
55
fn test_ceno_rt_mini() -> Result<()> {

ceno_emul/tests/test_vm_trace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use anyhow::Result;
33
use std::collections::HashMap;
44

55
use ceno_emul::{
6-
ByteAddr, Cycle, EmuContext, InsnKind, StepRecord, Tracer, VMState, WordAddr, CENO_PLATFORM,
6+
ByteAddr, CENO_PLATFORM, Cycle, EmuContext, InsnKind, StepRecord, Tracer, VMState, WordAddr,
77
};
88

99
#[test]

ceno_zkvm/benches/riscv_add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::time::{Duration, Instant};
33
use ark_std::test_rng;
44
use ceno_zkvm::{
55
self,
6-
instructions::{riscv::arith::AddInstruction, Instruction},
6+
instructions::{Instruction, riscv::arith::AddInstruction},
77
scheme::prover::ZKVMProver,
88
structs::{ZKVMConstraintSystem, ZKVMFixedTraces},
99
};

ceno_zkvm/examples/riscv_opcodes.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use clap::Parser;
99
use const_env::from_env;
1010

1111
use ceno_emul::{
12-
ByteAddr,
12+
ByteAddr, CENO_PLATFORM,
1313
InsnKind::{ADD, BLTU},
14-
StepRecord, VMState, CENO_PLATFORM,
14+
StepRecord, VMState,
1515
};
1616
use ceno_zkvm::{
1717
scheme::{constants::MAX_NUM_VARIABLES, verifier::ZKVMVerifier},
@@ -23,7 +23,7 @@ use mpcs::{Basefold, BasefoldRSParams, PolynomialCommitmentScheme};
2323
use rand_chacha::ChaCha8Rng;
2424
use sumcheck::util::is_power_of_2;
2525
use tracing_flame::FlameLayer;
26-
use tracing_subscriber::{fmt, layer::SubscriberExt, EnvFilter, Registry};
26+
use tracing_subscriber::{EnvFilter, Registry, fmt, layer::SubscriberExt};
2727
use transcript::Transcript;
2828

2929
#[from_env]

ceno_zkvm/src/expression.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ mod tests {
639639

640640
use crate::circuit_builder::{CircuitBuilder, ConstraintSystem};
641641

642-
use super::{fmt, Expression, ToExpr};
642+
use super::{Expression, ToExpr, fmt};
643643
use ff::Field;
644644

645645
#[test]

ceno_zkvm/src/expression/monomial.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ mod tests {
167167
use super::*;
168168
use ff::Field;
169169
use goldilocks::{Goldilocks as F, GoldilocksExt2 as E};
170-
use rand_chacha::{rand_core::SeedableRng, ChaChaRng};
170+
use rand_chacha::{ChaChaRng, rand_core::SeedableRng};
171171

172172
#[test]
173173
fn test_to_monomial_form() {

ceno_zkvm/src/instructions/riscv/arith.rs

Lines changed: 93 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::marker::PhantomData;
33
use ceno_emul::{InsnKind, StepRecord};
44
use ff_ext::ExtensionField;
55

6-
use super::{constants::UInt, r_insn::RInstructionConfig, RIVInstruction};
6+
use super::{RIVInstruction, constants::UInt, r_insn::RInstructionConfig};
77
use crate::{
88
circuit_builder::CircuitBuilder, error::ZKVMError, instructions::Instruction, uint::Value,
99
witness::LkMultiplicity,
@@ -178,7 +178,7 @@ mod test {
178178
use crate::{
179179
circuit_builder::{CircuitBuilder, ConstraintSystem},
180180
instructions::Instruction,
181-
scheme::mock_prover::{MockProver, MOCK_PC_ADD, MOCK_PC_MUL, MOCK_PC_SUB, MOCK_PROGRAM},
181+
scheme::mock_prover::{MOCK_PC_ADD, MOCK_PC_MUL, MOCK_PC_SUB, MOCK_PROGRAM, MockProver},
182182
};
183183

184184
#[test]
@@ -197,20 +197,19 @@ mod test {
197197
.unwrap()
198198
.unwrap();
199199

200-
let (raw_witin, _) = AddInstruction::assign_instances(
201-
&config,
202-
cb.cs.num_witin as usize,
203-
vec![StepRecord::new_r_instruction(
204-
3,
205-
MOCK_PC_ADD,
206-
MOCK_PROGRAM[0],
207-
11,
208-
0xfffffffe,
209-
Change::new(0, 11_u32.wrapping_add(0xfffffffe)),
210-
0,
211-
)],
212-
)
213-
.unwrap();
200+
let (raw_witin, _) =
201+
AddInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
202+
StepRecord::new_r_instruction(
203+
3,
204+
MOCK_PC_ADD,
205+
MOCK_PROGRAM[0],
206+
11,
207+
0xfffffffe,
208+
Change::new(0, 11_u32.wrapping_add(0xfffffffe)),
209+
0,
210+
),
211+
])
212+
.unwrap();
214213

215214
MockProver::assert_satisfied(
216215
&mut cb,
@@ -240,20 +239,19 @@ mod test {
240239
.unwrap()
241240
.unwrap();
242241

243-
let (raw_witin, _) = AddInstruction::assign_instances(
244-
&config,
245-
cb.cs.num_witin as usize,
246-
vec![StepRecord::new_r_instruction(
247-
3,
248-
MOCK_PC_ADD,
249-
MOCK_PROGRAM[0],
250-
u32::MAX - 1,
251-
u32::MAX - 1,
252-
Change::new(0, (u32::MAX - 1).wrapping_add(u32::MAX - 1)),
253-
0,
254-
)],
255-
)
256-
.unwrap();
242+
let (raw_witin, _) =
243+
AddInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
244+
StepRecord::new_r_instruction(
245+
3,
246+
MOCK_PC_ADD,
247+
MOCK_PROGRAM[0],
248+
u32::MAX - 1,
249+
u32::MAX - 1,
250+
Change::new(0, (u32::MAX - 1).wrapping_add(u32::MAX - 1)),
251+
0,
252+
),
253+
])
254+
.unwrap();
257255

258256
MockProver::assert_satisfied(
259257
&mut cb,
@@ -283,20 +281,19 @@ mod test {
283281
.unwrap()
284282
.unwrap();
285283

286-
let (raw_witin, _) = SubInstruction::assign_instances(
287-
&config,
288-
cb.cs.num_witin as usize,
289-
vec![StepRecord::new_r_instruction(
290-
3,
291-
MOCK_PC_SUB,
292-
MOCK_PROGRAM[1],
293-
11,
294-
2,
295-
Change::new(0, 11_u32.wrapping_sub(2)),
296-
0,
297-
)],
298-
)
299-
.unwrap();
284+
let (raw_witin, _) =
285+
SubInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
286+
StepRecord::new_r_instruction(
287+
3,
288+
MOCK_PC_SUB,
289+
MOCK_PROGRAM[1],
290+
11,
291+
2,
292+
Change::new(0, 11_u32.wrapping_sub(2)),
293+
0,
294+
),
295+
])
296+
.unwrap();
300297

301298
MockProver::assert_satisfied(
302299
&mut cb,
@@ -326,20 +323,19 @@ mod test {
326323
.unwrap()
327324
.unwrap();
328325

329-
let (raw_witin, _) = SubInstruction::assign_instances(
330-
&config,
331-
cb.cs.num_witin as usize,
332-
vec![StepRecord::new_r_instruction(
333-
3,
334-
MOCK_PC_SUB,
335-
MOCK_PROGRAM[1],
336-
3,
337-
11,
338-
Change::new(0, 3_u32.wrapping_sub(11)),
339-
0,
340-
)],
341-
)
342-
.unwrap();
326+
let (raw_witin, _) =
327+
SubInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
328+
StepRecord::new_r_instruction(
329+
3,
330+
MOCK_PC_SUB,
331+
MOCK_PROGRAM[1],
332+
3,
333+
11,
334+
Change::new(0, 3_u32.wrapping_sub(11)),
335+
0,
336+
),
337+
])
338+
.unwrap();
343339

344340
MockProver::assert_satisfied(
345341
&mut cb,
@@ -363,20 +359,19 @@ mod test {
363359
.unwrap();
364360

365361
// values assignment
366-
let (raw_witin, _) = MulInstruction::assign_instances(
367-
&config,
368-
cb.cs.num_witin as usize,
369-
vec![StepRecord::new_r_instruction(
370-
3,
371-
MOCK_PC_MUL,
372-
MOCK_PROGRAM[2],
373-
11,
374-
2,
375-
Change::new(0, 22),
376-
0,
377-
)],
378-
)
379-
.unwrap();
362+
let (raw_witin, _) =
363+
MulInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
364+
StepRecord::new_r_instruction(
365+
3,
366+
MOCK_PC_MUL,
367+
MOCK_PROGRAM[2],
368+
11,
369+
2,
370+
Change::new(0, 22),
371+
0,
372+
),
373+
])
374+
.unwrap();
380375

381376
MockProver::assert_satisfied(
382377
&mut cb,
@@ -400,20 +395,19 @@ mod test {
400395
.unwrap();
401396

402397
// values assignment
403-
let (raw_witin, _) = MulInstruction::assign_instances(
404-
&config,
405-
cb.cs.num_witin as usize,
406-
vec![StepRecord::new_r_instruction(
407-
3,
408-
MOCK_PC_MUL,
409-
MOCK_PROGRAM[2],
410-
u32::MAX / 2 + 1,
411-
2,
412-
Change::new(0, 0),
413-
0,
414-
)],
415-
)
416-
.unwrap();
398+
let (raw_witin, _) =
399+
MulInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
400+
StepRecord::new_r_instruction(
401+
3,
402+
MOCK_PC_MUL,
403+
MOCK_PROGRAM[2],
404+
u32::MAX / 2 + 1,
405+
2,
406+
Change::new(0, 0),
407+
0,
408+
),
409+
])
410+
.unwrap();
417411

418412
MockProver::assert_satisfied(
419413
&mut cb,
@@ -441,20 +435,19 @@ mod test {
441435
let (c_limb, _, _) = a.mul(&b, &mut LkMultiplicity::default(), true);
442436

443437
// values assignment
444-
let (raw_witin, _) = MulInstruction::assign_instances(
445-
&config,
446-
cb.cs.num_witin as usize,
447-
vec![StepRecord::new_r_instruction(
448-
3,
449-
MOCK_PC_MUL,
450-
MOCK_PROGRAM[2],
451-
a.as_u64() as u32,
452-
b.as_u64() as u32,
453-
Change::new(0, Value::<u32>::from_limb_unchecked(c_limb).as_u64() as u32),
454-
0,
455-
)],
456-
)
457-
.unwrap();
438+
let (raw_witin, _) =
439+
MulInstruction::assign_instances(&config, cb.cs.num_witin as usize, vec![
440+
StepRecord::new_r_instruction(
441+
3,
442+
MOCK_PC_MUL,
443+
MOCK_PROGRAM[2],
444+
a.as_u64() as u32,
445+
b.as_u64() as u32,
446+
Change::new(0, Value::<u32>::from_limb_unchecked(c_limb).as_u64() as u32),
447+
0,
448+
),
449+
])
450+
.unwrap();
458451

459452
MockProver::assert_satisfied(
460453
&mut cb,

0 commit comments

Comments
 (0)