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

AVM: Switch opcode #4458

Merged
merged 23 commits into from
Sep 16, 2022
Merged

AVM: Switch opcode #4458

merged 23 commits into from
Sep 16, 2022

Conversation

algoidurovic
Copy link
Contributor

@algoidurovic algoidurovic commented Aug 24, 2022

Adding new switch opcode that contains a variable size list of label references, aka targets. Consumes one integer from the top of the stack A and branches to targets[A].

Test Plan

Assembly and evaluation unit tests.

data/transactions/logic/assembler.go Outdated Show resolved Hide resolved
data/transactions/logic/eval.go Outdated Show resolved Hide resolved
data/transactions/logic/eval.go Outdated Show resolved Hide resolved
data/transactions/logic/eval.go Outdated Show resolved Hide resolved
data/transactions/logic/eval.go Outdated Show resolved Hide resolved
data/transactions/logic/opcodes.go Outdated Show resolved Hide resolved
@jannotti jannotti changed the title Switch opcode AVM: Switch opcode Aug 25, 2022
@algoidurovic algoidurovic marked this pull request as ready for review September 8, 2022 21:40
@codecov
Copy link

codecov bot commented Sep 9, 2022

Codecov Report

Merging #4458 (f103b5e) into master (b243e18) will increase coverage by 0.02%.
The diff coverage is 87.09%.

@@            Coverage Diff             @@
##           master    #4458      +/-   ##
==========================================
+ Coverage   55.27%   55.29%   +0.02%     
==========================================
  Files         398      398              
  Lines       50366    50440      +74     
==========================================
+ Hits        27839    27891      +52     
- Misses      20198    20213      +15     
- Partials     2329     2336       +7     
Impacted Files Coverage Δ
data/transactions/logic/doc.go 61.53% <ø> (ø)
data/transactions/logic/eval.go 89.31% <71.42%> (-0.24%) ⬇️
data/transactions/logic/assembler.go 85.96% <95.65%> (+0.21%) ⬆️
data/transactions/logic/opcodes.go 84.47% <100.00%> (+0.60%) ⬆️
cmd/algoh/blockWatcher.go 77.77% <0.00%> (-3.18%) ⬇️
crypto/merkletrie/trie.go 66.42% <0.00%> (-2.19%) ⬇️
agreement/cryptoVerifier.go 67.60% <0.00%> (-2.12%) ⬇️
agreement/proposalManager.go 96.07% <0.00%> (-1.97%) ⬇️
crypto/merkletrie/node.go 91.62% <0.00%> (-1.87%) ⬇️
cmd/tealdbg/debugger.go 72.69% <0.00%> (-0.81%) ⬇️
... and 2 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@algochoi algochoi left a comment

Choose a reason for hiding this comment

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

PR to generate docs for the new opcode: algoidurovic#2

jannotti and others added 6 commits September 14, 2022 21:24
Moved opcode number to be by other "strange jumps"

Added simple tests for normal cases, and for fallthrough

Added some overflow protection from handcrafted bytecode by limiting
switch labels to 2^16.
…_pr_review

Feedback on #3 for switchi fall-through
Made some changes to cast the label count (numOffsets) to `int`
sooner.  My bug was multiplying numOffsets by 2 while it was still a
byte and _then_ casting to int. It had already wrapped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants