algorand / pyteal

Algorand Smart Contracts in Python

Home Page:https://pyteal.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve `Router` clear state program generation

jasonpaulos opened this issue · comments

Problem

Currently the ABI Router class supports methods and bare app calls for the clear state action. Any such bare app call and/or methods get put into the clear state program, following the same routing rules as the approval program.

This is a problem, since clear state programs operate under very different failure rules. A clear state program which wishes to have any effect on the state of the chain must never fail, since doing so reverts any effects made in that program. With the current routing rules, it's possible to fail a program by attempting to call an unsupported ABI method, or by providing any arguments when attempting to issue a bare app call.

Solution

Based on internal discussion, we've agreed on the following solution:

  • Drop support for clear state bare app calls and for ABI methods on clear state.
    • These argument keys should still exist, but an error should be thrown at runtime if someone attempts to use them. The error message should indicate the alternative approach described below.
  • Introduce a new top-level Router argument, clear_state, that takes an Expr. If provided, this expression would become the entire clear state program; no additional code would be injected by PyTeal.