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

feat: DYN and DYNCALL takes a memory address instead of digest on stack #1535

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

plafer
Copy link
Contributor

@plafer plafer commented Oct 15, 2024

Closes #1091
Closes #1478

@bobbinth
Copy link
Contributor

This change breaks how dyncall works (i.e. dyncall compiles to call(dyn)), since after the call, the memory is wiped since we entered a new context, and hence placing the procedure hash in memory before the call doesn't work.

We might need to do #1478 before we can merge this.

Ah yes - good point! I didn't think of this. Indeed, we may need to do #1478 first.

@plafer plafer force-pushed the plafer-1091-dyn-op-rework branch 3 times, most recently from b83bb5c to 26f33fa Compare October 18, 2024 19:37
@plafer plafer requested a review from bobbinth October 18, 2024 19:38
Copy link
Contributor

@bobbinth bobbinth left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you! I left some comments inline - but nothing major.

The complexity in the stack resulting from having to do a left shift and a context switch at the same time is a bit unfortunate - but I'm not seeing a better way to do it. We should probably create an issue to come back to this later and try to make the constraints a bit more uniform.

core/src/operations/mod.rs Show resolved Hide resolved
processor/src/operations/io_ops.rs Outdated Show resolved Hide resolved
processor/src/decoder/block_stack.rs Outdated Show resolved Hide resolved
Comment on lines 139 to 141
pub fn decoder_hasher_state_element(&self, element: usize, i: RowIndex) -> Felt {
self.columns.get_column(DECODER_TRACE_OFFSET + HASHER_STATE_OFFSET + element)[i + 1]
self.columns.get_column(DECODER_TRACE_OFFSET + HASHER_STATE_OFFSET + element)[i]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this a bug previously?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but for some reason it never manifested itself. I think only RESPAN used it, so maybe looking in the next row there was always what we expected? I'm really not sure why it went unnoticed for this long.

air/src/constraints/stack/overflow/mod.rs Outdated Show resolved Hide resolved
processor/src/decoder/mod.rs Show resolved Hide resolved
processor/src/lib.rs Outdated Show resolved Hide resolved
processor/src/chiplets/aux_trace/mod.rs Outdated Show resolved Hide resolved
processor/src/stack/mod.rs Outdated Show resolved Hide resolved
processor/src/stack/mod.rs Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth left a 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've reviewed pretty much everything except for test code (I'll review it tomorrow).

Once docs are updated we can merge. Or we can merge sooner and update docs in another PR.

@plafer plafer marked this pull request as ready for review October 22, 2024 15:43
@plafer
Copy link
Contributor Author

plafer commented Oct 22, 2024

@bobbinth docs are ready for review

Copy link
Contributor

@bobbinth bobbinth left a 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! For tests, I did a relatively superficial review - so, would appreciate another set of eyes on them (cc @Al-Kindi-0).

One other thing: I'm not sure we should commit the excalidraw files here. It is not possible to easily verify what's in these files and they blow up the line count. Maybe an alternative could be to create a shared excalidraw workspace so that we have access to all these diagrams? cc @Dominik1999.

docs/src/design/decoder/main.md Outdated Show resolved Hide resolved
docs/src/user_docs/assembly/code_organization.md Outdated Show resolved Hide resolved
docs/src/user_docs/assembly/code_organization.md Outdated Show resolved Hide resolved
docs/src/user_docs/assembly/execution_contexts.md Outdated Show resolved Hide resolved
processor/src/decoder/tests.rs Outdated Show resolved Hide resolved
@plafer plafer changed the title feat: DYN takes a memory address instead of digest on stack feat: DYN and DYNCALL takes a memory address instead of digest on stack Oct 23, 2024
@plafer plafer requested a review from bobbinth October 23, 2024 12:03
Copy link
Collaborator

@Al-Kindi-0 Al-Kindi-0 left a comment

Choose a reason for hiding this comment

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

Looks great, thank you!
A few questions and remarks inline mainly.

air/src/constraints/stack/mod.rs Outdated Show resolved Hide resolved
core/src/mast/mod.rs Show resolved Hide resolved
docs/src/design/decoder/constraints.md Outdated Show resolved Hide resolved
docs/src/design/decoder/constraints.md Show resolved Hide resolved
docs/src/design/decoder/constraints.md Outdated Show resolved Hide resolved
docs/src/user_docs/assembly/execution_contexts.md Outdated Show resolved Hide resolved
docs/src/user_docs/assembly/execution_contexts.md Outdated Show resolved Hide resolved
docs/src/design/decoder/main.md Show resolved Hide resolved
processor/src/decoder/aux_trace/block_stack_table.rs Outdated Show resolved Hide resolved
processor/src/decoder/mod.rs Show resolved Hide resolved
Comment on lines 273 to 274
&+ \alpha_5 \cdot fmp + \alpha_6 \cdot b_0 + \alpha_7 \cdot b_1 + <[\alpha_8, \alpha_{11}], fn\_hash[0..3]>) \text{ | degree} = 6
\end{align*}
Copy link
Collaborator

Choose a reason for hiding this comment

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

fn_hash is not rendering well, I think this is what I tried to refer to earlier

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed them all to \mathrm{fnhash}, which should render not run into any rendering issues

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is now rendering well on GitHub

Copy link
Contributor

@bobbinth bobbinth left a 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'll merge this PR tomorrow (after miden-base has been migrated to the current next).

@bobbinth
Copy link
Contributor

I'll merge this PR tomorrow (after miden-base has been migrated to the current next).

Let's hold off on merging this until we have a corresponding PR in miden-base (otherwise it'll break miden-base). @Fumuran will start working on this in the next day or so.

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.

3 participants