-
Notifications
You must be signed in to change notification settings - Fork 173
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
Add MastForest::advice_map
for the data required in the advice provider before execution
#1574
Conversation
f1fd68b
to
a36a9af
Compare
d890a6a
to
fe7a7da
Compare
c9860b6
to
eda4a01
Compare
MastForest::advice_map
for the data required in the advice provider before executionMastForest::advice_map
for the data required in the advice provider before execution
eda4a01
to
006e03a
Compare
MastForest::advice_map
for the data required in the advice provider before executionMastForest::advice_map
for the data required in the advice provider before execution
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 for taking this on!
core/src/mast/merger/mod.rs
Outdated
@@ -163,6 +167,17 @@ impl MastForestMerger { | |||
Ok(()) | |||
} | |||
|
|||
fn merge_advice_map(&mut self, other_forest: &MastForest) -> Result<(), MastForestError> { | |||
for (key, value) in other_forest.advice_map.clone().into_iter() { | |||
if self.mast_forest.advice_map().get(&key).is_some() { |
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.
It would be a bit more forgiving to only return an error if the advice maps have different values at the same key
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.
Good point! Done.
My line of thinking was that keys in the advice map are expected to be so unique (hashes) that any collision would mean that something is off and we better fail early. I suppose we can cut some slack when values are the same (user sets the values twice?).
processor/src/lib.rs
Outdated
@@ -253,6 +253,18 @@ where | |||
return Err(ExecutionError::ProgramAlreadyExecuted); | |||
} | |||
|
|||
// Load the program's advice data into the advice provider | |||
for (digest, values) in program.mast_forest().advice_map().clone().into_iter() { | |||
if self.host.borrow().advice_provider().get_mapped_values(&digest).is_some() { |
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.
Similarly here, could be return an error only if the values are different at the same key?
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.
Done.
Since the behavior if the key is already present is to replace the value with the new one there is no other error that can possibly arise in this method.
92f3309
to
6dcac60
Compare
@plafer Thank you for the review! I addressed all the comments. Please do another round. |
6dcac60
to
2f8f3fe
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! Just a few nits but we're basically there.
Let's hold off on merging this temporarily while we figure out with #1572 how we want the Host
/AdviceProvider
API to look like
When merging forests, merge their advice maps and return error on key collision.
2f8f3fe
to
93869ef
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.
LGTM, thank you!
This PR implements VM-facing part of #1547 and adds advice map to the
MastForest
that is loaded in the advice provider when theMastForest
executed.This PR contains changes exposing
AdviceProvider
inHost
(see commit) introduced in #1572 (see comment)