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

Source Mapper: possible conflict on Windows #710

Open
CiottiGiorgio opened this issue Aug 29, 2023 · 1 comment
Open

Source Mapper: possible conflict on Windows #710

CiottiGiorgio opened this issue Aug 29, 2023 · 1 comment
Assignees
Labels
new-bug Bug report that needs triage

Comments

@CiottiGiorgio
Copy link
Contributor

Reporting this on behalf of one of our users @ErikHasselwander.
Discord thread: https://discord.com/channels/491256308461207573/1143656409905504406
PyTeal source mapper seems to apparently generate incorrect mapping while on Windows but correct elsewhere.

Your environment

Windows and WSL.

Steps to reproduce

PyTeal code in both cases

from feature_gates import FeatureGates
FeatureGates.set_sourcemap_enabled(True)

import pyteal as pt


def approval_program() -> pt.Expr:
    def create() -> pt.Expr:
        return pt.Return(pt.Int(1))

    def call() -> pt.Expr:
        return pt.Seq(
            pt.Pop(pt.Sha256(pt.Txn.sender())),
            pt.Return(pt.Int(1))
        )

    return pt.Cond(
        [pt.Global.current_application_id() == pt.Int(0), create()],
        [pt.Int(1), call()]
    )


if __name__ == "__main__":
    print(pt.Compilation(approval_program(), pt.Mode.Application, version=4).compile(
        with_sourcemap=True,
        annotate_teal=True,
        pcs_in_sourcemap=True,
        annotate_teal_headers=True,
        annotate_teal_concise=True,
    ).sourcemap.annotated_teal)
python -m venv venv
./venv/bin/activate.ps1
pip install pyteal=0.25.0
python ./test.py

Expected behaviour (captured on WSL)

// GENERATED TEAL            //    PC    PYTEAL
#pragma version 4            //    (0)   pt.Compilation(approval_program(), pt.Mode.Application, version=4).compile(with_sourcemap=True, annotate_teal=True, pcs_in_sourcemap=True, annotate_teal_headers=True, annotate_teal_concise=True)
global CurrentApplicationID  //    (4)   pt.Global.current_application_id()
int 0                        //    (6)   pt.Int(0)
==                           //    (8)   pt.Global.current_application_id() == pt.Int(0)
bnz main_l4                  //    (9)
int 1                        //    (12)  pt.Int(1)
bnz main_l3                  //    (13)
err                          //    (16)  pt.Cond([pt.Global.current_application_id() == pt.Int(0), create()], [pt.Int(1), call()])
main_l3:                     //          pt.Int(1)
txn Sender                   //    (17)  pt.Txn.sender()
sha256                       //    (19)  pt.Sha256(pt.Txn.sender())
pop                          //    (20)  pt.Pop(pt.Sha256(pt.Txn.sender()))
int 1                        //    (21)  pt.Int(1)
return                       //    (22)  pt.Return(pt.Int(1))
main_l4:                     //          pt.Global.current_application_id() == pt.Int(0)
int 1                        //    (23)  pt.Int(1)
return                       //    (24)  pt.Return(pt.Int(1))

Actual behaviour (captured on Windows)

// GENERATED TEAL            //    PC    PYTEAL
#pragma version 4            //    (0)   super().__init__(None)
global CurrentApplicationID  //    (4)   super().__init__()
int 0                        //    (6)   super().__init__()
==                           //    (8)   super().__init__()
bnz main_l4                  //    (9)
int 1                        //    (12)  super().__init__()
bnz main_l3                  //    (13)
err                          //    (16)  super().__init__()
main_l3:                     //          super().__init__()
txn Sender                   //    (17)  super().__init__()
sha256                       //    (19)  super().__init__()
pop                          //    (20)
int 1                        //    (21)  super().__init__()
return                       //    (22)  super().__init__()
main_l4:                     //          super().__init__()
int 1                        //    (23)  super().__init__()
return                       //    (24)  super().__init__()
@CiottiGiorgio CiottiGiorgio added the new-bug Bug report that needs triage label Aug 29, 2023
@bbroder-algo
Copy link
Contributor

Thanks! This doesn't completely surprise me. We'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-bug Bug report that needs triage
Projects
None yet
Development

No branches or pull requests

3 participants