CN116049280A - Method and apparatus for mapping block data into structured data - Google Patents

Method and apparatus for mapping block data into structured data Download PDF

Info

Publication number
CN116049280A
CN116049280A CN202211733501.1A CN202211733501A CN116049280A CN 116049280 A CN116049280 A CN 116049280A CN 202211733501 A CN202211733501 A CN 202211733501A CN 116049280 A CN116049280 A CN 116049280A
Authority
CN
China
Prior art keywords
data
contract
target
rule
column
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211733501.1A
Other languages
Chinese (zh)
Inventor
陈骁杰
范学冬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
Ant Blockchain Technology Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ant Blockchain Technology Shanghai Co Ltd filed Critical Ant Blockchain Technology Shanghai Co Ltd
Priority to CN202211733501.1A priority Critical patent/CN116049280A/en
Publication of CN116049280A publication Critical patent/CN116049280A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/258Data format conversion from or to a database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/221Column-oriented storage; Management thereof

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Embodiments of the present disclosure provide a method and apparatus for mapping block data into structured data, the method performed by block link points, comprising: acquiring a target intelligent contract called by a target transaction to be executed, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the contract methods and are set for the contract methods; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt; executing the target transaction to obtain a contract receipt; and according to the first analysis rule, mapping the block data related to the contract methods into first structural data, and according to the second analysis rule, mapping the block data related to the contract return execution into second structural data. According to different intelligent contracts, the block data can be mapped into the structured data efficiently and conveniently.

Description

