algorand-devrel / community

11 stars 3 forks source link

TEAL - Produce Assembly Map During Compilation #17

Closed barnjamin closed 2 years ago

barnjamin commented 2 years ago

There are 2 valuable bits of information the are available during contract assembly.

1) Program Counter (pc), the index in the bytecode of a given instruction 2) Template Variable Locations, the index in the bytecode of a given template variable and its type

Producing an output file with the above would help with debugging and with variable insertion.

More tooling for encoding and inserting template variables would be needed as well.

pbennett commented 2 years ago

This would be VERY valuable actually. I'd like to see compilation as you mentioned produce the named TMPL_XX byte offsets as a json array in a json object return for eg. Would this be kind of a partial compilation? I'd want to be able to pass teal as-is w/ TMPL_XX placeholders and get the real bytecode back but w/ insertion offsets (which I could adjust for as I inserted) for each of the parameters. This way I could compile the TEAL once and cache it, then replace the parameters efficiently without having to recompile.

barnjamin commented 2 years ago

https://github.com/algorand/go-algorand/pull/2921 re-opened this pr which should provide the map during compilation if given the appropriate flag

barnjamin commented 2 years ago

https://github.com/algorand/go-algorand/pull/3726