Distributed ledger systems (DLSs), which can also be referred to as consensus networks, and/or blockchain networks, enable participating entities to securely, and immutably store data. DLSs are commonly referred to as blockchain networks without referencing any particular use case (e.g., crypto-currencies). Example types of blockchain networks can include public blockchain networks, private blockchain networks, and consortium blockchain networks. A public blockchain network is open for all entities to use the DLS, and participate in the consensus process. A private blockchain network is provided for a particular entity, which centrally controls read and write permissions. A consortium blockchain network is provided for a select group of entities, which control the consensus process, and includes an access control layer.
Information recorded on a blockchain can be viewed using third-party blockchain browsers. The third-party blockchain browsers can return static information on a blockchain such as the balance of individual accounts, transaction history, and smart contract terms, among other information. In some cases, however, a blockchain also contains dynamic data such as variables responsible for the execution of smart contracts. Traditional blockchain browsers do not have the capability to show such dynamic information.
Implementations of the present specification include computer-implemented methods for displaying dynamic information of a blockchain. More particularly, implementations of the present specification are directed to converting dynamic information in a blockchain into one or more binary logs, and updating a database using the binary logs.
In some implementations, actions include polling the blockchain at specified time intervals, receiving block information from one or more updated blocks, the block information including static information and dynamic information, the dynamic information including one or more variables to be used in a smart contract, converting the dynamic information into one or more binary logs, and updating the local database using the one or more binary logs. Other implementations include corresponding systems, apparatus, and computer programs, configured to perform the actions of the methods, encoded on computer storage devices.
These and other implementations may each optionally include one or more of the following features: the one or more binary logs are stored in a binary log file separate from the local database; the local database is a relational database; the one or more binary logs are written in accordance with structured query languages; the polling of the blockchain is triggered by an execution of the smart contract; actions further include updating the local database using the static information; and actions further include, in response to a user query to the local database, presenting the dynamic information to a user device.
The present specification also provides one or more non-transitory computer-readable storage media coupled to one or more processors and having instructions stored thereon which, when executed by the one or more processors, cause the one or more processors to perform operations in accordance with implementations of the methods provided herein.
The present specification further provides a system for implementing the methods provided herein. The system includes one or more processors, and a computer-readable storage medium coupled to the one or more processors having instructions stored thereon which, when executed by the one or more processors, cause the one or more processors to perform operations in accordance with implementations of the methods provided herein.
It is appreciated that methods in accordance with the present specification may include any combination of the aspects and features described herein. That is, methods in accordance with the present specification are not limited to the combinations of aspects and features specifically described herein, but also include any combination of the aspects and features provided.
The details of one or more implementations of the present specification are set forth in the accompanying drawings and the description below. Other features and advantages of the present specification will be apparent from the description and drawings, and from the claims.
Like reference symbols in the various drawings indicate like elements.
Implementations of the present specification include computer-implemented methods for replicating blockchain data using binary logs. More particularly, implementations of the present specification are directed to converting smart contract information into binary logs and updating a relational database using the binary logs. In some implementations, actions include polling the blockchain at specified time intervals, receiving block information from one or more updated blocks, the block information including static information and dynamic information, the dynamic information including one or more variables to be used in a smart contract, converting the dynamic information into one or more binary logs, and updating the local database using the one or more binary logs.
To provide further context for implementations of the present specification, and as introduced above, distributed ledger systems (DLSs), which can also be referred to as consensus networks (e.g., made up of peer-to-peer nodes), and blockchain networks, enable participating entities to securely, and immutably conduct transactions, and store data. Although the term blockchain is generally associated with a crypto-currency network, blockchain is used herein to generally refer to a DLS without reference to any particular use case. As introduced above, a blockchain network can be provided as a public blockchain network, a private blockchain network, or a consortium blockchain network.
In a public blockchain network, the consensus process is controlled by nodes of the consensus network. For example, hundreds, thousands, even millions of entities can cooperate a public blockchain network, each of which operates at least one node in the public blockchain network. Accordingly, the public blockchain network can be considered a public network with respect to the participating entities. In some examples, a majority of entities (nodes) must sign every block in order for the block to be valid, and added to the blockchain (distributed ledger) of the blockchain network. An example public blockchain network includes particular crypto-currency networks, which are provided as peer-to-peer payment networks, which leverage distributed ledgers, referred to as blockchains. As noted above, the term blockchain, however, is used to generally refer to distributed ledgers without reference to any particular crypto-currency network.
In general, a public blockchain network supports public transactions. A public transaction is shared with all of the nodes within the public blockchain network, and are stored in a global blockchain. A global blockchain is a blockchain that is replicated across all nodes. That is, all nodes are in perfect state consensus with respect to the global blockchain. To achieve consensus (e.g., agreement to the addition of a block to a blockchain), a consensus protocol is implemented within the public blockchain network. An example consensus protocol includes, without limitation, proof-of-work (POW) implemented in particular crypto-currency networks.
In general, a private blockchain network private blockchain network is provided for a particular entity, which centrally controls read and write permissions. The entity controls, which nodes are able to participate in the blockchain network. Consequently, private blockchain networks are generally referred to as permissioned networks that place restrictions on who is allowed to participate in the network, and on their level of participation (e.g., only in certain transactions). Various types of access control mechanisms can be used (e.g., existing participants vote on adding new entities, a regulatory authority can control admission).
In general, a consortium blockchain network is private among the participating entities. In a consortium blockchain network, the consensus process is controlled by an authorized set of nodes, one or more nodes being operated by a respective entity (e.g., a financial institution, insurance company). For example, a consortium of ten (10) entities (e.g., financial institutions, insurance companies) can operate a consortium blockchain network, each of which operates at least one node in the consortium blockchain network. Accordingly, the consortium blockchain network can be considered a private network with respect to the participating entities. In some examples, each entity (node) must sign every block in order for the block to be valid, and added to the blockchain. In some examples, at least a sub-set of entities (nodes) (e.g., at least 7 entities) must sign every block in order for the block to be valid, and added to the blockchain.
Implementations of the present specification are described in further detail herein with reference to a public blockchain network, which is public among the participating entities. It is contemplated, however, that implementations of the present specification can be realized in any appropriate type of blockchain network.
Implementations of the present specification are described in further detail herein in view of the above context. More particularly, and as introduced above, implementations of the present specification are directed to displaying dynamic information such as smart contact variables of a blockchain. In accordance with implementations of the present specification, instructions to update dynamic information on a blockchain, such as during the execution of a smart contract, are converted into binary logs compatible with structured query languages. The binary logs are used to update a database storing a state of the blockchain. A user can query the database (e.g., using SQL queries) to view data associated with the blockchain.
In the depicted example, the computing systems 106, 108 can each include any appropriate computing system that enables participation as a node in the public blockchain network 102. Example computing devices include, without limitation, a server, a desktop computer, a laptop computer, a tablet computing device, and a smartphone. In some examples, the computing systems 106, 108 hosts one or more computer-implemented services for interacting with the public blockchain network 102. For example, the computing system 106 can host computer-implemented services of a first entity (e.g., user A), such as transaction management system that the first entity uses to manage its transactions with one or more other entities (e.g., other users). The computing system 108 can host computer-implemented services of a second entity (e.g., user B), such as transaction management system that the second entity uses to manage its transactions with one or more other entities (e.g., other users). In the example of
In the depicted example, the hosted services layer 204 includes interfaces 210 for each transaction management system 210. In some examples, a respective transaction management system 208 communicates with a respective interface 210 over a network (e.g., the network 110 of
As described herein, the blockchain network 212 is provided as a peer-to-peer network including a plurality of nodes 214 that immutably record information in a blockchain 216. Although a single blockchain 216 is schematically depicted, multiple copies of the blockchain 216 are provided, and are maintained across the blockchain network 212. For example, each node 214 stores a copy of the blockchain. In some implementations, the blockchain 216 stores information associated with transactions that are performed between two or more entities participating in the public blockchain network.
The system 300 is implemented to provide dynamic information maintained in a blockchain network (e.g., the blockchain network 212). As described in
In addition to the static information, the blockchain 216 can include dynamic information that changes based on operations within the blockchain network 212. For example, dynamic information can include, without limitation, variables used in the execution of smart contracts on the blockchain 216. To record the dynamic information to the blockchain history database 308, the system 300 converts instructions that operate on the dynamic information into a structured query language, and stores the converted structured query language as binary logs in a binary log file 306. For example, the blockchain 216 can include a smart contract with the following statements:
The system 300 can convert these example statements into the following query languages to be added to the binary log file 306: “update contract set ‘status’=‘new_value’ where ‘contract_addr’=‘abcdefeas123343’.”
When the dynamic information is updated (e.g., by the execution of a smart contract), the binary log file 306 replicates the updated binary logs to the blockchain history database 308. As a result, the blockchain history database 308 includes the updated record of the dynamic information in the blockchain 216. An example of dynamic data stored in the blockchain history database 308 is shown in Table 1 below.
To view the updated dynamic information, a user can submit a query (e.g., SQL query) to the blockchain history database 308 using the application 310, or the web browser 312.
The system polls information from a blockchain to receive updated information. For example, the system can poll the blockchain at specified time intervals, or the blockchain can notify the system when new transactions have been written to the blockchain. In some cases, the system can add a hook to functions that write to the blockchain (402).
After polling the blockchain, the system receives dynamic information such as new values produced by smart contracts executing on the blockchain (404).
The system converts the dynamic information into SQL compatible binary logs for storing in a log file (406). For example, a smart contract can be written in a specific programming language to set a particular variable. The system can convert the set function into a SQL query as described in
The system updates a relational database using the binary logs (408). For example, the relational database can be set as a slave in a master/slave scheme to receive binary logs from the binary log file. In some cases, the polling of binary logs to the relational database can be done using a dedicated program running in the system.
The features described may be implemented in digital electronic circuitry, or in computer hardware, firmware, software, or in combinations of them. The apparatus may be implemented in a computer program product tangibly embodied in an information carrier (e.g., in a machine-readable storage device) for execution by a programmable processor; and method steps may be performed by a programmable processor executing a program of instructions to perform functions of the described implementations by operating on input data and generating output. The described features may be implemented advantageously in one or more computer programs that are executable on a programmable system including at least one programmable processor coupled to receive data and instructions from, and to transmit data and instructions to, a data storage system, at least one input device, and at least one output device. A computer program is a set of instructions that may be used, directly or indirectly, in a computer to perform a certain activity or bring about a certain result. A computer program may be written in any form of programming language, including compiled or interpreted languages, and it may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or another unit suitable for use in a computing environment.
Suitable processors for the execution of a program of instructions include, by way of example, both general and special purpose microprocessors, and the sole processor or one of the multiple processors of any kind of computer. Generally, a processor will receive instructions and data from a read-only memory or a random access memory or both. Elements of a computer may include a processor for executing instructions and one or more memories for storing instructions and data. Generally, a computer may also include, or be operatively coupled to communicate with, one or more mass storage devices for storing data files; such devices include magnetic disks, such as internal hard disks and removable disks; magneto-optical disks; and optical disks. Storage devices suitable for tangibly embodying computer program instructions and data include all forms of non-volatile memory, including by ways of example semiconductor memory devices, such as EPROM, EEPROM, and flash memory devices; magnetic disks such as internal hard disks and removable disks; magneto-optical disks; and CD-ROM and DVD-ROM disks. The processor and the memory may be supplemented by, or incorporated in, application-specific integrated circuits (ASICs).
To provide for interaction with a user, the features may be implemented on a computer having a display device such as a cathode ray tube (CRT) or liquid crystal display (LCD) monitor for displaying information to the user and a keyboard and a pointing device such as a mouse or a trackball by which the user may provide input to the computer.
The features may be implemented in a computer system that includes a back-end component, such as a data server, or that includes a middleware component, such as an application server or an Internet server, or that includes a front-end component, such as a client computer having a graphical user interface or an Internet browser, or any combination of them. The components of the system may be connected by any form or medium of digital data communication such as a communication network. Examples of communication networks include, e.g., a local area network (LAN), a wide area network (WAN), and the computers and networks forming the Internet.
The computer system may include clients and servers. A client and server are generally remote from each other and typically interact through a network, such as the described one. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other.
In addition, the logic flows depicted in the figures do not require the particular order shown, or sequential order, to achieve desirable results. In addition, other steps may be provided, or steps may be eliminated, from the described flows, and other components may be added to, or removed from, the described systems. Accordingly, other implementations are within the scope of the following claims.
A number of implementations of the present specification have been described. Nevertheless, it will be understood that various modifications may be made without departing from the spirit and scope of the present specification. Accordingly, other implementations are within the scope of the following claims.
This application is a continuation of PCT Application No. PCT/CN2018/118369, filed on Nov. 30, 2018, which is hereby incorporated by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2018/118369 | Nov 2018 | US |
Child | 16390873 | US |