diff --git a/basic/src/bin/valida.rs b/basic/src/bin/valida.rs index d3d808a..604e9c0 100644 --- a/basic/src/bin/valida.rs +++ b/basic/src/bin/valida.rs @@ -9,7 +9,7 @@ use p3_baby_bear::BabyBear; use p3_fri::{FriConfig, TwoAdicFriPcs, TwoAdicFriPcsConfig}; use valida_cpu::MachineWithCpuChip; -use valida_machine::{AdviceProvider, FixedAdviceProvider, 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 +65,7 @@ struct Context { last_fp_: u32, recorded_current_fp_: u32, last_fp_size_: u32, - advice : Box, + advice : GlobalAdviceProvider, } impl Context { @@ -78,13 +78,7 @@ impl Context { last_fp_: args.stack_height, recorded_current_fp_: args.stack_height, last_fp_size_: 0, - advice: match &args.advice { - Some(file) => { - let mut file = File::open(file).unwrap(); - Box::new(FixedAdviceProvider::from_file(&mut file)) - } - _ => Box::new(StdinAdviceProvider), - }, + 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 994ed5b..f2420c4 100644 --- a/machine/src/advice.rs +++ b/machine/src/advice.rs @@ -69,11 +69,11 @@ impl AdviceProvider for StdinAdviceProvider { } } -struct GlobalAdviceProvider { +pub struct GlobalAdviceProvider { 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();