-
Notifications
You must be signed in to change notification settings - Fork 73
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
Powdr ASM: Allow machines to be linked via permutaions #1073
Comments
I just realized this about connecting machines via permutation (perhaps related to #1077): 1: Use different selectors
2: Use an extra argument
In our case (where we have a third operation, the "bootloader write"), we could do this:
Here, I think option 2 is usually better, especially if the number of operations is high (because the number of witness columns in the main machine is always 2, regardless of the number of operations). Also, it is more consistent with how we already do things in the block machine. The only difference between a block machine that's connected via permutation vs lookup is that the latch is a witness column (actually, a set of witness columns, one for each permutation argument), otherwise the PIL would be essentially the same (i.e., we'd also have an auto-generated But option 2 isn't currently supported in ASM (perhaps it is after #1077, see my comment in the issue). Until that's fixed, we could do this:
This would work and be a small change to the status quo, but it would create a few redundant columns in the memory machine (e.g. |
With that, let me suggest an ASM-to-PIL conversion. Status QuoThis is a a sketch of how we currently define block machines:
This compiles to the lookup:
Also, some constraints are added to the block machine to force the operation ID to be constant within a block:
Connecting via PermutationsWe add a field to the machine declaration:
This Then, there is a new syntax to say that a machine should be connected via a permutation, for example:
This compiles to:
Note that:
And to the submachine, we add:
|
Putting all of this together, a classic read/write memory (no bootloader write) would could be specified like this:
|
Actually, perhaps instead of the "magic" constraints added by the compiler, we should just pass the
But if we do that, then we should also remove the auto-generated constraints that force the |
I haven't read the whole thing yet, but I'd say the least magic the better |
From discussing with @georgwiese: When a block machine ( When
The If This way, |
Or
|
Fixed by #1126 |
We currently link machines via lookups. Using permutations instead can be cheaper and allows us to distinguish blocks that are actually used from dummy blocks (relevant for #1055). This is an example from Polygon's zkEVM.
We don't have a way to generate this from ASM right now.
A few notes:
result
). They should be constrained to be boolean and such that at most one is active.Proposed Spec (TLDR of my comments below)
We add a third machine argument to the machine declaration, like so:
Also, machine operations can be called via permutations (instead of lookups) if the instruction is declared like this:
This compiles to:
Also, in the
MyMachine
scope, the compiler adds:The text was updated successfully, but these errors were encountered: