Skip to content
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

less_than util #183

Merged
merged 17 commits into from
Sep 12, 2024
Merged

less_than util #183

merged 17 commits into from
Sep 12, 2024

Conversation

zemse
Copy link
Collaborator

@zemse zemse commented Sep 3, 2024

Closes #167

@zemse zemse force-pushed the 167-util-lt branch 2 times, most recently from 62f00a9 to 17f7a7a Compare September 4, 2024 10:55
@zemse zemse changed the base branch from master to feat/mock-prover September 4, 2024 10:56
@zemse zemse changed the base branch from feat/mock-prover to master September 4, 2024 10:56
@zemse zemse marked this pull request as ready for review September 4, 2024 11:01
@zemse zemse requested a review from hero78119 September 4, 2024 11:01
ceno_zkvm/src/scheme/mock_prover.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/scheme/mock_prover.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/scheme/mock_prover.rs Show resolved Hide resolved
let name = name_fn();
let is_lt = cb.create_witin(|| format!("{name} witin"))?;
// TODO add name_fn to lookup_ltu_limb8, not done yet to avoid merge conflicts
cb.lookup_ltu_limb8(is_lt.expr(), lhs, rhs)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use lookup_ltu_limb8 because this can be only use in lhs/rhs are byte expression. Need to design less_than for general expression, refer lt.rs in zkEVM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the ref, I have made the change, however I think the diff has to be bounded to be < the range. Hence I had to use a ux lookup

@zemse zemse force-pushed the 167-util-lt branch 2 times, most recently from 2df1e21 to 30256ec Compare September 6, 2024 07:26
@zemse zemse requested a review from hero78119 September 6, 2024 07:26
ceno_zkvm/src/chip_handler/general.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/chip_handler/general.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/chip_handler/general.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/chip_handler/general.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/chip_handler/general.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/instructions/riscv/addsub.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/instructions/riscv/config.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/instructions/riscv/addsub.rs Outdated Show resolved Hide resolved
ceno_zkvm/src/scheme/mock_prover.rs Show resolved Hide resolved
@zemse zemse force-pushed the 167-util-lt branch 2 times, most recently from 1eb74f0 to 7834bda Compare September 10, 2024 07:51
@zemse zemse requested a review from hero78119 September 10, 2024 07:53
@zemse zemse changed the title lt util less_than util Sep 10, 2024
prev_ts: Expression<E>,
ts: Expression<E>,
prev_values: &V,
values: &V,
) -> Result<Expression<E>, ZKVMError> {
) -> Result<(Expression<E>, ExprLtConfig, ExprLtConfig, ExprLtConfig), ZKVMError> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering if it's possible not to return these three ExprLtConfig, and embeds these lt gadgets inside RegisterChipOperations? If we return these ExprLtConfig to the caller, it means almost all the opcodes need to declare them in their own circuit, like this. It would look more succinct if we manage these three gadgets in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After discussed with @hero78119, we can do this refactor in the later PR.

// TODO implement lt gadget
// let is_lt = prev_ts.lt(self, ts)?;
// self.require_one(is_lt)?;
let lt_rs1_cfg =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not this line. As mentioned in L53 this file, I guess register_read needs the logic here as well,

ceno_zkvm/src/instructions/riscv/config.rs Show resolved Hide resolved
@hero78119 hero78119 merged commit 67e530b into scroll-tech:master Sep 12, 2024
4 checks passed
@zemse zemse deleted the 167-util-lt branch September 23, 2024 19:07
hero78119 pushed a commit that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Util] implement predicate function: greater/less than
3 participants