Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

AVM: Add a lot of type annotations to opcodes #5902

Merged
merged 4 commits into from
Jan 19, 2024

Conversation

jannotti
Copy link
Contributor

@jannotti jannotti commented Jan 11, 2024

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:

  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

Summary

Test Plan

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.
Copy link

codecov bot commented Jan 11, 2024

Codecov Report

Attention: 6 lines in your changes are missing coverage. Please review.

Comparison is base (71fff6d) 55.97% compared to head (d631323) 55.95%.
Report is 10 commits behind head on master.

Files Patch % Lines
data/transactions/logic/eval.go 62.50% 3 Missing and 3 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

@jannotti jannotti requested a review from jasonpaulos January 16, 2024 19:22
jasonpaulos
jasonpaulos previously approved these changes Jan 16, 2024
Copy link
Contributor

@jasonpaulos jasonpaulos left a 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

@jannotti jannotti merged commit d8dfaad into algorand:master Jan 19, 2024
11 checks passed
@jannotti jannotti deleted the byte-types branch January 19, 2024 16:08
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants