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

DO NOT MERGE: True-idempotency-fails #2

Draft
wants to merge 3 commits into
base: source-map-b1
Choose a base branch
from

Conversation

tzaffi
Copy link
Owner

@tzaffi tzaffi commented Jan 27, 2023

Reproducible Example of Scratchslot Instability

NOTE About Reproducibility

This is flakey. Also, you'll need to try on a specific comit such as 218c306 (as of writing this, the latest comit is totally broken)

Related issues

#199

Description

With the goal of solving PyTeal compilation non-idempotency, this PR shows how compilations of unrelated programs can cause unpredictability of output. To reproduce the inconsistency, run the following:

pytest -sv tests/unit/sourcemap_test.py

Observe something like the following in the output

tests/unit/sourcemap_test.py::test_config FAILED
tests/unit/sourcemap_test.py::test_idempotent ----------unified_diff(a1, a2, "approval1.teal", "approval2.teal")----------
--- approval1.teal

+++ approval2.teal

@@ -27,13 +27,13 @@

 assert
 txna ApplicationArgs 1
 btoi
-store 6
+store 5
 txna ApplicationArgs 2
 int 0
 getbyte
-store 8
-load 6
-load 8
+store 7
+load 5
+load 7
 callsub withdraw_3
 int 1
 return
@@ -50,9 +50,9 @@

 int 0
 getbyte
 callsub getBalance_2
-store 4
+store 3
 byte 0x151f7c75
-load 4
+load 3
 itob
 concat
 log
@@ -167,11 +167,11 @@

 
 // deposit
 deposit_1:
-store 3
+store 4
 store 2
 load 2
 gtxns Sender
-load 3
+load 4
 txnas Accounts
 ==
 assert
@@ -180,10 +180,10 @@

 global CurrentApplicationAddress
 ==
 assert
-load 3
-txnas Accounts
-byte "balance"
-load 3
+load 4
+txnas Accounts
+byte "balance"
+load 4
 txnas Accounts
 byte "balance"
 app_local_get
@@ -202,23 +202,23 @@

 
 // withdraw
 withdraw_3:
-store 7
-store 5
-txn Sender
-byte "balance"
-txn Sender
-byte "balance"
-app_local_get
-load 5
+store 8
+store 6
+txn Sender
+byte "balance"
+txn Sender
+byte "balance"
+app_local_get
+load 6
 -
 app_local_put
 itxn_begin
 int pay
 itxn_field TypeEnum
-load 7
+load 8
 txnas Accounts
 itxn_field Receiver
-load 5
+load 6
 itxn_field Amount
 int 0
 itxn_field Fee
FAILED

You can also see similar failures in C.I.

@gmalouf gmalouf deleted the true-idempotency-fails branch February 25, 2025 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant