Skip to content

Commit

Permalink
refactor: remove set_advice() and get_advice() methods from `Advi…
Browse files Browse the repository at this point in the history
…ceProvider` trait
  • Loading branch information
plafer committed Nov 19, 2024
1 parent b7e9d44 commit 99ad892
Show file tree
Hide file tree
Showing 11 changed files with 232 additions and 498 deletions.
10 changes: 5 additions & 5 deletions miden/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ let exec_options = ExecutionOptions::default();
let trace = execute(&program, stack_inputs.clone(), &mut host, exec_options).unwrap();

// now, execute the same program in debug mode and iterate over VM states
for vm_state in execute_iter(&program, stack_inputs, host) {
for vm_state in execute_iter(&program, stack_inputs, &mut host) {
match vm_state {
Ok(vm_state) => println!("{:?}", vm_state),
Err(_) => println!("something went terribly wrong!"),
Expand Down Expand Up @@ -111,13 +111,13 @@ let program = assembler.assemble_program("begin push.3 push.5 add end").unwrap()
let (outputs, proof) = prove(
&program,
StackInputs::default(), // we won't provide any inputs
DefaultHost::default(), // we'll be using a default host
&mut DefaultHost::default(), // we'll be using a default host
ProvingOptions::default(), // we'll be using default options
)
.unwrap();

// the output should be 8
assert_eq!(8, outputs.stack().first().unwrap().as_int());
assert_eq!(8, outputs.first().unwrap().as_int());
```

### Verifying program execution
Expand Down Expand Up @@ -196,7 +196,7 @@ let mut assembler = Assembler::default();
let program = assembler.assemble_program(&source).unwrap();

// initialize a default host (with an empty advice provider)
let host = DefaultHost::default();
let mut host = DefaultHost::default();

// initialize the stack with values 0 and 1
let stack_inputs = StackInputs::try_from_ints([0, 1]).unwrap();
Expand All @@ -205,7 +205,7 @@ let stack_inputs = StackInputs::try_from_ints([0, 1]).unwrap();
let (outputs, proof) = miden_vm::prove(
&program,
stack_inputs,
host,
&mut host,
ProvingOptions::default(), // use default proving options
)
.unwrap();
Expand Down
23 changes: 8 additions & 15 deletions miden/tests/integration/operations/decorators/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::sync::Arc;

use processor::{
AdviceExtractor, AdviceProvider, ExecutionError, Host, HostResponse, MastForest,
MemAdviceProvider, ProcessState,
AdviceProvider, ExecutionError, Host, HostResponse, MastForest, MemAdviceProvider, ProcessState,
};
use vm_core::{AdviceInjector, DebugOptions};
use vm_core::DebugOptions;

mod advice;
mod asmop;
Expand All @@ -31,20 +30,14 @@ impl Default for TestHost<MemAdviceProvider> {
}

impl<A: AdviceProvider> Host for TestHost<A> {
fn get_advice(
&mut self,
process: ProcessState,
extractor: AdviceExtractor,
) -> Result<HostResponse, ExecutionError> {
self.adv_provider.get_advice(process, &extractor)
type AdviceProvider = A;

fn advice_provider(&self) -> &Self::AdviceProvider {
&self.adv_provider
}

fn set_advice(
&mut self,
process: ProcessState,
injector: AdviceInjector,
) -> Result<HostResponse, ExecutionError> {
self.adv_provider.set_advice(process, &injector)
fn advice_provider_mut(&mut self) -> &mut Self::AdviceProvider {
&mut self.adv_provider
}

fn on_event(
Expand Down
2 changes: 1 addition & 1 deletion processor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ let exec_options = ExecutionOptions::default();
let trace = execute(&program, stack_inputs.clone(), &mut host, exec_options).unwrap();

// now, execute the same program in debug mode and iterate over VM states
for vm_state in execute_iter(&program, stack_inputs, host, exec_options) {
for vm_state in execute_iter(&program, stack_inputs, &mut host, exec_options) {
match vm_state {
Ok(vm_state) => println!("{:?}", vm_state),
Err(_) => println!("something went terribly wrong!"),
Expand Down
106 changes: 0 additions & 106 deletions processor/src/host/advice/extractors.rs

This file was deleted.

Loading

0 comments on commit 99ad892

Please sign in to comment.