SQLess

module
v0.0.0-...-020e20f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2022 License: Apache-2.0

README

CQL is a Byzantine Fault Tolerant distributed relational database

Features:

  • ServerLess: Free, High Availabile, Auto Sync Database Service for Serverless App
  • SQL: Most SQL-92 support.
  • Decentralize: Running on Open Internet without Central Coordination.
  • Privacy: Access with Granted Permission and Encryption Pass.
  • Immutable: Query History in CQL is Immutable and Trackable.
  • Permission: Column Level ACL and SQL Pattern Whitelist.

What is CQL?

  • Open source alternative of Amazon QLDB
  • Low cost DBaaS
  • Just like filecoin + IPFS is the decentralized file system, CQL is the decentralized database

CQL is a derived work of CovenantSQL.

Quick Start

CQL client supports:

  • macOS X 10.9+
  • Linux 2.6.23+

How CQL works

3 Layers Arch
  • Layer 1: Global Consensus Layer (the main chain, the middle ring in the architecture diagram):
    • There will only be one main chain throughout the network.
    • Mainly responsible for database Miner and the user’s contract matching, transaction settlement, anti-cheating, shard chain lock hash and other global consensus matters.
  • Layer 2: SQL Consensus Layer (shard chain, rings on both sides):
    • Each database will have its own separate shard chain.
    • Mainly responsible for: the signature, delivery and consistency of the various Transactions of the database. The data history of the permanent traceability is mainly implemented here, and the hash lock is performed in the main chain.
  • Layer 3: Datastore Layer (database engine with SQL-92 support):
    • Each Database has its own independent distributed engine.
    • Mainly responsible for: database storage & encryption, query processing & signature, efficient indexing.
Consensus Algorithm

CQL supports 2 kinds of consensus algorithm:

  1. DPoS (Delegated Proof-of-Stake) is applied in Eventually consistency mode database and also Layer 1 (Global Consensus Layer) in BlockProducer. CQL miners pack all SQL queries and its signatures by the client into blocks thus form a blockchain.
  2. BFT-Raft (Byzantine Fault-Toleranted Raft)is applied in Strong consistency mode database. The CQL miner leader does a Two-Phase Commit with Kayak to support Transaction.

CQL database consistency mode and node count can be selected in database creation with command cql create '{"UseEventualConsistency": true, "Node": 3}'

Comparison

Ethereum Hyperledger Fabric Amazon QLDB CQL
Dev language Solidity, ewasm Java, Go, Node.js Java Java, Go, Node.js, Python
Dev Pattern Smart Contract Chaincode SQL SQL
Open Source Y Y N Y
Nodes for HA 3 15 ? 3
Column Level ACL N Y ? Y
Data Format File Key-value Document Key-value, Structured
Storage Encryption N API Y Y
Data Desensitization N N N Y
Multi-tenant DIY DIY N Y
Consistency Delay 2~6 min < 1 s ? < 10 ms
Secure for Open Internet Y N Only in AWS Y
Consensus PoW + PoS(Casper) CFT ? DPoS (Eventually Consistency)
BFT-Raft (Strong Consistency)

Use cases

Traditional App
Privacy data

If you are a developer of password management tools just like 1Password or LastPass. You can use CQL as the database to take benefits:

  1. Serverless: no need to deploy a server to store your user's password for sync which is the hot potato.
  2. Security: CQL handles all the encryption work. Decentralized data storage gives more confidence to your users.
  3. Regulation: CQL naturally comply with GDPR.
IoT storage

CQL miners are deployed globally, IoT node can write to nearest CQL miner directly.

  1. Cheaper: Without passing all the traffic through a gateway, you can save a large bandwidth fee. And, CQL is a shared economic database which makes storage cheaper.
  2. Faster: CQL consensus protocol is designed for Internet where network latency is unavoidable.
Open data service

For example, you are the most detailed Bitcoin OHLC data maintainer. You can directly expose an online SQL interface to your customers to meet a wide range of query needs.

  1. CQL can limit specific SQL query statements to meet the needs while also balancing data security;
  2. CQL can record SQL query records on the blockchain, which is very convenient for customers to check their bills for long-tail customers and billing.
  3. For customers with high performance requirements, Slave nodes can be deployed at the customer to meet the needs of customers with low latency queries while enabling almost real-time data updates.
Secure storage

