Giter Club home page Giter Club logo

sqlidity's Introduction

Sqlidity

Simplified sqlite3 implementation on-chain written in Solidity.

Contract: @high_byte | Contributing

Usage

Run tests:

forge test -vv

Generate new test queries:

python ./script/parser.py

Example: echo "SELECT * FROM votes WHERE votes > 100" | python ./script/parser.py | pbcopy

(pbcopy will copy solidity code to the clipboard, paste it in ./test/Sqlite.t.sol)

Debugging

Make sure DEBUG = true in ./src/Types.sol

Why?

Sqlidity is part of an experiment to merge the world of classic databases and blockchains.

Blockchain is a database but it is hardly used as a classic database. With strange account-storage trees, 32-byte slots and niche languages to access and manipulate them, the friction of using such database as an actual database is very high.

Ideally one key benefit this technological improvement will allow is to easily on-board the 20 million web2 developers such that the transition is seamless, while inheriting web3 properties such as security, accessibility, liveness, integrated finance, etc.

How?

There are several approaches to bring classic databases on chain.

Sqlidity aims to implement SQLite databases on EVM chains, starting as a Solidity smart contract.

SQLite is a perfect candidate for initial proof of concept:

  • synchronous, no multiprocess / multithreaded access (just like EVM blockchains)
  • built-in rollbacks (simply revert the transaction)
  • aimed towards small-mid sized databases
  • simple structure

See opcodes.md to see implementation progress.

Different Approaches

Several frameworks have taken different approaches to bringing the worlds of databases and blockchains together.

  • TheGraph is a blockchain indexing network anyone can participate in. Indexing and querying happens off-chain.
  • Dune Analytics is the largest off-chain index service and can be queries with PostgreSQL.
  • Tableland implement a query oracle that can be instantiated on-chain. Query strings are built on chain and emitted as an event to be executed by the oracle off-chain.
  • BigchainDB is an experiment to bring blockchain to databases, rather than bring databases to blockchain. It seems inactive, but is one interesting approaching the Sqlidity experiment is interested in.
  • MUD engine by @latticexyz is building data querying on-chain.

Roadmap

The future of on-chain SQL (and databases in general) is unknown, but I believe it has a bright future.

  1. Table database smart contract (SQLite) <== we are here - PoC ready
  2. Production deployed to mainnet, optimistic and ZK rollups
  3. Implement as a whole new rollup
  4. Add ZK proofs to new rollup
  5. Implement on cosmos ecosystem as L0 or whatever

Contributing

Feel free to experiment with this repository. Contributions of any form are welcome, including:

  • Code contributions to this repo
  • Additional research & development with (or without) relation to the roadmap
  • Grants to fund future research.

Contract: @high_byte

sqlidity's People

Contributors

hananbeer avatar santongding avatar

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.