Skip to content

feat: memory access adapters, boundary chips, merkle chip E3 #1640

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

Merged
merged 15 commits into from
May 13, 2025

Conversation

Golovanov399
Copy link
Contributor

@Golovanov399 Golovanov399 commented May 9, 2025

Resolves INT-3801.

  • Added memory access adapters. To improve:
    • Allocate the trace buffer once before filling it as opposed to pushing to Vec how it's done now,
    • Maybe not call get_f too often (although I don't know how to avoid it normally).
  • Added volatile and persistent boundary chips tracegen,
  • Added merkle chip tracegen as described here. To improve:
    • Parallelize at least something,
    • Maybe support passing this struct between segments.
  • VmChipTestBuilder now has ::default_persistent, so all tests in extensions/rv32im/circuit pass both with volatile and persistent memory interface.

self.control
.execute_instruction(state, &mut self.chip_complex)?;
.execute_instruction(state, &instruction.clone(), &mut self.chip_complex)?;
Copy link
Contributor

Choose a reason for hiding this comment

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

how come it's both reference and clone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's because

  • design-wise I prefer passing a reference
  • currently it's hard to do without tricks, because this reference is inside self.something, and self.execute_instruction requires a mutable reference to self. That is why I did this hack and added a // TODO above

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant does &instruction not work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No
Because it is an immutable reference to something inside &self
And execute_instruction(&mut self, ...)

) {
let ptr = pointer / ALIGN;
let meta = unsafe { self.meta.get_unchecked_mut(address_space) };
meta.set(
Copy link
Contributor

Choose a reason for hiding this comment

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

is this faster or should we still do a pre-check and return early when block_size == ALIGN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would we do in this case? We still want to set the meta block. Or do you think that iterating over 1..1 is slower than branch prediction in practice?

Copy link
Contributor

Choose a reason for hiding this comment

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

oh hm I somehow thought we didn't need to set the meta block in this case, but I guess you need to update the timestamp regardless?

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

LGTM except comments around (1) avoiding const generic ALIGN when possible because (2) the boundary memories need to account for per-address space min block size.

@Golovanov399 Golovanov399 merged commit 169d5bb into feat/new-execution May 13, 2025
3 of 20 checks passed
@Golovanov399 Golovanov399 deleted the feat/new-execution-boundary-4 branch May 13, 2025 21:34
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.

2 participants