masa-finance / masa-oracle

Masa Oracle: Decentralized Data Protocol 🌐
https://developers.masa.ai/docs/category/oracle-node
MIT License
16 stars 15 forks source link

Spike: On chain ledger #345 #350

Closed jdutchak closed 3 months ago

jdutchak commented 3 months ago

Implemented PoC blockchain from edgevpn project - Parking ledger for new ticket and PR added to node testing storing and announcing

jdutchak commented 3 months ago

Project Summary: Masa Blockchain Implementation

Overview

This (PoC) for a blockchain implementation named "Masa Blockchain." It aims to demonstrate the core functionalities of a blockchain, including block creation, consensus mechanisms, and data persistence. The project will eventually be integrated into the Masa Protocol codebase.

Key Features

  1. Consensus Mechanisms: Proof of Work (PoW): Implemented in src/blockchain/pow.go. Proof of Stake (PoS): Implemented in src/blockchain/pos.go. Based on n number of MASA tokens staked?

  2. Block Management: Block creation and validation. Serialization and deserialization of blocks. Adding blocks to the blockchain.

  3. Blockchain Operations: Iterating over the blockchain. Fetching the last block. Updating and maintaining the last hash.

  4. CLI Interface: Adding blocks. Listing all blocks or the last block. Selecting consensus mechanisms via command-line arguments.

  5. Persistence: Data storage using BadgerDB for TXNs. Initialization and management of the blockchain database.

Benefits Modularity: The project is organized into distinct modules for consensus mechanisms, block management, and persistence, making it easy to extend and maintain.

Flexibility: Support both PoW and PoS, allowing for experimentation with different consensus algorithms. CLI Interface: Provides a user-friendly command-line interface for interacting with the blockchain. Persistence: Ensures data durability and integrity using BadgerDB.

Conclusion A Masa Blockchain PoC provides a foundational implementation of blockchain technology, demonstrating key features and benefits. It serves as a robust starting point for further development and integration into larger systems.

@mudler @H34D @nolanjacobson @restevens402 https://github.com/masa-finance/masa-chain

jdutchak commented 3 months ago
INFO[0000] = Last Block =                               
INFO[0000] Fetching last stored hash...                 
INFO[0000] Getting last hash from the chain...          
INFO[0000] Fetching last stored hash...                 
INFO[0000] Getting last hash from the chain...          
INFO[0000] Getting block 0000051d38746ed1569a20fae1888838edd092aa7231a6605cbeef6fb3318d6e
         Data:  test 4
         Hash:  0000051d38746ed1569a20fae1888838edd092aa7231a6605cbeef6fb3318d6e
         Link:  000002b08a7a750783a92c52888169bc1991de8bd4123cfabfdd199c9bb51dd3
         Nonce: 3795394
INFO[0000] Adding block to the blockchain...            
INFO[0000] Fetching last stored hash...                 
INFO[0000] Getting last hash from the chain...          
INFO[0000] Running Proof of Work...                      block_content="test 5"
196e22289bce7e20384f505e39fd039920062f58fe7d8ca
INFO[0000] = Last Block =                               
INFO[0000] Fetching last stored hash...                 
INFO[0000] Getting last hash from the chain...          
INFO[0000] Fetching last stored hash...                 
INFO[0000] Getting last hash from the chain...          
INFO[0000] Getting block 00000240414bd46f36abf884528f3762dca5e69d23b6f51858ddb5beb78d3950... 
         Data:  test 8
         Hash:  00000240414bd46f36abf884528f3762dca5e69d23b6f51858ddb5beb78d3950
         Link:  00000254137975ce0cfebbc26bf8ae7e58175aae22ec815cde96dd289ae5c116
         Nonce: 1719777956
INFO[0000] Adding block to the blockchain...            
INFO[0000] Fetching last stored hash...                 
INFO[0000] Getting last hash from the chain...          
INFO[0000] Running Proof of Stake...                     block_content="test 2"
000000e2b6ddabb704bfe422785644168ff20f3496d6bc305dbc80909a9da816