System and method for supporting SQL-based rich queries in hyperledger fabric blockchains
Described herein are systems and methods for supporting SQL-based rich queries in a blockchain fabric. In accordance with an embodiment, the systems and methods provided herein provide the ability to execute SQL queries to allow for the creation of complex smart contracts much easier and more maintainable manner. Also, performance is improved both by pushing the data filtering back to the storage engine (rather than happening at the smart contract level), and by being able to rely on relational engines which support concurrent read and write data access. As well, the state of the world database can also provide for concurrent read/write access.
1 . A system for supporting SQL-based rich queries in a blockchain fabric, the system comprising:
one or more computers, each comprising a microprocessor;
a blockchain fabric running on the one or more computers; and
a transaction manager, the transaction manager controlling access to a database associated with the blockchain fabric;
wherein a smart contract comprising a query is run against the blockchain fabric;
wherein the query, when executed, accesses the database via a relational interface, the relational interface comprising an abstraction layer that provides use of a relational engine, the relational engine supporting concurrent read write access to the database;
wherein the query, when executed, compares a plurality of values utilizing the relational engine to execute reads and writes of the query concurrently, wherein the plurality of compared values are written in at least two blocks of the blockchain fabric.
2 . The system of claim 1 ,
wherein a result of the query is obtained.
3 . The system of claim 2 ,
wherein the result of the query is validated prior to being committed to a block of the blockchain fabric.
4 . The system of claim 1 ,
wherein the database comprises a state of the world database for the blockchain fabric.
5 . The system of claim 4 ,
wherein the state of the world database comprises a versioned database and the relational interface.
6 . The system of claim 5 ,
wherein the state of the world database provides concurrent read write access.
7 . The system of claim 1 ,
wherein the query further comprises a data filtering step; and
wherein the data filtering step is performed at a storage engine.
8 . A method for supporting SQL-based rich queries in a blockchain fabric, the method comprising:
providing one or more computers, each comprising a microprocessor;
running a blockchain fabric on the one or more computers; and
providing a transaction manager, the transaction manager controlling access to a database associated with the blockchain fabric;
running a smart contract comprising a query against the blockchain fabric; and
accessing, via the query when executed, the database via a relational interface, the relational interface comprising an abstraction layer that provides use of a relational engine, the relational engine supporting concurrent read write access to the database;
wherein the query, when executed, compares a plurality of values utilizing the relational engine to execute reads and writes of the query concurrently, wherein the plurality of compared values are written in at least two blocks of the blockchain fabric.
9 . The method of claim 8 ,
wherein a result of the query is obtained.
10 . The method of claim 9 ,
wherein the result of the query is validated prior to being committed to a block of the blockchain fabric.
11 . The method of claim 8 ,
wherein the database comprises a state of the world database for the blockchain fabric.
12 . The method of claim 11 ,
wherein the state of the world database comprises a versioned database and the relational interface.
13 . The method of claim 12 ,
wherein the state of the world database provides concurrent read write access.
14 . The method of claim 8 ,
wherein the query further comprises a data filtering step; and
wherein the data filtering step is performed at a storage engine.
15 . A non-transitory computer readable storage medium having instructions thereon for supporting SQL-based rich queries in a blockchain fabric, which when read and executed cause a computer to perform steps comprising:
running a blockchain fabric on the computer; and
providing a transaction manager, the transaction manager controlling access to a database associated with the blockchain fabric;
running a smart contract comprising a query against the blockchain fabric; and
accessing, via the query when executed, the database via a relational interface, the relational interface comprising an abstraction layer that provides use of a relational engine, the relational engine supporting concurrent read write access to the database;
wherein the query, when executed, compares a plurality of values utilizing the relational engine to execute reads and writes of the query concurrently, wherein the plurality of compared values are written in at least two blocks of the blockchain fabric.
16 . The non-transitory computer readable storage medium of claim 15 ,
wherein a result of the query is obtained.
17 . The non-transitory computer readable storage medium of claim 16 ,
wherein the result of the query is validated prior to being committed to a block of the blockchain fabric.
18 . The non-transitory computer readable storage medium of claim 15 ,
wherein the database comprises a state of the world database for the blockchain fabric.
19 . The non-transitory computer readable storage medium of claim 18 ,
wherein the state of the world database comprises a versioned database and the relational interface.
20 . The non-transitory computer readable storage medium of claim 19 ,
wherein the state of the world database provides concurrent read write access.