Vulkan is a high-performance cryptocurrency implementation written in C that focuses on efficiency and modularity. The codebase features a complete RPC server interface, peer-to-peer networking, and blockchain management systems.
- Full Bitcoin-compatible JSON-RPC API implementation
- Supports all standard mining and blockchain query operations
- Thread-safe request handling with connection pooling
- CORS support for web integrations
- Comprehensive error handling and logging
Key RPC methods:
Vulkan supports both RocksDB and LevelDB for efficient data storage. Developers can choose RocksDB for high write throughput or LevelDB for simplicity and smaller memory footprints, depending on the use case. It provides customizable compression options, including:
- Snappy Compression
- LZ4 Compression
- Zstandard Compression
Developers can toggle compression using set_want_blockchain_compression()
and set specific compression algorithms with set_blockchain_compression_type()
.
During blockchain initialization, Vulkan validates and inserts the genesis block. This ensures a solid foundation for the blockchain, whether operating in mainnet or testnet mode.
Vulkan employs rigorous validation checks, including:
- Timestamp Validation: Ensures blocks are not timestamped too far in the future.
- Merkle Root Verification: Confirms transaction integrity within a block.
- Proof-of-Work Checks: Verifies that blocks meet the required difficulty.
Vulkan offers comprehensive tools for managing blockchain data:
- Database Repair: Functions like
repair_blockchain()
fix corrupted databases. - Backup and Restore: Backup functionality is implemented with
backup_blockchain()
andrestore_blockchain()
. - Rollback Mechanism: The blockchain can rollback to a specific height using
rollback_blockchain()
.
Vulkan dynamically adjusts mining difficulty based on block production times, ensuring stable block intervals even during fluctuations in network activity. For example, in periods of increased miner participation, difficulty rises to maintain balance. This ensures consistent block generation, using functions like get_next_work_required()
to calculate difficulty.
Transactions are organized into Merkle trees, with the root hash stored in each block. This provides a fast and efficient way to verify transaction integrity.
Vulkan’s P2P communication protocol manages the interactions between nodes on the network, ensuring a secure and efficient decentralized system. For instance, during blockchain synchronization, nodes utilize grouped synchronization to transfer multiple blocks simultaneously, reducing latency.
- Packets: Serialized structures containing:
id
: Packet type identifier.size
: Payload size.data
: Payload data.
- Serialization and deserialization are handled by
serialize_packet()
anddeserialize_packet()
functions.
- Peer Management:
PKT_TYPE_CONNECT_ESTABLISH_REQ
andPKT_TYPE_CONNECT_ESTABLISH_RESP
for establishing peer connections.PKT_TYPE_GET_PEERLIST_REQ
andPKT_TYPE_GET_PEERLIST_RESP
for managing the network’s peer list.
- Blockchain Synchronization:
PKT_TYPE_GET_BLOCK_HEIGHT_REQ
andPKT_TYPE_GET_BLOCK_HEIGHT_RESP
for blockchain height synchronization.PKT_TYPE_GET_BLOCK_BY_HASH_REQ
,PKT_TYPE_GET_BLOCK_BY_HEIGHT_REQ
, and their respective responses for fetching specific blocks.
- Transaction Propagation:
PKT_TYPE_INCOMING_MEMPOOL_TRANSACTION
for broadcasting new transactions to the mempool.
- Processing Messages:
handle_packet()
andhandle_packet_sendto()
manage routing and processing of incoming/outgoing packets.- Ensures anonymous connections and version compatibility with enforced checks.
- Serialization:
serialize_message()
packages messages for transmission.deserialize_message()
decodes received packets into actionable messages.
- Sync Requests: Initiates synchronization based on block height and ensures backup integrity with
init_sync_request()
. - Backup and Rollback: Uses
backup_blockchain_and_rollback()
to ensure blockchain consistency during synchronization. - Grouped Synchronization: Efficiently synchronizes multiple blocks at once to minimize delays.
Robust error-checking mechanisms handle issues such as corrupted packets, invalid transactions, or failed connections.
Vulkan includes submodules in the external
directory for required dependencies. Precompiled dependencies can be used for faster setup.
Detailed setup instructions will be provided soon.
Install the necessary packages using Homebrew:
brew install leveldb
brew install rocksdb
brew install libsodium
brew install json-c
Install the required dependencies using apt-get
:
sudo apt-get install librocksdb-dev
sudo apt-get install libsodium-dev
sudo apt-get install libjson-c-dev
Once dependencies are installed, compile the Vulkan daemon using CMake.
git clone https://github.com/vulkancurrency/vulkan.git
cd vulkan
git submodule update --init --recursive
mkdir build
cd build
cmake -G "Visual Studio 14 Win64" ..
git clone https://github.com/vulkancurrency/vulkan.git
cd vulkan
git submodule update --init --recursive
mkdir build
cd build
cmake .. && make -j 4
For ARM-based MacBooks, run:
arch -x86_64 /usr/local/bin/cmake ..
make -j <NUMBER_OF_THREADS>
Vulkan encourages forking to foster innovation and improve the blockchain.
- Update
parameters.h
: Modify definitions for testnet or mainnet configurations. - Recompile: Build the Vulkan daemon and generate a genesis block.
- Adjust Configurations: Update the genesis block details in the configuration files.
Block:
Version: 1
Previous Hash: 0000000000000000000000000000000000000000000000000000000000000000
Hash: 00000000ca2796715a7515bf51295cce6715d6a6dfafe67effab4e2a7798423f
...
Bitcoin is the foundational cryptocurrency that inspired Vulkan’s development. By understanding Bitcoin’s architecture and limitations, Vulkan was designed to enhance scalability, provide customizable features, and reduce resource consumption. Below is an in-depth explanation of how Bitcoin works.
Bitcoin operates on a decentralized, peer-to-peer network. Transactions are verified by miners and recorded on a public ledger called the blockchain. Bitcoin’s architecture eliminates the need for central authorities, making it trustless and secure.
- Blockchain: A distributed ledger that records all transactions.
- Nodes: Computers that participate in the network, maintaining and validating the blockchain.
- Miners: Nodes that solve cryptographic puzzles to add new blocks to the blockchain.
- Wallets: Digital tools that store users’ private and public keys, enabling them to send and receive Bitcoin.
- Transactions: Transfers of Bitcoin between users, verified and added to blocks by miners.
- Consensus Mechanism: The network’s consensus ensures that all nodes agree on the current state of the blockchain.
graph LR
A[User A Sends Bitcoin] -->|Broadcast Transaction| B[Network Nodes]
B -->|Validation| C[Transaction Pool]
C -->|Selected by Miners| D[Block Created]
D -->|Added to Blockchain| E[User B Receives Bitcoin]
Mining involves solving a computationally intensive problem called a proof of work. This ensures the network’s security and prevents malicious actors from altering the blockchain.
graph TD
A[Pending Transactions] --> B[Form a Block]
B --> C[Solve Puzzle with Hashing]
C -->|Puzzle Solved| D[Broadcast New Block]
D --> E[Validated by Network]
E --> F[Block Added to Blockchain]
graph LR
A[Decentralized Network] --> B[No Single Point of Failure]
A --> C[Resistant to Censorship]
D[Proof of Work] --> E[High Computational Barrier]
F[Blockchain Structure] --> G[Immutable Ledger]
Bitcoin has a wide range of applications, including:
- Digital Payments: Facilitating peer-to-peer transactions globally.
- Store of Value: Often referred to as "digital gold," Bitcoin is used as a hedge against inflation.
- Smart Contracts: Limited capabilities through Layer 2 solutions like Lightning Network.
- Decentralized Finance (DeFi): Enabling financial services without intermediaries.
Vulkan is released under the MIT License. Refer to the LICENSE file for detailed information.