Method and apparatus for mapping block data into structured data
Technical Field
The embodiment of the specification belongs to the technical field of block chains, and particularly relates to a method and a device for mapping block data into structured data.
Background
Blockchain (Blockchain) is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanisms, encryption algorithms, and the like. In the block chain system, the data blocks are combined into a chain data structure in a sequential connection mode according to the time sequence, and the distributed account book which is not tamperable and counterfeit and is ensured in a cryptographic mode is formed. Because the blockchain has the characteristics of decentralization, non-tamperability of information, autonomy and the like, the blockchain is also receiving more and more attention and application.
The block data in the conventional block link points adopts an unstructured stored data structure, and the data structure is not suitable for complex data query, data analysis, data calculation and other works. The block data needs to be mapped into structured data for the service to extract the data fields of interest to itself.
When block data is mapped into structured data in the prior art, the block data is independently developed aiming at different intelligent contracts, and a great deal of engineering repetition and time waste exist.
Disclosure of Invention
The invention aims to provide a method and a device for mapping block data into structured data, which can realize the mapping of block data into structured data in an efficient and convenient way aiming at different intelligent contracts.
A first aspect of the present specification provides a method of mapping block data into structured data, the method performed by a block link point, comprising:
acquiring a target intelligent contract called by a target transaction to be executed, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the contract methods and are set for the contract methods; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt;
executing the target transaction to obtain a contract receipt;
and according to the first analysis rule, mapping the block data related to the contract methods into first structural data, and according to the second analysis rule, mapping the block data related to the contract return execution into second structural data.
A second aspect of the present specification provides an apparatus for mapping block data to structured data, the apparatus being provided at a blockchain node, comprising:
an acquisition unit configured to acquire a target smart contract called by a target exchange to be executed, the target smart contract including a plurality of contract methods and having parsing rules attached thereto and set for the same; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt;
The execution unit is used for executing the target transaction to obtain a contract receipt;
and the mapping unit is used for mapping the block data related to the contract methods into first structural data according to the first analysis rule acquired by the acquisition unit, and mapping the block data related to the contract return execution acquired by the execution unit into second structural data according to the second analysis rule acquired by the acquisition unit.
A third aspect of the present description provides a computer-readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of the first aspect.
A fourth aspect of the present specification provides a computing device comprising a memory having executable code stored therein and a processor which, when executing the executable code, implements the method of the first aspect.
Through the scheme provided by the embodiment of the specification, the blockchain node firstly acquires a target intelligent contract called by a target transaction to be executed, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the contract methods and are set for the contract methods; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt; then executing the target transaction to obtain a contract receipt; and finally, according to the first analysis rule, mapping the block data related to the contract methods into first structural data, and according to the second analysis rule, mapping the block data related to the contract return execution into second structural data. As can be seen from the foregoing, in the embodiment of the present disclosure, the smart contract has parsing rules attached thereto and set for the smart contract, so that the blockchain node automatically maps the blockdata to the structured data according to the parsing rules after obtaining the contract receipt. In addition, the parsing rules have a common framework, including a first parsing rule for the several contract methods and a second parsing rule for the contract receipt, which masks the differences between intelligent contracts, and which still retains sufficient flexibility and complete scalability for different application scenarios. Therefore, the block data can be mapped into the structured data in an efficient and convenient manner aiming at different intelligent contracts.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings that are needed in the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present disclosure, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 illustrates a block chain architecture diagram in one embodiment;
FIG. 2 is a schematic diagram of a consensus process in a PBFT consensus algorithm;
FIG. 3 illustrates a flow diagram of a method of mapping block data into structured data, according to one embodiment;
fig. 4 shows a schematic block diagram of an apparatus for mapping tile data into structured data, according to one embodiment.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
FIG. 1 illustrates a block chain architecture diagram in one embodiment. In the blockchain architecture diagram shown in fig. 1, the blockchain 100 includes N nodes, and nodes 1-8 are schematically shown in fig. 1. The connections between nodes schematically represent P2P (Peer to Peer) connections, which may be TCP connections or the like, for example, for transmitting data between nodes. The nodes may store a full amount of ledgers, i.e., the state of all blocks and all accounts. Wherein each node in the blockchain may generate the same state in the blockchain by performing the same transaction, each node in the blockchain may store the same state database.
Transactions in the blockchain domain may refer to task units that execute in the blockchain and are recorded in the blockchain. The transaction typically includes a send field (From), a receive field (To), and a Data field (Data). Where the transaction is a transfer transaction, the From field indicates an account address From which the transaction was initiated (i.e., a transfer task To another account was initiated), the To field indicates an account address From which the transaction was received (i.e., a transfer was received), and the Data field includes the transfer amount.
The functionality of the smart contract may be provided in the blockchain. Intelligent contracts on blockchains are contracts on blockchain systems that can be executed by transaction triggers. The smart contracts may be defined in the form of codes. Invoking the smart contract in the blockchain initiates a transaction directed to the smart contract address such that each node in the blockchain runs the smart contract code in a distributed manner.
In the scenario of deploying contracts, for example, bob sends a transaction containing information to create an intelligent contract (i.e., deploying a contract) into a blockchain as shown in fig. 1, the data field of the transaction includes the code (e.g., bytecode or machine code) of the contract to be created, and the to field of the transaction is empty to indicate that the transaction is for deploying the contract. After agreement is reached between the nodes through a consensus mechanism, a contract address of '0 x6f8ae93 …' of the contract is determined, each node adds a contract account corresponding to the contract address of the intelligent contract in a state database, allocates a state storage corresponding to the contract account, stores a contract code, and stores a hash value of the contract code in the state storage of the contract, so that the contract creation is successful.
In the scenario of invoking a contract, for example, bob sends a transaction for invoking a smart contract into the blockchain as shown in fig. 1, the from field of the transaction is the address of the account of the transaction initiator (i.e., bob), the to field is the aforementioned "0x6f8ae93 …", i.e., the address of the invoked smart contract, and the data field of the transaction includes the method and parameters for invoking the smart contract. After the transaction is consensus in the blockchain, each node in the blockchain may execute the transaction separately, thereby executing the contract separately, updating the status database based on execution of the contract.
Blockchain technology differs from one of the decentralized features of conventional technology in that accounting is performed on individual nodes, otherwise known as distributed accounting, rather than conventional centralized accounting. The blockchain system is to be a hard-to-break, public, untampered, decentralised, honest and trusted system for data records, and needs to be secure, clear and irreversible for distributed data records in as short a time as possible. In different types of blockchain networks, in order to keep account books consistent among the nodes of each record account book, a consensus algorithm is generally adopted to ensure that the above-mentioned consensus mechanism is adopted. For example, a block granularity consensus mechanism may be implemented between blockchain nodes, such as after a node (e.g., a unique node) generates a block, if the generated block is approved by other nodes, the other nodes record the same block. For another example, a transaction granularity consensus mechanism may be implemented between blockchain nodes, for example, after a node (e.g., a unique node) obtains a blockchain transaction, if the blockchain transaction is approved by other nodes, each node approving the blockchain transaction may respectively add the blockchain transaction to its own maintained latest block, and finally, each node may be ensured to generate the same latest block. The consensus mechanism is a mechanism that the blockchain node achieves the consensus of the whole network about the blockinformation (or blockdata), and can ensure that the latest block is accurately added to the blockchain. The consensus mechanisms of the current mainstream include: proof of Work (POW), proof of equity (POS), proof of commission (Delegated Proof of Stake, DPOS), practical bayer fault tolerance (Practical Byzantine Fault Tolerance, PBFT) algorithms, and the like. Among the various consensus algorithms, the success of consensus on a consensus proposal is determined, typically after a preset number of nodes agree on the data to be consensus (i.e., the consensus proposal). Specifically, in the PBFT algorithm, f malicious nodes can be tolerated for N.gtoreq.3f+1 consensus nodes, that is, when 2f+1 nodes in the N consensus nodes agree, success of the consensus can be determined.
Fig. 2 is a schematic diagram of a consensus process in a PBFT consensus algorithm. As shown in fig. 2, according to the PBFT consensus algorithm, the consensus process can be divided into four phases, request, prepare and Commit. Assuming that a blockchain includes four consensus nodes of node n 1-node n4, wherein node n1 is, for example, a master node, and node n 2-node n4 is, for example, a slave node, f=1 malicious nodes can be tolerated in node n 1-node n4 according to the PBFT algorithm. Specifically, during the request phase, a user of the blockchain may send a request, for example in the form of a blockchain transaction, to node n1 through his user device. In the preliminary stage, the node n1 may package a plurality of transactions into a consensus proposal after receiving the plurality of transactions from one or more user devices, and send the consensus proposal and a signature of the consensus proposal by the node n1 to other consensus nodes (i.e. nodes n 2-n 4) for generating blocks, where the consensus proposal may include information such as a transaction body of the plurality of transactions and a submitting sequence of the plurality of transactions. In the preparation phase, each slave node may sign the consensus proposal and send it to the other individual nodes. Assuming node n4 is a malicious node, nodes n1, n2, and n3, after each receiving the signatures of 2 f=2 other consensus nodes for the consensus proposal, may determine that the preparation phase is complete, and may enter the commit phase. For example, as shown in fig. 2, after receiving the signatures of node n2 and node n3, node n1 verifies that both the signatures of node n2 and node n3 are correct signatures of the consensus proposal, and then determines that the preparation phase is complete, and node n2 determines that the preparation phase is complete after receiving the signature of node n3 and the signature of preparation phase node n1 and verifying passed. In the submitting stage, each consensus node performs signature of the submitting stage on the consensus proposal and sends the signature to other consensus nodes, and each consensus node can determine that the submitting stage is completed and the consensus is successful after receiving the signatures of the submitting stages of 2 f=2 other consensus nodes. For example, the node n1 may determine that the commit phase is completed after receiving the signatures of the commit phases of the node n2 and the node n3 and verifying, so that the node n1 may execute the plurality of transactions according to the consensus proposal, generate and store a block (e.g., block B1) including the plurality of transactions, update the world state according to the execution results of the plurality of transactions, and return the execution results of the plurality of transactions to the user device. Similarly, after determining that the commit phase is completed, node n2 and node n3 execute the plurality of transactions and update the world state according to the execution results of the plurality of transactions, generating and storing a block. Through the above process, the storage consistency of the node n1, the node n2 and the node n3 is realized. That is, the nodes n 1-n 4 can still realize successful consensus of the consensus proposal in the presence of a malicious node, and complete execution of the block.
Specific steps of a method for mapping block data into structured data are further described below based on the block chain architecture diagram shown in fig. 1 and the consensus process diagram in the PBFT consensus algorithm shown in fig. 2.
FIG. 3 illustrates a flow chart of a method of mapping block data into structured data, according to one embodiment. The method may be performed by a blockchain node in a blockchain network, which node may be embodied as any device, platform or cluster of devices having computing, processing capabilities. As shown in fig. 3, the method of mapping block data into structured data may include the steps of: step 31, obtaining a target intelligent contract called by a target transaction to be executed, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the target intelligent contract and are set for the target intelligent contract; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt; step 32, executing the target transaction to obtain a contract receipt; step 33, mapping the block data related to the contract methods into first structured data according to the first parsing rule, and mapping the block data related to the contract return into second structured data according to the second parsing rule. The specific execution of the above steps is described below, respectively.
Firstly, in step 31, a target intelligent contract called by a target exchange to be executed is acquired, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the target intelligent contract and are set for the target intelligent contract; the parsing rules include a first parsing rule for the number of contract methods and a second parsing rule for contract receipts. It is to be appreciated that one smart contract may include only one contract method or may include a plurality of contract methods.
In the embodiment of the specification, the user can interact with the user in a Schema form, and the user can fill the structured parsed Schema in the additional field of the contract while deploying the contract, so that the blockchain node can automatically perform structured disassembly and table storage on the contract method and the contract receipt of the contract. The block data is commonly used as two types of data, namely a contract method and a contract receipt, and the scheme supports the analysis of the two types of data, wherein the analysis of the contract method only needs to configure a structured framework Schema when deploying contracts, and the analysis of the contract receipt needs to set an analysis rule field aiming at the current receipt in the receipt data besides the structured framework Schema.
In one example, the parsing rule further includes: metadata of at least one data table;
the first structured data and the second structured data are stored in the at least one data table.
Further, the metadata of any one data table includes: column information for each column contained in a table name of the data table, the column information including: column name, column type:
an index indicating whether an index is created for the column;
a primary key for indicating whether the column is set as a primary key;
and the self-increasing mode is used for indicating whether the column data is in the self-increasing mode or not.
For example, tables are a array structure for recording tables of data associated with contracts, which may be broken down into one or more tables. Each table needs to have a name to display the corresponding table name and a Schema, and complete configuration information of the table is recorded in the Schema. The Schema is a structure of a plurality of groups, each element is a string type, and includes a combination of the following fields, separated by separators. The Schema will contain the following information:
column name: the names of each column in the database are stored in the form of character strings.
Column type: the format of the column data store supports commonly used string, integer configuration, and provides a hash configuration type specific to the blockchain.
index: an option, indicating whether an index is created for the column.
primary: an option, indicating whether the column is set as a primary key.
auto_incr: indicating that the column data is in self-increasing mode.
The foregoing tables may be configured by a user for a particular smart contract, for example, two data tables are configured, the information of one data table being expressed as,
Figure BDA0004032326740000061
the information of the other data table is represented as,
Figure BDA0004032326740000062
Figure BDA0004032326740000063
it can be appreciated that the specific information of each field can be configured by a user, so that enough flexibility and complete expandability are reserved.
Further, the first parsing rule includes: a plurality of sub-rules respectively corresponding to the plurality of contract methods; any sub-rule includes a method name for the contract method and at least one segment of table operation rules, any segment of table operation rules including:
a table name field for indicating a target data table of the at least one data table;
an operation field indicating an operation type of a target operation performed with respect to the target data table;
a plurality of column fields for indicating a target data column for which the target operation is directed and a data source indicating a value taken from a contract parameter value or a value built in a block through a preset indicator.
Further, the alternative value of the operation field corresponds to insert, update or delete; when the target operation is update or deletion, the arbitrary table operation rule further includes a key field for indicating a query key of the target operation.
Further, the number of contract methods includes a first contract method, and the number of sub-rules includes a first sub-rule; the first sub-rule includes a method name of the first contract method, and a first table operation rule including a first data table in a table name field, a first operation in an operation field, a first data column in a column field, and a first data source indicated by a first indicator.
For example, methods define parsing rules for contract methods, each method having a name field identifying its contract method name and a table's configuration item. the tables define a table structure into which a contract method call is broken down, in the form of a tuple. the tables will contain the following fields:
name: the data table name indicates that the corresponding data is to be inserted into the corresponding table.
operation: the value is "insert", "update" or "delete", which means to insert, update or delete table data.
key: if a query key is required to be specified for update or delete operations, a plurality of key values are required to be specified for the combination of the primary key and the group structure.
column ns: the inserted or updated columns, being a string structure, each element being a string type, contain the following field doublets, separated by separators:
column name: the columns, string types, that require data insertion are defined.
And (3) taking the value: the source of the inserted data, the scheme provides three definitions of data sources: one source of data is by taking the contract parameter value, # such as #param, which means taking the value of param in the contract parameter, and when param is a resolvable structure, taking the value of #param.incer1.incer2; another source of data is by $taking the value built in the block, such as $block_number, $tx_index; yet another source of data is that [ ] represents an array type field, e.g., # param [ ] represents that param is an array.
The aforementioned methods may be configured by a user for a particular smart contract, e.g., a parsing rule configured with one contract method is expressed as,
Figure BDA0004032326740000071
/>
Figure BDA0004032326740000081
it will be appreciated that "CreateUser" corresponds to the method name of the first contract method described above, "tables" corresponds to the first table operation rule described above, "user_info" corresponds to the first data table described above, "insert" corresponds to the first operation described above, and "columns" corresponds to the column field described above. The user_id corresponds to the first data column and the #user_info.id corresponds to the first data source indicated by the first indicator; the name corresponds to a first data column, # user_info name corresponds to a first data source indicated by a first indicator; the policy corresponds to the first data column, and the #policy corresponds to the first data source indicated by the first indicator; bn corresponds to the first data column and $ block_number corresponds to the first data source indicated by the first indicator.
Further, the first sub-rule further includes a second table operation rule including a second data table in a table name field.
In the embodiment of the present specification, two tables may be involved in the parsing rule of one contract method.
The aforementioned methods may be configured by a user for a particular smart contract, e.g., a parsing rule configured with one contract method is expressed as,
Figure BDA0004032326740000082
/>
Figure BDA0004032326740000091
it will be appreciated that the contract method of the method name "Transfer" involves two tables, one of which is named "user_info" and the other of which is named "data_info".
Further, the second parsing rule includes: several pieces of table operation rules, any piece of table operation rule includes:
a table name field for indicating a target data table of the at least one data table;
an operation field indicating an operation type of a target operation performed with respect to the target data table;
and a plurality of column fields for indicating a target data column for which the target operation is directed and a data source, wherein the data source indicates a key value pair or a value built in a block, which is taken from a contract return through a preset indicator.
For example, the rules for parsing contract returns are defined in the receipts, each of which has a type field specifying the rule type for parsing it, and different types are matched into different tables. Each receipt also carries a table configuration item for disassembling the contents of a transaction receipt into multiple tables. the tables are array structures, comprising the following fields:
name: the data table name indicates that the corresponding data is to be inserted into the corresponding table.
operation: the value is "insert" or "update", and the table data is inserted or updated.
key: if an update operation is performed, a query key needs to be specified.
column ns: the inserted or updated columns, being a string structure, each element being a string type, contain the following field doublets, separated by separators:
column name: the columns, string types, that require data insertion are defined.
And (3) taking the value: there are two forms, 1> using key, when no symbol is specified, extracting key from receipt KV, mapping the corresponding value into column; 2> $block represents taking the values built in the block, such as $block_number, $tx_index.
The target transaction is then executed, step 32, resulting in a contract receipt. It will be appreciated that execution of the transaction corresponds to execution of the contract method.
In the embodiment of the specification, the target transaction can be executed by adopting a general processing procedure.
Finally, in step 33, the block data related to the contract methods are mapped into first structured data according to the first parsing rule, and the block data related to the contract returns are mapped into second structured data according to the second parsing rule. It will be appreciated that the structured data may be stored in a data table comprised by the parsing rules.
Based on the first parsing rule introduced in the foregoing example, in one example, the mapping the block data related to the several contract methods into the first structured data according to the first parsing rule includes:
and reading the data value of the first data source according to the first indicator, and performing the first operation on a first data column in the first data table based on the data value.
Based on the second parsing rule introduced in the foregoing example, in one example, the mapping the block data related to the contract return to second structured data according to the second parsing rule includes:
extracting block data related to the contract return from the data source according to the preset indicator;
and based on the block data, performing the target operation indicated by the operation field on the target data table indicated by the table name field, wherein the target data columns are indicated by the column fields.
Through the method provided by the embodiment of the specification, the blockchain node firstly acquires a target intelligent contract called by a target transaction to be executed, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the contract methods and are set for the contract methods; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt; then executing the target transaction to obtain a contract receipt; and finally, according to the first analysis rule, mapping the block data related to the contract methods into first structural data, and according to the second analysis rule, mapping the block data related to the contract return execution into second structural data. As can be seen from the foregoing, in the embodiment of the present disclosure, the smart contract has parsing rules attached thereto and set for the smart contract, so that the blockchain node automatically maps the blockdata to the structured data according to the parsing rules after obtaining the contract receipt. In addition, the parsing rules have a common framework, including a first parsing rule for the several contract methods and a second parsing rule for the contract receipt, which masks the differences between intelligent contracts, and which still retains sufficient flexibility and complete scalability for different application scenarios. Therefore, the block data can be mapped into the structured data in an efficient and convenient manner aiming at different intelligent contracts.
In the embodiment of the present specification, the parsing rule may be in the form of a frame, and the whole frame may be defined in the form of JSON, XML, YAML, etc., and in the example of JSON, the frame is divided into five parts protocal, enable, tables, methods, receipts.
The protocol defines the protocol rule and version number of the framework, which is used for protocol matching and backward compatibility, and this field is included in the environment used for production. The content of the method can be a description of a special character string related to the protocol version, and can also carry version related information. The enable is used for judging whether to enable the analysis rule, the configuration can be provided in the production environment to conveniently control the start and stop of the structured mapping, and a user can select to close the analysis if necessary. tables, methods, receipts are described above and will not be described here. The entire rule framework may contain the components as shown in table one.
Table one: structure table of rule frame
Figure BDA0004032326740000101
/>
Figure BDA0004032326740000111
Referring to the table one, a rule framework shown in the table one can be adopted for different intelligent contracts, and the values of various fields are flexibly configured on the basis, so that the user operation is simplified.
In general, because of the complex diversity of smart contracts, each individual blockchain application needs to develop a system that can export business data based on its own contracts, with significant engineering duplication and time waste. Labor-intensive repetition: independent services each deploy a set of data export systems belonging to the independent services in an application environment. Engineering waste, businesses develop their own data field parsing tools for their respective contract data formats. The timeliness is lagged, and the on-chain data export system asynchronously pulls the node data under the chain by monitoring the blocking event behavior on the chain, so that a delay exists between the data visibility and the real generation time on the chain. And (3) resource redundancy, wherein the service analyzes the data on the chain under the chain, stores the data in the database under the chain according to a certain rule, and repeats the content and the data on the chain. The degree of duplication of data is more severe when multiple federated participants all need to use this data in their own environment.
In the embodiment of the present disclosure, unlike the usual processing manner, in order to facilitate the service contract to be more efficiently and conveniently accessed into the structured system, a set of general framework rules for the contract method, parameters and output contents of the receipt are defined. The output data format of the service contract is defined by the service itself, and the different services are far from each other. The contract data analysis framework shields the difference among the businesses, and realizes the self-adaptive analysis of the business output fields by formulating a set of unified weak format Schema. For different application scenes, the contract business analysis framework still keeps enough flexibility and complete expandability.
In the embodiment of the specification, the block data automatic structured mapping is realized by introducing one configuration rule, and different configuration files are only required to be set for different services. Meanwhile, when the user needs to modify the mapping rule, the blockchain is only required to reload the configuration file. By defining an automatic mapping rule of a structured table, the structured mapping of block data is automatically completed by different service contracts.
According to an embodiment of another aspect, an apparatus is provided for mapping blockdata into structured data, deployed in any blockchain node in a blockchain network, which can be embodied as any device, platform or cluster of devices with computing, processing capabilities. Fig. 4 shows a schematic block diagram of an apparatus for mapping tile data into structured data, according to one embodiment. As shown in fig. 4, the apparatus 400 includes:
An acquisition unit 41 for acquiring a target smart contract called by a target exchange to be executed, the target smart contract including a plurality of contract methods and having parsing rules attached thereto and set for the same; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt;
an execution unit 42, configured to execute the target transaction to obtain a contract receipt;
the mapping unit 43 is configured to map the block data related to the plurality of contract methods into first structured data according to the first parsing rule acquired by the acquiring unit 41, and map the block data related to the contract return execution acquired by the executing unit 42 into second structured data according to the second parsing rule acquired by the acquiring unit 41.
Optionally, as an embodiment, the parsing rule further includes: metadata of at least one data table;
the first structured data and the second structured data are stored in the at least one data table.
Further, the metadata of any one data table includes: column information for each column contained in a table name of the data table, the column information including: column name, column type:
An index indicating whether an index is created for the column;
a primary key for indicating whether the column is set as a primary key;
and the self-increasing mode is used for indicating whether the column data is in the self-increasing mode or not.
Further, the first parsing rule includes: a plurality of sub-rules respectively corresponding to the plurality of contract methods; any sub-rule includes a method name for the contract method and at least one segment of table operation rules, any segment of table operation rules including:
a table name field for indicating a target data table of the at least one data table;
an operation field indicating an operation type of a target operation performed with respect to the target data table;
a plurality of column fields for indicating a target data column for which the target operation is directed and a data source indicating a value taken from a contract parameter value or a value built in a block through a preset indicator.
Further, the alternative value of the operation field corresponds to insert, update or delete; when the target operation is update or deletion, the arbitrary table operation rule further includes a key field for indicating a query key of the target operation.
Further, the number of contract methods includes a first contract method, and the number of sub-rules includes a first sub-rule; the first sub-rule includes a method name of the first contract method, and a first table operation rule including a first data table in a table name field, a first operation in an operation field, a first data column in a column field, and a first data source indicated by a first indicator.
Further, the mapping unit 43 is specifically configured to read the data value of the first data source according to the first indicator, and perform the first operation on the first data column in the first data table based on the data value.
Further, the first sub-rule further includes a second table operation rule including a second data table in a table name field.
Further, the second parsing rule includes: several pieces of table operation rules, any piece of table operation rule includes:
a table name field for indicating a target data table of the at least one data table;
an operation field indicating an operation type of a target operation performed with respect to the target data table;
and a plurality of column fields for indicating a target data column for which the target operation is directed and a data source, wherein the data source indicates a key value pair or a value built in a block, which is taken from a contract return through a preset indicator.
Further, the mapping unit 43 includes:
an extracting subunit, configured to extract, from the data source, block data related to the contract return according to the preset indicator;
and the operation subunit is used for carrying out target operation indicated by the operation field on the target data table indicated by the table name field, the target data columns indicated by the column fields and the block data extracted by the extraction subunit.
With the apparatus provided by the embodiment of the present specification, the obtaining unit 41 of the blockchain node first obtains a target smart contract called by a target transaction to be executed, the target smart contract including a plurality of contract methods and having parsing rules attached thereto and set for it; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt; then the execution unit 42 executes the target transaction to obtain a contract receipt; finally, the mapping unit 43 maps the block data related to the contract methods to first structured data according to the first parsing rule, and maps the block data related to the contract returns to second structured data according to the second parsing rule. As can be seen from the foregoing, in the embodiment of the present disclosure, the smart contract has parsing rules attached thereto and set for the smart contract, so that the blockchain node automatically maps the blockdata to the structured data according to the parsing rules after obtaining the contract receipt. In addition, the parsing rules have a common framework, including a first parsing rule for the several contract methods and a second parsing rule for the contract receipt, which masks the differences between intelligent contracts, and which still retains sufficient flexibility and complete scalability for different application scenarios. Therefore, the block data can be mapped into the structured data in an efficient and convenient manner aiming at different intelligent contracts.
The present description also provides a computer-readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method as shown in fig. 3.
Embodiments of the present disclosure also provide a computing device including a memory having executable code stored therein and a processor that, when executing the executable code, implements the method shown in fig. 3.
In the 90 s of the 20 th century, improvements to one technology could clearly be distinguished as improvements in hardware (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software (improvements to the process flow). However, with the development of technology, many improvements of the current method flows can be regarded as direct improvements of hardware circuit structures. Designers almost always obtain corresponding hardware circuit structures by programming improved method flows into hardware circuits. Therefore, an improvement of a method flow cannot be said to be realized by a hardware entity module. For example, a programmable logic device (Programmable Logic Device, PLD) (e.g., field programmable gate array (Field Programmable Gate Array, FPGA)) is an integrated circuit whose logic function is determined by the programming of the device by a user. A designer programs to "integrate" a digital system onto a PLD without requiring the chip manufacturer to design and fabricate application-specific integrated circuit chips. Moreover, nowadays, instead of manually manufacturing integrated circuit chips, such programming is mostly implemented by using "logic compiler" software, which is similar to the software compiler used in program development and writing, and the original code before the compiling is also written in a specific programming language, which is called hardware description language (Hardware Description Language, HDL), but not just one of the hdds, but a plurality of kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), lava, lola, myHDL, PALASM, RHDL (Ruby Hardware Description Language), etc., VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog are currently most commonly used. It will also be apparent to those skilled in the art that a hardware circuit implementing the logic method flow can be readily obtained by merely slightly programming the method flow into an integrated circuit using several of the hardware description languages described above.
The controller may be implemented in any suitable manner, for example, the controller may take the form of, for example, a microprocessor or processor and a computer readable medium storing computer readable program code (e.g., software or firmware) executable by the (micro) processor, logic gates, switches, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable logic controllers, and embedded microcontrollers, examples of which include, but are not limited to, the following microcontrollers: ARC 625D, atmel AT91SAM, microchip PIC18F26K20, and Silicone Labs C8051F320, the memory controller may also be implemented as part of the control logic of the memory. Those skilled in the art will also appreciate that, in addition to implementing the controller in a pure computer readable program code, it is well possible to implement the same functionality by logically programming the method steps such that the controller is in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, embedded microcontrollers, etc. Such a controller may thus be regarded as a kind of hardware component, and means for performing various functions included therein may also be regarded as structures within the hardware component. Or even means for achieving the various functions may be regarded as either software modules implementing the methods or structures within hardware components.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation device is a server system. Of course, the present application does not exclude that as future computer technology evolves, the computer implementing the functions of the above-described embodiments may be, for example, a personal computer, a laptop computer, a car-mounted human-computer interaction device, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Although one or more embodiments of the present description provide method operational steps as described in the embodiments or flowcharts, more or fewer operational steps may be included based on conventional or non-inventive means. The order of steps recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. When implemented in an actual device or end product, the instructions may be executed sequentially or in parallel (e.g., in a parallel processor or multi-threaded processing environment, or even in a distributed data processing environment) as illustrated by the embodiments or by the figures. The terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, it is not excluded that additional identical or equivalent elements may be present in a process, method, article, or apparatus that comprises a described element. For example, if first, second, etc. words are used to indicate a name, but not any particular order.
For convenience of description, the above devices are described as being functionally divided into various modules, respectively. Of course, when one or more of the present description is implemented, the functions of each module may be implemented in the same piece or pieces of software and/or hardware, or a module that implements the same function may be implemented by a plurality of sub-modules or a combination of sub-units, or the like. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, read only compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage, graphene storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
One skilled in the relevant art will recognize that one or more embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, one or more embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Moreover, one or more embodiments of the present description can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
One or more embodiments of the present specification may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. One or more embodiments of the present specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments. In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present specification. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
The foregoing is merely an example of one or more embodiments of the present specification and is not intended to limit the one or more embodiments of the present specification. Various modifications and alterations to one or more embodiments of this description will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, or the like, which is within the spirit and principles of the present specification, should be included in the scope of the claims.

Claims (13)

1. A method of mapping block data to structured data, the method performed by block link points, comprising:
acquiring a target intelligent contract called by a target transaction to be executed, wherein the target intelligent contract comprises a plurality of contract methods and has analysis rules which are attached to the contract methods and are set for the contract methods; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt;
executing the target transaction to obtain a contract receipt;
and according to the first analysis rule, mapping the block data related to the contract methods into first structural data, and according to the second analysis rule, mapping the block data related to the contract return execution into second structural data.
2. The method of claim 1, wherein the parsing rule further comprises: metadata of at least one data table;
the first structured data and the second structured data are stored in the at least one data table.
3. The method of claim 2, wherein the metadata of any one data table comprises: column information for each column contained in a table name of the data table, the column information including: column name, column type:
an index indicating whether an index is created for the column;
a primary key for indicating whether the column is set as a primary key;
and the self-increasing mode is used for indicating whether the column data is in the self-increasing mode or not.
4. The method of claim 2, wherein the first parsing rule comprises: a plurality of sub-rules respectively corresponding to the plurality of contract methods; any sub-rule includes a method name for the contract method and at least one segment of table operation rules, any segment of table operation rules including:
a table name field for indicating a target data table of the at least one data table;
an operation field indicating an operation type of a target operation performed with respect to the target data table;
a plurality of column fields for indicating a target data column for which the target operation is directed and a data source indicating a value taken from a contract parameter value or a value built in a block through a preset indicator.
5. The method of claim 4, wherein the alternate value of the operation field corresponds to an insert, update, or delete; when the target operation is update or deletion, the arbitrary table operation rule further includes a key field for indicating a query key of the target operation.
6. The method of claim 4, wherein the number of contract methods includes a first contract method and the number of sub-rules includes a first sub-rule; the first sub-rule includes a method name of the first contract method, and a first table operation rule including a first data table in a table name field, a first operation in an operation field, a first data column in a column field, and a first data source indicated by a first indicator.
7. The method of claim 6, wherein the mapping block data related to the number of contract methods into first structured data according to the first parsing rule comprises:
and reading the data value of the first data source according to the first indicator, and performing the first operation on a first data column in the first data table based on the data value.
8. The method of claim 6, wherein the first sub-rule further comprises a second table operation rule comprising a second data table in a table name field.
9. The method of claim 2, wherein the second parsing rule comprises: several pieces of table operation rules, any piece of table operation rule includes:
a table name field for indicating a target data table of the at least one data table;
an operation field indicating an operation type of a target operation performed with respect to the target data table;
and a plurality of column fields for indicating a target data column for which the target operation is directed and a data source, wherein the data source indicates a key value pair or a value built in a block, which is taken from a contract return through a preset indicator.
10. The method of claim 9, wherein the mapping the chunk data related to the contract return to second structured data according to the second parsing rule comprises:
extracting block data related to the contract return from the data source according to the preset indicator;
and based on the block data, performing the target operation indicated by the operation field on the target data table indicated by the table name field, wherein the target data columns are indicated by the column fields.
11. An apparatus for mapping block data to structured data, the apparatus disposed at a blockchain node, comprising:
an acquisition unit configured to acquire a target smart contract called by a target exchange to be executed, the target smart contract including a plurality of contract methods and having parsing rules attached thereto and set for the same; the parsing rules comprise a first parsing rule for the plurality of contract methods and a second parsing rule for contract receipt;
the execution unit is used for executing the target transaction to obtain a contract receipt;
and the mapping unit is used for mapping the block data related to the contract methods into first structural data according to the first analysis rule acquired by the acquisition unit, and mapping the block data related to the contract return execution acquired by the execution unit into second structural data according to the second analysis rule acquired by the acquisition unit.
12. A computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of any of claims 1-10.
13. A computing device comprising a memory having executable code stored therein and a processor, which when executing the executable code, implements the method of any of claims 1-10.
CN202211733501.1A 2022-12-30 2022-12-30 Method and apparatus for mapping block data into structured data Pending CN116049280A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211733501.1A CN116049280A (en) 2022-12-30 2022-12-30 Method and apparatus for mapping block data into structured data

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211733501.1A CN116049280A (en) 2022-12-30 2022-12-30 Method and apparatus for mapping block data into structured data