Thanks to the CQL data history is immutable, CQL can be used as a storage for sensitive operational logs to prevent hacking and erasure access logs.

ĐApp

Storing data on Bitcoin or Ethereum is quite expensiveProgramming is very complicated due to the lack of support for structured data storage. CQL gives you a low-cost structured SQL database and also provides more room for ĐApp to exchange data with real-world.

Directories

Path Synopsis
Package blockproducer implements blockproducer node block genreation and database management logics.
Package blockproducer implements blockproducer node block genreation and database management logics.
interfaces
Package interfaces defines commonly used interfaces for block producers.
Package interfaces defines commonly used interfaces for block producers.
Package client is a golang sql driver implementation to interact with SQLess.
Package client is a golang sql driver implementation to interact with SQLess.
toolkit
Package toolkit implements handy functions for `AES-128-CBC PKCS#7` encryption and decryption for `end to end encryption`.
Package toolkit implements handy functions for `AES-128-CBC PKCS#7` encryption and decryption for `end to end encryption`.
cmd
cql
testnet
Package testnet contains the paraemters of the SQLess TestNet.
Package testnet contains the paraemters of the SQLess TestNet.
Package consistent provides a consistent hashing function.
Package consistent provides a consistent hashing function.
Package crypto implements Asymmetric, Symmetric Encryption and Hash function.
Package crypto implements Asymmetric, Symmetric Encryption and Hash function.
asymmetric
Package asymmetric implements Asymmetric Encryption methods ported from btcd, Ethereum-go etc.
Package asymmetric implements Asymmetric Encryption methods ported from btcd, Ethereum-go etc.
etls
Package etls implements "Enhanced Transport Layer Security", but more efficient than TLS used in https.
Package etls implements "Enhanced Transport Layer Security", but more efficient than TLS used in https.
hash
Package hash provides abstracted hash functionality.
Package hash provides abstracted hash functionality.
kms
Package kms implements Key Management System According the best practices from "sections 3.5 and 3.6 of the PCI DSS standard" and "ANSI X9.17 - Financial Institution Key Management".
Package kms implements Key Management System According the best practices from "sections 3.5 and 3.6 of the PCI DSS standard" and "ANSI X9.17 - Financial Institution Key Management".
secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
symmetric
Package symmetric implements Symmetric Encryption methods.
Package symmetric implements Symmetric Encryption methods.
Package kayak implements a configurable consistency consensus middleware.
Package kayak implements a configurable consistency consensus middleware.
types
Package types defines required types of kayak.
Package types defines required types of kayak.
wal
Package wal defines toy implementations of kayak wal.
Package wal defines toy implementations of kayak wal.
Package naconn provides node-oriented connection based on ETLS crypto connection.
Package naconn provides node-oriented connection based on ETLS crypto connection.
pow
cpuminer
Package cpuminer implements CPU based PoW functions.
Package cpuminer implements CPU based PoW functions.
Package proto contains DHT RPC protocol struct.
Package proto contains DHT RPC protocol struct.
rpc
Package rpc provides a RPC implementation over the node-oriented connections.
Package rpc provides a RPC implementation over the node-oriented connections.
mux
Package mux provides a RPC implementation with connection multiplexing.
Package mux provides a RPC implementation with connection multiplexing.
Package sqlchain provides a blockchain implementation for database state tracking.
Package sqlchain provides a blockchain implementation for database state tracking.
Package storage provides underlying storage implementation of CQL.
Package storage provides underlying storage implementation of CQL.
Package twopc provides a implementation of Two-Phase Commit.
Package twopc provides a implementation of Two-Phase Commit.
Package types defines commonly used types for sql-chain.
Package types defines commonly used types for sql-chain.
Package utils provides useful standalone function for test and network, etc.
Package utils provides useful standalone function for test and network, etc.
log
Package worker defines miner node logic for database storage and sql-chain accounting integration.
Package worker defines miner node logic for database storage and sql-chain accounting integration.
Package xenomint provides an eventual consistency implementation of the blockchain database.
Package xenomint provides an eventual consistency implementation of the blockchain database.
interfaces
Package interfaces defines common used interfaces of the xenomint package.
Package interfaces defines common used interfaces of the xenomint package.
sqlite
Package sqlite introduces a sqlite3 implementation of the xenomint/interfaces.Storage interface.
Package sqlite introduces a sqlite3 implementation of the xenomint/interfaces.Storage interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL