Skip to content

Allow Users to Allocate Space for DynamicScratchVar's #200

@tzaffi

Description

@tzaffi

Problem

When a user creates a DynamicScratchVar, the compiler -by design- does not block-off slot space for this variable. Typically, the compiler allocates scratch slots at runtime with slot numbers which are as small as possible. However, without knowing at compile time what slots the compiler will create, there is always the possibility that the compiler will step on a user's dynamic slots. In the worst case, this could lead to unpredictable run-time behavior.

Solution

We should allow users to allocate a range of dynamic scratch var's at compile time. For example, the following API might work:

def approval_program():
    DynamicScratchVar.allocate(range(128, 256))   # allocates slot id's [128, 255] for use only by DynamicScratchVar's

    return Seq( ... the actual pyteal ... )

Dependencies

#195

Urgency

Medium

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions