Initial commit: readme, license, poetry boilerplate, and a minimal example

of using simpy.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Emma Hopwood 2023-09-24 10:29:58 +01:00
commit 1ace46834f
7 changed files with 200 additions and 0 deletions

104
.gitignore vendored Normal file
View File

@ -0,0 +1,104 @@
*.swp
*.save
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/

19
LICENSE Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2023 The Zcash developers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

28
README.md Normal file
View File

@ -0,0 +1,28 @@
# Trailing Finality Layer Simulator
This is an experimental simulator for research into a potential
[Trailing Finality Layer](https://electriccoin.co/blog/the-trailing-finality-layer-a-stepping-stone-to-proof-of-stake-in-zcash/)
for Zcash.
Note the caveats: *experimental*, *simulator*, *research*, *potential*.
## Instructions
1. Install `poetry`:
sudo apt install python3-poetry
or see [poetry's installation docs](https://python-poetry.org/docs/)
if not on Debian/Ubuntu.
2. Install dependencies:
poetry install
3. Run the script:
poetry run simtfl
## License
This software is provided under the terms of the [MIT License](LICENSE).

18
poetry.lock generated Normal file
View File

@ -0,0 +1,18 @@
# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand.
[[package]]
name = "simpy"
version = "4.0.2"
description = "Event discrete, process based simulation for Python."
category = "main"
optional = false
python-versions = ">=3.6"
files = [
{file = "simpy-4.0.2-py2.py3-none-any.whl", hash = "sha256:603cdf4299e396c9f16b10806e749decb0d08a7e72e0c26f9eb9762b9bde29cc"},
{file = "simpy-4.0.2.tar.gz", hash = "sha256:6d8adc0229df6b02fb7e26dcd1338703b4f4f63f167a5ac2a7213cb80aba4484"},
]
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "473dcab15fa28886d82a57bafb3bcaea24776cd32294b5793cf9fc314656509f"

18
pyproject.toml Normal file
View File

@ -0,0 +1,18 @@
[tool.poetry]
name = "simtfl"
version = "0.1.0"
description = "Experimental simulator for Trailing Finality Layer"
authors = ["Daira Emma Hopwood <daira@jacaranda.org>", "Nate Wilcox <nathan+dev@electriccoin.co>"]
license = "MIT"
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
simpy = "^4"
[tool.poetry.scripts]
simtfl = "simtfl.runner:run"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0
simtfl/__init__.py Normal file
View File

13
simtfl/runner.py Normal file
View File

@ -0,0 +1,13 @@
import simpy
def clock(env, name, tick):
while True:
print(name, env.now)
yield env.timeout(tick)
def run():
print("This is just the minimal example for simpy.")
env = simpy.Environment()
env.process(clock(env, 'fast', 0.5))
env.process(clock(env, 'slow', 1))
env.run(until=2)