algorand / go-algorand

Algorand's official implementation in Go.
https://developer.algorand.org/
Other
1.35k stars 473 forks source link

TEAL op_code for Byte Concatenation #781

Closed ryanRfox closed 4 years ago

ryanRfox commented 4 years ago

User Story:

As a TEAL user I desire the ability to concatenate two stack elements of type bytes so the resulting bytes may be processed later in the program.

Example Scenario:

Sample TEAL code snippet of desired functionality:

arg_0
arg_1
.       // new operator: bytes concatenate bytes => bytes
sha256

In this scenario the program is loading two bytes type elements onto the stack. A new operator . is introduced which intends to concatenate the top two stack elements, both of type bytes, then return bytes to the stack. Note: the stack will now contain a number of bytes equal to the sum of bytes arg_0 and arg_1. Finally, the concatenated bytes are hashed, leaving 32 bytes on the stack and the program continues.

algobolson commented 4 years ago

Hi Ryan, this is definitely something we've been planning on and hope to have in a future expansion of TEAL. It's been designed as an opcode named concat. No word yet on when that will happen though.

derbear commented 4 years ago

If you want the details of what we're proposing to do, you can look at @algobolson's work in #637: https://github.com/algorand/go-algorand/pull/637/files#diff-ece92c5f928e8cdec0723b27bf000532R97

algobolson commented 4 years ago

Spec in the works https://github.com/algorandfoundation/specs/pull/23

ian-algorand commented 4 years ago

fixed in TEAL v2 and never closed.