GithubHelp home page GithubHelp logo

daniele1209 / singularity-network Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 226 KB

Minimal implementation of a PoS based Blockchain, written in Python

License: MIT License

Python 98.70% Dockerfile 1.30%
blockchain blockchain-technology cryptography p2p-network p2p-node python python3 rsa

singularity-network's Introduction

Singularity Network is my minimal implementation of a PoS based Blockchain, written in Python. This is my Bachelor Thesis project and it is available as an open source project on Github. It uses P2P communication in order to handle the decentralized aspect of the chain. The Lottery PoS system is done by using hash chaining and it has an API system for user communication - written using Flask

Formatting

Use default black installation.

Installing

Tools you need: Poetry, Python 3.9 After installing poetry run poetry install, and to install git hooks run command pre-commit install

Running

Generating Keys

Generate RSA Key pairs for genesis and set the path for them using the config keys genesis_public_key_path and genesis_private_key_path. A node needs only the genesis public key. You use the private key to make a genesis transaction.

Wallet keys file name format is {wallet_name}_PrivateKey.pem and {wallet_name}_PublicKey.pem and reads from the folder specified by wallet_keys_folder. By default, it generates new keys and writes them to those files. Wallets belonging to nodes have the wallet_name as # and it always generates new keys.

Running a node

Running a node from command line

Project Root Folder is BlockChain First you have to start the origin node, and then other nodes. Otherwise, child nodes will not connect to the origin.

Run with command: python3 -m BlockChain.Application <ipaddr> <port> <apiport> <origin_ipaddr> <origin_port> [publickeypath] [privatekeypath]

Running a node with docker

First you have to build the image yourself by using docker build --tag <name>:<tag> ..

By default, origin_ip is specified using an environment variable in the Dockerfile, and by default it connects to the localhost of the local machine. This is specified using the name host.docker.internal. On linux when you use docker run you have to add the following option --add-host host.docker.internal:host-gateway.
The node ports and api ports by default are 10001 and 5000 respectively. These options can be overridden in settings.toml or by specifying environment variables at build time or run time. For more information check out https://www.dynaconf.com/envvars/.

You can run a node using docker run -p host-port:5000 -p host-port:10001 -d <name>:<tag>.
You first have to start the origin node and then other subsequent nodes specifying other host ports that are not already bound.

Running multiple nodes

Running multiple nodes with docker-compose

Build docker image with docker build --tag singularitycoin:latest . And then you can start the nodes with docker compose up -d. Only the origin node will be exposed on ports 10001 and 5000. The rest of the nodes are assigned random ports at the hosts, see the assigned ports using docker ps.

singularity-network's People

Contributors

daniele1209 avatar sweethuman avatar

Watchers

 avatar  avatar

singularity-network's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.