|
| 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. |
0 commit comments