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

add a python function that can be called but it compiles to inline teal #247

Open
Loedn opened this issue Jun 11, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@Loedn
Copy link

Loedn commented Jun 11, 2024

Problem

I want to achieve this inlining to save space in a logic signature, which has a size limit of 1000 bytes, while keeping the code organized within functions.

Solution

Example

def x(g1: Bytes) -> Bytes:
    return extract(g1, 0, key_size)

@subroutine
def negate_proof(g1: Bytes) -> Bytes:
    negated_rhs_bigUint: BigUInt = negate(g1)
    negated_rhs: Bytes = negated_rhs_bigUint.bytes
    negated_proof = concat(x(g1), negated_rhs)

Relevant link

Discord convo

@Loedn Loedn added the enhancement New feature or request label Jun 11, 2024
@joe-p
Copy link
Contributor

joe-p commented Jun 11, 2024

In addition to saving program bytecode size, this would also help reduce opcode cost. Subroutine calls (assuming they have variables) require at least a callsub, proto, and retsub. In scenarios where a set of operations is frequently repeated, this can quickly add up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants