diff --git a/basic/src/bin/valida.rs b/basic/src/bin/valida.rs index 183c4ca9..d6b9ceac 100644 --- a/basic/src/bin/valida.rs +++ b/basic/src/bin/valida.rs @@ -9,7 +9,10 @@ use p3_baby_bear::BabyBear; use p3_fri::{FriConfig, TwoAdicFriPcs, TwoAdicFriPcsConfig}; use valida_cpu::MachineWithCpuChip; -use valida_machine::{AdviceProvider, GlobalAdviceProvider, Machine, MachineProof, ProgramROM, StdinAdviceProvider, StoppingFlag}; +use valida_machine::{ + AdviceProvider, GlobalAdviceProvider, Machine, MachineProof, ProgramROM, StdinAdviceProvider, + StoppingFlag, +}; use valida_memory::MachineWithMemoryChip; use valida_elf::{load_executable_file, Program}; @@ -65,7 +68,7 @@ struct Context { last_fp_: u32, recorded_current_fp_: u32, last_fp_size_: u32, - advice : GlobalAdviceProvider, + advice: GlobalAdviceProvider, } impl Context { @@ -78,7 +81,7 @@ impl Context { last_fp_: args.stack_height, recorded_current_fp_: args.stack_height, last_fp_size_: 0, - advice : GlobalAdviceProvider::new(&args.advice), + advice: GlobalAdviceProvider::new(&args.advice), }; let Program { code, data } = load_executable_file( diff --git a/machine/src/advice.rs b/machine/src/advice.rs index f2420c46..7edfefa6 100644 --- a/machine/src/advice.rs +++ b/machine/src/advice.rs @@ -1,7 +1,7 @@ use core::slice; +use std::fs::File; use std::io; use std::io::Read; -use std::fs::File; pub trait AdviceProvider { /// Get the next byte from the advice tape, if any. @@ -35,7 +35,7 @@ impl FixedAdviceProvider { pub fn new(advice: Vec) -> Self { Self { advice, index: 0 } } - pub fn from_file(file : &mut File) -> Self { + pub fn from_file(file: &mut File) -> Self { // read the entire file into self::advice: let mut advice = Vec::new(); file.read_to_end(&mut advice).unwrap(); @@ -70,21 +70,21 @@ impl AdviceProvider for StdinAdviceProvider { } pub struct GlobalAdviceProvider { - provider : AdviceProviderType, + provider: AdviceProviderType, } impl GlobalAdviceProvider { - pub fn new(file_name : &Option) -> Self { + pub fn new(file_name: &Option) -> Self { match file_name { Some(file_name) => { let mut file = File::open(file_name).unwrap(); let provider = AdviceProviderType::Fixed(FixedAdviceProvider::from_file(&mut file)); Self { provider } - }, + } None => { let provider = AdviceProviderType::Stdin(StdinAdviceProvider); Self { provider } } - } + } } } @@ -92,4 +92,4 @@ impl AdviceProvider for GlobalAdviceProvider { fn get_advice(&mut self) -> Option { self.provider.get_advice() } -} \ No newline at end of file +}