From 6c801927387856c141bcbf964a6a9410d5b9f6f9 Mon Sep 17 00:00:00 2001 From: Christoph Hagedorn Date: Wed, 10 Apr 2024 21:59:12 +0200 Subject: [PATCH 1/7] - added missing requirements and version dependencies --- .gitignore | 3 + dev-requirements.txt | 9 +++ requirements.txt | 154 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 166 insertions(+) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 49357d74..00b02c8e 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,10 @@ dist/ .hypothesis/ .idea/ .pytest_cache + +# pythen virtual environments venv/ +.venv/ *.env .coverage diff --git a/dev-requirements.txt b/dev-requirements.txt index 93d94bad..74ef21e4 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -16,3 +16,12 @@ sphinx-rtd-theme # jupyter jupyter_server nest_asyncio + +eth-stdlib>=0.2.7,<0.3.0 +eth-abi>=5.1.0 +eth-typing>=4.1.0 +eth-utils>=4.1.0 +eth-account>=0.12.1 +vyper==0.3.10 +py-evm>=0.10.0b4 +rich diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..78bf18d9 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,154 @@ +ipython==8.23.0 +Sphinx==7.2.6 +black==24.3.0 +flake8==7.0.0 +flake8-bugbear==24.2.6 +flake8-use-fstring==1.4 +hypothesis==6.100.1 +isort==5.13.2 +mypy==1.9.0 +pre-commit==3.7.0 +pytest==8.1.1 +pytest-xdist==3.5.0 +pytest-cov==5.0.0 +sphinx-rtd-theme==2.0.0 + +# jupyter +jupyter_server==2.13.0 +nest-asyncio==1.6.0 +eth-stdlib==0.2.7 +eth_abi==5.1.0 +eth-typing==4.1.0 +eth-utils==4.1.0 +eth-account==0.12.1 +vyper==0.3.10 +py-evm==0.10.0b6 +rich==13.7.1 +## The following requirements were added by pip freeze: +alabaster==0.7.16 +annotated-types==0.6.0 +anyio==4.3.0 +argon2-cffi==23.1.0 +argon2-cffi-bindings==21.2.0 +arrow==1.3.0 +asttokens==2.4.1 +attrs==23.2.0 +Babel==2.14.0 +beautifulsoup4==4.12.3 +bitarray==2.9.2 +bleach==6.1.0 +cached-property==1.5.2 +cbor2==5.6.2 +certifi==2024.2.2 +cffi==1.16.0 +cfgv==3.4.0 +charset-normalizer==3.3.2 +ckzg==1.0.0 +click==8.1.7 +coverage==7.4.4 +cytoolz==0.12.3 +decorator==5.1.1 +defusedxml==0.7.1 +distlib==0.3.8 +docutils==0.20.1 +eth-bloom==3.0.0 +eth-hash==0.7.0 +eth-keyfile==0.8.0 +eth-keys==0.5.0 +eth-rlp==2.1.0 +execnet==2.1.1 +executing==2.0.1 +fastjsonschema==2.19.1 +filelock==3.13.4 +fqdn==1.5.1 +hexbytes==1.2.0 +identify==2.5.35 +idna==3.6 +imagesize==1.4.1 +importlib_metadata==7.1.0 +iniconfig==2.0.0 +isoduration==20.11.0 +jedi==0.19.1 +Jinja2==3.1.3 +jsonpointer==2.4 +jsonschema==4.21.1 +jsonschema-specifications==2023.12.1 +jupyter-events==0.10.0 +jupyter_client==8.6.1 +jupyter_core==5.7.2 +jupyter_server_terminals==0.5.3 +jupyterlab_pygments==0.3.0 +lru-dict==1.3.0 +markdown-it-py==3.0.0 +MarkupSafe==2.1.5 +matplotlib-inline==0.1.6 +mccabe==0.7.0 +mdurl==0.1.2 +mistune==3.0.2 +mypy-extensions==1.0.0 +nbclient==0.10.0 +nbconvert==7.16.3 +nbformat==5.10.4 +nodeenv==1.8.0 +overrides==7.7.0 +packaging==23.2 +pandocfilters==1.5.1 +parsimonious==0.10.0 +parso==0.8.4 +pathspec==0.12.1 +pexpect==4.9.0 +platformdirs==4.2.0 +pluggy==1.4.0 +prometheus_client==0.20.0 +prompt-toolkit==3.0.43 +ptyprocess==0.7.0 +pure-eval==0.2.2 +py-ecc==7.0.0 +pycodestyle==2.11.1 +pycparser==2.22 +pycryptodome==3.20.0 +pydantic==2.6.4 +pydantic_core==2.16.3 +pyflakes==3.2.0 +Pygments==2.17.2 +python-dateutil==2.9.0.post0 +python-json-logger==2.0.7 +PyYAML==6.0.1 +pyzmq==25.1.2 +referencing==0.34.0 +regex==2023.12.25 +requests==2.31.0 +rfc3339-validator==0.1.4 +rfc3986-validator==0.1.1 +rlp==4.0.0 +rpds-py==0.18.0 +Send2Trash==1.8.3 +six==1.16.0 +sniffio==1.3.1 +snowballstemmer==2.2.0 +sortedcontainers==2.4.0 +soupsieve==2.5 +sphinxcontrib-applehelp==1.0.8 +sphinxcontrib-devhelp==1.0.6 +sphinxcontrib-htmlhelp==2.0.5 +sphinxcontrib-jquery==4.1 +sphinxcontrib-jsmath==1.0.1 +sphinxcontrib-qthelp==1.0.7 +sphinxcontrib-serializinghtml==1.1.10 +stack-data==0.6.3 +terminado==0.18.1 +tinycss2==1.2.1 +toolz==0.12.1 +tornado==6.4 +traitlets==5.14.2 +trie==2.1.1 +types-python-dateutil==2.9.0.20240316 +typing_extensions==4.11.0 +uri-template==1.3.0 +urllib3==2.2.1 +virtualenv==20.25.1 +wcwidth==0.2.13 +webcolors==1.13 +webencodings==0.5.1 +websocket-client==1.7.0 +zipp==3.18.1 From d226be3cf11388cd5b278448155d5fcbb73289da Mon Sep 17 00:00:00 2001 From: Christoph Hagedorn Date: Wed, 10 Apr 2024 22:09:16 +0200 Subject: [PATCH 2/7] - added development environment installation notes --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 312480a3..f68d120c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,28 @@ Titanoboa achieves feature parity with the vyper compiler while providing an int Usage and quickstart are [below](#usage-quick-start). For more detailed documentation, please see the [documentation](https://titanoboa.readthedocs.io/en/latest/index.html). -## Installation +## Setup dev environment +Clone titanoboa git repo and change into the newly created directory. + +Create python virtual environment inside titanoboa folder +``` +python -m venv .venv +``` +Switch to virtual envrionment +``` +source .venv/bin/activate +``` +Upgrade pip +``` +pip install --upgrade pip +``` + +Install package dependencies +``` +pip install -r dev-requirements.txt +``` + +## Alternative Installation ``` pip install titanoboa ``` From a1970067756c681718ed9b44911ccf417657e62b Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 11 Apr 2024 18:22:39 +0200 Subject: [PATCH 3/7] Update .gitignore Co-authored-by: Daniel Schiavini --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 00b02c8e..a4962709 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ dist/ .idea/ .pytest_cache -# pythen virtual environments +# Python virtual environments venv/ .venv/ *.env From 0d5418ce8fb9f86bb46f5ca46408bf19f8d28eae Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 11 Apr 2024 18:24:18 +0200 Subject: [PATCH 4/7] Update README.md Wording adjusted as suggested Co-authored-by: Daniel Schiavini --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f68d120c..9d17055d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Titanoboa achieves feature parity with the vyper compiler while providing an int Usage and quickstart are [below](#usage-quick-start). For more detailed documentation, please see the [documentation](https://titanoboa.readthedocs.io/en/latest/index.html). ## Setup dev environment -Clone titanoboa git repo and change into the newly created directory. +Clone the titanoboa git repository and change into the newly created directory. Create python virtual environment inside titanoboa folder ``` From 4ca4175add341003b1b078fd41231064030c505c Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 11 Apr 2024 19:06:21 +0200 Subject: [PATCH 5/7] Update README.md changed order of commands Co-authored-by: Daniel Schiavini --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9d17055d..7175f38a 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ pip install --upgrade pip Install package dependencies ``` +pip install . pip install -r dev-requirements.txt ``` From c0c9f9344f8a8df709ca94d9131c07040c471c84 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 11 Apr 2024 19:30:35 +0200 Subject: [PATCH 6/7] Update README.md Co-authored-by: Daniel Schiavini --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7175f38a..769cc45b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ pip install . pip install -r dev-requirements.txt ``` -## Alternative Installation +## Install as dependency ``` pip install titanoboa ``` From 8cd83879ca73310d187142128a21294c3b6a6aa3 Mon Sep 17 00:00:00 2001 From: Christoph Hagedorn Date: Thu, 11 Apr 2024 23:17:37 +0200 Subject: [PATCH 7/7] Cleaned up and reorganized - cleaned up and reorganized readme.md - moved dev dependencies from .toml to dev-requirements.txt - updated .toml with runtime dependencies - added upper limits for possible versions - added .vscode folder to .gitignore --- .gitignore | 3 + README.md | 130 ++++++++++++++++++++++++++++++------------- dev-requirements.txt | 9 +-- pyproject.toml | 16 +++--- requirements.txt | 16 +++--- 5 files changed, 111 insertions(+), 63 deletions(-) diff --git a/.gitignore b/.gitignore index a4962709..5dcba843 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,8 @@ venv/ .venv/ *.env +# Visual Code +.vscode/ + .coverage .coverage.* diff --git a/README.md b/README.md index 769cc45b..8ec56363 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,23 @@ A [Vyper](https://github.com/vyperlang/vyper) interpreter with pretty tracebacks Titanoboa achieves feature parity with the vyper compiler while providing an interpreted experience. How does it do this? Internally, titanoboa uses vyper as a library to compile source code to bytecode, and then runs the bytecode using [py-evm](https://github.com/ethereum/py-evm), adding instrumenting hooks to provide introspection. The use of `py-evm` means that the entire experience is highly configurable, down to the ability to patch opcodes and precompiles at the EVM level. -## Documentation +## Origin of name -Usage and quickstart are [below](#usage-quick-start). For more detailed documentation, please see the [documentation](https://titanoboa.readthedocs.io/en/latest/index.html). +Titanoboa (/ˌtaɪtənəˈboʊə/;[1] lit. 'titanic boa') is an extinct genus of very large snakes that lived in what is now La Guajira in northeastern Colombia. They could grow up to 12.8 m (42 ft), perhaps even 14.3 m (47 ft) long and reach a body mass of 730–1,135 kg (1,610–2,500 lb). This snake lived during the Middle to Late Paleocene epoch, around 60 to 58 million years ago, following the extinction of all non-avian dinosaurs. Although originally thought to be an apex predator, the discovery of skull bones revealed that it was more than likely specialized in preying on fish. The only known species is Titanoboa cerrejonensis, the largest snake ever discovered,[2] which supplanted the previous record holder, Gigantophis garstini.[3] -## Setup dev environment -Clone the titanoboa git repository and change into the newly created directory. +# Documentation -Create python virtual environment inside titanoboa folder -``` -python -m venv .venv -``` -Switch to virtual envrionment -``` -source .venv/bin/activate -``` -Upgrade pip -``` -pip install --upgrade pip -``` +Content +- [Usage and quickstart guide](#usage-quick-start) +- [Details on setup of development environment](#initial-preparation) +- [Notes and performance hints](#notes-and-performance-hints) + + +External links +- [Detailed documentation on readthedoc.io](https://titanoboa.readthedocs.io/en/latest/index.html) +- [Titanoboa on PyPi](https://pypi.org/project/titanoboa/) +- [GitHub project](https://github.com/vyperlang/titanoboa) -Install package dependencies -``` -pip install . -pip install -r dev-requirements.txt -``` ## Install as dependency ``` @@ -43,23 +35,6 @@ pip install git+https://github.com/vyperlang/titanoboa ``` -If you are installing titanoboa from git alongside brownie, you may have to manually install titanoboa *after* installing brownie - -``` -pip install brownie -pip install git+https://github.com/vyperlang/titanoboa -``` - -Sometimes, using [pypy](https://www.pypy.org/download.html) can result in a substantial performance improvement for computation heavy contracts. `Pypy` can usually be used as a drop-in replacement for `CPython`. - -To get a performance boost for mainnet forking, install with the `forking-recommended` extra (`pip install "git+https://github.com/vyperlang/titanoboa#egg=titanoboa[forking-recommended]"`, or `pip install titanoboa[forking-recommended]`). This installs `plyvel` to cache RPC results between sessions, and `ujson` which improves json performance. - -If you are running titanoboa on a local [Vyper](https://github.com/vyperlang/vyper) project folder, you might need to run `python setup.py install` on your [Vyper](https://github.com/vyperlang/vyper) project if you encounter errors such as `ModuleNotFoundError: No module named 'vyper.version'` - -## Background - -Titanoboa (/ˌtaɪtənəˈboʊə/;[1] lit. 'titanic boa') is an extinct genus of very large snakes that lived in what is now La Guajira in northeastern Colombia. They could grow up to 12.8 m (42 ft), perhaps even 14.3 m (47 ft) long and reach a body mass of 730–1,135 kg (1,610–2,500 lb). This snake lived during the Middle to Late Paleocene epoch, around 60 to 58 million years ago, following the extinction of all non-avian dinosaurs. Although originally thought to be an apex predator, the discovery of skull bones revealed that it was more than likely specialized in preying on fish. The only known species is Titanoboa cerrejonensis, the largest snake ever discovered,[2] which supplanted the previous record holder, Gigantophis garstini.[3] - ## Usage / Quick Start ### Hello, world @@ -237,3 +212,82 @@ You can use Jupyter to execute titanoboa code in network mode from your browser ```bash $ python -m tests.integration.sim_veYFI ``` + + +# Appendix + +## Detailed setup of development environment + +### Requirements +- Python 3.11 +- git + +### Initial preparation +Clone the titanoboa git repository and change into the newly created directory. +```bash +# clone +git clone https://github.com/vyperlang/titanoboa.git +cd titanoboa + +# Create python virtual environment inside titanoboa folder +python -m venv .venv +``` +Your environment is ready for coding or testing now. + +### Preparation of each coding session +```bash +# Switch to virtual envrionment +source .venv/bin/activate + +# Upgrade pip (every now an then) +pip install --upgrade pip + +# Install or upgrade package dependencies (every now an then) +pip install . +pip install -r dev-requirements.txt + +# Leaving the virtual envrionment when you are done +deactivate +``` + +## Notes and performance hints +### Brownie and Titanoboa + +If you are installing titanoboa from git alongside brownie, you may have to manually install **brownie before titanoboa**: + + +``` +pip install brownie +pip install git+https://github.com/vyperlang/titanoboa +``` + +### Vyper version errors +If you are running titanoboa on a local **vyper project folder** and encounter errors in your vyper project such as `ModuleNotFoundError: No module named 'vyper.version'`, +you might need to run +``` +python setup.py install +``` +See also [Vyper](https://github.com/vyperlang/vyper) on GitHub. + + +### Contract computation performance +Sometimes, using PyPy can result in a substantial performance improvement for computation heavy contracts. **PyPy** can usually be used as a drop-in replacement for **CPython**. + +See also [PyPy documentation](https://www.pypy.org/download.html). + + +### Mainnet forking performance +To get a performance boost for mainnet forking, install with the `forking-recommended` extra: + +``` + pip install titanoboa[forking-recommended] + ``` + + or for latest dev version: + + ``` + pip install git+https://github.com/vyperlang/titanoboa#egg=titanoboa[forking-recommended] + ``` + + `forking-recommended` installs **plyvel** to cache RPC results between sessions, and **ujson** which improves json performance. + diff --git a/dev-requirements.txt b/dev-requirements.txt index 74ef21e4..022f05d5 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -17,11 +17,4 @@ sphinx-rtd-theme jupyter_server nest_asyncio -eth-stdlib>=0.2.7,<0.3.0 -eth-abi>=5.1.0 -eth-typing>=4.1.0 -eth-utils>=4.1.0 -eth-account>=0.12.1 -vyper==0.3.10 -py-evm>=0.10.0b4 -rich + diff --git a/pyproject.toml b/pyproject.toml index d7804fc1..0e9c076f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,15 +15,13 @@ classifiers = ["Topic :: Software Development"] # Requirements dependencies = [ - "vyper >= 0.3.10", + "vyper>=0.3.10,<0.4.0", "eth-stdlib>=0.2.7,<0.3.0", - "eth-abi", - "py-evm>=0.10.0b4", - "eth-typing", - "hypothesis", - "pytest", - "pytest-cov", - + "eth-abi>=5.1.0,<6.0.0", + "py-evm>=0.10.0b4,<0.11.0", + "eth-typing>=4.1.0,<5.0.0", + "eth-utils>=4.1.0,<5.0.0", + # eth-rlp requirement, not installed by default with 3.12 "typing-extensions", @@ -34,7 +32,7 @@ dependencies = [ "requests", # required for networked accounts - "eth-account", + "eth-account>=0.12.1,<0.13.0", ] [project.optional-dependencies] diff --git a/requirements.txt b/requirements.txt index 78bf18d9..fb9a18f7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,14 +16,6 @@ sphinx-rtd-theme==2.0.0 # jupyter jupyter_server==2.13.0 nest-asyncio==1.6.0 -eth-stdlib==0.2.7 -eth_abi==5.1.0 -eth-typing==4.1.0 -eth-utils==4.1.0 -eth-account==0.12.1 -vyper==0.3.10 -py-evm==0.10.0b6 -rich==13.7.1 ## The following requirements were added by pip freeze: alabaster==0.7.16 annotated-types==0.6.0 @@ -51,11 +43,16 @@ decorator==5.1.1 defusedxml==0.7.1 distlib==0.3.8 docutils==0.20.1 +eth-account==0.12.1 eth-bloom==3.0.0 eth-hash==0.7.0 eth-keyfile==0.8.0 eth-keys==0.5.0 eth-rlp==2.1.0 +eth-stdlib==0.2.7 +eth-typing==4.1.0 +eth-utils==4.1.0 +eth_abi==5.1.0 execnet==2.1.1 executing==2.0.1 fastjsonschema==2.19.1 @@ -104,6 +101,7 @@ prompt-toolkit==3.0.43 ptyprocess==0.7.0 pure-eval==0.2.2 py-ecc==7.0.0 +py-evm==0.10.0b6 pycodestyle==2.11.1 pycparser==2.22 pycryptodome==3.20.0 @@ -120,6 +118,7 @@ regex==2023.12.25 requests==2.31.0 rfc3339-validator==0.1.4 rfc3986-validator==0.1.1 +rich==13.7.1 rlp==4.0.0 rpds-py==0.18.0 Send2Trash==1.8.3 @@ -147,6 +146,7 @@ typing_extensions==4.11.0 uri-template==1.3.0 urllib3==2.2.1 virtualenv==20.25.1 +vyper==0.3.10 wcwidth==0.2.13 webcolors==1.13 webencodings==0.5.1