-
Notifications
You must be signed in to change notification settings - Fork 493
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
AVM: Add a lot of type annotations to opcodes #5902
Conversation
This allows the assembler to complain about clear mistakes, but maybe more importantly, it improves the specs/documentation. We can now document all the required byte lengths, even if they are strange, but using "b{33}" in `proto()` call to require a 33 byte input. But we also just missed a bunch of opportunities to annotate opcodes in the past. I tried to consider ever single "b" in opcodes.go. things to consider in review: 1) This should not change any behavior of assembled code. If it does, that's a bug. 2) This _could_ make something that used to assemble stop assembling. Probably, that means the author has a bug. If they really want to call these opcodes with the wrong sized inputs, the can, using `#pragma typetrack false` 3) Should we eliminate the existing single character names in proto() that are only used to indicate a byte length? For example ``` {0x84, "ed25519verify_bare", opEd25519VerifyBare, proto("b63:T"), 7, costly(1900)}, ``` could now be written ``` {0x84, "ed25519verify_bare", opEd25519VerifyBare, proto("b{64}b{32}:T"), 7, costly(1900)}, ``` Perhaps that is clearer.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #5902 +/- ##
==========================================
- Coverage 55.97% 55.95% -0.02%
==========================================
Files 477 477
Lines 67463 67476 +13
==========================================
- Hits 37761 37755 -6
- Misses 27149 27162 +13
- Partials 2553 2559 +6 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, though I believe the markdown/langspec needs to be regenerated
This allows the assembler to complain about clear mistakes, but maybe more importantly, it improves the specs/documentation. We can now document all the required byte lengths, even if they are strange, by using "b{33}" in
proto()
call to require a 33 byte input.But we also just missed a bunch of opportunities to annotate opcodes in the past. I tried to consider every single "b" in opcodes.go.
things to consider in review:
This should not change any behavior of assembled code. If it does, that's a bug.
This could make something that used to assemble stop assembling. Probably, that means the author has a bug. If they really want to call these opcodes with the wrong sized inputs, the can, using
#pragma typetrack false
Summary
Test Plan