Skip to content

Commit 29ae56a

Browse files
committed
initial commit
0 parents  commit 29ae56a

23 files changed

+1198
-0
lines changed

.gitignore

+131
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
131+
receipt.json

.vscode/launch.json

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Python: Debug Server",
6+
"type": "debugpy",
7+
"request": "launch",
8+
"program": "${workspaceFolder}/rpc/server.py",
9+
"console": "integratedTerminal",
10+
"env": {
11+
"PYTHONPATH": "${workspaceRoot}",
12+
"DOCKER_HOST": "unix:///var/run/docker.sock"
13+
},
14+
"args": []
15+
},
16+
{
17+
"name": "Python: Debug Launch Prototype",
18+
"type": "debugpy",
19+
"request": "launch",
20+
"program": "${workspaceFolder}/scripts/debug_prototype.py",
21+
"console": "integratedTerminal",
22+
"env": {
23+
"PYTHONPATH": "${workspaceRoot}",
24+
"DOCKER_HOST": "unix:///var/run/docker.sock"
25+
},
26+
"args": []
27+
},
28+
{
29+
"name": "Python: Run wizzard_of_coin",
30+
"type": "debugpy",
31+
"request": "launch",
32+
"program": "${workspaceFolder}/genvm/contracts/wizzard_of_coin.py",
33+
"console": "integratedTerminal",
34+
"env": {
35+
"PYTHONPATH": "${workspaceRoot}",
36+
"FLASK_APP": "json_rpc_server.py",
37+
"FLASK_ENV": "development",
38+
"DOCKER_HOST": "unix:///var/run/docker.sock"
39+
},
40+
"args": []
41+
}
42+
],
43+
"compounds": [
44+
{
45+
"name": "Debug All",
46+
"configurations": ["Python: Debug Server", "Python: Debug Launch Prototype"]
47+
}
48+
]
49+
}
50+

README.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# GenLayer Prototype
2+
## Introduction
3+
Welcome to the GenLayer prototype, the first step towards a decentralized platform that combines the ease of using Python to write contracts, the access to the internet, the intelligence of the LLMs, and the security and efficiency of a blockchain.
4+
5+
## Prototype Components
6+
The GenLayer prototype consists of the following main components:
7+
8+
* **State Storage (PostgreSQL):** We use a SQL database to maintain the blockchain's updated and persistent state.
9+
* **State Manager (JSON-RPC Server):** A backend that processes requests, either to read the state of the blockchain or to execute transactions involving intelligent contracts.
10+
* **Developer Interface:** CLI and some execution scripts to facilitate developers' interaction with the node, allowing the deployment and execution of intelligent contracts.
11+
* **The Consensus Algorithm:** A python routine that launches execution processes into the GenVM, following the approach defined in the whitepaper.
12+
* **Gen Virtual Machine (GenVM):** A Dockerized environment prepared to run intelligent contracts safely.
13+
14+
## Installation
15+
16+
* Install `postgresql` on your computer and start the server.
17+
* Create a user in the `postgresql` server named `postgresql` with password `postgresql`.
18+
* Create a new venv called `genlayer` with `python 3.11`. For instance `conda create --name genlayer python=3.11`.
19+
* Activate venv and install requirements.
20+
* Execute `python database/init_db.py` to create the tables of the db.
21+
* Build GenVM docker image. First `cd` into `genvm` folder. Then `docker build -t genvm .`.
22+
23+
## Execution
24+
25+
* Run `rpc/server.py` to launch the server on port `4000`.
26+
* Run some CLI commands to create an initial state with validators, and deployed contracts:
27+
```
28+
python genlayer.py register-validators --count 10 --min-stake 1 --max-stake 10
29+
30+
New validator registered with stake 1.51
31+
New validator registered with stake 6.96
32+
New validator registered with stake 7.40
33+
New validator registered with stake 3.95
34+
New validator registered with stake 7.30
35+
New validator registered with stake 2.26
36+
New validator registered with stake 4.34
37+
New validator registered with stake 8.26
38+
New validator registered with stake 9.87
39+
New validator registered with stake 8.13
40+
Registered 10 validators with stakes ranging from 1.0 to 10.0.
41+
```
42+
```
43+
python genlayer.py create-eoa --balance 10
44+
45+
{'id': 1, 'jsonrpc': '2.0', 'result': {'balance': 10.0, 'id': '95594942-17e5-4f91-8862-c3a4eae5b58c', 'status': 'EOA created'}}
46+
```
47+
```
48+
python genlayer.py deploy --from-account 95594942-17e5-4f91-8862-c3a4eae5b58c /home/user/Documents/genlayer/genlayer-node-prototype/contracts/wizzard_of_coin.py
49+
50+
{{'30a079b5-4615-4b4f-a7c8-807f1f9d1577', 'status': 'deployed'}}
51+
```
52+
53+
That will create an initial state that enables the user to start sending transactions to the network. You can check all the changes on DB with a viewer such as `dbeaver`.
54+
55+
* Execute a transaction. You can use the `scripts/debug_contract.py` there you would see the execution syntax, and you can start creating and debugging intelligent contracts.
56+
57+
From now on you can create new intelligent contracts and test them by executing transactions with this prototype.

__init__.py

Whitespace-only changes.

cli/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)