Publications (1)

Publication Number Publication Date
CN116049280A true CN116049280A (en) 2023-05-02

Family

ID=86123163

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211733501.1A Pending CN116049280A (en) 2022-12-30 2022-12-30 Method and apparatus for mapping block data into structured data

Country Status (1)

Country Link
CN (1) CN116049280A (en)

Similar Documents

Publication Publication Date Title
CN107562775B (en) Data processing method and device based on block chain
CN107577427B (en) data migration method, device and storage medium for blockchain system
US11847135B2 (en) Blockchain node and transaction method
CN110032598B (en) Method and device for updating field and electronic equipment
CN111782668A (en) Data structure reading and updating method and device, and electronic equipment
WO2020125224A1 (en) Data structure reading method and apparatus, data structure updating method and apparatus, and electronic device
CN114529417A (en) Method for executing transaction, block chain, main node and slave node
WO2024066007A1 (en) Transaction execution method in blockchain system, consensus node, and blockchain system
CN116032756A (en) Method for updating configuration information of application program based on block chain and block chain link point
CN116049280A (en) Method and apparatus for mapping block data into structured data
CN116167099A (en) Data access method and block link point in block chain system
CN115150409A (en) Method for executing transaction in block chain system, block chain system and node
CN114785800A (en) Cross-link communication method and device
CN116186763A (en) Method and apparatus for processing block data in a blockchain system
CN118069713A (en) Method for acquiring transaction read-write set in block chain and block chain link point
CN115658806A (en) Transaction execution method and node in blockchain system
CN114697344B (en) Method for determining consensus node in blockchain system, node, storage medium and computing device
CN116827970A (en) Data management method based on block chain system and block chain link point
CN116126966A (en) Method, device and blockchain node for inquiring data in blockchain system
CN116226277A (en) NFT resource transfer method and block chain link point
CN115665176A (en) Method and device for converting node types in block chain system and block chain system
CN116668002A (en) Transaction distribution method in blockchain system, blockchain node and blockchain system
CN116668001A (en) Transaction processing method in block chain and block chain link point
CN117808587A (en) Transaction deduplication method and nodes in blockchain system
CN116049170A (en) Block chain state storage and verification method and block chain link point

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination