-
Notifications
You must be signed in to change notification settings - Fork 169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce Host object #1082
Introduce Host object #1082
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Looks good! I left some comments inline - mostly about simplifying the structure a bit and renaming a few method.
Also, let's merge #1085 into this as I think that's the way to go and it would make it simpler to review the changes more holistically.
One other thought: maybe it makes sense to rename Update: though, maybe let's not do this for now - maybe we can do it as a next step. |
4ecd55d
to
9d8311a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Looks good! I left a few more comments inline - mostly about improving ergonomics of the code.
Another thing I'm wondering is whether it would make sense to split pub trait Host {
// REQUIRED METHODS
// --------------------------------------------------------------------------------------------
fn get_advice<S: ProcessState>(
&mut self,
process: &S,
extractor: AdviceExtractor,
) -> Result<HostResponse, ExecutionError>;
fn set_advice<S: ProcessState>(
&mut self,
process: &S,
injector: AdviceInjector,
) -> Result<HostResponse, ExecutionError>;
// PROVIDED METHODS
// --------------------------------------------------------------------------------------------
fn on_debug<S: ProcessState>(&self, process: &S, options: &DebugOptions) {
debug::print_debug_info(process, options);
}
fn pop_adv_stack<S: ProcessState>(&mut self, process: &S) -> Result<Felt, ExecutionError> {
self.get_advice(process, AdviceExtractor::PopStack).map(|res| res.into())
}
// TODO: other extractor wrappers From the implementer's standpoint, I don't think this is any more complicated than the current approach (and maybe slightly simpler), and I think it is cleaner overall. Would be even cleaner if |
I think this has implications for encapsulation and extensibility. We are removing a level of indirection / encapsulation (removal of the |
304cd25
to
a5efd8f
Compare
I agree that there is a tradeoff here - but I think it is probably OK to make it. My thinking is that we probably won't introduce top-level variants of |
c61f8fd
to
6161c14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Thank you! I left a few small comments inline. Once these are addressed, we can merge.
6161c14
to
1d5c025
Compare
1d5c025
to
1efc2c0
Compare
This PR introduces a
Host
trait as described in #1073 with a default implementation provided by theDefaultHost
.