Add toy_vm with sort lookup argument example #30
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.
Adds an example of a toy vm that has a
sortopcode. For that sort there is an optimization where the sort is done out of trace, and the result is verified in the trace, but only when running on starstream.For really small vectors the lookup argument it's actually worse, since the verification is more expensive than actually sorting. But for vectors of 500 elements it's already a significant speedup (almost half the trace size).
NOTE: It's not actually possible to run the nebula side of this right now, because of these:
ICME-Lab/zkEngine_dev#47
ICME-Lab/zkEngine_dev#48
Although I could test it by patching those locally (not necessarily with the proper patch though)
NOTES for reviewing:
Op::Sortimplementation.derivethat much because of it. But I think that would be an ideal scenario for integrating a vm.TODO/QUESTION:
The unconstrained function currently doesn't check memory bounds.
Right now, the rust code checks that the resulting array is a sort of the original. The problem is that it's not really viable to test that the function didn't randomly modify other sections of memory. This is obviously unsound, so there has to be a way of constraining the function to a certain memory range.
I think there are generally two options: