CN115543178A - Block data processing method and device, computer readable medium and electronic equipment - Google Patents

Block data processing method and device, computer readable medium and electronic equipment Download PDF

Info

Publication number
CN115543178A
CN115543178A CN202110729702.3A CN202110729702A CN115543178A CN 115543178 A CN115543178 A CN 115543178A CN 202110729702 A CN202110729702 A CN 202110729702A CN 115543178 A CN115543178 A CN 115543178A
Authority
CN
China
Prior art keywords
data
block
block data
processing
cache
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
CN202110729702.3A
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110729702.3A priority Critical patent/CN115543178A/en
Publication of CN115543178A publication Critical patent/CN115543178A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0655Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
    • G06F3/0656Data buffering arrangements
    • 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
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0602Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
    • G06F3/061Improving I/O performance
    • G06F3/0613Improving I/O performance in relation to throughput

Landscapes

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

Abstract

The embodiment of the application provides a method and a device for processing block data, a computer readable medium and electronic equipment. The block data processing method comprises the following steps: carrying out consensus processing on block data, wherein the block data comprises a plurality of transaction information; acquiring transaction execution result data generated by carrying out consensus processing on the block data; writing the block data and the transaction execution result data into a designated cache; and if the number of the blocks corresponding to the data written into the specified cache reaches a set threshold, performing persistence processing on the data in the specified cache. According to the technical scheme of the embodiment of the application, the write-in performance of the disk can be improved in a batch persistence processing mode, and the transaction throughput of the block chain is favorably improved.

Description

Block data processing method and device, computer readable medium and electronic equipment
Technical Field
The present application relates to the field of computer and communication technologies, and in particular, to a method and an apparatus for processing block data, a computer-readable medium, and an electronic device.
Background
In the related art of the blockchain, after the consensus node agrees on the block, the blockchain ledger usually adopts a mode of synchronously writing in the persistent storage, which is influenced by the performance of the disk, and thus the efficiency of the persistent processing is reduced, and further the transaction throughput of the blockchain is reduced.
Disclosure of Invention
Embodiments of the present application provide a method and an apparatus for processing block data, a computer-readable medium, and an electronic device, so that write-in performance of a disk can be improved at least to a certain extent by a batch persistence processing mode, which is beneficial to improving transaction throughput of a block chain.
According to an aspect of the embodiments of the present application, there is provided a method for processing block data, including: carrying out consensus processing on block data, wherein the block data comprises a plurality of transaction information; acquiring transaction execution result data generated by carrying out consensus processing on the block data; writing the block data and the transaction execution result data into a designated cache; and if the number of the blocks corresponding to the data written into the specified cache reaches a set threshold, performing persistence processing on the data in the specified cache.
According to an aspect of the embodiments of the present application, there is provided a processing apparatus for tile data, including: the system comprises a consensus unit, a data processing unit and a data processing unit, wherein the consensus unit is configured to perform consensus processing on block data, and the block data comprises a plurality of transaction information; the acquisition unit is configured to acquire transaction execution result data generated by carrying out consensus processing on the block data; a write unit configured to write the block data and the transaction execution result data into a designated cache; and the persistence unit is configured to perform persistence processing on the data in the specified cache if the number of blocks corresponding to the data written in the specified cache reaches a set threshold.
In some embodiments of the present application, based on the foregoing scheme, the writing unit is configured to: writing the block data into a log cache; and writing the index data of the block data in the log and the transaction execution result data into a block chain account book cache.
In some embodiments of the present application, based on the foregoing scheme, the persistence unit is configured to: and if the number of the blocks corresponding to the block data written into the log cache reaches a first threshold value, performing persistent processing on the block data in the log cache.
In some embodiments of the present application, based on the foregoing scheme, the persistence unit is configured to: and if the number of the blocks corresponding to the index data and the transaction execution result data written into the block chain account book cache reaches a second threshold value, performing persistence processing on the index data and the transaction execution result data in the block chain account book cache.
In some embodiments of the present application, based on the foregoing solution, the apparatus for processing block data further includes: the first reading unit is configured to read index data of the specified block data in a log from a block chain account book if the specified block data needs to be acquired after the data in the specified cache is subjected to persistence processing; and reading the specified block data from the log according to the index data of the specified block data in the log.
In some embodiments of the present application, based on the foregoing solution, the apparatus for processing block data further includes: and the second reading unit is configured to acquire a transaction execution result of the specified transaction information from the blockchain ledger through the transaction hash after the data in the specified cache is subjected to persistence processing.
In some embodiments of the present application, based on the foregoing scheme, the writing unit is configured to: calling a log submitting interface to write the block data into the log cache; and calling a block chain ledger layer submission interface to write the index data of the block data in the log and the transaction execution result data into a block chain ledger cache.
In some embodiments of the present application, based on the foregoing solution, the apparatus for processing block data further includes: a generation unit configured to collect transaction information; and if the quantity of the collected transaction information reaches a set quantity or the time length for collecting the transaction information reaches a set time length, generating the block data according to the collected transaction information.
In some embodiments of the present application, based on the foregoing solution, the apparatus for processing block data further includes: and the broadcasting unit is configured to broadcast the block data to other nodes after generating the block data according to the collected transaction information so as to start a consensus processing process of the block data.
In some embodiments of the present application, based on the foregoing scheme, the persistence unit is further configured to: deleting the cached data from the specified cache after persisting the data in the specified cache.
In some embodiments of the present application, based on the foregoing solution, the consensus unit is configured to: carrying out consensus processing on the block data through a Raft consensus algorithm; the writing unit is configured to: writing the block data into a Raft log.
In some embodiments of the present application, based on the foregoing scheme, the transaction execution result data includes a write set and a transaction execution result set corresponding to the tile data.
According to an aspect of the embodiments of the present application, there is provided a computer-readable medium on which a computer program is stored, the computer program, when executed by a processor, implementing the processing method of block data as described in the above embodiments.
According to an aspect of an embodiment of the present application, there is provided an electronic device including: one or more processors; a storage device for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the processing method of the block data as described in the above embodiments.
According to an aspect of embodiments herein, there is provided a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the block data processing method provided in the above-mentioned various optional embodiments.
In the technical solutions provided in some embodiments of the present application, block data and transaction execution result data are written into an assigned cache, and when the number of blocks corresponding to the data written into the assigned cache reaches a set threshold, data in the assigned cache is subjected to persistence processing, so that the write-in performance of a disk can be improved in a batch persistence processing manner, a problem of low disk performance caused by a synchronous persistence manner is avoided, which is beneficial to improving transaction throughput of a block chain, and further effectively improving processing performance of a block chain network.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application. It is obvious that the drawings in the following description are only some embodiments of the application, and that for a person skilled in the art, other drawings can be derived from them without inventive effort. In the drawings:
fig. 1 shows a schematic structural diagram of a blockchain network;
FIG. 2 is a diagram illustrating the connection relationship between blocks in a block chain;
FIG. 3 shows a schematic diagram of an exemplary system architecture to which aspects of embodiments of the present application may be applied;
FIGS. 4-6 show schematic views of an election process in a Raft system;
FIG. 7 shows a flow diagram of a method of processing tile data according to one embodiment of the present application;
fig. 8 shows a block diagram of a processing device of tile data according to an embodiment of the present application;
FIG. 9 illustrates a schematic structural diagram of a computer system suitable for use in implementing the electronic device of an embodiment of the present application.
Detailed Description
Example embodiments will now be described in a more complete manner with reference to the accompanying drawings. However, the illustrated embodiments can be embodied in various forms and should not be construed as limited to only these examples; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the concept of example embodiments to those skilled in the art.
Furthermore, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are set forth in order to provide a thorough understanding of embodiments of the present application. However, it will be recognized by one skilled in the art that all of the specific features of the embodiments may not be required to practice the subject innovation, one or more of the specific details may be omitted, or other methods, components, devices, steps, etc. may be utilized.
The block diagrams shown in the figures are functional entities only and do not necessarily correspond to physically separate entities. I.e. these functional entities may be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and/or processor means and/or microcontroller means.
The flow charts shown in the drawings are merely illustrative and do not necessarily include all of the contents and operations/steps, nor do they necessarily have to be performed in the order described. For example, some operations/steps may be decomposed, and some operations/steps may be combined or partially combined, so that the actual execution sequence may be changed according to the actual situation.
It should be noted that: reference herein to "a plurality" means two or more. "and/or" describe the association relationship of the associated objects, meaning that there may be three relationships, e.g., A and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
The Blockchain (Blockchain) is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism, an encryption algorithm and the like. The blockchain is essentially a decentralized database, which is a string of data blocks (i.e., blocks) associated by using cryptography, and each data block contains information of a batch of network transactions for verifying the validity (anti-counterfeiting) of the information and generating the next block. The blockchain may include a blockchain underlying platform, a platform product services layer, and an application services layer.
The block chain underlying platform can comprise processing modules such as user management, basic service, intelligent contract and operation monitoring. The user management module is responsible for identity information management of all blockchain participants, and comprises the steps of maintaining public and private key generation (account management), key management, user real identity and blockchain address corresponding relation maintenance (authority management) and the like, and under the authorized condition, supervising and auditing the transaction condition of some real identities, and providing rule configuration (wind control audit) of risk control; the basic service module is deployed on all block chain node equipment and used for verifying the validity of the service request, recording the service request to storage after consensus on the valid request is completed, for a new service request, the basic service firstly performs interface adaptation analysis and authentication processing (interface adaptation), then encrypts service information (consensus management) through a consensus algorithm, transmits the service information to a shared account (network communication) completely and consistently after encryption, and performs recording and storage; the intelligent contract module is responsible for registering and issuing contracts, triggering the contracts and executing the contracts, developers can define contract logics through a certain programming language, issue the contract logics to a block chain (contract registration), call keys or other event triggering and executing according to the logics of contract clauses, complete the contract logics and simultaneously provide the function of upgrading and canceling the contracts; the operation monitoring module is mainly responsible for deployment, configuration modification, contract setting, cloud adaptation in the product release process, and visual output of real-time status in product operation, for example: alarm, monitoring network conditions, monitoring node equipment health status, and the like.
The platform product service layer provides basic capability and an implementation framework of typical application, and developers can complete block chain implementation of business logic based on the basic capability and the characteristics of the superposed business. The application service layer provides the application service based on the block chain scheme for the business participants to use.
As described above, a blockchain is essentially a decentralized database, and blockchains are commonly maintained by nodes in a blockchain network. For example, in the blockchain network shown in fig. 1, a plurality of nodes 101 may be included, and the plurality of nodes 101 may be respective clients forming the blockchain network. Each node 101 may receive input information and maintain shared data within the blockchain network based on the received input information while operating normally. In order to ensure information intercommunication in the blockchain network, information connection can exist between each node in the blockchain network, and information transmission can be performed between the nodes through the information connection. For example, when any node in the blockchain network receives input information, other nodes in the blockchain network acquire the input information according to a consensus algorithm, and store the input information as shared data, so that the data stored on all nodes in the blockchain network are consistent.
Each node in the blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes, so that the generated blocks can be broadcasted to other nodes in the blockchain network according to the node identifiers of other nodes. Each node can maintain a node identification list, and the node name and the node identification are correspondingly stored in the node identification list. The node identifier may be an IP (Internet Protocol) address and any other information that can be used to identify the node.
Each node in the blockchain network stores one identical blockchain. The block chain is composed of a plurality of blocks, as shown in fig. 2, the block chain is composed of a plurality of blocks, the starting block includes a block header and a block main body, the block header stores an input information characteristic value, a version number, a timestamp, a difficulty value and the like, and the block main body stores input information; the next block of the starting block takes the starting block as a parent block, the next block also comprises a block head and a block main body, the block head stores the input information characteristic value of the current block, the block head characteristic value of the parent block, the version number, the timestamp, the difficulty value and the like, so that the block data stored in each block in the block chain is associated with the block data stored in the parent block, and the safety of the input information in the block is ensured.
Each node in the blockchain network may be a server or a terminal device. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a Cloud server providing basic Cloud Computing services such as Cloud service, a Cloud database, cloud Computing (Cloud Computing), cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, content Delivery Network (CDN), big data, an artificial intelligence platform, and the like. The terminal device may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, and the like. The nodes may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
In the related art of the blockchain, after the consensus node agrees on the block, the blockchain ledger usually adopts a mode of synchronously writing in the persistent storage, which is influenced by the performance of the disk, and thus the efficiency of the persistent processing is reduced, and further the transaction throughput of the blockchain is reduced. For a coalition chain adopting a Raft (a distributed algorithm) consensus algorithm, a Raft architecture requires that a Raft log and a consensus ledger layer need to write disks once for each Raft instance (such as block data), generally the Raft requires more than 3 copies, that is, the total copies can reach more than 6, which not only causes more data redundancy, but also increases the disk write bandwidth. Meanwhile, because a single raw instance needs to correspond to one log file, the single-machine disk capacity limits the number of the raw instances, so that the throughput cannot be improved through the trans-form of multiple concurrent write disks, and secondly, the interaction of the raw protocol is serial, so that the throughput of the single raw instance is limited by RTT (Round-Trip Time).
The above-mentioned alliance chain is a kind of block chain, mainly for members of a specific group and limited third parties, and a plurality of preselected nodes are designated as accounting nodes in the alliance chain, the generation of each block is jointly determined by the accounting nodes, and other nodes can participate in transactions without inquiring about the accounting process. Consensus is easy to achieve due to the small number of nodes in the federation chain compared to the public block chain.
Based on the problems in the related art, the technical scheme of the embodiment of the application provides a new block data processing scheme, so that the write-in performance of a disk can be improved, and the problem of low performance of the disk caused by a synchronous persistence mode is solved. Meanwhile, the storage copies of the block data can be reduced, and the write bandwidth of the disk is further reduced.
Specifically, in an application scenario of the present application, as shown in fig. 3, a client 301 and a blockchain platform 302 are mainly included. Where client 301 may generate transaction information for uplink, blockchain platform 302 may be a platform built based on the blockchain network shown in fig. 1.
The transaction information generated in the client 301 may be sent to a certain blockchain node in the blockchain platform 302, and when the number of the collected transaction information reaches a set number or the duration of collecting the transaction information reaches a set duration, the blockchain node may generate blocky data according to the collected transaction information. The tile data may then be consensus processed in the blockchain platform 302.
In the consensus process, each block link point can acquire transaction execution result data generated by performing consensus processing on the block data, such as a write set and a transaction execution result set. The block data and the transaction execution result data can be written into a designated cache, and when the number of blocks corresponding to the data written into the designated cache reaches a set threshold, the data in the designated cache is subjected to persistence processing, so that the write-in performance of the disk can be improved in a batch persistence processing mode, the problem of low disk performance caused by a synchronous persistence mode is avoided, the transaction throughput of a block chain is improved, and the processing performance of a block chain network is effectively improved.
Optionally, a Raft consensus algorithm may be adopted for the block chain nodes in the block chain platform 302, and the block data is written into the log cache, that is, the cache for writing the Raft log, and accordingly, the architecture of the block chain platform 302 may be a Raft system architecture. In the Raft system, the states of the nodes include: leader, follower, and candidate states are interchangeable.
The leader node is responsible for receiving the request of the client, copying the logs to other nodes and informing other nodes when it is safe to apply the logs, and only one leader can exist in the Raft system at any time. The candidate node is generated in the election process, and if the follower node does not receive the heartbeat or the log of the leader node within the timeout period, the candidate node is switched to the candidate state, and the election process is entered. The follower node is a node which passively accepts requests, does not send any request, only responds to requests from the leader or the candidate, and forwards the requests to the leader node if the follower node receives the requests of the client. The following briefly introduces the leader election process and the log replication process in the Raft protocol.
In the leader election process, as shown in fig. 4, the initial states of the nodes at startup are all F (follower), after a node finishes counting down (Timeout), the node enters C (candidate) state for election, and the node sends an election request (requestvolume) to other nodes. If all four other nodes return information confirming the election, the state of this node changes from C to L (i.e., leader), and every short time interval, a Heartbeat message (Heartbeat) is sent to all Followers to maintain the state of all nodes, and the Follower resets Timeout upon receiving the Leader's Heartbeat. In one embodiment, the Candidate is elected as Leader whenever more than half of the nodes cast a supporting vote (i.e., confirm the election).
As shown in fig. 5, if there is one Leader node, all nodes operate normally, and when the Leader fails, other Follower nodes will perform re-election, the election process is similar to the flow shown in fig. 4, and after the election is successful, a new Leader node appears.
As shown in fig. 6, after a new Leader node is elected, if the original Leader is recovered and rejoined, since each round of election in the Raft protocol is recorded, the processing is performed according to the latest election result, that is, the original Leader is downgraded to folower.
In the election process, votes may be equally divided, for example, 5 nodes a, B, C, D, E, 4 nodes remain after leader a goes down, the Raft protocol stipulates that each node can only cast one vote during one election period, if B and D have the latest logs respectively and initiate election voting at the same time, then B and D may obtain 2 votes respectively, and if most of the votes cannot be confirmed, the leader cannot be selected. In order to avoid the situation, the Raft protocol avoids the situation of vote sharing by using a random timeout mechanism, wherein election timeout time is randomly selected from a fixed interval, and due to different timeout times of all nodes, after a leader goes down, a follower with the shortest election timeout time and the most logs initiates election voting firstly and becomes the leader. Once candidate becomes a leader, heartbeat packets are sent to other nodes to prevent a new round of election from starting.
In the log copying process, a leader sends a log to a follower, the log carries an adjacent previous log, the follower finds the previous log at the same option number and index position when receiving the log, and if the log exists and is matched with the previous log, the log is received; otherwise, sending information of refusing log replication to the leader. After rejection, the leader will reduce the log index position and retry until a certain position is consistent with the follower, then the follower deletes all logs after indexing and adds the logs sent by the leader, and once the log addition is successful, all logs of the follower and the leader are consistent. And only after most of the followers respond to the received log, the transaction can be submitted, and the information of successful submission can be returned to the client.
Based on the Raft protocol, in an application scenario of the application, when the block data and the transaction execution result data are written into a designated cache, the block data can be written into a Raft log cache, and the index data of the block data in the Raft log and the transaction execution result data are written into a block chain ledger cache.
Various implementation details of the technical solution of the embodiments of the present application are set forth in detail below:
fig. 7 illustrates a flowchart of a processing method of tile data, which may be performed by tile link points, according to an embodiment of the present application. Referring to fig. 7, the method for processing block data at least includes steps S710 to S740, which are described in detail as follows:
in step S710, a consensus process is performed on the block data, wherein the block data includes a plurality of transaction information.
In an embodiment of the present application, the technical solution of the embodiment shown in fig. 7 may be executed by a block chain node that generates block data, or may also be executed by a block chain node that receives block data that needs to be identified.
If the block link node is executed by the block link node which generates the block data, the block link node can collect the received transaction information when receiving the transaction information, and if the quantity of the collected transaction information reaches the set quantity or the time length for collecting the transaction information reaches the set time length, the block data is generated according to the collected transaction information. After the tile data is generated, the tile data may be broadcast to other nodes to initiate a consensus process for the tile data.
In step S720, transaction execution result data generated by performing consensus on the tile data is obtained.
In one embodiment of the present application, the transaction execution result data includes a write set and a transaction execution result set corresponding to the tile data. Optionally, the write set includes a value pre-written by the endorsement node to the variable during the pre-execution transaction, that is, the writing to the variable is only recorded in the write set, and does not change the actual state, and the write set may be recorded in the form of a key-value pair. The transaction execution result set includes the execution result of each transaction information in the block data. The endorsement node is a node in the blockchain system that undertakes the endorsement task, namely, a node used for performing pre-execution on the transaction information in the blockchain data to verify the transaction information.
In step S730, the block data and the transaction execution result data are written into the designated buffer.
In one embodiment of the present application, the block data may be written into a log cache; and writing the index data of the block data in the log and the transaction execution result data into a block chain account book cache. The technical scheme of the embodiment enables the block data not to be written into the block chain account book, reduces the disk write bandwidth during the persistence processing, and can reduce the storage copy of the block data.
In one embodiment of the present application, the log submitting interface may be called to write the block data into the log cache, and the blockchain ledger layer submitting interface may be called to write the index data of the block data in the log and the transaction execution result data into the blockchain ledger cache.
Alternatively, the block link points may perform consensus processing on the block data through a Raft consensus algorithm, in which case the block data may be written into a Raft log.
In step S740, if the number of blocks corresponding to the data written into the designated cache reaches the set threshold, the data in the designated cache is subjected to persistence processing.
Optionally, the set threshold may be set according to actual needs, for example, may be set to 10, and when the data corresponding to 10 blocks is stored in the designated cache, the data in the designated cache may be subjected to persistence processing.
In an embodiment of the present application, if the block data is written into the log cache, and the index data of the block data in the log and the transaction execution result data are written into the block chain ledger cache, when performing the persistence processing, the block data in the log cache may be performed with the persistence processing only when the number of blocks corresponding to the block data written into the log cache reaches the first threshold. The first threshold may be 10, for example, if there is 10 blocks of data written into the log cache, then the data in the log cache is persisted.
In an embodiment of the present application, if the block data is written into the log cache, and the index data of the block data in the log and the transaction execution result data are written into the block chain ledger cache, when performing the persistence processing, the index data and the transaction execution result data in the block chain ledger cache may be persisted only when the number of blocks corresponding to the index data and the transaction execution result data written into the block chain ledger cache reaches a second threshold. The second threshold may be 10, for example, if the index data of the tile data of 10 tiles and the transaction execution result are written into the log cache, then the tile data in the log cache is persisted. Optionally, the second threshold may be the same as or different from the first threshold.
In an embodiment of the present application, after performing the persistence process, if the designated block data needs to be acquired, the index data of the designated block data in the log may be read from the block chain ledger, and then the designated block data may be read from the log according to the index data of the designated block data in the log.
In one embodiment of the present application, after the persistence processing is performed, since the transaction execution result is stored in the blockchain ledger, the transaction execution result specifying the transaction information can be acquired from the blockchain ledger by the transaction hash.
In one embodiment of the present application, after the data in the cache is persisted, the cached data may be deleted from the cache. The technical scheme of the embodiment can ensure that the cache is cleared in time after the block related data is subjected to the persistence processing so as to release the storage space of the cache.
The technical scheme of the embodiment of the present application is explained in detail by a Raft consensus algorithm compatible with BFT (Byzantine Fault Tolerance):
in an embodiment of the application, a block chain system adopting a BFT-Raft consensus algorithm may collect transaction information of a client at a Leader node, and in order to reduce the number of interactions between nodes adopting a Raft protocol, after waiting for time consumption or when the number of accumulated transaction information reaches a threshold value, the BFT-Raft block chain Leader node packs the collected transaction information into a candidate block and broadcasts the candidate block to a Followers node, and a BFT-Raft consensus process is triggered.
In the BFT-Raft consensus process, in addition to the candidate Block data Block, a write set WriteSet and a transaction execution result set TransactionResultList after the candidate Block is executed are generated.
When the BFT-Raft consensus is agreed, the accounting layer submitting interface and the BFT-Raft log submitting interface can be called respectively. The BFT-Raft log submitting interface writes Block data Block into a log cache; and the ledger layer submission interface writes the index data of the Block data Block in the BFT-Raft log, the write set WriteSet and the transaction execution result set TransactionResultList into a Block chain ledger cache.
It should be noted that: the log cache and the block chain account book cache in the embodiment of the application may share the same physical cache space, or may adopt mutually independent physical cache spaces.
After the cache is written, the block chain ledger cache checks whether the number of blocks accumulated to be flushed reaches a threshold, for example, 10 blocks are cached, and if 10 blocks of related data are cached, a disk flushing operation of the block chain ledger layer is triggered, that is, log index data, write set WriteSet and transaction execution result set TransactionResultList related to the cached 10 blocks are written into the disk. If the number does not reach the threshold, wait until the next write cache check.
Similarly, the BFT-Raft log cache may also check whether the accumulated block data to be written into the log reaches a threshold, for example, cache 10 blocks, and if 10 block data are cached, trigger a log disk-flushing operation, that is, write the cached 10 block data into the disk. If the number does not reach the threshold, wait until the next write cache check.
Based on the above processing, since the block chain ledger layer only retains the block log index and has no block data, when there is a need to read the block data, the block log index can be read from the block chain ledger layer first, and then the complete block data can be read from the BFT-Raft log through the block log index. Meanwhile, when a transaction result is inquired, the transaction result can be read from the blockchain ledger layer through transaction hash.
As described above, according to the technical scheme of the embodiment of the application, the disk writing throughput and the interaction times between nodes are improved in a manner of writing the block data into the disk in batches, and meanwhile, because the complete block data is only written into the log, the block chain ledger layer only keeps the index of the block data in the log, so that the storage copies of the block data are reduced, the disk writing bandwidth is further reduced, and the throughput of the block chain to external services can be improved.
The following describes embodiments of the apparatus of the present application, which can be used to perform the block data processing method in the above embodiments of the present application. For details that are not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the block data processing method described above in the present application.
Fig. 8 shows a block diagram of a block data processing device according to an embodiment of the present application, which may be disposed within block link points.
Referring to fig. 8, an apparatus 800 for processing tile data according to an embodiment of the present application includes: a consensus unit 802, an acquisition unit 804, a writing unit 806, and a persistence unit 808.
The consensus unit 802 is configured to perform consensus on block data, where the block data includes a plurality of transaction messages; the obtaining unit 804 is configured to obtain transaction execution result data generated by performing consensus processing on the block data; the writing unit 806 is configured to write the block data and the transaction execution result data into a designated cache; the persistence unit 808 is configured to perform persistence processing on the data in the designated cache if the number of blocks corresponding to the data written in the designated cache reaches a set threshold.
In some embodiments of the present application, based on the foregoing scheme, the writing unit 806 is configured to: writing the block data into a log cache; and writing the index data of the block data in the log and the transaction execution result data into a block chain account book cache.
In some embodiments of the present application, based on the foregoing scheme, the persistence unit 808 is configured to: and if the number of the blocks corresponding to the block data written into the log cache reaches a first threshold value, performing persistent processing on the block data in the log cache.
In some embodiments of the present application, based on the foregoing scheme, the persistence unit 808 is configured to: and if the number of the blocks corresponding to the index data and the transaction execution result data written into the block chain account book cache reaches a second threshold value, performing persistence processing on the index data and the transaction execution result data in the block chain account book cache.
In some embodiments of the present application, based on the foregoing solution, the apparatus 800 for processing block data further includes: the first reading unit is configured to read index data of the specified block data in a log from a block chain account book if the specified block data needs to be acquired after the data in the specified cache is subjected to persistence processing; and reading the specified block data from the log according to the index data of the specified block data in the log.
In some embodiments of the present application, based on the foregoing solution, the apparatus 800 for processing block data further includes: and the second reading unit is configured to acquire a transaction execution result of the specified transaction information from the blockchain ledger through the transaction hash after the data in the specified cache is subjected to persistence processing.
In some embodiments of the present application, based on the foregoing scheme, the writing unit 806 is configured to: calling a log submitting interface to write the block data into the log cache; and calling a submitting interface of a block chain ledger layer to write the index data of the block data in the log and the transaction execution result data into a block chain ledger cache.
In some embodiments of the present application, based on the foregoing solution, the apparatus 800 for processing block data further includes: a generation unit configured to collect transaction information; and if the quantity of the collected transaction information reaches a set quantity or the time length for collecting the transaction information reaches a set time length, generating the block data according to the collected transaction information.
In some embodiments of the present application, based on the foregoing solution, the apparatus 800 for processing block data further includes: and the broadcasting unit is configured to broadcast the block data to other nodes after generating the block data according to the collected transaction information so as to start a consensus processing process of the block data.
In some embodiments of the present application, based on the foregoing scheme, the persistence unit 808 is further configured to: deleting the cached data from the specified cache after the data in the specified cache is persisted.
In some embodiments of the present application, based on the foregoing solution, the consensus unit 802 is configured to: carrying out consensus processing on the block data through a Raft consensus algorithm; the writing unit is configured to: writing the block data into a Raft log.
In some embodiments of the present application, based on the foregoing solution, the transaction execution result data includes a write set and a transaction execution result set corresponding to the tile data.
FIG. 9 illustrates a schematic structural diagram of a computer system suitable for use to implement the electronic device of the embodiments of the subject application.
It should be noted that the computer system 900 of the electronic device shown in fig. 9 is only an example, and should not bring any limitation to the functions and the scope of the application of the embodiments.
As shown in fig. 9, the computer system 900 includes a Central Processing Unit (CPU) 901, which can perform various appropriate actions and processes, such as executing the methods described in the above embodiments, according to a program stored in a Read-Only Memory (ROM) 902 or a program loaded from a storage portion 908 into a Random Access Memory (RAM) 903. In the RAM 903, various programs and data necessary for system operation are also stored. The CPU 901, ROM 902, and RAM 903 are connected to each other via a bus 904. An Input/Output (I/O) interface 905 is also connected to bus 904.
The following components are connected to the I/O interface 905: an input portion 906 including a keyboard, a mouse, and the like; an output portion 907 including a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, a speaker, and the like; a storage portion 908 including a hard disk and the like; and a communication section 909 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 909 performs communication processing via a network such as the internet. The drive 910 is also connected to the I/O interface 905 as necessary. A removable medium 911 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 910 as necessary, so that a computer program read out therefrom is mounted into the storage section 908 as necessary.
In particular, according to embodiments of the present application, the processes described above with reference to the flow diagrams may be implemented as computer software programs. For example, embodiments of the present application include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising a computer program for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 909, and/or installed from the removable medium 911. The computer program executes various functions defined in the system of the present application when executed by a Central Processing Unit (CPU) 901.
It should be noted that the computer readable media shown in the embodiments of the present application may be computer readable signal media or computer readable storage media or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a Read-Only Memory (ROM), an Erasable Programmable Read-Only Memory (EPROM), a flash Memory, an optical fiber, a portable Compact Disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer-readable signal medium may include a propagated data signal with a computer program embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. Each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware, and the described units may also be disposed in a processor. Wherein the names of the elements do not in some way constitute a limitation on the elements themselves.
As another aspect, the present application also provides a computer-readable medium, which may be contained in the electronic device described in the above embodiment; or may exist separately without being assembled into the electronic device. The computer readable medium carries one or more programs which, when executed by an electronic device, cause the electronic device to implement the method described in the above embodiments.
It should be noted that although in the above detailed description several modules or units of the device for action execution are mentioned, such a division is not mandatory. Indeed, the features and functions of two or more modules or units described above may be embodied in one module or unit according to embodiments of the application. Conversely, the features and functions of one module or unit described above may be further divided into embodiments by a plurality of modules or units.
Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein may be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a usb disk, a removable hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (15)

1. A processing method of block data is characterized in that the block data comprises a plurality of transaction information, and the processing method of the block data comprises the following steps:
performing a consensus process on the block data,
acquiring transaction execution result data generated by carrying out consensus processing on the block data;
writing the block data and the transaction execution result data into a designated cache;
and if the number of the blocks corresponding to the data written into the specified cache reaches a set threshold, performing persistence processing on the data in the specified cache.
2. The method of claim 1, wherein writing the block data and the transaction execution result data into a designated cache comprises:
writing the block data into a log cache;
and writing the index data of the block data in the log and the transaction execution result data into a block chain account book cache.
3. The method for processing block data according to claim 2, wherein if the number of blocks corresponding to the data written into the designated cache reaches a set threshold, performing persistence processing on the data in the designated cache includes:
and if the number of the blocks corresponding to the block data written into the log cache reaches a first threshold value, performing persistent processing on the block data in the log cache.
4. The method for processing block data according to claim 2, wherein if the number of blocks corresponding to the data written into the designated cache reaches a set threshold, performing persistence processing on the data in the designated cache includes:
and if the number of the blocks corresponding to the index data and the transaction execution result data written into the block chain account book cache reaches a second threshold value, performing persistence processing on the index data and the transaction execution result data in the block chain account book cache.
5. The method for processing block data according to claim 2, further comprising:
after the data in the designated cache is subjected to persistence processing, if the designated block data needs to be acquired, reading the index data of the designated block data in the log from a block chain account book;
and reading the specified block data from the log according to the index data of the specified block data in the log.
6. The method for processing block data according to claim 2, further comprising:
and after the data in the specified cache is subjected to persistence processing, acquiring a transaction execution result of specified transaction information from the blockchain ledger through transaction hash.
7. The method of claim 2, wherein writing the block data into a log cache comprises: calling a log submitting interface to write the block data into the log cache;
writing the index data of the block data in the log and the transaction execution result data into a block chain account book cache, including: and calling a submitting interface of a block chain ledger layer to write the index data of the block data in the log and the transaction execution result data into a block chain ledger cache.
8. The method as claimed in claim 1, wherein before performing consensus processing on the block data, the method further comprises:
collecting transaction information;
and if the quantity of the collected transaction information reaches a set quantity or the time length for collecting the transaction information reaches a set time length, generating the block data according to the collected transaction information.
9. The method for processing block data according to claim 8, further comprising:
after generating the block data according to the collected transaction information, broadcasting the block data to other nodes to start a consensus process on the block data.
10. The method for processing block data according to claim 1, further comprising:
deleting the cached data from the specified cache after persisting the data in the specified cache.
11. A method as claimed in any one of claims 2 to 10, wherein the consensus processing is performed on the block data, including: carrying out consensus processing on the block data through a Raft consensus algorithm;
writing the block data into a log cache, comprising: writing the block data into a Raft log.
12. A method as claimed in any one of claims 1 to 10, wherein the transaction execution result data comprises a write set and a transaction execution result set corresponding to the tile data.
13. An apparatus for processing block data, comprising:
the system comprises a consensus unit, a data processing unit and a data processing unit, wherein the consensus unit is configured to perform consensus processing on block data, and the block data comprises a plurality of transaction information;
the acquisition unit is configured to acquire transaction execution result data generated by carrying out consensus processing on the block data;
a write unit configured to write the block data and the transaction execution result data into a designated cache;
and the persistence unit is configured to perform persistence processing on the data in the specified cache if the number of blocks corresponding to the data written in the specified cache reaches a set threshold.
14. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of processing tile data according to any one of claims 1 to 12.
15. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement a method of processing tile data according to any one of claims 1 to 12.
CN202110729702.3A 2021-06-29 2021-06-29 Block data processing method and device, computer readable medium and electronic equipment Pending CN115543178A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110729702.3A CN115543178A (en) 2021-06-29 2021-06-29 Block data processing method and device, computer readable medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110729702.3A CN115543178A (en) 2021-06-29 2021-06-29 Block data processing method and device, computer readable medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN115543178A true CN115543178A (en) 2022-12-30

Family

ID=84716787

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110729702.3A Pending CN115543178A (en) 2021-06-29 2021-06-29 Block data processing method and device, computer readable medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN115543178A (en)

Similar Documents

Publication Publication Date Title
US11538003B2 (en) Sharded permissioned distributed ledgers
CN109636427B (en) Business processing method, device, medium and electronic equipment based on block chain system
CN113098907B (en) Group division method and device for block chain
WO2020048440A1 (en) Election method and apparatus for representative node device, computer device, and storage medium
JP2019200580A (en) Decentralized ledger system, decentralized ledger subsystem, and decentralized ledger node
US11657035B2 (en) Methods, devices and systems for real-time checking of data consistency in a distributed heterogenous storage system
CN112291372A (en) Asynchronous posting method, device, medium and electronic equipment for block chain
US11627122B2 (en) Inter-system linking method and node
CN113347164A (en) Block chain-based distributed consensus system, method, device and storage medium
CN111400112A (en) Writing method and device of storage system of distributed cluster and readable storage medium
CN110599384B (en) Organization relation transferring method, device, equipment and storage medium
Vizier et al. ComChain: A blockchain with Byzantine fault‐tolerant reconfiguration
US20230360046A1 (en) Blockchain-based block processing method and apparatus, device, storage medium, and program product
CN116384993B (en) Method and system for realizing high consistency of order payment state based on cloud payment center
CN112053155A (en) Community decision method, device and storage medium
CN112269838A (en) Block chain-based supervision method and device, electronic equipment and storage medium
CN115543178A (en) Block data processing method and device, computer readable medium and electronic equipment
CN112926981B (en) Transaction information processing method, device and medium for block chain and electronic equipment
CN116095081A (en) Event processing method and device based on block chain system, equipment and medium
CN116112506A (en) Transaction information processing method, device, medium and equipment based on alliance chain system
WO2024093593A1 (en) Multi-blockchain-based data processing method and apparatus, and electronic device, computer-readable storage medium and computer program product
WO2024078109A1 (en) Multi-blockchain data processing method and apparatus, and device, system and medium
WO2024082818A1 (en) Multi-blockchain-based cross-chain processing method and apparatus, and device, system and medium
WO2024099023A1 (en) Multi-blockchain data processing method and apparatus, and device, computer-readable storage medium and computer program product
US20240137208A1 (en) Asset transferring method and apparatus based on multiple blockchains, device, medium, and product

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40080352

Country of ref document: HK