algorand / pyteal

Algorand Smart Contracts in Python
https://pyteal.readthedocs.io
MIT License
285 stars 131 forks source link

Non idempotence of router #639

Closed tzaffi closed 1 year ago

tzaffi commented 1 year ago

The PR in its current state attempts 2 changes.

The first -some minor refactoring of the router- is not very controversial.

~The second -resetting ScratchSlot.nextSlotId is causing flakey tests, and I will need to revert it unless I can find a more fundamental fix. In particular, this assertion becomes flakey on my machine in with the 2nd change:~

https://github.com/algorand/pyteal/blob/a240ec01ccc0e20076be298a04f282a516e7267b/pyteal/compiler/optimizer/optimizer_test.py#L261

Seems like the current PR state is stable, but still requires careful consideration.

tzaffi commented 1 year ago

The PR in its current state attempts 2 changes.

The first -some minor refactoring of the router- is not very controversial.

The second -resetting ScratchSlot.nextSlotId is causing flakey tests, and I will need to revert it unless I can find a more fundamental fix. In particular, this assertion becomes flakey on my machine in with the 2nd change:

https://github.com/algorand/pyteal/blob/a240ec01ccc0e20076be298a04f282a516e7267b/pyteal/compiler/optimizer/optimizer_test.py#L261

The controversial fix doesn't work as is because you end up overwriting previous assignments. I need to think more about it.