-
Notifications
You must be signed in to change notification settings - Fork 58
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
Eliminate hashing shims for hardcoded tags across the LEM codebase #810
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -245,7 +245,7 @@ | |
use super::*; | ||
use crate::circuit::gadgets::constraints::{add, alloc_equal, and, mul}; | ||
use crate::lem::Tag as LEMTag; | ||
use crate::tag::{ContTag, ExprTag, Tag}; | ||
use crate::tag::{ExprTag, Tag}; | ||
use std::marker::PhantomData; | ||
|
||
/// A dumb Coprocessor for testing. | ||
|
@@ -347,18 +347,10 @@ | |
.get_allocated_const(LEMTag::Expr(ExprTag::Num).to_field()) | ||
.expect("Num tag should have been allocated"); | ||
|
||
// the following is a temporary shim for compatibility with Lurk Alpha | ||
// otherwise we could just have a pointer whose value is zero | ||
Comment on lines
-350
to
-351
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is gone |
||
let err_cont_ptr = LEMPtr::null(LEMTag::Cont(ContTag::Error)); | ||
let err_cont_z_ptr = s.hash_ptr(&err_cont_ptr).expect("hash_ptr failed"); | ||
let allocated_error_tag = g | ||
.get_allocated_const(err_cont_z_ptr.tag_field()) | ||
.expect("Error tag should have been allocated"); | ||
let allocated_error_hash = g | ||
.get_allocated_const(*err_cont_z_ptr.value()) | ||
.expect("Error hash should have been allocated"); | ||
let cont_err = | ||
AllocatedPtr::from_parts(allocated_error_tag.clone(), allocated_error_hash.clone()); | ||
let err_cont_z_ptr = s.hash_ptr(&s.cont_error()).expect("hash_ptr failed"); | ||
let cont_err = g | ||
.get_allocated_ptr_from_z_ptr(&err_cont_z_ptr) | ||
.expect("Error pointer should have been allocated"); | ||
|
||
let (expr, env, cont) = | ||
self.synthesize_aux(cs, input_exprs, input_env, input_cont, num_tag, &cont_err)?; | ||
|
@@ -433,22 +425,18 @@ | |
|
||
fn evaluate_lem( | ||
&self, | ||
_s: &LEMStore<F>, | ||
s: &LEMStore<F>, | ||
args: &[LEMPtr<F>], | ||
env: &LEMPtr<F>, | ||
cont: &LEMPtr<F>, | ||
) -> Vec<LEMPtr<F>> { | ||
let LEMPtr::Atom(LEMTag::Expr(ExprTag::Num), a) = &args[0] else { | ||
return vec![args[0], *env, LEMPtr::null(LEMTag::Cont(ContTag::Error))]; | ||
return vec![args[0], *env, s.cont_error()]; | ||
}; | ||
let LEMPtr::Atom(LEMTag::Expr(ExprTag::Num), b) = &args[1] else { | ||
return vec![args[1], *env, LEMPtr::null(LEMTag::Cont(ContTag::Error))]; | ||
return vec![args[1], *env, s.cont_error()]; | ||
}; | ||
vec![ | ||
LEMPtr::Atom(LEMTag::Expr(ExprTag::Num), (*a * *a) + *b), | ||
*env, | ||
*cont, | ||
] | ||
vec![LEMPtr::num((*a * *a) + *b), *env, *cont] | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is gone