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

Teal to PyTeal Source Mapper #650

Merged
merged 379 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
379 commits
Select commit Hold shift + click to select a range
23e4026
remove old comments
ahangsu Jan 13, 2023
dc20da4
or none
ahangsu Jan 14, 2023
6cf3b40
taking with minor mods
ahangsu Jan 14, 2023
60e559c
renaming and comments
ahangsu Jan 14, 2023
ac3172c
function bundle things
ahangsu Jan 14, 2023
fc854a0
type casting
ahangsu Jan 14, 2023
ed7e062
Merge branch 'master' into feature/fp-router
ahangsu Jan 17, 2023
e9282ff
test _failing_ on master
Jan 19, 2023
70efea9
Merge branch 'feature/fp-router' into bug-router-not-idempotent
Jan 20, 2023
a8b7e17
wip
Jan 20, 2023
6c49bb2
unit test done
Jan 20, 2023
4f79eba
stateful bug
Jan 20, 2023
6c8b12a
lint
Jan 20, 2023
58b68ce
is this the bug that's been bugging me for almost a year?
Jan 20, 2023
7857d81
Update pyteal/ast/router.py
tzaffi Jan 20, 2023
b3e2cf4
does finally finally fix the bug?
Jan 20, 2023
7f16efe
lint
Jan 20, 2023
a8f0755
i think this works...
Jan 20, 2023
5f3bb74
🤞
Jan 20, 2023
8ce19ac
lint and re-sort imports
Jan 20, 2023
a27e8e1
revert
Jan 20, 2023
b53e302
Update pyteal/ast/router_test.py
tzaffi Jan 20, 2023
d27e8b9
oops - remove integration tests that snuck into unit tests
Jan 20, 2023
987634e
Merge branch 'master' into feature/fp-router
ahangsu Jan 20, 2023
0fc291c
Merge branch 'feature/fp-router' into bug-router-not-idempotent
ahangsu Jan 20, 2023
e99e005
Merge branch 'master' into feature/fp-router
ahangsu Jan 21, 2023
03a8592
Merge branch 'feature/fp-router' into bug-router-not-idempotent
ahangsu Jan 21, 2023
90f1f4c
revive skipped tests in tests/unit/sourcemap_monkey_unit_test.py
Jan 21, 2023
576cfb0
Merge pull request #642 from algorand/merge-feature-router
tzaffi Jan 21, 2023
c76e18d
manual merge
Jan 21, 2023
0d5db9c
Merge remote-tracking branch 'algorand/feature/fp-router' into source…
Jan 21, 2023
b58c503
Merge branch 'feature/fp-router' into source-map
Jan 21, 2023
d0cf180
Update .gitignore
tzaffi Jan 21, 2023
bb7b0a4
reorder
Jan 21, 2023
0c9b7b3
wip
Jan 21, 2023
bf3a770
small improvments e.g. better PC column output
Jan 21, 2023
3033d3f
fine grained control over sync/asyn of unit and integration tests
Jan 22, 2023
9e48d86
finally all merged
Jan 22, 2023
d80f264
threading the synchronous tesst needle
Jan 23, 2023
5083a6d
don't need notebooks
Jan 23, 2023
706292e
remove mistakenly checked in files
Jan 23, 2023
2102a9a
Update .flake8
tzaffi Jan 23, 2023
2d39c6d
sort lines
Jan 23, 2023
f3787fa
Merge branch 'master' into merge-updates-fp-reouter
Jan 23, 2023
a9d1bed
Merge pull request #646 from algorand/merge-updates-fp-reouter
ahangsu Jan 23, 2023
96cdece
hide build program method in router
ahangsu Jan 23, 2023
4873b34
fix doc error
ahangsu Jan 23, 2023
9a8dcd3
Merge pull request #647 from algorand/hide-build-program
ahangsu Jan 23, 2023
6412626
Merge branch 'feature/fp-router' into bug-router-not-idempotent
ahangsu Jan 23, 2023
bac2e13
Merge branch 'feature/fp-router' into source-map
Jan 23, 2023
db6c8e5
Zeph's sick move
ahangsu Jan 23, 2023
b91dc7a
enforce "_root_expr" for members and "root_expr" everywhere else
Jan 23, 2023
2b4b213
Merge branch 'master' into feature/fp-router
ahangsu Jan 24, 2023
9c5a3ea
Merge branch 'feature/fp-router' into bug-router-not-idempotent
ahangsu Jan 24, 2023
b2f9100
Refactoring non-idempotent fix with contextmanager a bit (#649)
ahangsu Jan 24, 2023
eef19f7
Merge remote-tracking branch 'algorand/feature/fp-router' into source…
Jan 25, 2023
eadaa95
bring in `test_constructs()` passing in `source-mapper-that-works`
Jan 26, 2023
d3a7892
back to square 1.5
Jan 26, 2023
793c932
actions -> as_list
Jan 26, 2023
de188db
deleting obsolete test
Jan 26, 2023
45ce15b
mostly just formatting
Jan 26, 2023
d05070c
remove comments
Jan 26, 2023
5fc6ced
add 3rd case to test_build_program_clear_state_invalid_config
Jan 26, 2023
f9cee64
Update pyteal/ast/router.py
tzaffi Jan 26, 2023
eb853ab
minor refactoring
ahangsu Jan 26, 2023
cbed02e
Merge pull request #651 from algorand/minor-refactoring-on-non-idempo…
tzaffi Jan 26, 2023
459487f
Merge pull request #639 from algorand/bug-router-not-idempotent
tzaffi Jan 26, 2023
ed359d2
small changes to monkey unit test
Jan 26, 2023
a43cf2a
Merge remote-tracking branch 'algorand/feature/fp-router' into source…
Jan 26, 2023
4df29f6
passing tests hopefully (at least on 3.11)
Jan 26, 2023
7e13a94
Update pyteal/ast/router.py
tzaffi Jan 26, 2023
e41bd50
Apply suggestions from code review
tzaffi Jan 26, 2023
2d57ca4
should pass the docs build -even if haven't properly updated them
Jan 27, 2023
2c8285c
Update pyteal/stack_frame_test.py
tzaffi Jan 27, 2023
9aa4982
unskip the weak idempotence reliant tests
Jan 27, 2023
f3c8034
begone `source_inference` and `hybrid_source` params
Jan 27, 2023
ace910d
begone `source_inference` and `hybrid_source` params
Jan 27, 2023
0ba0c79
refactor part 1) CompileResults with safe data
Jan 27, 2023
4c318e5
refactor part 2) RouterResults with safe data
Jan 27, 2023
d3b9cf6
move SourceMapDisabledError up into errors.py
Jan 27, 2023
f2a945a
side-effectless infer method
Jan 27, 2023
da56f90
small cleanup
Jan 27, 2023
5944d88
unify source mapper outputs in `PyTealSourceMap` type
Jan 27, 2023
008fb61
make `Compilation.compile()` kw-only
Jan 27, 2023
b9a89b0
small cleanup/fixes
Jan 27, 2023
9a1a50c
remove comment
Jan 28, 2023
725a2e4
comment StackFrames + reorder params + reformat
Jan 30, 2023
eb8d1ed
more comments + remove unused method + reduce the chance of a false p…
Jan 30, 2023
6c0040e
remove StackFrames' `keep_one_frame_only` param and privatize the `_k…
Jan 30, 2023
8048f28
StackFrames ought not be subscriptable
Jan 30, 2023
44b3a8e
remove unused StackFrames.frame_infos method
Jan 30, 2023
7f3daa5
Privatizing StackFrames._frames
Jan 30, 2023
8a91c9d
StackFrames becomes NatalStackFrame
Jan 30, 2023
de4672c
pass the unit test
Jan 30, 2023
26f43ad
commentary
Jan 30, 2023
fe355b5
remove unused const _PYTEAL_FRAME
Jan 30, 2023
07846ba
R3SourceMap commentary
Jan 30, 2023
a21d6c3
fixture for source map integration tests
Jan 30, 2023
d539531
non-controversial changes
Jan 31, 2023
a545e04
rename to what the test expects
Jan 31, 2023
e2edde9
commentary
Jan 31, 2023
07706f6
Simplify NatalStackFrame's constructor while maintaining green tets
Jan 31, 2023
866b02c
hard code the logic and set last_drop_idx=1, but introduce unit test_…
Jan 31, 2023
8d034b4
fix unit test now that _keep_all init param is gone
Jan 31, 2023
df7f645
commentary
Jan 31, 2023
aa97b2b
commentary
Jan 31, 2023
21c60bb
make sourcemap-coverage
Jan 31, 2023
e8c4484
EOL
Jan 31, 2023
792168f
BareCallActions.asdict|list
Feb 1, 2023
6edc25c
algokit "ruff"s up sourcemap.py
Feb 1, 2023
e7296d9
Merge branch 'master' into feature/fp-router
ahangsu Feb 1, 2023
f601c88
bad merge
ahangsu Feb 1, 2023
9bcce00
removing ignoreExprEquality context
Feb 1, 2023
7ade42b
Merge branch 'master' into feature/fp-router
ahangsu Feb 1, 2023
ad43a5c
minor, index_start_from
ahangsu Feb 1, 2023
96f7787
Merge branch 'feature/fp-router' into source-map-b1
Feb 1, 2023
efd0ceb
remove dupe test_bare_call_actions_asdict
Feb 1, 2023
52a9cd6
documentation
ahangsu Feb 1, 2023
48004db
doc for de abify subroutine frame pointer
ahangsu Feb 1, 2023
2b6397f
doc for de abify subroutine frame pointer
ahangsu Feb 1, 2023
92ba2d6
Merge branch 'feature/fp-router' into source-map-b1
Feb 1, 2023
a98779c
doc for de abify subroutine vanilla
ahangsu Feb 1, 2023
943a3c9
explanatory coment
Feb 2, 2023
dca1f8e
Merge branch 'feature/fp-router' into source-map-b1
Feb 2, 2023
a9200bc
lint
Feb 2, 2023
721ff7a
unshadow `str`
Feb 2, 2023
f1ae6bf
Small tweaks of Router.bare_calls (#659)
tzaffi Feb 2, 2023
ccaf8bf
Merge branch 'feature/fp-router' into source-map-b1
Feb 2, 2023
c415375
commentary
Feb 8, 2023
a441a10
first stab at issue #658
Feb 8, 2023
f96ef86
_root_expr members renamed to more accurate _sframes_container
Feb 8, 2023
ec1e06c
remove obsolete comment
Feb 8, 2023
e153eae
Graviton 4 abi router (#634)
tzaffi Feb 9, 2023
4b5fd61
Merge branch 'feature/fp-router' into source-map-b1
Feb 9, 2023
3c9c009
try nightly
Feb 10, 2023
4711226
typo
Feb 10, 2023
2529c9d
try gin
Feb 10, 2023
430208a
and agin
Feb 10, 2023
aba8819
tg
Feb 10, 2023
d2e75f9
default `annotate_teal=False` in `compile()`
Feb 11, 2023
407d153
just look for startswith("def") instead of decorators AST property
Feb 12, 2023
ed299d7
fix and test hybrid_w_offset
Feb 12, 2023
86d90bc
mokey patched tests should be run serially
Feb 12, 2023
71588ea
temp todos
Feb 13, 2023
82feb4f
fix MethodReturn
Feb 13, 2023
c704fd9
no more BRUTE_FORCE_TERRIBLE_SKIP + improved interpretation of loadin…
Feb 13, 2023
483527b
pass the tests
Feb 13, 2023
78e0e2f
remove unneeded duplicates pyteal printouts in annotate()
Feb 13, 2023
bfc8b2e
Update pyteal/ast/router_test.py
tzaffi Feb 13, 2023
b1e9833
better import grouping
Feb 13, 2023
bc23cb4
working on nightly in separate branch
Feb 14, 2023
6e9bdea
Update pyteal/stack_frame.py
tzaffi Feb 15, 2023
f615c01
comment per CR suggestion
Feb 15, 2023
85a633e
remove a TODO
Feb 15, 2023
13bfc3b
per CR suggestion, add tests that assert no regressions against algob…
Feb 15, 2023
224f3e2
RPS fixture test to assert no regressions
Feb 15, 2023
469ddf2
Merge tag 'v0.23.0' into merge-v0.23.0
Feb 15, 2023
d8aee70
Merge pull request #670 from algorand/merge-v0.23.0
tzaffi Feb 15, 2023
a74cfbd
Merge remote-tracking branch 'algorand/feature/fp-router' into source…
Feb 15, 2023
c5fb967
Merge remote-tracking branch 'algorand/rps-fixture' into source-map-b1
Feb 15, 2023
4737ae1
unit tests with RPS; next up, integration tests
Feb 15, 2023
aa47f67
default Compilation.compile() to not calc sourcemap
Feb 15, 2023
bf0a76f
rps integration test
Feb 15, 2023
3a304c8
router improvements + break out slow test
Feb 16, 2023
8418e96
lint
Feb 16, 2023
a132f4a
register the custom pytest mark "slow"
Feb 16, 2023
ddd9e4c
Tightening up types in 2 subroutine.py invokations (#672)
tzaffi Feb 17, 2023
91467fb
Merge branch 'master' into merge-master-fp-router
Feb 17, 2023
df19efe
Merge pull request #673 from algorand/merge-master-fp-router
tzaffi Feb 17, 2023
02840d5
Update pyteal/ast/router.py
ahangsu Feb 17, 2023
9261f3f
update comments
ahangsu Feb 17, 2023
477981b
default optimize object
ahangsu Feb 17, 2023
5864633
update comments and docs
ahangsu Feb 17, 2023
f3344bd
update comments and docs
ahangsu Feb 17, 2023
2b28442
update router comments
ahangsu Feb 17, 2023
2938ed0
default `wrap_to_name`
ahangsu Feb 17, 2023
a12f538
update comments
ahangsu Feb 17, 2023
4fa06fa
update comments
ahangsu Feb 17, 2023
57a8320
update comments
ahangsu Feb 17, 2023
90dbff1
update comments
ahangsu Feb 17, 2023
aeb8cd8
update comments
ahangsu Feb 17, 2023
1b44e79
update comments
ahangsu Feb 17, 2023
183de2c
update comments
ahangsu Feb 17, 2023
fb2b50e
update comments and docs
ahangsu Feb 17, 2023
0c64e56
update comments and docs
ahangsu Feb 17, 2023
ed9e95b
update comments and docs
ahangsu Feb 17, 2023
ef94354
update comments and docs
ahangsu Feb 17, 2023
6295dc2
update comments and docs
ahangsu Feb 17, 2023
a53c0b2
update comments and docs
ahangsu Feb 17, 2023
ef08bef
update comments and docs
ahangsu Feb 17, 2023
4ed640b
minor
ahangsu Feb 17, 2023
c15f1d3
Merge branch 'feature/fp-router' into source-map-b1
Feb 18, 2023
4f164e0
sort imports
Feb 18, 2023
00e61c5
yes, I want NIGHTly tests
Feb 21, 2023
fbd91b4
don't print a warning in the default no-sourcemapping case
Feb 21, 2023
3970c43
Assert that the teal in the sourcemap is the same as the compiled teal
Feb 22, 2023
606c2c1
re-run compilation _without_ sourcemapping and assert that the teal p…
Feb 22, 2023
54a4d47
verify that building with stackframes off also produces the same teal
Feb 22, 2023
ca9030d
better yield pattern in context manager
ahangsu Feb 22, 2023
4333efa
Merge branch 'feature/fp-router' into source-map-b1
Feb 22, 2023
91770b2
better docstrings
Feb 22, 2023
d556756
recursive subroutine test example
Feb 23, 2023
d51426b
frame pointers start at v8
Feb 23, 2023
2652f3d
per CR suggestions
Feb 23, 2023
86f99f6
revert sourcemapping changes in `break_.py`
Feb 23, 2023
fbae6d0
revert unneeded commentse
Feb 23, 2023
56041f0
per CR suggestion
Feb 23, 2023
a7da7c3
oopsie
Feb 23, 2023
e243038
revert changes to TealSimpleBlock
Feb 23, 2023
7f8addf
test aimed at resolving Source Mapper: Poor Mapping of Subroutines #658
Feb 23, 2023
31b6f17
Merge master fp router (#678)
tzaffi Feb 23, 2023
29fe704
Merge branch 'feature/fp-router' into source-map-b1
Feb 23, 2023
d75e741
CHANGELOG
Feb 23, 2023
f8d7350
Merge remote-tracking branch 'origin/master' into source-map-b1
Feb 23, 2023
b5daedd
Merge branch 'master' into rps-fixture
Feb 23, 2023
a76ddb9
Merge branch 'rps-fixture' into source-map-b1
Feb 23, 2023
422685d
per CR suggestion - moder typing
Feb 23, 2023
0c4acd8
simplify typing (mypy is smarter now)
Feb 23, 2023
a8e89f8
per CR suggestion. Call a spade a spade.
Feb 24, 2023
f8278f4
per CR suggestion, better doc-strings in `compiler.py`
Feb 24, 2023
6fd0ed5
remove todo per CR suggestion
Feb 24, 2023
205fdd5
per CR suggestion. streamlined `pcs_repr()`
Feb 27, 2023
a3b8e1d
per CR suggestion: don't check for impossible pyteal lineno() == None
Feb 28, 2023
092caf3
Sprinkle some mypy-immutability + per CR suggestion, axe `pcs_hydrated`
Feb 28, 2023
8273967
CR response de-spawn in favore of simpler clone
Feb 28, 2023
89925a5
per CR suggestion: tweak _hybrid_impl + more coverage of it
Feb 28, 2023
10767d1
R3SourceMap to always use `hybrid_unparsed` plus use `raw_code()` ins…
Feb 28, 2023
13b3453
Per CR nudge - turns out we don't need _PT_GEN for code annotation. J…
Feb 28, 2023
df2b5ec
per CR inquiry: remove code smell TealMapItem._hybrid_w_offset
Feb 28, 2023
139ebff
per CR discussion - remove obsolete TODO's
Feb 28, 2023
b38a83c
per CR suggestion - clear the unused lists
Feb 28, 2023
b141783
Update pyteal/compiler/sourcemap.py
tzaffi Feb 28, 2023
624d659
per CR suggestion - avoid mutable default args
Feb 28, 2023
b9a054c
lazy eval of annotation columns
Mar 1, 2023
d027e2e
don't shadow self
Mar 1, 2023
9583cba
expunge unused property "Tabulatable Teal"
Mar 1, 2023
46cae54
for completeness: add beginning and end column TEAL offsets to TealMa…
Mar 1, 2023
236da81
capitalize T in Py_T_ealFrameStatus
Mar 1, 2023
1a90c61
better commentary in _PyTealSourceMapper.tabulate()
Mar 1, 2023
f588e1a
typos
Mar 1, 2023
de09702
mypy whack-a-mole
Mar 1, 2023
2045afe
small optimization
Mar 1, 2023
3534190
comma column alignment
Mar 1, 2023
601d9a2
Merge branch 'master' into source-map-b1
Mar 7, 2023
02dfc12
first removal of deprecated declarations.get_declaration()
Mar 7, 2023
a27396b
per CR suggestion
Mar 7, 2023
2960d39
Update pyteal/compiler/compiler.py
tzaffi Mar 7, 2023
d990ed0
lint
Mar 7, 2023
3cde973
slight optimization
Mar 7, 2023
d9706b1
Update pyteal/compiler/compiler.py
tzaffi Mar 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ per-file-ignores =
examples/signature/recurring_swap.py: F403, F405
examples/signature/split.py: F403, F405
pyteal/__init__.py: F401, F403
pyteal/compiler/flatten.py: F821
pyteal/compiler/optimizer/__init__.py: F401
pyteal/ir/ops.py: E221
pyteal/ir/tealconditionalblock.py: F821
pyteal/ir/tealsimpleblock.py: F821
pyteal/stack_frame.py: F821
tests/teal/rps_helpers/program.py: F401, F403, F405
tests/teal/rps.py: F403, F405, I252
tests/unit/module_test.py: F401, F403

# from flake8-tidy-imports
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Build workflow"
name: "On Commit Workflow"
on:
pull_request:
push:
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python: [ "3.10" ]
python: ["3.10"]
steps:
- name: Check out code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Nightly Build"
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
on:
schedule:
- cron: "10 17 * * *"
- cron: "10 1 * * *"

jobs:
nightly-slow-unit-tests:
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

* Clarify that `Approve` and `Reject` always exit in the documentation. ([#660](https://github.com/algorand/pyteal/pull/660))
* Added frame pointer support for router. ([#600](https://github.com/algorand/pyteal/pull/600))
* NOTE: a backwards incompatable change was imposed in this PR: previous `build_program` method in `Router` was exported and public, now this method is hidden. Use `compile_program` only.
* NOTE: a backwards incompatable change was imposed in this PR: previous `build_program` method in `Router` was exported and public, now this method is hidden. Use `compile_program` only.
* Experimental source mapping capability. ([#650](https://github.com/algorand/pyteal/pull/650))

## Fixed

Expand Down
39 changes: 27 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ bdist-wheel:

bundle-docs-clean:
rm -rf docs/pyteal.docset
rm -rf docs/_build
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
rm -f docs/pyteal.docset.tar.gz

bundle-docs: bundle-docs-clean
cd docs && \
Expand Down Expand Up @@ -51,14 +53,19 @@ lint: black flake8 mypy sdist-check

# ---- Unit Tests (no algod) ---- #

# TODO: add blackbox_test.py to multithreaded tests when following issue has been fixed https://github.com/algorand/pyteal/issues/199
# Slow test which are fast enough on python 3.11+
test-unit-slow:
pytest tests/unit/sourcemap_constructs311_test.py -m serial

test-unit-very-slow:
pytest tests/unit/sourcemap_constructs_allpy_test.py -m serial

NUM_PROCS = auto
test-unit-async:
pytest -n $(NUM_PROCS) --durations=10 -sv pyteal tests/unit -m "not serial"
pytest -n auto --durations=10 pyteal tests/unit -m "not slow" -m "not serial"

test-unit-sync:
pytest --durations=10 -sv pyteal tests/unit -m serial
# Run tests w/ @pytest.mark.serial under ~/tests/unit each in its own proc:
test-unit-sync: test-unit-slow
find tests/unit -name '*_test.py' | sort | xargs -t -I {} pytest --suppress-no-test-exit-code --dist=no --durations=10 {} -m serial -m "not slow"

test-unit: test-unit-async test-unit-sync

Expand All @@ -76,13 +83,19 @@ algod-start-report: algod-start algod-version

algod-stop:
docker compose stop algod
integration-run:
pytest -n $(NUM_PROCS) --durations=10 -sv tests/integration -m "not serial"
pytest --durations=10 -sv tests/integration -m serial

test-integration: integration-run
test-integ-async:
pytest -n auto --durations=10 -sv tests/integration -m "not serial"

# Run tests w/ @pytest.mark.serial under ~/tests/integration each in its own proc:
test-integ-sync:
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
find tests/integration -name '*_test.py' | sort | xargs -t -I {} pytest --suppress-no-test-exit-code --dist=no --durations=10 {} -m serial

test-integration: test-integ-async test-integ-sync

all-tests: lint-and-test test-integration
all-sync: test-unit-sync test-integ-sync

all-lint-unit-integ: lint-and-test test-integration

# ---- Github Actions 1-Liners ---- #

Expand All @@ -94,8 +107,7 @@ check-code-changes:
git config --global --add safe.directory /__w/pyteal/pyteal
[ -n "$$(git log --since='24 hours ago')" ] && (echo "should_run=true" >> $(GITHUB_ENV)) || (echo "should_run=false" >> $(GITHUB_ENV))

nightly-slow:
echo "TODO - this is a stub for a very slow test"
nightly-slow: test-unit-very-slow

# ---- Local Github Actions Simulation via `act` ---- #
# assumes act is installed, e.g. via `brew install act`
Expand All @@ -111,3 +123,6 @@ local-gh-simulate:

coverage:
pytest --cov-report html --cov=pyteal

sourcemap-coverage:
pytest --cov-report html --cov=pyteal.stack_frame --cov=pyteal.compiler.sourcemap --cov=pyteal.compiler.compiler --dist=no tests/unit/sourcemap_monkey_unit_test.py -m serial
4 changes: 3 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
sphinx==5.1.1
sphinx-rtd-theme==1.0.0
# dependencies from setup.py
docstring-parser==0.14.1
executing==1.2.0
py-algorand-sdk>=2.0.0,<3.0.0
semantic-version>=2.9.0,<3.0.0
docstring-parser==0.14.1
tabulate>=0.9.0,<0.10.0
8 changes: 4 additions & 4 deletions examples/application/abi/algobank.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ def withdraw(amount: abi.Uint64, recipient: abi.Account) -> Expr:
)


approval_program, clear_state_program, contract = router.compile_program(
version=6, optimize=OptimizeOptions(scratch_slots=True)
)

if __name__ == "__main__":
approval_program, clear_state_program, contract = router.compile_program(
version=6, optimize=OptimizeOptions(scratch_slots=True)
)

with open("algobank_approval.teal", "w") as f:
f.write(approval_program)

Expand Down
5 changes: 5 additions & 0 deletions pyteal.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pyteal]

[pyteal-source-mapper]
enabled = False
debug = False
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
8 changes: 8 additions & 0 deletions pyteal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
MIN_PROGRAM_VERSION,
DEFAULT_PROGRAM_VERSION,
CompileOptions,
Compilation,
compileTeal,
OptimizeOptions,
PyTealSourceMap,
)
from pyteal.types import TealType
from pyteal.errors import (
AlgodClientError,
SourceMapDisabledError,
TealInternalError,
TealTypeError,
TealSeqError,
Expand Down Expand Up @@ -43,9 +47,13 @@
"DEFAULT_PROGRAM_VERSION",
"CompileOptions",
"pragma",
"Compilation",
"compileTeal",
"OptimizeOptions",
"PyTealSourceMap",
"TealType",
"AlgodClientError",
"SourceMapDisabledError",
"TealInternalError",
"TealTypeError",
"TealSeqError",
Expand Down
9 changes: 9 additions & 0 deletions pyteal/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ from pyteal.compiler import (
MIN_PROGRAM_VERSION,
DEFAULT_PROGRAM_VERSION,
CompileOptions,
Compilation,
compileTeal,
OptimizeOptions,
PyTealSourceMap,
)
from pyteal.types import TealType
from pyteal.errors import (
AlgodClientError,
SourceMapDisabledError,
TealInternalError,
TealTypeError,
TealSeqError,
Expand All @@ -39,6 +43,7 @@ __all__ = [
"AccountParamObject",
"Add",
"Addr",
"AlgodClientError",
"And",
"App",
"AppField",
Expand Down Expand Up @@ -91,6 +96,7 @@ __all__ = [
"BytesZero",
"CallConfig",
"Comment",
"Compilation",
"CompileOptions",
"Concat",
"Cond",
Expand Down Expand Up @@ -175,6 +181,7 @@ __all__ = [
"Or",
"Pop",
"Pragma",
"PyTealSourceMap",
"RETURN_HASH_PREFIX",
"Reject",
"Replace",
Expand All @@ -194,6 +201,7 @@ __all__ = [
"Sha512_256",
"ShiftLeft",
"ShiftRight",
"SourceMapDisabledError",
"Sqrt",
"Subroutine",
"SubroutineCall",
Expand All @@ -210,6 +218,7 @@ __all__ = [
"TealInternalError",
"TealLabel",
"TealOp",
"TealPragma",
"TealPragmaError",
"TealSeqError",
"TealSimpleBlock",
Expand Down
8 changes: 6 additions & 2 deletions pyteal/ast/abi/method_return.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from pyteal.ast.unaryexpr import Log
from pyteal.ast.naryexpr import Concat
from pyteal.ast.bytes import Bytes
from pyteal.ir import TealBlock, TealSimpleBlock, Op
from pyteal.config import RETURN_HASH_PREFIX
from pyteal.ir import TealBlock, TealSimpleBlock, Op
tzaffi marked this conversation as resolved.
Show resolved Hide resolved
from pyteal.stack_frame import NatalStackFrame

if TYPE_CHECKING:
from pyteal.compiler import CompileOptions
Expand All @@ -19,15 +20,18 @@ def __init__(self, arg: BaseType):
if not isinstance(arg, BaseType):
raise TealInputError(f"Expecting an ABI type argument but get {arg}")
self.arg = arg
self._sframes_container: Expr | None = None

def __teal__(self, options: "CompileOptions") -> Tuple[TealBlock, TealSimpleBlock]:
if options.version < Op.log.min_version:
raise TealInputError(
f"current version {options.version} is lower than log's min version {Op.log.min_version}"
)
return Log(Concat(Bytes(RETURN_HASH_PREFIX), self.arg.encode())).__teal__(
start, end = Log(Concat(Bytes(RETURN_HASH_PREFIX), self.arg.encode())).__teal__(
options
)
NatalStackFrame.reframe_ops_in_blocks(self._sframes_container or self, start)
return start, end

def __str__(self) -> str:
return f"(MethodReturn {self.arg.type_spec()})"
Expand Down
12 changes: 6 additions & 6 deletions pyteal/ast/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
class OnComplete:
"""An enum of values that :any:`TxnObject.on_completion()` may return."""

NoOp = EnumInt("NoOp")
OptIn = EnumInt("OptIn")
CloseOut = EnumInt("CloseOut")
ClearState = EnumInt("ClearState")
UpdateApplication = EnumInt("UpdateApplication")
DeleteApplication = EnumInt("DeleteApplication")
NoOp = EnumInt("NoOp") # T2PT8
OptIn = EnumInt("OptIn") # T2PT8
CloseOut = EnumInt("CloseOut") # T2PT8
ClearState = EnumInt("ClearState") # T2PT8
UpdateApplication = EnumInt("UpdateApplication") # T2PT8
DeleteApplication = EnumInt("DeleteApplication") # T2PT8


OnComplete.__module__ = "pyteal"
Expand Down
2 changes: 2 additions & 0 deletions pyteal/ast/assert_.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def __init__(

self.comment = comment
self.cond = [cond] + list(additional_conds)
self._sframes_container: Expr | None = None

def __teal__(self, options: "CompileOptions"):
if len(self.cond) > 1:
asserts: list[Expr] = []
for cond in self.cond:
asrt = Assert(cond, comment=self.comment)
asrt.trace = cond.trace
asrt._sframes_container = cond
asserts.append(asrt)
return Seq(*asserts).__teal__(options)

Expand Down
5 changes: 3 additions & 2 deletions pyteal/ast/cond.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def __init__(self, *argv: List[Expr]):
def __teal__(self, options: "CompileOptions"):
start = None
end = TealSimpleBlock([])
prevBranch = None
prevBranch: TealConditionalBlock | None = None
for i, (cond, pred) in enumerate(self.args):
condStart, condEnd = cond.__teal__(options)
predStart, predEnd = pred.__teal__(options)

branchBlock = TealConditionalBlock([])
branchBlock = TealConditionalBlock([], root_expr=cond)
branchBlock.setTrueBlock(predStart)

condEnd.setNextBlock(branchBlock)
Expand All @@ -91,6 +91,7 @@ def __teal__(self, options: "CompileOptions"):
start = condStart
else:
cast(TealConditionalBlock, prevBranch).setFalseBlock(condStart)

prevBranch = branchBlock

errBlock = TealSimpleBlock([TealOp(self, Op.err)])
Expand Down
4 changes: 3 additions & 1 deletion pyteal/ast/expr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING

from pyteal.types import TealType
from pyteal.ir import TealBlock, TealSimpleBlock
from pyteal.stack_frame import NatalStackFrame
from pyteal.types import TealType

if TYPE_CHECKING:
from pyteal.compiler import CompileOptions
Expand All @@ -15,6 +16,7 @@ def __init__(self):
import traceback

self.trace = traceback.format_stack()[0:-1]
self.stack_frames: NatalStackFrame = NatalStackFrame()

def getDefinitionTrace(self) -> list[str]:
return self.trace
Expand Down
3 changes: 2 additions & 1 deletion pyteal/ast/for_.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ def __teal__(self, options: "CompileOptions"):

stepStart, stepEnd = self.step.__teal__(options)
stepEnd.setNextBlock(condStart)
stepEnd._sframes_container = self
doEnd.setNextBlock(stepStart)

branchBlock = TealConditionalBlock([])
branchBlock = TealConditionalBlock([], root_expr=self)
branchBlock.setTrueBlock(doStart)
branchBlock.setFalseBlock(end)

Expand Down
2 changes: 2 additions & 0 deletions pyteal/ast/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pyteal.types import TealType, require_type
from pyteal.errors import TealInputError, TealInternalError, verifyProgramVersion
from pyteal.ir import TealBlock, TealSimpleBlock, TealOp, Op
from pyteal.stack_frame import NatalStackFrame

if TYPE_CHECKING:
from pyteal.compiler import CompileOptions
Expand Down Expand Up @@ -190,6 +191,7 @@ def __teal__(self, options: "CompileOptions") -> tuple[TealBlock, TealSimpleBloc
proto_srt, proto_end = TealBlock.FromOp(options, op)
local_srt, local_end = self.mem_layout.__teal__(options)
proto_end.setNextBlock(local_srt)
NatalStackFrame.reframe_ops_in_blocks(self, proto_srt)
return proto_srt, local_end

def __str__(self) -> str:
Expand Down
Loading