Outerspace Blockchain
This application is instable and under development.
Please, use it with caution and at your own risk.
A Ruby implementation of web blockchain framework.
Developed using TDD (Test Driven Development).
Github Actions CI/CD pipeline.
Firestore is used to store the blockchain.
Simplecov is used to test code coverage.
Rails Engine is used to create the blockchain.
Tailwind CSS is used to style the blockchain web interface.
Rspec is used to test the blockchain.
Build Version: 0.2.0
Todo
- [ ] Firebase integration (this will be use instead of Redis management)
- [ ] Add and correct tests
- [ ] Add and correct documentation
- [ ] Add user verification methods
- [ ] Better mobile layout
- [ ] Create the price visualization and the price history api
- [ ] Add more blockchain features
- [ ] Add more blockchain tests
- [ ] Add more blockchain documentation
- [ ] Add nft's classification class
- [ ] Add nft's modularization class
- [ ] Add nft's generator class
- [ ] Benchmark blockchain and mining
- [ ] Create a blockchain explorer
- [ ] Create a default blockchain wallet android app generator with flutter
- [ ] Create generators that will work with rails and flutter at the same time
- [ ] Create the user marketplace
- [ ] Integrate Blockchain Api in other projects
Kubernets integration will be worked on in the future.
System dependencies
1. Docker
2. Postgresql
3. Ruby
4. Redis
- Ruby 3.0.3
- Compose Version 3.3
Docker Image: ruby:3.0.3
Install it from RubyGems (Ruby 3.0.3)
gem install osbc
Run to generate new project
osbc PATH
Compile OSBC from source
========================
Compile the gem from source with the following commands:
git clone
cd outerspace-blockchain
bundle install
Run OSBC
========================
Run the gem with the following command:
bin/osbc
Installation
========================
Build and install the gem with the following commands:
gem build osbc.gemspec
gem install osbc-GENERATED_VERSION.gem
Use the gem with the following command:
osbc PATH_TO_GENERATE_BLOCKCHAIN
RVM Commands to install Ruby 3.0.3 and Compile the Gem
rvm install 3.0.3
rvm use 3.0.3
rvm gemset create outerspace
rvm gemset use outerspace
gem install bundler
bundle install
Environment Variables
The application has a .env file in root folder with the following environment variables:
FIRST_CHAIN_NAME=YOUR_CHAIN_NAME FIRST_CHAIN_MAINTAINER=YOUR_NAME CONTRACTS_LIMIT=100 SIGNATURES_LIMIT=5
Configuration
Rake tasks
This application has rake tasks to help you with the development process with docker. The tasks are:
Docker actions
rake compose:install
- build docker compose and migrate the databaserake compose:build
- build docker compose servicesrake compose:up
- start the docker compose servicesrake compose:down
- stop the docker compose servicesrake compose:db_detach
- detach the database from the docker compose servicesrake compose:redis_detach
- detach the redis from the docker compose servicesrake compose:back_detach
- detach the backend(redis, sidekiq, db) from the docker compose servicesrake compose:restart
- restart the docker compose servicesrake compose:clean_all
- clean all docker compose services #### Database actionsrake compose_db:migrate
- migrate the databaserake compose_db:reset
- reset the databaserake compose_db:drop
- drop the databaserake compose_db:create
- create the databaserake compose_db:seed
- seed the databaserake compose_db:rollback
- rollback the databaserake compose_db:setup
- setup the databaserake compose_db:complete_setup
- complete setup the databaserake compose_db:reset_setup
- drop and setup the databaserake compose_db:reset
- reset the database
Tests actions
rake compose_test:all
- run all testsrake compose_test:clean_all
- run all tests after cleaning docker compose servicesrake compose_test:controllers
- run controllers testsrake compose_test:models
- run models testsrake compose_test:requests
- run requests testsrake compose_test:helpers
- run helpers testsrake compose_test:mailers
- run mailers testsrake compose_test:routing
- run routing testsrake compose_test:views
- run views tests
LOGS actions
rake compose_logs:web
- show web logsrake compose_logs:db
- show db logsrake compose_logs:redis
- show redis logsrake compose_logs:sidekiq
- show sidekiq logsrake compose_logs:all
- show all logsrake compose_logs:tail_web
- tail web logsrake compose_logs:tail_db
- tail db logsrake compose_logs:tail_redis
- tail redis logsrake compose_logs:tail_sidekiq
- tail sidekiq logsrake compose_logs:tail_all
- tail all logsrake compose_logs:follow_web
- follow web logsrake compose_logs:follow_db
- follow db logsrake compose_logs:follow_redis
- follow redis logsrake compose_logs:follow_sidekiq
- follow sidekiq logsrake compose_logs:follow_all
- follow all logs
Start the blockchain
$ rake compose:up
Access the blockchain web interface
Mining Concept
- Every user will have a randomized acceptable word list
- This word list will have three classes of words
- Common words
- Symbol Sequence
- Number Sequence
When a user want to mine a block, the user will open a ticket in the server and after the ticket is open, the user will start to mine the block
The mine will depend of the contract signatures that will be formed by the server using the word list of the user
Steps to mine a block:
- The user will open a TICKET in the server
- The server will send a message to the user to start mining if the POOL is open
- The users will load the RANDOM WORD LIST provided by the server API
- The user have to use 1 common word, 1 symbol sequence and 1 number sequence, randomize the characters
- Transform the shuffled chartacters in a SHA256 hash
- The user will send the hash to the server
- The server will validate the hash and will send a message to the user if the hash is valid
- If the hash is valid, check if the same transactions have the same block state confirmation, if yes, the user will have to mine again in a new state of the transactions timeline
- If this transactions was not confirmed at this point at block history the server will add the user signature to the transactions contracts included in the users ticket timeline range
- The block only can be hashed when the minimum number of contracts valids with minimum number of signatures is reached
- The server will use the signature timeline to determine what transactions will be added to the block
- The server will calculate the master hash after confirm all valid contracts signatures
- Assignmaster hash to the block, create new block and add to the blockchain with previous block hash
- The server will start a open/closed pool cycle ( pool is open only if has a minimun of transactions to mine )
- The server will send a message to the user to start mining when the POOL is open and user has a ticket
The timestamps of the signatures will be usefull to version the block, checking it as a timeline
The miners will be rewarded with the block reward distributed by the number of signatures
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/JesusGautamah/outerspace-blockchain
License
The gem is available as open source under the terms of the MIT License.
- LICENSE - MIT License