I’m developing a lifter from teal/avm into a SSA representation (the idea is to enable advanced tooling for both developers and auditors). Most operations are relatively simple to implement (given a few constraints that we found are regularly followed like “on basic block mergepoints the stack should have a single height”).
I’m now trying my best at implementing intcblock/bytecblock and friends. A small thing is bothering me though. On every contract i’ve seen on algoexplorer developers just have a single use of these instructions at the start and that use dominates the whole execution.
Would it be wise to cut this corner (for now) and allow usage of intcblock and bytecblock iff the usage dominates the whole execution? From what i’ve seen this is the code that it’s usually generated by pyteal, tealish and friends.
Are there good reasons to use intcblock and bytecblock multiple times on the same contract?
Have a look at ARC23 for “Appending application information to the compiled TEAL application”:
This uses a bytecblock to store additional information, but is NOT part of program execution. I’m not aware of TEAL programs that redefine the bytecblock during execution, as the reference algod compile endpoint will not produce this type of AMV bytecode.
Yes, you can use intcblock and bytecblock multiple times in TEAL, however I’ve never come across any smart contracts that actually do it. If you’re looking to scope some values consider using subroutines (callsub t, retsub) and using the protoframe feature (proto a r), as it give you a stack of arguments which is discarded once you return.
It’s also worth noting though that when reassigning these values debugging becomes harder. In the following example the comments are now wrong and show the incorrect values.
#pragma version 8
intcblock 1 2
bytecblock "one" "two"