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

Fixed requirements #192

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ dist/
.hypothesis/
.idea/
.pytest_cache

# Python virtual environments
venv/
.venv/
*.env

# Visual Code
.vscode/

.coverage
.coverage.*
116 changes: 96 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,25 @@ 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

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]

# Documentation

Content
- [Usage and quickstart guide](#usage-quick-start)
- [Details on setup of development environment](#initial-preparation)
- [Notes and performance hints](#notes-and-performance-hints)

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
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 as dependency
```
pip install titanoboa
```
Expand All @@ -21,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
Expand Down Expand Up @@ -215,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.

2 changes: 2 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ sphinx-rtd-theme
# jupyter
jupyter_server
nest_asyncio


16 changes: 7 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",

Expand All @@ -34,7 +32,7 @@ dependencies = [
"requests",

# required for networked accounts
"eth-account",
"eth-account>=0.12.1,<0.13.0",
]

[project.optional-dependencies]
Expand Down
154 changes: 154 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
ipython==8.23.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be deleted, the dependencies are in pyproject.toml

Copy link
Author

@Hg347 Hg347 Apr 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too, I'm new to python. My understanding so far, the .toml file contains the runtime or "production" configuration, while requirements.txt specifies the development setup.

Here is my reasoning

That is, .toml should contain neither pytest nor hypothesis, but requirements.txt should contain both.

Second, as developer I would like to have two things:

  1. exact dependencies that are proven to work and where all tests pass successfully (freezed requirements.txt)
  2. loose dependencies to receive latest updates of libraries and develop with most recent versions (dev-requirements.txt)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly if there is an update to a library that causes an issue, we should want to find out in the development cycle. freezing the requirements like so silences the issue until users find it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I see your point. Still, I couldn't work or contribute for weeks because the tests failed.
From my perspective, the idea of the master branch in Git is that there is a common, working base. This why I suggested a dev_requirements and a freezed_requirements. This solution would take both views into account.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how were the tests failing? and how did you end up fixing them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easy to reproduce: few weeks ago I fetched the main branch: commit 98c7b58

Then I did:

source .venv/bin/activate
pip install git+https://github.com/vyperlang/titanoboa
pip install titanoboa==0.1.9

The last command is necessary since you published a newer version of titanoboa meanwhile.
Finally I executed

make test

Result: 23 failed, 168 passed, 2 warnings, 71 errors in 19.26s

If I use the requirements.txt as specified in this PR all tests pass.

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
## 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-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
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
py-evm==0.10.0b6
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
rich==13.7.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
vyper==0.3.10
wcwidth==0.2.13
webcolors==1.13
webencodings==0.5.1
websocket-client==1.7.0
zipp==3.18.1
Loading