WO2020233086A1 - Block processing method and apparatus, computer device and storage medium - Google Patents

Block processing method and apparatus, computer device and storage medium Download PDF

Info

Publication number
WO2020233086A1
WO2020233086A1 PCT/CN2019/122676 CN2019122676W WO2020233086A1 WO 2020233086 A1 WO2020233086 A1 WO 2020233086A1 CN 2019122676 W CN2019122676 W CN 2019122676W WO 2020233086 A1 WO2020233086 A1 WO 2020233086A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
block
verification
blocks
sequence
Prior art date
Application number
PCT/CN2019/122676
Other languages
French (fr)
Chinese (zh)
Inventor
褚镇飞
冯世伟
张培培
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2020233086A1 publication Critical patent/WO2020233086A1/en

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/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24553Query execution of query operations
    • G06F16/24554Unary operations; Data partitioning operations
    • 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/0604Improving or facilitating administration, e.g. storage management
    • G06F3/0607Improving or facilitating administration, e.g. storage management by facilitating the process of upgrading existing storage systems, e.g. for improving compatibility between host and storage device
    • 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/0629Configuration or reconfiguration of storage systems
    • G06F3/0631Configuration or reconfiguration of storage systems by allocating resources to storage systems
    • 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/0668Interfaces specially adapted for storage systems adopting a particular infrastructure
    • G06F3/067Distributed or networked storage systems, e.g. storage area networks [SAN], network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3247Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials involving digital signatures

Definitions

  • This application relates to a block processing method, device, computer equipment and storage medium.
  • Blockchain is usually understood as a distributed ledger, essentially a block-based distributed database.
  • Blockchain includes consortium chains used between institutions.
  • the privacy protection mechanism of consortium chains is usually realized based on signature encryption and verification and decoding in cryptography, so that only members of specific groups and limited third parties can view the area according to their authority.
  • the block transaction submission process of the alliance chain includes three steps: signature verification, multi-version checking and transaction persistence.
  • the data node usually executes the transaction commit process for the transactions in each block in sequence according to the block generation order through a single thread.
  • the inventor realized that when a data node executes the transaction submission process of a block through a single thread, it can usually only process fewer transactions, which reduces the overall throughput of the blockchain system and wastes the computer resources of the server where the data node is located. .
  • the block contains only a few transactions, the overall throughput of the blockchain system is further reduced, and the submission efficiency of block transactions is reduced, thereby reducing the efficiency of block processing.
  • a block processing method, device, computer equipment, and storage medium are provided.
  • a block processing method includes:
  • the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a division reference point;
  • a transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence; transaction commit performed on multiple transaction blocks in the transaction block sequence
  • the operations include: performing transaction signature verification on the plurality of transaction blocks in parallel; performing transaction multi-version checking on each of the transaction blocks serially; and simultaneously writing the plurality of transaction blocks to a disk.
  • a block processing device includes:
  • the query module is used to query the configuration block in the currently cached block sequence according to the transaction commit instruction
  • the segmentation module is used to, when the configuration block is queried, use the queried configuration block as a splitting reference point to split the block sequence into a configuration block and a transaction block sequence;
  • the commit module is configured to perform transaction commit operations on the configuration block and the transaction block in the transaction block sequence according to the sequence of the block sequence; for multiple transaction areas in the transaction block sequence
  • the transaction commit operation performed by the block includes: performing transaction signature verification on the multiple transaction blocks in parallel; performing multi-version check on each transaction block serially; writing the multiple transaction blocks simultaneously Into the disk.
  • a computer device includes a memory and one or more processors.
  • the memory stores computer readable instructions.
  • the computer readable instructions are executed by the one or more processors, the one or more Each processor implements the steps of the block processing method provided in any embodiment of the present application.
  • One or more non-volatile computer-readable storage media storing computer-readable instructions.
  • the computer-readable instructions When executed by one or more processors, the one or more processors implement any of the present application The steps of the block processing method provided in an embodiment.
  • Fig. 1 is an application scenario diagram of a block processing method according to one or more embodiments.
  • Fig. 2 is a schematic flowchart of a block processing method according to one or more embodiments.
  • FIG. 3 is a schematic flowchart of a block processing method in another embodiment.
  • FIG. 4 is a schematic flowchart of a transaction commit operation performed on multiple transaction blocks in a transaction block sequence according to one or more embodiments.
  • Fig. 5 is a block diagram of a block processing device according to one or more embodiments.
  • Figure 6 is a block diagram of a computer device according to one or more embodiments.
  • the block processing method provided in this application can be applied to the application environment shown in FIG. 1.
  • the data node 102 communicates with the consensus node 104 through the network.
  • the data node 102 obtains the transaction commit instruction, and queries the configuration block in the currently cached block sequence according to the obtained transaction commit instruction; when the configuration block is queried, the queried configuration block is used as the dividing reference point, and the current
  • the cached block sequence is divided into a configuration block and a transaction block sequence, and the transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence.
  • the transaction commit operation performed by the data node 102 for multiple transaction blocks in the transaction block sequence includes: performing transaction signature verification on multiple transaction blocks in parallel; performing transaction multi-version checks on each transaction block serially; Write multiple transaction blocks to disk at the same time.
  • the data node 102 receives the block sent by the consensus node 104 and caches the received block so that the data node 102 can execute the block processing method described above when it obtains the transaction commit instruction.
  • Both the data node 102 and the consensus node 104 correspond to a server, and the server can be implemented by an independent server or a server cluster composed of multiple servers.
  • the data node 102 and the data node 102 both belong to the blockchain network, and the blockchain network includes multiple data nodes 102 and multiple data nodes 102.
  • a data node is a server, and correspondingly, a consensus node is a server.
  • a block processing method is provided. Taking the method applied to the data node in FIG. 1 as an example, the method includes the following steps:
  • the transaction commit instruction is an instruction used to trigger the transaction commit operation. Specifically, when the previously executed transaction commit operation is completed, the data node detects in real time whether there is a block sequence to be processed currently in the cache. When a block sequence to be processed is detected in the cache, the data node triggers the generation of a transaction commit instruction corresponding to the block sequence.
  • the transaction commit operation performed last time may be a transaction commit operation performed on multiple transaction blocks in the configuration block, transaction block sequence, or currently cached block sequence. It is understandable that both the transaction block sequence and the block sequence can include a single transaction block.
  • the data node receives the block (transaction block or configuration block) sent by the consensus node, and caches the received block in the local cache.
  • the data node can cache the received block in the cache queue.
  • the data node sequentially caches the blocks in the cache queue according to their block numbers.
  • a block sequence is a block set composed of multiple blocks arranged according to their respective block numbers.
  • the block can be a transaction block or a configuration block.
  • the transaction block corresponds to the transaction block identifier
  • the configuration block corresponds to the configuration block identifier.
  • the transaction data in the transaction block corresponds to the business data.
  • the transaction data in the configuration block corresponds to the configuration data.
  • the configuration data refers to the data on which the data node performs the transaction commit operation on the transaction block or the configuration block, such as verification logic or rule parameters. For example, when the number of digital signatures that have passed the verification reaches the preset number threshold, it is determined that the signature verification result of the corresponding transaction is verified, and the verification logic or rule parameter may be the preset number threshold.
  • the data node queries the currently cached block sequence in the cache or cache queue according to the acquired transaction commit instruction, and according to the pre-configured configuration block sequence identifier, the current cache Query the configuration block in the block sequence to determine whether there is a configuration block in the currently cached block sequence according to the query result.
  • the transaction block sequence is a block set composed of multiple transaction blocks arranged according to their respective block numbers.
  • the transaction block sequence may specifically be a block set composed of multiple transaction blocks with continuous block numbers arranged according to their respective block numbers.
  • the data node uses the queried configuration block as a dividing reference point to divide the block sequence into a configuration block and a transaction block sequence. It is understandable that one or more transaction block sequences can be obtained by dividing the block sequence with the configuration block as the dividing reference point.
  • the data node when the queried configuration block is located at the critical position (starting position or end position) of the block sequence, the data node divides the block sequence into configuration blocks and a transaction block sequence. When the queried configuration block is located in the middle of the block sequence, the data node divides the block sequence into a configuration block and two transaction block sequences. It is understandable that when multiple configuration blocks are queried in the currently cached block sequence, the data node uses the multiple configuration blocks as the dividing reference point to divide the block sequence into multiple configuration blocks and Sequence of multiple transaction blocks.
  • the block sequence includes blocks a, b, c, d, e, and f
  • d is the configuration block.
  • the transaction block sequence X including transaction Blocks a, b, and c
  • transaction block sequence Y including transaction blocks e and f.
  • S208 Perform transaction commit operations on the configuration block and transaction blocks in the transaction block sequence respectively in the order of the block sequence; the transaction commit operations performed on multiple transaction blocks in the transaction block sequence include: Transaction signature verification is performed on multiple transaction blocks; multiple transaction versions are checked for each transaction block serially; multiple transaction blocks are simultaneously written to the disk.
  • Transaction signature verification refers to verifying whether the digital signature corresponding to the transaction in the block meets the preset signature conditions.
  • the preset signature condition for example, the number of digital signatures that have passed the verification reaches a preset number threshold.
  • Transaction multi-version checking refers to checking whether the target data version number contained in the transaction in the block is consistent with the corresponding latest data version number.
  • the data nodes when the currently cached block sequence is divided into a configuration block and a transaction block sequence, the data nodes respectively perform the configuration block and transaction block sequence according to the order of the configuration block and transaction block sequence in the block sequence.
  • the transaction block in the block sequence performs the transaction commit operation.
  • the transaction commit operation performed for the configuration block includes: the data node performs transaction signature verification on the transaction in the configuration block; when the transaction signature verification step is completed, the data node performs multiple transactions on the transaction in the configuration block Version check: When the multi-version check step of the transaction is completed, the data node calls the preset write interface to write the configuration block to the disk, that is, write the configuration block to the corresponding blockchain.
  • the data node when the transaction signature verification step is executed, the data node writes the signature verification result into the configuration block, and performs multiple transactions for the transaction whose signature verification result in the configuration block is verified. Version check; when the result of the multi-version check is passed, the data node updates its configuration data according to the transaction data corresponding to the transaction that passed the check, so that the data node can use the updated configuration data for all subsequent configuration blocks. Configure the block or transaction block to perform transaction commit operations. Correspondingly, the data node writes the multi-version check result into the configuration block, and writes the configuration block to the disk,
  • the transaction commit operation performed on multiple transaction blocks in the transaction block sequence includes: the data node performs transaction signature verification on the multiple transaction blocks in parallel through multiple verification threads; When the transaction signature verification steps performed by the transaction block are all executed, the data node serially performs multi-version check on each transaction block through a single check thread, that is, the data node performs multi-version check on each transaction block according to the multiple transaction blocks.
  • the transaction multi-version check is performed on each transaction block in turn; when the transaction multi-version check for each transaction block is sequentially executed, the data node calls the preset write interface to write the multiple transaction blocks Disk.
  • the preset write interface may specifically be a preset batch write interface, and the data node can call the batch write interface to write multiple transaction blocks into the disk at one time.
  • the data node determines the number of check threads equal to the number of transaction blocks, and compares the number of check threads in the transaction block sequence Each transaction block is allocated to a corresponding verification thread to perform transaction signature verification on the allocated transaction block in parallel by the verification thread of the number of transaction blocks.
  • the data node determines the preset number of verification threads, and allocates multiple transaction blocks in the transaction block sequence to the preset number of verification threads to pass the preset number.
  • a number of verification threads perform transaction signature verification on the allocated transaction blocks in parallel.
  • the data node first performs transaction commit operations on transaction blocks a, b, and c in the transaction block sequence X according to the sequence of the block sequence; when the transaction commit operation for the transaction block sequence X is completed, the data The node performs transaction commit operation on configuration block d, and updates its own configuration data according to the configuration data in configuration block d; when the transaction commit operation for configuration block d is completed, the data node performs transaction block sequence Y
  • the transaction blocks e and f perform transaction commit operations.
  • the data node may receive the consensus The block sent by the node (transaction block or configuration block), and the received block is cached as a new block. Therefore, the transaction block sequence Y may also include blocks newly added during the transaction commit operation on the transaction block sequence X and the configuration block d.
  • the data node can use transaction block sequence Y as the currently cached block sequence, and query whether there is a configuration block in the currently cached block sequence according to the above query method, According to the query result, the transaction commit operation is performed on the block sequence according to the method provided in the corresponding embodiment of this application.
  • the configuration block is queried in the currently cached block sequence according to the acquired transaction commit instruction.
  • the configuration block is used as a partition
  • the currently cached block sequence is divided into a configuration block and a transaction block sequence, and the transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence according to the sequence of the block sequence.
  • the transaction commit operation performed in sequence for multiple transaction blocks in the transaction block sequence includes: performing transaction signature verification on multiple transaction blocks in parallel; performing transaction multi-version checks on each transaction block serially; A transaction block is written to the disk at the same time.
  • the overall efficiency of signature verification is improved, thereby improving the processing efficiency of the block.
  • the multiple transaction blocks are written to the disk at the same time, which improves the overall submission efficiency of transactions in the transaction block, thereby further improving the block processing efficiency. Further, writing multiple transaction blocks to the disk at the same time improves the overall throughput of the blockchain system, thereby saving computer resources.
  • performing transaction signature verification on multiple transaction blocks in parallel includes: determining the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the corresponding server; Multiple verification threads are allocated according to the number; multiple verification threads are used to perform transaction signature verification on multiple transaction blocks in parallel.
  • the data node obtains the number of transaction blocks in the transaction block sequence and the number of CPU cores of its corresponding server, determines the number of verification threads according to the number of transaction blocks and the number of CPU cores of the server, and determines the number and the number of cores. Multiple verification threads with the same number of verification threads.
  • the service node allocates multiple transaction blocks in the transaction block sequence to the multiple verification threads, so as to perform transaction signature verification on the multiple transaction blocks in parallel through the multiple verification threads.
  • the data node is a server
  • the number of CPU cores of the server corresponding to the data node itself is the number of CPU cores of the data node itself.
  • the data node determines the threshold of the number of check threads that the server is allowed to carry according to the number of CPU cores of the server, and compares the threshold with the number of transaction blocks. When the number of transaction blocks is less than or equal to the number threshold, the data node determines the number of transaction blocks as the number of verification threads; when the number of transaction blocks is greater than the number threshold, the data node determines the number threshold as the verification thread quantity.
  • the threshold of the number of check threads that the server is allowed to carry is determined according to the number of CPU cores. If the number of transaction blocks in the transaction block sequence is 5, the number of check threads determined according to the number of CPU cores and the number of transaction blocks is 5, and 5 transaction blocks are distributed to the 5 check threads in parallel Perform transaction signature verification; if the number of transaction blocks is 10, the number of verification threads is determined to be 6, and the 10 transaction blocks are distributed to the 6 verification threads to perform transaction signature verification in parallel. For example, 4 verification threads are allocated 2 transaction blocks, and 2 verification threads are allocated 1 transaction block.
  • the data node may create corresponding multiple verification threads according to the number of verification threads, or obtain multiple idle threads from the thread pool according to the number, as the multiple verification threads allocated.
  • the number of verification threads is determined according to the number of transaction blocks to be processed and the number of CPU cores of the corresponding server, so that the number of verification threads can perform transaction signature verification on multiple transaction blocks in parallel.
  • the computer resources are fully utilized, the efficiency of transaction signature verification is improved, and the efficiency of block sorting and processing is improved.
  • performing transaction signature verification on multiple transaction blocks in parallel through multiple verification threads includes: allocating multiple transaction blocks to multiple verification threads; The allocated transaction block is analyzed to obtain multiple transactions corresponding to the analyzed transaction block; transaction signature verification is performed on each transaction in turn according to the order of the multiple transactions in the transaction block.
  • the data node allocates multiple transaction blocks in the transaction block sequence to the multiple verification threads. For the transaction block that has been allocated to each verification thread, the data node analyzes its own allocated transaction block in parallel through each verification thread, and obtains multiple transactions corresponding to the analyzed transaction block, and according to the multiple The order of the transaction in the corresponding transaction block, and the transaction signature verification for each transaction in the multiple transactions in turn.
  • the data node allocates the multiple transaction blocks to the determined multiple verification threads at the same time in accordance with the principle of equal distribution or proportional distribution, and uses each verification thread to allocate the multiple
  • the transaction block performs transaction signature verification serially.
  • the data node uses each verification thread to assign multiple transaction blocks to itself, according to the ordering of the multiple transaction blocks in the transaction block sequence (or the block number corresponding to the transaction block), and sequentially Each transaction block in the plurality of transaction blocks performs transaction signature verification.
  • the steps of performing transaction signature verification on each transaction block include: parsing the transaction block to obtain multiple transactions, and sequentially performing transaction signature verification on each transaction according to the order of the transactions in the transaction block.
  • the data node extracts a transaction block equal to the number of verification threads from the transaction block sequence in the order of the transaction block sequence, and allocates the extracted transaction block to the corresponding verification thread , To perform transaction signature verification on the extracted multiple transaction blocks in parallel through the multiple verification threads.
  • the data node detects the check thread in the idle state in real time, extracts from the transaction block sequence the transaction block that has not yet been subjected to the transaction commit operation and is sorted first, and allocates it to the check thread in the idle state.
  • multiple transaction blocks are allocated to multiple verification threads, so that each verification thread performs transaction signature verification on transactions in the allocated transaction block in parallel, which improves transaction signature verification. Therefore, the processing efficiency of the block is improved.
  • allocating multiple transaction blocks to multiple verification threads includes: creating a block cache queue corresponding to each verification thread; and allocating multiple transaction blocks to each block according to a preset allocation method The cache queue is used as a transaction block allocated to the corresponding verification thread.
  • the preset allocation method for example, allocates multiple transaction blocks to multiple created block cache queues according to the principle of equal allocation or proportional allocation.
  • the data node when multiple verification threads are allocated according to the number of verification threads, the data node creates a block cache queue whose number is equal to the number of verification threads, and the created block cache queue corresponds to the verification thread respectively.
  • the data node allocates multiple transaction blocks in the transaction block sequence to the created block cache queue for caching according to a preset allocation method, so that each verification thread can read from the corresponding block cache queue in parallel Transaction block, and perform transaction signature verification on the read transaction block.
  • the data node when the number of transaction blocks in the transaction block sequence is greater than the specified number, allocates the specified number of transaction blocks that are ranked higher in the transaction block sequence to the multiple created regions
  • the block cache queue is cached to read transaction blocks from the corresponding block cache queue in parallel through each verification thread and perform transaction signature verification.
  • the specified number is determined by the number of CPU cores of the server and the threshold of the number of transaction blocks allowed by each verification thread.
  • the threshold of the number of verification threads allowed by the server is determined according to the number of CPU cores, and the calculation of the verification thread
  • the product of the number threshold and the number threshold of the transaction block corresponding to the number of each verification thread is the specified number.
  • the transaction block is allocated to the block cache queue corresponding to each verification thread for caching, so that each verification thread reads the transaction block cached in the block cache queue in parallel, and signs the transaction Verification improves the efficiency of transaction block allocation, thereby improving the efficiency of transaction signature verification.
  • each transaction is parsed in turn according to the ordering of multiple transactions in the transaction block to obtain transaction data and digital signature arrays corresponding to the parsed transactions; the digital signature array is parsed to obtain multiple digital signatures and digital signatures.
  • the public key corresponding to the signature decrypt the corresponding digital signature according to each public key to obtain the decrypted digital signature; generate the transaction hash value according to the transaction data, and based on the transaction hash value and each decrypted digital signature, respectively
  • Each digital signature is verified; when the number of digital signatures that have passed the verification reaches a preset number threshold, it is determined that the signature verification result corresponding to the parsed transaction is a verification pass.
  • Transaction data is data corresponding to the transaction in the transaction block.
  • the transaction data includes the business data to be updated (may be called target data) and the updated business data (may be called update data), and the data identifier corresponding to the business data, and may also include the target data version number corresponding to the target data.
  • the data identifier corresponding to the business data can be used as the corresponding transaction data and/or the transaction data identifier corresponding to the transaction. It is understandable that the transaction data identifier corresponds to one or more transaction data (and/or transactions), that is, the corresponding one or more transactions can be queried in the blockchain according to the transaction data identifier, and the corresponding transaction data Transaction data.
  • the preset number threshold is a preset value, such as 2.
  • the digital signature array includes one or more digital signatures, and may also include a decryption key (public key or private key) corresponding to each digital signature.
  • the decryption key and the encryption key form a key pair. For example, if the encryption key is a private key, the decryption key is the public key corresponding to the private key.
  • a digital signature is a data ciphertext obtained by encrypting transaction data using an encryption algorithm, for example, using a public key and a private key to encrypt transaction data to obtain a digital signature. Encryption algorithms such as symmetric encryption algorithms and asymmetric encryption algorithms.
  • Symmetric encryption algorithm such as DES (Data Encryption Standard, symmetric algorithm), AES (Advanced Encryption Standard, Advanced Encryption Standard), or IDEA (International Data Encryption Algorithm, International Data Encryption Algorithm), etc.
  • Asymmetric encryption algorithms such as RSA (Rivest, Shamir, Adleman, encryption algorithm), DSA (Digital Signature Algorithm, digital signature algorithm), or ECC (Elliptic curve cryptography, elliptic curve encryption algorithm), etc.
  • the data node uses the verification thread according to the order of the multiple transactions in the transaction block to order the Each transaction in multiple transactions is analyzed, and transaction data and digital signature array corresponding to the analyzed transaction are obtained.
  • the data node parses the digital signature array through the verification thread to obtain the corresponding multiple digital signatures and the public key corresponding to each digital signature, and decrypts the corresponding digital signature according to each public key to obtain the decrypted digital signature.
  • the data node uses the verification thread to hash the parsed transaction data based on the hash algorithm to obtain the transaction hash value, and compare the transaction hash value with each decrypted digital signature to compare As a result, the corresponding digital signature is verified.
  • the transaction hash value is consistent with the decrypted digital signature, it indicates that the verification result of the corresponding digital signature is a verification pass.
  • the data node counts the verification result as the number of digital signatures that have passed the verification through the verification thread. When the counted number is greater than or equal to the preset number threshold, it is determined that the signature verification result of the corresponding transaction is the verification passed.
  • Commonly used hash algorithms such as MD5 (Message Digest Algorithm, fifth edition of message digest algorithm), SHA1 (Secure Hash Algorithm, secure hash algorithm), and SHA2, are not specifically limited in this embodiment.
  • the digital signature array includes a single digital signature and corresponding public key, and the preset number threshold is 1. Similar to the above transaction signature verification steps, the data node verifies the digital signature through the verification thread. When the verification result of the digital signature is a verification pass, it is determined that the signature verification result of the corresponding transaction is verification. by.
  • the data node receives the signature request sent by the blockchain client, obtains the transaction data to be signed according to the signature request, and hashes the transaction data to be signed by the hash algorithm to obtain the transaction hash value (can be Understand as a digest), use its own private key to encrypt the transaction hash value to obtain a digital signature, and feed the digital signature and its own public key to the blockchain client.
  • the blockchain client detects the business data in real time, uses the detected business data as the transaction data to be signed, and sends the transaction data to be signed to multiple data nodes for digital signature according to the signature configuration, and the multiple The digital signatures and public keys fed back by each data node are spliced to obtain a digital signature array.
  • the blockchain client obtains the transaction according to the transaction data and the corresponding digital signature array, and sends the transaction to the consensus node for consensus.
  • the consensus node performs a consensus on the received transaction based on the consensus mechanism, generates a corresponding block according to the transaction passed by the consensus, and sends the generated block to the data node, so that the data node is based on the information provided in the foregoing embodiments
  • the block processing method writes the block into the block chain.
  • the blockchain client, data node, and consensus node all belong to the blockchain network, and the blockchain network may include multiple blockchain clients, data nodes, and consensus nodes.
  • the transaction signature verification is performed on the transaction based on the digital signature array and the transaction hash value to ensure the authenticity, validity and reliability of the corresponding transaction data.
  • performing transaction multi-version checking on each transaction block in series includes: according to the sequence of the transaction block sequence, sequentially performing the following transaction multi-version checking steps on multiple transactions in each transaction block : Analyze each transaction in turn according to the order of multiple transactions in the transaction block to obtain the transaction data identifier and target data version number corresponding to the parsed transaction; query the latest data version number corresponding to the transaction data identifier; when the latest data version When the number is consistent with the target data version number, it is determined that the multi-version check result of the parsed transaction is passed.
  • the data node sequentially performs the multiple transaction blocks according to the order of the multiple transaction blocks in the transaction block sequence.
  • Each transaction block in each transaction block performs transaction multi-version check.
  • the data node performs transaction multi-version check on the transaction block.
  • the data node performs transaction multi-version check for multiple transactions in the transaction block, which specifically includes the following steps: the data node parses the transaction block to obtain the corresponding multiple transactions , According to the order of the multiple transactions in the transaction block, analyze each transaction in the multiple transactions in turn to obtain the transaction data identifier and target data version number corresponding to the analyzed transaction.
  • the data node queries the corresponding latest data version number in the blockchain and/or local cache according to the transaction data identifier, and compares the latest data version number found with the target data version number. When the latest data version number is consistent with the target data version number, the data node determines that the multi-version check result of the corresponding transaction is passed.
  • the data node queries the corresponding latest data version number in the cache according to the parsed transaction data identifier, and performs the above-mentioned transaction multi-version check operation according to the latest data version number found.
  • the data node queries the latest data version number from the blockchain that has been written to the disk, and executes the above transaction based on the latest data version number queried. Version check operation.
  • each transaction block corresponds to a block number
  • the block number can be used to characterize the order of the transaction block in the transaction block sequence, block sequence, or corresponding blockchain.
  • Each transaction in the transaction block corresponds to a transaction number, and the transaction number is used to characterize the order of each transaction in the corresponding transaction block.
  • the data node When the multi-version check result of a transaction is passed, the data node generates a corresponding data version number according to the transaction number and block number corresponding to the transaction, which is used as the corresponding transaction data to identify the current corresponding latest data version number.
  • the data node When the multi-version check result of the transaction is that the check fails, the data node will mark the multi-version check result and will not generate the corresponding data version number, that is, the data version number corresponding to the transaction data identifier corresponding to the transaction will not be updated .
  • the data node when the transaction signature verification operation performed for each transaction in the transaction block is completed, marks the transaction according to the signature verification result corresponding to the transaction.
  • the data node performs multi-version check on the transaction whose signature verification result is the verification result according to the signature verification result marked for the transaction, and according to the transaction corresponding
  • the multi-version check result marks the transaction. It is understandable that the data node writes multiple transactions in each transaction block, as well as the signature verification results and multi-version verification results corresponding to each transaction, into the blockchain.
  • the data node may mark a transaction whose signature verification result is that the verification fails and/or the multi-version check result is that the verification fails as an invalid transaction.
  • the data node may specifically perform the above-mentioned transaction multi-version check step on multiple transactions in each transaction block in the order of the transaction block sequence through a single check thread.
  • multi-version concurrency control is achieved through multi-version checking operations, so as to avoid the problem of data update errors caused when the same target data is modified by different users or different operations at the same time, and to ensure the accuracy and consistency of transaction data.
  • the block processing method described above further includes: when the configuration block is not found, directly perform the following transaction commit operation on multiple transaction blocks in the block sequence: Transaction signature verification is performed on each transaction block; transaction multi-version check is performed on each transaction block serially; multiple transaction blocks are simultaneously written to the disk.
  • the data node uses the currently cached block sequence as a transaction block sequence and targets multiple transaction areas in the transaction block sequence.
  • the block performs the following transaction commit operations: transaction signature verification is performed on multiple transaction blocks in parallel through multiple verification threads; when the transaction signature verification operations performed for each transaction block are all executed, follow the transaction block
  • the sequence of the sequence is to perform transaction multi-version checks on each transaction block serially; when the transaction multi-version check performed for each transaction block is executed sequentially, the preset write interface is called to write the multiple transaction blocks at the same time Disk.
  • the data node in the process of sequentially performing transaction multi-version checks for multiple transaction blocks in the transaction block sequence, caches the transaction blocks that have performed transaction multi-version checks locally, so as to facilitate the When the multi-version checks of the transactions that are executed in sequence are all executed, the multiple transaction blocks are directly read from the cache, which improves the reading efficiency and thus the writing efficiency.
  • the data node determines the block sequence as a transaction block sequence, and is based on the transaction block sequence provided in the foregoing embodiments.
  • the transaction executed by the block is submitted for processing.
  • a block processing method which specifically includes the following steps:
  • S308 Perform transaction commit operations on the configuration block and transaction blocks in the transaction block sequence respectively in the order of the block sequence; the transaction commit operations performed on multiple transaction blocks in the transaction block sequence include: Transaction signature verification is performed on multiple transaction blocks; multiple transaction versions are checked for each transaction block serially; multiple transaction blocks are simultaneously written to the disk.
  • S310 When the configuration block is not queried, directly perform the following transaction commit operations on multiple transaction blocks in the block sequence: perform transaction signature verification on multiple transaction blocks in parallel; and perform transaction signature verification on multiple transaction blocks in series; Block multi-version checking of transactions; write multiple transaction blocks to disk at the same time.
  • the corresponding block processing procedures are provided for the two cases of whether the currently cached block sequence contains configuration blocks, and the block sequence and the divided transaction block sequence are processed in batches. , Improve the efficiency of block processing.
  • the transaction commit operation performed by the data node for multiple transaction blocks in the transaction block sequence includes the following steps:
  • S402 Determine the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the corresponding server.
  • S406 Create a block buffer queue corresponding to each verification thread.
  • S408 Allocate multiple transaction blocks to each block cache queue according to a preset allocation method, as transaction blocks allocated to corresponding verification threads.
  • S410 Analyze the allocated transaction block by each verification thread to obtain multiple transactions corresponding to the analyzed transaction block.
  • S412 Analyze each transaction in turn according to the order of multiple transactions in the transaction block to obtain transaction data and a digital signature array corresponding to the analyzed transaction.
  • S414 Parse the digital signature array to obtain multiple digital signatures and public keys corresponding to each digital signature.
  • S416 Decrypt the corresponding digital signature according to each public key to obtain a decrypted digital signature.
  • S418 Generate a transaction hash value according to the transaction data, and verify each digital signature based on the transaction hash value and each decrypted digital signature.
  • S422 According to the order of the transaction block sequence, sequentially analyze the multiple transactions in each transaction block according to the order of the multiple transactions in the transaction block to obtain the transaction data identifier and the transaction data corresponding to the analyzed transaction. Target data version number.
  • S424 Query the latest data version number corresponding to the transaction data identifier.
  • S428 Write multiple transaction blocks into the disk at the same time.
  • the transaction signature verification is performed on multiple transaction blocks in parallel, which improves the overall efficiency of transaction signature verification.
  • the serial multi-version check ensures the correctness and consistency of transaction data. Transaction blocks are written to the disk at the same time, reducing the number of calls of the blockchain network system, improving the overall throughput of the system, improving the submission efficiency of transaction blocks, and saving computer resources. As a result, the overall block processing efficiency is improved.
  • the block processing method provided in the above embodiments can be applied to the alliance chain, and can also be applied to the public chain or the private chain.
  • the consensus node and the data node may be the same blockchain node, and the consensus node and the data node may correspond to the same server or server cluster.
  • a block processing device 500 which includes: an acquisition module 502, a query module 504, a segmentation module 506, and a submission module 508, wherein:
  • the obtaining module 502 is used to obtain a transaction commit instruction.
  • the query module 504 is used to query the configuration block in the currently cached block sequence according to the transaction commit instruction.
  • the dividing module 506 is used to divide the block sequence into the configuration block and the transaction block sequence when the configuration block is queried, using the queried configuration block as the dividing reference point.
  • the commit module 508 is used to perform transaction commit operations on the configuration block and transaction blocks in the transaction block sequence according to the sequence of the block sequence; the transaction commit operations performed for multiple transaction blocks in the transaction block sequence include : Perform transaction signature verification on multiple transaction blocks in parallel; perform transaction multi-version check on each transaction block serially; write multiple transaction blocks into the disk at the same time.
  • the commit module 508 is further configured to determine the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of its corresponding server; and to allocate multiple verification threads according to the number; Multiple verification threads perform transaction signature verification on multiple transaction blocks in parallel.
  • the commit module 508 is also used to allocate multiple transaction blocks to multiple verification threads; each verification thread analyzes the allocated transaction blocks by each verification thread to obtain the resolved transaction block correspondence A number of transactions; according to the order of multiple transactions in the transaction block, transaction signature verification is performed on each transaction.
  • the commit module 508 is also used to parse each transaction in turn according to the ordering of multiple transactions in the transaction block to obtain transaction data and digital signature array corresponding to the parsed transaction; parse the digital signature array to obtain Multiple digital signatures and public keys corresponding to each digital signature; decrypt the corresponding digital signature according to each public key to obtain the decrypted digital signature; generate transaction hash value based on transaction hash value and each decryption After the digital signature, each digital signature is verified separately; when the number of digital signatures that have passed the verification reaches the preset number threshold, it is determined that the signature verification result corresponding to the parsed transaction is the verification passed.
  • the submission module 508 is also used to create a block cache queue corresponding to each verification thread; to allocate multiple transaction blocks to each block cache queue according to a preset allocation method, as the allocation to the corresponding school The transaction block of the verification thread.
  • the commit module 508 is also used to perform the following transaction multi-version check steps on multiple transactions in each transaction block in sequence according to the order of the transaction block sequence: The sorting in parses each transaction in turn to obtain the transaction data ID and target data version number corresponding to the parsed transaction; query the latest data version number corresponding to the transaction data ID; when the latest data version number is consistent with the target data version number, It is determined that the result of the multi-version check of the parsed transaction is passed.
  • the commit module 508 is also used to directly perform the following transaction commit operations on multiple transaction blocks in the block sequence when the configuration block is not queried: perform multiple transaction blocks in parallel Transaction signature verification; serially perform transaction multi-version check on each transaction block; write multiple transaction blocks to the disk at the same time.
  • each module in the block processing device described above can be implemented in whole or in part by software, hardware, and a combination thereof.
  • the foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
  • a computer device is provided.
  • the computer device may be a server corresponding to a data node, and its internal structure diagram may be as shown in FIG. 6.
  • the computer equipment includes a processor, a memory, a network interface and a database connected through a system bus.
  • the processor of the computer device is used to provide calculation and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer readable instructions, and a database.
  • the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium.
  • the database of the computer device is used to store a block sequence, and the stored block sequence includes configuration blocks and/or transaction blocks.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer readable instructions are executed by the processor to realize a block processing method.
  • FIG. 6 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied.
  • the specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
  • a computer device including a memory and one or more processors.
  • the memory stores computer readable instructions.
  • the computer readable instructions are executed by one or more processors, the one or more processors can realize any one of the present application.
  • One or more non-volatile computer-readable storage media storing computer-readable instructions.
  • the one or more processors implement any one of the embodiments of the present application. Provides the steps of the block processing method. In one of the embodiments in one of the embodiments
  • Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory may include random access memory (RAM) or external cache memory.
  • RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM double data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous chain Channel
  • memory bus Radbus direct RAM
  • RDRAM direct memory bus dynamic RAM
  • RDRAM memory bus dynamic RAM

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Human Computer Interaction (AREA)
  • Computer Security & Cryptography (AREA)
  • Computational Linguistics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A block processing method, comprising: acquiring a transaction commit instruction; querying the current cached block sequence for a configuration block according to the transaction commit instruction; when the configuration block is found, segmenting, by using the found configuration block as a segmentation reference point, the block sequence into a configuration block and a transaction block sequence; performing transaction commit operations on the configuration block and the transaction blocks in the transaction block sequence in the order of the block sequence; wherein the transaction commit operations performed on the plurality of transaction blocks in the transaction block sequence comprise: performing, in parallel, transaction signature verifications on the plurality of transaction blocks; serially performing multi-version transaction checks on each of the transaction blocks; and concurrently writing the plurality of transaction blocks into a disk.

Description

区块处理方法、装置、计算机设备和存储介质Block processing method, device, computer equipment and storage medium
本申请要求于2019年05月20日提交中国专利局,申请号为2019104201125,申请名称为“区块处理方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on May 20, 2019, the application number is 2019104201125, and the application name is "block processing method, device, computer equipment and storage medium", the entire content of which is by reference Incorporated in this application.
技术领域Technical field
本申请涉及一种区块处理方法、装置、计算机设备和存储介质。This application relates to a block processing method, device, computer equipment and storage medium.
背景技术Background technique
区块链通常被理解为一个分布式账本,本质上是一个基于区块的分布式数据库。区块链包括用于机构间的联盟链,通常基于密码学中的签名加密和验签解码来实现联盟链的隐私保护机制,以使得只有特定群体的成员和有限的第三方才能根据权限查看区块事务。联盟链的区块事务提交过程包括签名验证、多版本检查和事务持久化三个步骤。Blockchain is usually understood as a distributed ledger, essentially a block-based distributed database. Blockchain includes consortium chains used between institutions. The privacy protection mechanism of consortium chains is usually realized based on signature encryption and verification and decoding in cryptography, so that only members of specific groups and limited third parties can view the area according to their authority. Block transaction. The block transaction submission process of the alliance chain includes three steps: signature verification, multi-version checking and transaction persistence.
目前,对于共识节点生成并发送的区块一个或多个区块,数据节点通常通过单线程按照区块的生成顺序依次对每个区块中的事务执行事务提交过程。然而,发明人意识到,数据节点通过单线程执行区块的事务提交过程时,通常仅能处理较少的事务,降低了区块链系统的整体吞吐量,浪费了数据节点所在服务器的计算机资源。尤其是在区块仅包含较少事务时,进一步降低了区块链系统的整体吞吐量,降低了区块事务的提交效率,从而降低了区块处理效率。At present, for one or more blocks generated and sent by the consensus node, the data node usually executes the transaction commit process for the transactions in each block in sequence according to the block generation order through a single thread. However, the inventor realized that when a data node executes the transaction submission process of a block through a single thread, it can usually only process fewer transactions, which reduces the overall throughput of the blockchain system and wastes the computer resources of the server where the data node is located. . Especially when the block contains only a few transactions, the overall throughput of the blockchain system is further reduced, and the submission efficiency of block transactions is reduced, thereby reducing the efficiency of block processing.
发明内容Summary of the invention
根据本申请公开的各种实施例,提供一种区块处理方法、装置、计算机设备和存储介质。According to various embodiments disclosed in the present application, a block processing method, device, computer equipment, and storage medium are provided.
一种区块处理方法包括:A block processing method includes:
获取事务提交指令;Obtain transaction commit instructions;
根据所述事务提交指令在当前缓存的区块序列中查询配置区块;Query the configuration block in the currently cached block sequence according to the transaction commit instruction;
当查询到所述配置区块时,以查询到的所述配置区块为分割基准点,将所述区块序列分割为配置区块和事务区块序列;及When the configuration block is queried, the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a division reference point; and
按照所述区块序列的顺序分别对所述配置区块和所述事务区块序列中的事务区块执行事务提交操作;针对所述事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。A transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence; transaction commit performed on multiple transaction blocks in the transaction block sequence The operations include: performing transaction signature verification on the plurality of transaction blocks in parallel; performing transaction multi-version checking on each of the transaction blocks serially; and simultaneously writing the plurality of transaction blocks to a disk.
一种区块处理装置包括:A block processing device includes:
获取模块,用于获取事务提交指令;Obtaining module for obtaining transaction commit instructions;
查询模块,用于根据所述事务提交指令在当前缓存的区块序列中查询配置区块;The query module is used to query the configuration block in the currently cached block sequence according to the transaction commit instruction;
分割模块,用于当查询到所述配置区块时,以查询到的所述配置区块为分割基准点,将所述区块序列分割为配置区块和事务区块序列;及The segmentation module is used to, when the configuration block is queried, use the queried configuration block as a splitting reference point to split the block sequence into a configuration block and a transaction block sequence; and
提交模块,用于按照所述区块序列的顺序分别对所述配置区块和所述事务区块序列中的事务区块执行事务提交操作;针对所述事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。The commit module is configured to perform transaction commit operations on the configuration block and the transaction block in the transaction block sequence according to the sequence of the block sequence; for multiple transaction areas in the transaction block sequence The transaction commit operation performed by the block includes: performing transaction signature verification on the multiple transaction blocks in parallel; performing multi-version check on each transaction block serially; writing the multiple transaction blocks simultaneously Into the disk.
一种计算机设备,包括存储器和一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器实现本申请任意一个实施例中提供的区块处理方法的步骤。A computer device includes a memory and one or more processors. The memory stores computer readable instructions. When the computer readable instructions are executed by the one or more processors, the one or more Each processor implements the steps of the block processing method provided in any embodiment of the present application.
一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器实现本申请任意一个实施例中提供的区块处理方法的步骤。One or more non-volatile computer-readable storage media storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors implement any of the present application The steps of the block processing method provided in an embodiment.
本申请的一个或多个实施例的细节在下面的附图和描述中提出。本申请的其它特征和优点将从说明书、附图以及权利要求书变得明显。The details of one or more embodiments of the application are set forth in the following drawings and description. Other features and advantages of this application will become apparent from the description, drawings and claims.
附图说明Description of the drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其它的附图。In order to more clearly describe the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work.
图1为根据一个或多个实施例中区块处理方法的应用场景图。Fig. 1 is an application scenario diagram of a block processing method according to one or more embodiments.
图2为根据一个或多个实施例中区块处理方法的流程示意图。Fig. 2 is a schematic flowchart of a block processing method according to one or more embodiments.
图3为另一个实施例中区块处理方法的流程示意图。FIG. 3 is a schematic flowchart of a block processing method in another embodiment.
图4为根据一个或多个实施例中对事务区块序列中的多个事务区块执行事务提交操作的流程示意图。FIG. 4 is a schematic flowchart of a transaction commit operation performed on multiple transaction blocks in a transaction block sequence according to one or more embodiments.
图5为根据一个或多个实施例中区块处理装置的框图。Fig. 5 is a block diagram of a block processing device according to one or more embodiments.
图6为根据一个或多个实施例中计算机设备的框图。Figure 6 is a block diagram of a computer device according to one or more embodiments.
具体实施方式Detailed ways
为了使本申请的技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处描述的具体实施例仅仅用以解释本申请,并不用于限定本申请。In order to make the technical solutions and advantages of the present application clearer, the following further describes the present application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described here are only used to explain the application, and not used to limit the application.
本申请提供的区块处理方法,可以应用于如图1所示的应用环境中。数据节点102通 过网络与共识节点104进行通信。数据节点102获取事务提交指令,根据获取到的事务提交指令在当前缓存的区块序列中查询配置区块;当查询到配置区块时,以查询到的配置区块为分割基准点,将当前缓存的区块序列分割为配置区块和事务区块序列,并按照区块序列的顺序分别对配置区块和事务区块序列中的事务区块执行事务提交操作。数据节点102针对事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。可以理解的是,数据节点102接收共识节点104发送的区块,并将接收到的区块进行缓存,以便于数据节点102在获取到事务提交指令时执行上述区块处理方法。数据节点102和共识节点104均与服务器相对应,服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。数据节点102和数据节点102同属于区块链网络,区块链网络中包括多个数据节点102和多个数据节点102。在其中一个实施例中,一个数据节点即为一个服务器,相应地,一个共识节点即为一个服务器。The block processing method provided in this application can be applied to the application environment shown in FIG. 1. The data node 102 communicates with the consensus node 104 through the network. The data node 102 obtains the transaction commit instruction, and queries the configuration block in the currently cached block sequence according to the obtained transaction commit instruction; when the configuration block is queried, the queried configuration block is used as the dividing reference point, and the current The cached block sequence is divided into a configuration block and a transaction block sequence, and the transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence. The transaction commit operation performed by the data node 102 for multiple transaction blocks in the transaction block sequence includes: performing transaction signature verification on multiple transaction blocks in parallel; performing transaction multi-version checks on each transaction block serially; Write multiple transaction blocks to disk at the same time. It is understandable that the data node 102 receives the block sent by the consensus node 104 and caches the received block so that the data node 102 can execute the block processing method described above when it obtains the transaction commit instruction. Both the data node 102 and the consensus node 104 correspond to a server, and the server can be implemented by an independent server or a server cluster composed of multiple servers. The data node 102 and the data node 102 both belong to the blockchain network, and the blockchain network includes multiple data nodes 102 and multiple data nodes 102. In one of the embodiments, a data node is a server, and correspondingly, a consensus node is a server.
在其中一个实施例中,如图2所示,提供了一种区块处理方法,以该方法应用于图1中的数据节点为例进行说明,包括以下步骤:In one of the embodiments, as shown in FIG. 2, a block processing method is provided. Taking the method applied to the data node in FIG. 1 as an example, the method includes the following steps:
S202,获取事务提交指令。S202: Obtain a transaction commit instruction.
事务提交指令是用于触发事务提交操作的指令。具体地,在前次执行的事务提交操作执行完毕时,数据节点实时检测缓存中当前是否缓存有待处理的区块序列。当在缓存中检测到待处理的区块序列时,数据节点触发生成与该区块序列对应的事务提交指令。The transaction commit instruction is an instruction used to trigger the transaction commit operation. Specifically, when the previously executed transaction commit operation is completed, the data node detects in real time whether there is a block sequence to be processed currently in the cache. When a block sequence to be processed is detected in the cache, the data node triggers the generation of a transaction commit instruction corresponding to the block sequence.
在其中一个实施例中,前次执行的事务提交操作可以是针对配置区块、事务区块序列或当前缓存的区块序列中的多个事务区块执行的事务提交操作。可以理解的是,事务区块序列和区块序列均可包括单个事务区块。In one of the embodiments, the transaction commit operation performed last time may be a transaction commit operation performed on multiple transaction blocks in the configuration block, transaction block sequence, or currently cached block sequence. It is understandable that both the transaction block sequence and the block sequence can include a single transaction block.
在其中一个实施例中,数据节点接收共识节点发送的区块(事务区块或配置区块),并将接收到的区块缓存在本地缓存中。数据节点可将接收到的区块缓存在缓存队列中。当同时接收到多个区块时,数据节点按照各自的区块编号依次将各区块缓存至缓存队列中。In one of the embodiments, the data node receives the block (transaction block or configuration block) sent by the consensus node, and caches the received block in the local cache. The data node can cache the received block in the cache queue. When multiple blocks are received at the same time, the data node sequentially caches the blocks in the cache queue according to their block numbers.
S204,根据事务提交指令在当前缓存的区块序列中查询配置区块。S204: Query the configuration block in the currently cached block sequence according to the transaction commit instruction.
区块序列是由多个区块按照各自的区块编号排列组成的区块集合。区块可以是事务区块或配置区块,事务区块与事务区块标识相对应,配置区块与配置区块标识相对应。事务区块中的事务数据与业务数据相对应。配置区块中的事务数据与配置数据相对应,配置数据是指数据节点对事务区块或配置区块执行事务提交操作时所依据的数据,比如校验逻辑或规则参数。举例说明,当校验通过的数字签名的数量达到预设数量阈值时,判定相应事务的签名校验结果为校验通过,则校验逻辑或规则参数可以是预设数量阈值。A block sequence is a block set composed of multiple blocks arranged according to their respective block numbers. The block can be a transaction block or a configuration block. The transaction block corresponds to the transaction block identifier, and the configuration block corresponds to the configuration block identifier. The transaction data in the transaction block corresponds to the business data. The transaction data in the configuration block corresponds to the configuration data. The configuration data refers to the data on which the data node performs the transaction commit operation on the transaction block or the configuration block, such as verification logic or rule parameters. For example, when the number of digital signatures that have passed the verification reaches the preset number threshold, it is determined that the signature verification result of the corresponding transaction is verified, and the verification logic or rule parameter may be the preset number threshold.
具体地,当获取到事务提交指令时,数据节点根据所获取到的事务提交指令在缓存或缓存队列中查询当前缓存的区块序列,并根据预配置的配置区块序列标识,在该当前缓存的区块序列中查询配置区块,以根据查询结果判定该当前缓存的区块序列中是否存在配置区块。Specifically, when the transaction commit instruction is acquired, the data node queries the currently cached block sequence in the cache or cache queue according to the acquired transaction commit instruction, and according to the pre-configured configuration block sequence identifier, the current cache Query the configuration block in the block sequence to determine whether there is a configuration block in the currently cached block sequence according to the query result.
S206,当查询到配置区块时,以查询到的配置区块为分割基准点,将区块序列分割为配置区块和事务区块序列。S206: When the configuration block is queried, the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a dividing reference point.
事务区块序列是由多个事务区块按照各自的区块编号排列组成的区块集合。事务区块序列具体可以是由区块编号连续的多个事务区块按照各自的区块编号排列组成的区块集合。The transaction block sequence is a block set composed of multiple transaction blocks arranged according to their respective block numbers. The transaction block sequence may specifically be a block set composed of multiple transaction blocks with continuous block numbers arranged according to their respective block numbers.
具体地,当在当前缓存的区块序列中查询到配置区块时,数据节点以查询到的配置区块为分割基准点,将该区块序列分割为配置区块和事务区块序列。可以理解的是,以配置区块为分割基准点对区块序列进行分割,可得到一个或多个事务区块序列。Specifically, when the configuration block is queried in the currently cached block sequence, the data node uses the queried configuration block as a dividing reference point to divide the block sequence into a configuration block and a transaction block sequence. It is understandable that one or more transaction block sequences can be obtained by dividing the block sequence with the configuration block as the dividing reference point.
在其中一个实施例中,当查询到的配置区块位于区块序列的临界位置(起始位置或末尾位置)时,数据节点将该区块序列分割为配置区块和一个事务区块序列。当查询到的配置区块位于区块序列的中间位置时,数据节点将该区块序列分割为配置区块和两个事务区块序列。可以理解的是,当在当前缓存的区块序列中查询到多个配置区块时,数据节点以该多个配置区块为分割基准点,将该区块序列分割为多个配置区块和多个事务区块序列。In one of the embodiments, when the queried configuration block is located at the critical position (starting position or end position) of the block sequence, the data node divides the block sequence into configuration blocks and a transaction block sequence. When the queried configuration block is located in the middle of the block sequence, the data node divides the block sequence into a configuration block and two transaction block sequences. It is understandable that when multiple configuration blocks are queried in the currently cached block sequence, the data node uses the multiple configuration blocks as the dividing reference point to divide the block sequence into multiple configuration blocks and Sequence of multiple transaction blocks.
举例说明,假设区块序列中包括区块a、b、c、d、e和f,d为配置区块,则根据将区块序列分割为配置区块d,事务区块序列X(包括事务区块a、b和c),以及事务区块序列Y(包括事务区块e和f)。For example, suppose the block sequence includes blocks a, b, c, d, e, and f, and d is the configuration block. According to dividing the block sequence into configuration block d, the transaction block sequence X (including transaction Blocks a, b, and c), and transaction block sequence Y (including transaction blocks e and f).
S208,按照区块序列的顺序分别对配置区块和事务区块序列中的事务区块执行事务提交操作;针对事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。S208: Perform transaction commit operations on the configuration block and transaction blocks in the transaction block sequence respectively in the order of the block sequence; the transaction commit operations performed on multiple transaction blocks in the transaction block sequence include: Transaction signature verification is performed on multiple transaction blocks; multiple transaction versions are checked for each transaction block serially; multiple transaction blocks are simultaneously written to the disk.
事务签名校验是指校验区块中的事务所对应的数字签名是否符合预设签名条件。预设签名条件比如校验通过的数字签名的数量达到预设数量阈值。事务多版本检查是指检查区块中的事务所包含的目标数据版本号是否与相应的最新数据版本号一致。Transaction signature verification refers to verifying whether the digital signature corresponding to the transaction in the block meets the preset signature conditions. The preset signature condition, for example, the number of digital signatures that have passed the verification reaches a preset number threshold. Transaction multi-version checking refers to checking whether the target data version number contained in the transaction in the block is consistent with the corresponding latest data version number.
具体地,在当前缓存的区块序列分割为配置区块和事务区块序列时,数据节点按照配置区块和事务区块序列在该区块序列中的排序,分别对配置区块和事务区块序列中的事务区块执行事务提交操作。针对配置区块执行的事务提交操作包括:数据节点对配置区块中的事务进行事务签名校验;当事务签名校验的步骤执行完毕时,数据节点对该配置区块中的事务进行事务多版本检查;当事务多版本检查的步骤执行完毕时,数据节点调用预设写入接口将该配置区块写入磁盘中,即将该配置区块写入相应的区块链中。可以理解的是,当事务签名校验的步骤执行完毕时,数据节点将签名校验结果写入该配置区块中,并对配置区块中签名校验结果为校验通过的事务进行事务多版本检查;当多版本检查结果为检查通过时,数据节点根据检查通过的事务所对应的事务数据更新自身的配置数据,以便于数据节点根据更新后的配置数据,对该配置区块之后的各配置区块或事务区块执行事务提交操作。相应地,数据节点将多版本检查结果写入该配置区块中,并将该配置区块写入磁盘中,Specifically, when the currently cached block sequence is divided into a configuration block and a transaction block sequence, the data nodes respectively perform the configuration block and transaction block sequence according to the order of the configuration block and transaction block sequence in the block sequence. The transaction block in the block sequence performs the transaction commit operation. The transaction commit operation performed for the configuration block includes: the data node performs transaction signature verification on the transaction in the configuration block; when the transaction signature verification step is completed, the data node performs multiple transactions on the transaction in the configuration block Version check: When the multi-version check step of the transaction is completed, the data node calls the preset write interface to write the configuration block to the disk, that is, write the configuration block to the corresponding blockchain. It is understandable that when the transaction signature verification step is executed, the data node writes the signature verification result into the configuration block, and performs multiple transactions for the transaction whose signature verification result in the configuration block is verified. Version check; when the result of the multi-version check is passed, the data node updates its configuration data according to the transaction data corresponding to the transaction that passed the check, so that the data node can use the updated configuration data for all subsequent configuration blocks. Configure the block or transaction block to perform transaction commit operations. Correspondingly, the data node writes the multi-version check result into the configuration block, and writes the configuration block to the disk,
进一步地,对于事务区块序列中的多个事务区块执行的事务提交操作包括:数据节点通过多个校验线程并行地对该多个事务区块进行事务签名校验;当针对该多个事务区块执行的事务签名校验的步骤均执行完毕时,数据节点通过单个检查线程串行地对各事务区块进行事务多版本检查,即数据节点按照该多个事务区块在事务区块序列中的顺序,依次对各事务区块进行事务多版本检查;当针对各事务区块的事务多版本检查依次执行完毕时,数据节点调用预设写入接口将该多个事务区块写入磁盘中。预设写入接口具体可以是预先设定的批量写入接口,数据节点调用该批量写入接口可将多个事务区块一次性写入磁盘中。Further, the transaction commit operation performed on multiple transaction blocks in the transaction block sequence includes: the data node performs transaction signature verification on the multiple transaction blocks in parallel through multiple verification threads; When the transaction signature verification steps performed by the transaction block are all executed, the data node serially performs multi-version check on each transaction block through a single check thread, that is, the data node performs multi-version check on each transaction block according to the multiple transaction blocks. In the sequence of the sequence, the transaction multi-version check is performed on each transaction block in turn; when the transaction multi-version check for each transaction block is sequentially executed, the data node calls the preset write interface to write the multiple transaction blocks Disk. The preset write interface may specifically be a preset batch write interface, and the data node can call the batch write interface to write multiple transaction blocks into the disk at one time.
在其中一个实施例中,当事务区块序列中的事务区块数量小于或等于预设数量时,数据节点确定数量与事务区块数量相等的校验线程,并将该事务区块序列中的各事务区块分配给相应的校验线程,以通过该事务区块数量的校验线程并行地对已分配的事务区块进行事务签名校验。当事务区块数量大于预设数量时,数据节点确定预设数量的校验线程,并将该事务区块序列中的多个事务区块分配至预设数量的校验线程,以通过该预设数量的校验线程并行地对已分配的事务区块进行事务签名校验。In one of the embodiments, when the number of transaction blocks in the transaction block sequence is less than or equal to the preset number, the data node determines the number of check threads equal to the number of transaction blocks, and compares the number of check threads in the transaction block sequence Each transaction block is allocated to a corresponding verification thread to perform transaction signature verification on the allocated transaction block in parallel by the verification thread of the number of transaction blocks. When the number of transaction blocks is greater than the preset number, the data node determines the preset number of verification threads, and allocates multiple transaction blocks in the transaction block sequence to the preset number of verification threads to pass the preset number. Suppose a number of verification threads perform transaction signature verification on the allocated transaction blocks in parallel.
接着上述例子进行举例说明,当将区块序列分割为配置区块d和事务区块序列X(包括事务区块a、b和c),以及事务区块序列Y(包括事务区块e和f)时,数据节点按照区块序列的顺序,首先对事务区块序列X中的事务区块a、b和c执行事务提交操作;当针对事务区块序列X的事务提交操作执行完毕时,数据节点对配置区块d执行事务提交操作,并根据配置区块d中的配置数据更新自身的配置数据;当针对配置区块d的事务提交操作执行完毕时,数据节点对事务区块序列Y中的事务区块e和f执行事务提交操作。Next, the above example will illustrate, when the block sequence is divided into configuration block d and transaction block sequence X (including transaction blocks a, b, and c), and transaction block sequence Y (including transaction blocks e and f) ), the data node first performs transaction commit operations on transaction blocks a, b, and c in the transaction block sequence X according to the sequence of the block sequence; when the transaction commit operation for the transaction block sequence X is completed, the data The node performs transaction commit operation on configuration block d, and updates its own configuration data according to the configuration data in configuration block d; when the transaction commit operation for configuration block d is completed, the data node performs transaction block sequence Y The transaction blocks e and f perform transaction commit operations.
可以理解的是,在针对事务区块序列X中的事务区块执行事务提交操作的过程中,和/或,在对配置区块d执行事务提交操作的过程中,数据节点可能会接收到共识节点发送的区块(事务区块或配置区块),并将接收到的区块进行缓存,作为新增的区块。由此,事务区块序列Y中还可包括在对事务区块序列X和配置区块d执行事务提交操作的过程中新增的区块。当针对配置区块d的事务提交操作执行完毕时,数据节点可将事务区块序列Y作为当前缓存的区块序列,按照上述查询方式查询该当前缓存的区块序列中是否存在配置区块,并根据查询结果按照本申请中相应实施例中提供的方法,对该区块序列执行事务提交操作。It is understandable that in the process of executing the transaction commit operation on the transaction block in the transaction block sequence X, and/or in the process of executing the transaction commit operation on the configuration block d, the data node may receive the consensus The block sent by the node (transaction block or configuration block), and the received block is cached as a new block. Therefore, the transaction block sequence Y may also include blocks newly added during the transaction commit operation on the transaction block sequence X and the configuration block d. When the transaction commit operation for configuration block d is completed, the data node can use transaction block sequence Y as the currently cached block sequence, and query whether there is a configuration block in the currently cached block sequence according to the above query method, According to the query result, the transaction commit operation is performed on the block sequence according to the method provided in the corresponding embodiment of this application.
上述区块处理方法,在获取到事务提交指令时,根据所获取到的事务提交指令在当前缓存的区块序列中查询配置区块,当查询到配置区块时,以该配置区块为分割基准点,将当前缓存的区块序列分割为配置区块和事务区块序列,并按照区块序列的顺序分别对配置区块和事务区块序列中的事务区块执行事务提交操作。对于事务区块序列中的多个事务区块依次执行的事务提交操作包括:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。通过对多个事务区块并行地进行事务签名校验,提高了签名校验的整体效率,从而可以提高区块的处理效率。在 多个事务区块的事务多版本检查均执行完毕时,将该多个事务区块同时写入磁盘,提高了事务区块中事务的整体提交效率,从而进一步提高了区块处理效率。进一步地,将多个事务区块同时写入磁盘,提高了区块链系统的整体吞吐量,从而可以节省计算机资源。In the block processing method described above, when a transaction commit instruction is acquired, the configuration block is queried in the currently cached block sequence according to the acquired transaction commit instruction. When the configuration block is queried, the configuration block is used as a partition As a reference point, the currently cached block sequence is divided into a configuration block and a transaction block sequence, and the transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence according to the sequence of the block sequence. The transaction commit operation performed in sequence for multiple transaction blocks in the transaction block sequence includes: performing transaction signature verification on multiple transaction blocks in parallel; performing transaction multi-version checks on each transaction block serially; A transaction block is written to the disk at the same time. By performing transaction signature verification on multiple transaction blocks in parallel, the overall efficiency of signature verification is improved, thereby improving the processing efficiency of the block. When the transaction multi-version checks of multiple transaction blocks are all executed, the multiple transaction blocks are written to the disk at the same time, which improves the overall submission efficiency of transactions in the transaction block, thereby further improving the block processing efficiency. Further, writing multiple transaction blocks to the disk at the same time improves the overall throughput of the blockchain system, thereby saving computer resources.
在其中一个实施例中,并行地对多个事务区块进行事务签名校验,包括:根据事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量;按照数量分配多个校验线程;通过多个校验线程对多个事务区块并行地进行事务签名校验。In one of the embodiments, performing transaction signature verification on multiple transaction blocks in parallel includes: determining the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the corresponding server; Multiple verification threads are allocated according to the number; multiple verification threads are used to perform transaction signature verification on multiple transaction blocks in parallel.
具体地,数据节点获取事务区块序列中事务区块的数量和自身对应的服务器的CPU核数,根据事务区块的数量和服务器的CPU核数确定校验线程的数量,并确定数量与校验线程的数量相等的多个校验线程。服务节点将该事务区块序列中的多个事务区块分配至该多个校验线程,以通过该多个检验线程并行地对该多个事务区块进行事务签名校验。当数据节点即为服务器时,数据节点自身对应的服务器的CPU核数即为数据节点自身的CPU核数。Specifically, the data node obtains the number of transaction blocks in the transaction block sequence and the number of CPU cores of its corresponding server, determines the number of verification threads according to the number of transaction blocks and the number of CPU cores of the server, and determines the number and the number of cores. Multiple verification threads with the same number of verification threads. The service node allocates multiple transaction blocks in the transaction block sequence to the multiple verification threads, so as to perform transaction signature verification on the multiple transaction blocks in parallel through the multiple verification threads. When the data node is a server, the number of CPU cores of the server corresponding to the data node itself is the number of CPU cores of the data node itself.
在其中一个实施例中,数据节点根据服务器的CPU核数确定该服务器所允许承载的校验线程的数量阈值,并将该数量阈值与事务区块的数量进行比较。当事务区块的数量小于或等于数量阈值时,数据节点将事务区块的数量确定为校验线程的数量;当事务区块的数量大于数量阈值时,数据节点将数量阈值确定为校验线程的数量。In one of the embodiments, the data node determines the threshold of the number of check threads that the server is allowed to carry according to the number of CPU cores of the server, and compares the threshold with the number of transaction blocks. When the number of transaction blocks is less than or equal to the number threshold, the data node determines the number of transaction blocks as the number of verification threads; when the number of transaction blocks is greater than the number threshold, the data node determines the number threshold as the verification thread quantity.
举例说明,假设服务器的CPU核数为2,根据CPU核数确定该服务器所允许承载的校验线程的数量阈值为6。若事务区块序列中事务区块的数量为5,则根据CPU核数和事务区块数量确定的校验线程数量为5,并将5个事务区块分发至该5个校验线程并行地进行事务签名校验;若事务区块数量为10个,则确定校验线程数量为6,并将10个事务区块分发至该6个校验线程并行的进行事务签名校验。比如,其中4个校验线程分配有2个事务区块,2个校验线程分配有1个事务区块。For example, suppose that the number of CPU cores of the server is 2, and the threshold of the number of check threads that the server is allowed to carry is determined according to the number of CPU cores. If the number of transaction blocks in the transaction block sequence is 5, the number of check threads determined according to the number of CPU cores and the number of transaction blocks is 5, and 5 transaction blocks are distributed to the 5 check threads in parallel Perform transaction signature verification; if the number of transaction blocks is 10, the number of verification threads is determined to be 6, and the 10 transaction blocks are distributed to the 6 verification threads to perform transaction signature verification in parallel. For example, 4 verification threads are allocated 2 transaction blocks, and 2 verification threads are allocated 1 transaction block.
在其中一个实施例中,数据节点可按照校验线程的数量创建相应的多个校验线程,也可按照该数量从线程池中获取多个空闲线程,作为分配的多个校验线程。In one of the embodiments, the data node may create corresponding multiple verification threads according to the number of verification threads, or obtain multiple idle threads from the thread pool according to the number, as the multiple verification threads allocated.
上述实施例中,根据待处理的事务区块的数量和自身对应的服务器的CPU核数确定校验线程的数量,以通过该数量的校验线程并行地对多个事务区块进行事务签名校验,在考虑服务器承载能力的情况下,充分利用了计算机资源,提高了事务签名校验的效率,从而提高了区块的整理处理效率。In the above embodiment, the number of verification threads is determined according to the number of transaction blocks to be processed and the number of CPU cores of the corresponding server, so that the number of verification threads can perform transaction signature verification on multiple transaction blocks in parallel. In the case of considering the carrying capacity of the server, the computer resources are fully utilized, the efficiency of transaction signature verification is improved, and the efficiency of block sorting and processing is improved.
在其中一个实施例中,通过多个校验线程对多个事务区块并行地进行事务签名校验,包括:将多个事务区块分配至多个校验线程;通过各校验线程对自身已分配的事务区块进行解析,得到解析的事务区块对应的多项事务;按照多项事务在事务区块中的排序依次对各事务进行事务签名校验。In one of the embodiments, performing transaction signature verification on multiple transaction blocks in parallel through multiple verification threads includes: allocating multiple transaction blocks to multiple verification threads; The allocated transaction block is analyzed to obtain multiple transactions corresponding to the analyzed transaction block; transaction signature verification is performed on each transaction in turn according to the order of the multiple transactions in the transaction block.
具体地,当按照所确定的数量分配多个校验线程时,数据节点将事务区块序列中的多个事务区块分配至该多个校验线程。对于已分配给各校验线程的事务区块,数据节点通过各校验线程并行地对自身已分配的事务区块进行解析,得到解析的事务区块所对应的多项事务,并按照该多项事务在相应事务区块中的排序,依次对该多项事务中的各项事务进行 事务签名校验。Specifically, when multiple verification threads are allocated according to the determined number, the data node allocates multiple transaction blocks in the transaction block sequence to the multiple verification threads. For the transaction block that has been allocated to each verification thread, the data node analyzes its own allocated transaction block in parallel through each verification thread, and obtains multiple transactions corresponding to the analyzed transaction block, and according to the multiple The order of the transaction in the corresponding transaction block, and the transaction signature verification for each transaction in the multiple transactions in turn.
在其中一个实施例中,数据节点按照平均分配原则或比例分配原则,将该多个事务区块同时分配至所确定的多个校验线程,并通过各校验线程对自身已分配的多个事务区块串行地进行事务签名校验。具体地,数据节点通过各校验线程对自身已分配的多个事务区块,按照该多个事务区块在事务区块序列中的排序(或者事务区块对应的区块编号),依次对该多个事务区块中的各事务区块进行事务签名校验。对各事务区块执行的事务签名校验的步骤包括:解析事务区块得到多项事务,按照事务在该事务区块中的排序依次对各事务进行事务签名校验。In one of the embodiments, the data node allocates the multiple transaction blocks to the determined multiple verification threads at the same time in accordance with the principle of equal distribution or proportional distribution, and uses each verification thread to allocate the multiple The transaction block performs transaction signature verification serially. Specifically, the data node uses each verification thread to assign multiple transaction blocks to itself, according to the ordering of the multiple transaction blocks in the transaction block sequence (or the block number corresponding to the transaction block), and sequentially Each transaction block in the plurality of transaction blocks performs transaction signature verification. The steps of performing transaction signature verification on each transaction block include: parsing the transaction block to obtain multiple transactions, and sequentially performing transaction signature verification on each transaction according to the order of the transactions in the transaction block.
在其中一个实施例中,数据节点按照事务区块序列的顺序从该事务区块序列中,提取数量等于校验线程数量的事务区块,并将提取的事务区块分配给相应的校验线程,以通过该多个校验线程并行地对所提取的多个事务区块进行事务签名校验。数据节点实时检测处于空闲状态的校验线程,并从事务区块序列中提取尚未被执行事务提交操作、且排序最靠前的事务区块,分配给该处于空闲状态的校验线程。In one of the embodiments, the data node extracts a transaction block equal to the number of verification threads from the transaction block sequence in the order of the transaction block sequence, and allocates the extracted transaction block to the corresponding verification thread , To perform transaction signature verification on the extracted multiple transaction blocks in parallel through the multiple verification threads. The data node detects the check thread in the idle state in real time, extracts from the transaction block sequence the transaction block that has not yet been subjected to the transaction commit operation and is sorted first, and allocates it to the check thread in the idle state.
上述实施例中,将多个事务区块分配给多个校验线程,以通过各校验线程并行地对自身已分配的事务区块中的事务进行事务签名校验,提高了事务签名校验的效率,从而提高了区块的处理效率。In the above-mentioned embodiment, multiple transaction blocks are allocated to multiple verification threads, so that each verification thread performs transaction signature verification on transactions in the allocated transaction block in parallel, which improves transaction signature verification. Therefore, the processing efficiency of the block is improved.
在其中一个实施例中,将多个事务区块分配至多个校验线程,包括:创建与各校验线程对应的区块缓存队列;将多个事务区块按照预设分配方式分配至各区块缓存队列,作为分配给相应校验线程的事务区块。In one of the embodiments, allocating multiple transaction blocks to multiple verification threads includes: creating a block cache queue corresponding to each verification thread; and allocating multiple transaction blocks to each block according to a preset allocation method The cache queue is used as a transaction block allocated to the corresponding verification thread.
预设分配方式比如按照平均分配原则或比例分配原则,将多个事务区块分配至已创建的多个区块缓存队列。The preset allocation method, for example, allocates multiple transaction blocks to multiple created block cache queues according to the principle of equal allocation or proportional allocation.
具体地,当按照校验线程的数量分配多个校验线程时,数据节点创建数量与校验线程的数量相等的区块缓存队列,已创建的区块缓存队列与校验线程分别对应。数据节点按照预设分配方式将事务区块序列中的多个事务区块分配至已创建的区块缓存队列中进行缓存,以便于各校验线程并行地从相应的区块缓存队列中读取事务区块,并对读取的事务区块进行事务签名校验。Specifically, when multiple verification threads are allocated according to the number of verification threads, the data node creates a block cache queue whose number is equal to the number of verification threads, and the created block cache queue corresponds to the verification thread respectively. The data node allocates multiple transaction blocks in the transaction block sequence to the created block cache queue for caching according to a preset allocation method, so that each verification thread can read from the corresponding block cache queue in parallel Transaction block, and perform transaction signature verification on the read transaction block.
在其中一个实施例中,当事务区块序列中事务区块的数量大于指定数量时,数据节点将事务区块序列中排序靠前的指定数量的事务区块,分配至已创建的多个区块缓存队列中缓存,以通过各校验线程并行地从相应的区块缓存队列中读取事务区块并进行事务签名校验。指定数量由服务器的CPU核数和每个校验线程所允许承载的事务区块的数量阈值来确定,比如根据CPU核数确定服务器所允许承载的校验线程的数量阈值,计算校验线程的数量阈值和每个校验线程数量对应的事务区块的数量阈值的乘积,得到指定数量。In one of the embodiments, when the number of transaction blocks in the transaction block sequence is greater than the specified number, the data node allocates the specified number of transaction blocks that are ranked higher in the transaction block sequence to the multiple created regions The block cache queue is cached to read transaction blocks from the corresponding block cache queue in parallel through each verification thread and perform transaction signature verification. The specified number is determined by the number of CPU cores of the server and the threshold of the number of transaction blocks allowed by each verification thread. For example, the threshold of the number of verification threads allowed by the server is determined according to the number of CPU cores, and the calculation of the verification thread The product of the number threshold and the number threshold of the transaction block corresponding to the number of each verification thread is the specified number.
上述实施例中,将事务区块分配至各校验线程所对应的区块缓存队列进行缓存,以便于各校验线程并行地读取区块缓存队列中缓存的事务区块,并进行事务签名校验,提高了事务区块分配效率,从而提高了事务签名校验效率。In the above embodiment, the transaction block is allocated to the block cache queue corresponding to each verification thread for caching, so that each verification thread reads the transaction block cached in the block cache queue in parallel, and signs the transaction Verification improves the efficiency of transaction block allocation, thereby improving the efficiency of transaction signature verification.
在其中一个实施例中,按照多项事务在事务区块中的排序依次对各事务进行解析,得到解析的事务对应的事务数据和数字签名数组;解析数字签名数组得到多个数字签名和各数字签名对应的公钥;根据各公钥对相应的数字签名进行解密,得到解密后的数字签名;根据事务数据生成事务哈希值,并基于事务哈希值和各解密后的数字签名,分别对各数字签名进行校验;当校验通过的数字签名的数量达到预设数量阈值时,则判定解析的事务对应的签名校验结果为校验通过。In one of the embodiments, each transaction is parsed in turn according to the ordering of multiple transactions in the transaction block to obtain transaction data and digital signature arrays corresponding to the parsed transactions; the digital signature array is parsed to obtain multiple digital signatures and digital signatures. The public key corresponding to the signature; decrypt the corresponding digital signature according to each public key to obtain the decrypted digital signature; generate the transaction hash value according to the transaction data, and based on the transaction hash value and each decrypted digital signature, respectively Each digital signature is verified; when the number of digital signatures that have passed the verification reaches a preset number threshold, it is determined that the signature verification result corresponding to the parsed transaction is a verification pass.
事务数据是事务区块中的事务所对应的数据。事务数据包括待更新的业务数据(可称为目标数据)和更新后的业务数据(可称为更新数据),以及业务数据对应的数据标识,还可包括目标数据对应的目标数据版本号。业务数据对应的数据标识可作为相应事务数据和/或事务所对应的事务数据标识。可以理解的是,事务数据标识与一个或多个事务数据(和/或事务)相对应,即根据事务数据标识可在区块链中查询到相应的一个或多个事务,以及各事务对应的事务数据。预设数量阈值是预先设定的数值,比如2。Transaction data is data corresponding to the transaction in the transaction block. The transaction data includes the business data to be updated (may be called target data) and the updated business data (may be called update data), and the data identifier corresponding to the business data, and may also include the target data version number corresponding to the target data. The data identifier corresponding to the business data can be used as the corresponding transaction data and/or the transaction data identifier corresponding to the transaction. It is understandable that the transaction data identifier corresponds to one or more transaction data (and/or transactions), that is, the corresponding one or more transactions can be queried in the blockchain according to the transaction data identifier, and the corresponding transaction data Transaction data. The preset number threshold is a preset value, such as 2.
数字签名数组包括一个或多个数字签名,还可包括各数字签名对应的解密密钥(公钥或私钥)。解密密钥和加密密钥组成密钥对,比如,加密密钥为私钥,则解密密钥为私钥所对应的公钥。数字签名是利用加密算法对事务数据进行加密得到的数据密文,比如利用公钥和私钥对事务数据进行加密得到数字签名。加密算法比如对称加密算法和非对称加密算法等。对称加密算法,比如DES(Data Encryption Standard,对称算法)、AES(Advanced Encryption Standard,高级加密标准)或IDEA(International Data Encryption Algorithm,国际数据加密算法)等。非对称加密算法,比如RSA(Rivest、Shamir、Adleman,加密算法)、DSA(Digital Signature Algorithm,数字签名算法)或ECC(Elliptic curve cryptography,椭圆曲线加密算法)等。The digital signature array includes one or more digital signatures, and may also include a decryption key (public key or private key) corresponding to each digital signature. The decryption key and the encryption key form a key pair. For example, if the encryption key is a private key, the decryption key is the public key corresponding to the private key. A digital signature is a data ciphertext obtained by encrypting transaction data using an encryption algorithm, for example, using a public key and a private key to encrypt transaction data to obtain a digital signature. Encryption algorithms such as symmetric encryption algorithms and asymmetric encryption algorithms. Symmetric encryption algorithm, such as DES (Data Encryption Standard, symmetric algorithm), AES (Advanced Encryption Standard, Advanced Encryption Standard), or IDEA (International Data Encryption Algorithm, International Data Encryption Algorithm), etc. Asymmetric encryption algorithms, such as RSA (Rivest, Shamir, Adleman, encryption algorithm), DSA (Digital Signature Algorithm, digital signature algorithm), or ECC (Elliptic curve cryptography, elliptic curve encryption algorithm), etc.
具体地,当通过校验线程解析自身已分配的事务区块得到该事务区块中的多项事务时,数据节点通过校验线程按照该多项事务在事务区块中的排序,依次对该多项事务中的各项事务进行解析,得到解析的事务所对应的事务数据和数字签名数组。数据节点通过校验线程解析数字签名数组得到相应的多个数字签名和各数字签名对应的公钥,并根据各公钥对相应的数字签名进行解密,得到解密后的数字签名。相应地,数据节点通过校验线程基于哈希算法对解析得到的事务数据进行哈希运算得到事务哈希值,并将该事务哈希值分别与各解密后的数字签名进行比较,以根据比较结果对相应数字签名进行校验。当事务哈希值与解密后的数字签名一致时,表明相应数字签名的校验结果为校验通过。数据节点通过校验线程统计校验结果为校验通过的数字签名的数量,当统计的数量大于或等于预设数量阈值时,则判定相应事务的签名校验结果为校验通过。常用的哈希算法比如,MD5(Message Digest Algorithm,消息摘要算法第五版)、SHA1(Secure Hash Algorithm,安全哈希算法)和SHA2等,本实施例在此不做具体限定。Specifically, when multiple transactions in the transaction block are obtained by parsing the transaction block allocated by the verification thread, the data node uses the verification thread according to the order of the multiple transactions in the transaction block to order the Each transaction in multiple transactions is analyzed, and transaction data and digital signature array corresponding to the analyzed transaction are obtained. The data node parses the digital signature array through the verification thread to obtain the corresponding multiple digital signatures and the public key corresponding to each digital signature, and decrypts the corresponding digital signature according to each public key to obtain the decrypted digital signature. Correspondingly, the data node uses the verification thread to hash the parsed transaction data based on the hash algorithm to obtain the transaction hash value, and compare the transaction hash value with each decrypted digital signature to compare As a result, the corresponding digital signature is verified. When the transaction hash value is consistent with the decrypted digital signature, it indicates that the verification result of the corresponding digital signature is a verification pass. The data node counts the verification result as the number of digital signatures that have passed the verification through the verification thread. When the counted number is greater than or equal to the preset number threshold, it is determined that the signature verification result of the corresponding transaction is the verification passed. Commonly used hash algorithms, such as MD5 (Message Digest Algorithm, fifth edition of message digest algorithm), SHA1 (Secure Hash Algorithm, secure hash algorithm), and SHA2, are not specifically limited in this embodiment.
在其中一个实施例中,数字签名数组中包括单个数字签名和相应的公钥,预设数量阈值为1。类似于上述事务签名校验的步骤,数据节点通过校验线程对该数字签名进行校验, 当该数字签名的校验结果为校验通过时,则判定相应事务的签名校验结果为校验通过。In one of the embodiments, the digital signature array includes a single digital signature and corresponding public key, and the preset number threshold is 1. Similar to the above transaction signature verification steps, the data node verifies the digital signature through the verification thread. When the verification result of the digital signature is a verification pass, it is determined that the signature verification result of the corresponding transaction is verification. by.
在其中一个实施例中,数据节点接收区块链客户端发送的签名请求,根据签名请求得到待签名的事务数据,通过哈希算法对待签名的事务数据进行哈希运算得到事务哈希值(可理解为摘要),利用自身的私钥对事务哈希值进行加密得到数字签名,并将该数字签名和自身的公钥反馈至区块链客户端。可以理解的是,区块链客户端实时检测业务数据,将检测到的业务数据作为待签名的事务数据,按照签名配置将待签名的事务数据发送至多个数据节点进行数字签名,并将该多个数据节点对应反馈的数字签名和公钥进行拼接,得到数字签名数组。区块链客户端根据事务数据和相应的数字签名数组得到事务,并将事务发送至共识节点进行共识。In one of the embodiments, the data node receives the signature request sent by the blockchain client, obtains the transaction data to be signed according to the signature request, and hashes the transaction data to be signed by the hash algorithm to obtain the transaction hash value (can be Understand as a digest), use its own private key to encrypt the transaction hash value to obtain a digital signature, and feed the digital signature and its own public key to the blockchain client. It is understandable that the blockchain client detects the business data in real time, uses the detected business data as the transaction data to be signed, and sends the transaction data to be signed to multiple data nodes for digital signature according to the signature configuration, and the multiple The digital signatures and public keys fed back by each data node are spliced to obtain a digital signature array. The blockchain client obtains the transaction according to the transaction data and the corresponding digital signature array, and sends the transaction to the consensus node for consensus.
进一步地,共识节点基于共识机制对接收到的事务进行共识,根据共识通过的事务生成相应的区块,并将生成的区块发送到数据节点,以使得数据节点基于上述各实施例中提供的区块处理方法将该区块写入区块链中。可以理解的是,区块链客户端、数据节点和共识节点同属于区块链网络,且该区块链网络中可包括多个区块链客户端、数据节点和共识节点。Further, the consensus node performs a consensus on the received transaction based on the consensus mechanism, generates a corresponding block according to the transaction passed by the consensus, and sends the generated block to the data node, so that the data node is based on the information provided in the foregoing embodiments The block processing method writes the block into the block chain. It is understandable that the blockchain client, data node, and consensus node all belong to the blockchain network, and the blockchain network may include multiple blockchain clients, data nodes, and consensus nodes.
上述实施例中,基于数字签名数组和事务哈希值对事务进行事务签名校验,以保证相应事务数据的真实性、有效性和可靠性。In the foregoing embodiment, the transaction signature verification is performed on the transaction based on the digital signature array and the transaction hash value to ensure the authenticity, validity and reliability of the corresponding transaction data.
在其中一个实施例中,串行地对各事务区块进行事务多版本检查,包括:按照事务区块序列的顺序,依次对各事务区块中的多项事务执行以下事务多版本检查的步骤:按照多项事务在事务区块中的排序依次对各事务进行解析,得到解析的事务对应的事务数据标识和目标数据版本号;查询与事务数据标识对应的最新数据版本号;当最新数据版本号与目标数据版本号一致时,则判定解析的事务的多版本检查结果为检查通过。In one of the embodiments, performing transaction multi-version checking on each transaction block in series includes: according to the sequence of the transaction block sequence, sequentially performing the following transaction multi-version checking steps on multiple transactions in each transaction block : Analyze each transaction in turn according to the order of multiple transactions in the transaction block to obtain the transaction data identifier and target data version number corresponding to the parsed transaction; query the latest data version number corresponding to the transaction data identifier; when the latest data version When the number is consistent with the target data version number, it is determined that the multi-version check result of the parsed transaction is passed.
具体地,当针对事务区块序列中的多个事务区块执行的事务签名校验操作均执行完毕时,数据节点按照该多个事务区块在事务区块序列中的排序,依次对该多个事务区块中的各事务区块进行事务多版本检查。数据节点对事务区块进行事务多版本检查,具体是指数据节点针对该事务区块中的多项事务进行事务多版本检查,具体包括以下步骤:数据节点解析事务区块得到相应的多项事务,按照该多项事务在事务区块中的排序,依次对该多项事务中的各项事务进行解析,得到解析的事务所对应的事务数据标识和目标数据版本号。数据节点根据该事务数据标识在区块链和/或本地缓存中查询相应的最新数据版本号,并将查询到的最新数据版本号与目标数据版本号进行比较。当最新数据版本号与目标数据版本号一致时,数据节点判定相应事务的多版本检查结果为检查通过。Specifically, when the transaction signature verification operations performed on multiple transaction blocks in the transaction block sequence are all executed, the data node sequentially performs the multiple transaction blocks according to the order of the multiple transaction blocks in the transaction block sequence. Each transaction block in each transaction block performs transaction multi-version check. The data node performs transaction multi-version check on the transaction block. Specifically, the data node performs transaction multi-version check for multiple transactions in the transaction block, which specifically includes the following steps: the data node parses the transaction block to obtain the corresponding multiple transactions , According to the order of the multiple transactions in the transaction block, analyze each transaction in the multiple transactions in turn to obtain the transaction data identifier and target data version number corresponding to the analyzed transaction. The data node queries the corresponding latest data version number in the blockchain and/or local cache according to the transaction data identifier, and compares the latest data version number found with the target data version number. When the latest data version number is consistent with the target data version number, the data node determines that the multi-version check result of the corresponding transaction is passed.
在其中一个实施例中,数据节点根据解析得到的事务数据标识在缓存中查询相应的最新数据版本号,并根据查询到的最新数据版本号执行上述事务多版本检查操作。当在缓存中没有查询到与事务数据标识对应的最新数据版本号时,数据节点从已写入磁盘的区块链中查询最新数据版本号,并根据查询到的最新数据版本号执行上述事务多版本检查操作。In one of the embodiments, the data node queries the corresponding latest data version number in the cache according to the parsed transaction data identifier, and performs the above-mentioned transaction multi-version check operation according to the latest data version number found. When the latest data version number corresponding to the transaction data identifier is not queried in the cache, the data node queries the latest data version number from the blockchain that has been written to the disk, and executes the above transaction based on the latest data version number queried. Version check operation.
在其中一个实施例中,各事务区块与区块编号相对应,区块编号可用于表征事务区块 在事务区块序列、区块序列或相应区块链中的排序。事务区块中的各事务与事务编号相对应,事务编号用于表征各事务在相应事务区块中的排序。当事务的多版本检查结果为检查通过时,数据节点根据该事务对应的事务编号和区块编号生成相应的数据版本号,作为相应事务数据标识当前对应的最新数据版本号。当事务的多版本检查结果为检查未通过时,数据节点则标注出多版本检查结果、且不会生成相应的数据版本号,即不会更新该事务对应的事务数据标识所对应的数据版本号。In one of the embodiments, each transaction block corresponds to a block number, and the block number can be used to characterize the order of the transaction block in the transaction block sequence, block sequence, or corresponding blockchain. Each transaction in the transaction block corresponds to a transaction number, and the transaction number is used to characterize the order of each transaction in the corresponding transaction block. When the multi-version check result of a transaction is passed, the data node generates a corresponding data version number according to the transaction number and block number corresponding to the transaction, which is used as the corresponding transaction data to identify the current corresponding latest data version number. When the multi-version check result of the transaction is that the check fails, the data node will mark the multi-version check result and will not generate the corresponding data version number, that is, the data version number corresponding to the transaction data identifier corresponding to the transaction will not be updated .
在其中一个实施例中,当针对事务区块中的各项事务执行的事务签名校验操作执行完毕时,数据节点根据事务对应的签名校验结果对该事务进行标注。在对事务区块进行事务多版本检查时,数据节点根据针对事务标注的签名校验结果,对事务区块中签名校验结果为校验通过的事务进行事务多版本检查,并根据事务对应的多版本检查结果对事务进行标注。可以理解的是,数据节点将各事务区块中的多项事务,以及各项事务对应的签名校验结果和多版本检查结果写入区块链中。数据节点可将签名校验结果为校验未通过和/或多版本检查结果为检查未通过的事务标注为无效事务。In one of the embodiments, when the transaction signature verification operation performed for each transaction in the transaction block is completed, the data node marks the transaction according to the signature verification result corresponding to the transaction. When the transaction multi-version check is performed on the transaction block, the data node performs multi-version check on the transaction whose signature verification result is the verification result according to the signature verification result marked for the transaction, and according to the transaction corresponding The multi-version check result marks the transaction. It is understandable that the data node writes multiple transactions in each transaction block, as well as the signature verification results and multi-version verification results corresponding to each transaction, into the blockchain. The data node may mark a transaction whose signature verification result is that the verification fails and/or the multi-version check result is that the verification fails as an invalid transaction.
举例说明,假设待提交的事务对应的事务数据包括:目标数据为A=2,更新数据为A=3,目标数据版本号为1,若当前的最新数据版本号为1,则判定该事务的多版本检查结果为检查通过。若在缓存或区块链中查询到该事务数据标识A所对应的最新数据版本号为2,则判定该事务的多版本检查结果为检查未通过。For example, suppose that the transaction data corresponding to the transaction to be submitted includes: the target data is A=2, the update data is A=3, and the target data version number is 1. If the current latest data version number is 1, then the transaction is determined The result of multi-version inspection is inspection passed. If the latest data version number corresponding to the transaction data identifier A is found to be 2 in the cache or the blockchain, it is determined that the multi-version check result of the transaction is a failed check.
在其中一个实施例中,数据节点具体可通过单一的检查线程,按照事务区块序列的顺序,依次对各事务区块中的多项事务执行上述事务多版本检查的步骤。In one of the embodiments, the data node may specifically perform the above-mentioned transaction multi-version check step on multiple transactions in each transaction block in the order of the transaction block sequence through a single check thread.
上述实施例中,通过多版本检查操作实现多版本并发控制,以避免同一目标数据同时被不同用户或不同操作修改时导致的数据更新错误的问题,可以确保事务数据的准确性和一致性。In the above-mentioned embodiment, multi-version concurrency control is achieved through multi-version checking operations, so as to avoid the problem of data update errors caused when the same target data is modified by different users or different operations at the same time, and to ensure the accuracy and consistency of transaction data.
在其中一个实施例中,步骤S204之后,上述区块处理方法还包括:当未查询到配置区块时,直接对区块序列中的多个事务区块执行以下事务提交操作:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。In one of the embodiments, after step S204, the block processing method described above further includes: when the configuration block is not found, directly perform the following transaction commit operation on multiple transaction blocks in the block sequence: Transaction signature verification is performed on each transaction block; transaction multi-version check is performed on each transaction block serially; multiple transaction blocks are simultaneously written to the disk.
具体地,当在当前缓存的区块序列中没有查询到配置区块时,数据节点则将该当前缓存的区块序列作为事务区块序列,并针对该事务区块序列中的多个事务区块执行以下事务提交操作:通过多个校验线程并行地对该多个事务区块进行事务签名校验;当针对各事务区块执行的事务签名校验操作均执行完毕时,按照事务区块序列的顺序串行地对各事务区块进行事务多版本检查;当针对各事务区块执行的事务多版本检查依次执行完毕时,调用预设写入接口将该多个事务区块同时写入磁盘。Specifically, when the configuration block is not queried in the currently cached block sequence, the data node uses the currently cached block sequence as a transaction block sequence and targets multiple transaction areas in the transaction block sequence. The block performs the following transaction commit operations: transaction signature verification is performed on multiple transaction blocks in parallel through multiple verification threads; when the transaction signature verification operations performed for each transaction block are all executed, follow the transaction block The sequence of the sequence is to perform transaction multi-version checks on each transaction block serially; when the transaction multi-version check performed for each transaction block is executed sequentially, the preset write interface is called to write the multiple transaction blocks at the same time Disk.
在其中一个实施例中,在针对事务区块序列中的多个事务区块依次执行事务多版本检查的过程中,数据节点将已执行事务多版本检查的事务区块缓存在本地,以便于在依次执行的事务多版本检查均执行完毕时,直接从缓存中读取该多个事务区块,提高了读取效率, 从而可以提高写入效率。In one of the embodiments, in the process of sequentially performing transaction multi-version checks for multiple transaction blocks in the transaction block sequence, the data node caches the transaction blocks that have performed transaction multi-version checks locally, so as to facilitate the When the multi-version checks of the transactions that are executed in sequence are all executed, the multiple transaction blocks are directly read from the cache, which improves the reading efficiency and thus the writing efficiency.
值得说明的是,当在区块序列中未查询到配置区块时,数据节点将该区块序列确定为事务区块序列,并基于上述各个实施例中提供的针对事务区块序列中的事务区块执行的事务提交操作进行处理。It is worth noting that when the configuration block is not queried in the block sequence, the data node determines the block sequence as a transaction block sequence, and is based on the transaction block sequence provided in the foregoing embodiments. The transaction executed by the block is submitted for processing.
上述实施例中,当在当前缓存的区块序列中没有查询到配置区块时,直接对该区块序列中的所有事务区块进行批量处理,提高了事务签名校验效率,从而提高了区块处理效率。将多个事务区块同时写入磁盘中,减少了区块链网络系统的调用次数,减少了因系统频繁调用而导致的程序上下文切换,提高了系统的整体吞吐量,从而节省了计算机资源。In the above embodiment, when the configuration block is not queried in the currently cached block sequence, all transaction blocks in the block sequence are directly processed in batches, which improves the efficiency of transaction signature verification, thereby increasing the area. Block processing efficiency. Writing multiple transaction blocks to the disk at the same time reduces the number of calls to the blockchain network system, reduces program context switching caused by frequent system calls, improves the overall throughput of the system, and saves computer resources.
如图3所示,在其中一个实施例中,提供了一种区块处理方法,该方法具体包括以下步骤:As shown in Figure 3, in one of the embodiments, a block processing method is provided, which specifically includes the following steps:
S302,获取事务提交指令。S302: Obtain a transaction commit instruction.
S304,根据事务提交指令在当前缓存的区块序列中查询配置区块。S304, query the configuration block in the currently cached block sequence according to the transaction commit instruction.
S306,当查询到配置区块时,以查询到的配置区块为分割基准点,将区块序列分割为配置区块和事务区块序列。S306: When the configuration block is queried, the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a dividing reference point.
S308,按照区块序列的顺序分别对配置区块和事务区块序列中的事务区块执行事务提交操作;针对事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。S308: Perform transaction commit operations on the configuration block and transaction blocks in the transaction block sequence respectively in the order of the block sequence; the transaction commit operations performed on multiple transaction blocks in the transaction block sequence include: Transaction signature verification is performed on multiple transaction blocks; multiple transaction versions are checked for each transaction block serially; multiple transaction blocks are simultaneously written to the disk.
S310,当未查询到配置区块时,直接对区块序列中的多个事务区块执行以下事务提交操作:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。S310: When the configuration block is not queried, directly perform the following transaction commit operations on multiple transaction blocks in the block sequence: perform transaction signature verification on multiple transaction blocks in parallel; and perform transaction signature verification on multiple transaction blocks in series; Block multi-version checking of transactions; write multiple transaction blocks to disk at the same time.
上述实施例中,针对当前缓存的区块序列中是否包含配置区块这两种情况,分别提供了相应的区块处理流程,针对区块序列和分割得到的事务区块序列均采用批量处理方式,提高了区块处理效率。In the above-mentioned embodiment, the corresponding block processing procedures are provided for the two cases of whether the currently cached block sequence contains configuration blocks, and the block sequence and the divided transaction block sequence are processed in batches. , Improve the efficiency of block processing.
如图4所示,在其中一个实施例中,数据节点针对事务区块序列中的多个事务区块执行的事务提交操作,包括以下步骤:As shown in Figure 4, in one of the embodiments, the transaction commit operation performed by the data node for multiple transaction blocks in the transaction block sequence includes the following steps:
S402,根据事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量。S402: Determine the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the corresponding server.
S404,按照数量分配多个校验线程。S404: Allocate multiple verification threads according to the number.
S406,创建与各校验线程对应的区块缓存队列。S406: Create a block buffer queue corresponding to each verification thread.
S408,将多个事务区块按照预设分配方式分配至各区块缓存队列,作为分配给相应校验线程的事务区块。S408: Allocate multiple transaction blocks to each block cache queue according to a preset allocation method, as transaction blocks allocated to corresponding verification threads.
S410,通过各校验线程对自身已分配的事务区块进行解析,得到解析的事务区块对应的多项事务。S410: Analyze the allocated transaction block by each verification thread to obtain multiple transactions corresponding to the analyzed transaction block.
S412,按照多项事务在事务区块中的排序依次对各事务进行解析,得到解析的事务对 应的事务数据和数字签名数组。S412: Analyze each transaction in turn according to the order of multiple transactions in the transaction block to obtain transaction data and a digital signature array corresponding to the analyzed transaction.
S414,解析数字签名数组得到多个数字签名和各数字签名对应的公钥。S414: Parse the digital signature array to obtain multiple digital signatures and public keys corresponding to each digital signature.
S416,根据各公钥对相应的数字签名进行解密,得到解密后的数字签名。S416: Decrypt the corresponding digital signature according to each public key to obtain a decrypted digital signature.
S418,根据事务数据生成事务哈希值,并基于事务哈希值和各解密后的数字签名,分别对各数字签名进行校验。S418: Generate a transaction hash value according to the transaction data, and verify each digital signature based on the transaction hash value and each decrypted digital signature.
S420,当校验通过的数字签名的数量达到预设数量阈值时,则判定解析的事务对应的签名校验结果为校验通过。S420: When the number of digital signatures that have passed the verification reaches a preset number threshold, it is determined that the signature verification result corresponding to the parsed transaction is a verification pass.
S422,按照事务区块序列的顺序,依次对各事务区块中的多项事务,按照多项事务在事务区块中的排序依次对各事务进行解析,得到解析的事务对应的事务数据标识和目标数据版本号。S422: According to the order of the transaction block sequence, sequentially analyze the multiple transactions in each transaction block according to the order of the multiple transactions in the transaction block to obtain the transaction data identifier and the transaction data corresponding to the analyzed transaction. Target data version number.
S424,查询与事务数据标识对应的最新数据版本号。S424: Query the latest data version number corresponding to the transaction data identifier.
S426,当最新数据版本号与目标数据版本号一致时,则判定解析的事务的多版本检查结果为检查通过。S426: When the latest data version number is consistent with the target data version number, it is determined that the multi-version check result of the parsed transaction is passed.
S428,将多个事务区块同时写入磁盘中。S428: Write multiple transaction blocks into the disk at the same time.
上述实施例中,并行地对多个事务区块进行事务签名校验,提高了事务签名校验的整体效率,串行地进行多版本检查保证了事务数据的正确性和一致性,将多个事务区块同时写入磁盘中,减少了区块链网络系统的调用次数,提升了系统的整体吞吐量,提高了事务区块的提交效率,且节省了计算机资源。由此,从整体上提高了区块处理效率。In the above embodiment, the transaction signature verification is performed on multiple transaction blocks in parallel, which improves the overall efficiency of transaction signature verification. The serial multi-version check ensures the correctness and consistency of transaction data. Transaction blocks are written to the disk at the same time, reducing the number of calls of the blockchain network system, improving the overall throughput of the system, improving the submission efficiency of transaction blocks, and saving computer resources. As a result, the overall block processing efficiency is improved.
在其中一个实施例中,上述各个实施例中提供的区块处理方法,可应用于联盟链,也可应用于公有链或私有链。In one of the embodiments, the block processing method provided in the above embodiments can be applied to the alliance chain, and can also be applied to the public chain or the private chain.
在其中一个实施例中,共识节点和数据节点可以是同一个区块链节点,共识节点和数据节点可对应同一个服务器或服务器集群。In one of the embodiments, the consensus node and the data node may be the same blockchain node, and the consensus node and the data node may correspond to the same server or server cluster.
应该理解的是,虽然图2-4的流程图中的各个步骤按照箭头的指示依次显示,但是这些步骤并不是必然按照箭头指示的顺序依次执行。除非本文中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,图2-4中的至少一部分步骤可以包括多个子步骤或者多个阶段,这些子步骤或者阶段并不必然是在同一时刻执行完成,而是可以在不同的时刻执行,这些子步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤的子步骤或者阶段的至少一部分轮流或者交替地执行。It should be understood that although the various steps in the flowcharts of FIGS. 2-4 are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless specifically stated in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least some of the steps in Figures 2-4 may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. These sub-steps or stages The execution order of is not necessarily performed sequentially, but may be performed alternately or alternately with at least a part of other steps or sub-steps or stages of other steps.
在其中一个实施例中,如图5所示,提供了一种区块处理装置500,包括:获取模块502、查询模块504、分割模块506和提交模块508,其中:In one of the embodiments, as shown in FIG. 5, a block processing device 500 is provided, which includes: an acquisition module 502, a query module 504, a segmentation module 506, and a submission module 508, wherein:
获取模块502,用于获取事务提交指令。The obtaining module 502 is used to obtain a transaction commit instruction.
查询模块504,用于根据事务提交指令在当前缓存的区块序列中查询配置区块。The query module 504 is used to query the configuration block in the currently cached block sequence according to the transaction commit instruction.
分割模块506,用于当查询到配置区块时,以查询到的配置区块为分割基准点,将区 块序列分割为配置区块和事务区块序列。The dividing module 506 is used to divide the block sequence into the configuration block and the transaction block sequence when the configuration block is queried, using the queried configuration block as the dividing reference point.
提交模块508,用于按照区块序列的顺序分别对配置区块和事务区块序列中的事务区块执行事务提交操作;针对事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。The commit module 508 is used to perform transaction commit operations on the configuration block and transaction blocks in the transaction block sequence according to the sequence of the block sequence; the transaction commit operations performed for multiple transaction blocks in the transaction block sequence include : Perform transaction signature verification on multiple transaction blocks in parallel; perform transaction multi-version check on each transaction block serially; write multiple transaction blocks into the disk at the same time.
在其中一个实施例中,提交模块508,还用于根据事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量;按照数量分配多个校验线程;通过多个校验线程对多个事务区块并行地进行事务签名校验。In one of the embodiments, the commit module 508 is further configured to determine the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of its corresponding server; and to allocate multiple verification threads according to the number; Multiple verification threads perform transaction signature verification on multiple transaction blocks in parallel.
在其中一个实施例中,提交模块508,还用于将多个事务区块分配至多个校验线程;通过各校验线程对自身已分配的事务区块进行解析,得到解析的事务区块对应的多项事务;按照多项事务在事务区块中的排序依次对各事务进行事务签名校验。In one of the embodiments, the commit module 508 is also used to allocate multiple transaction blocks to multiple verification threads; each verification thread analyzes the allocated transaction blocks by each verification thread to obtain the resolved transaction block correspondence A number of transactions; according to the order of multiple transactions in the transaction block, transaction signature verification is performed on each transaction.
在其中一个实施例中,提交模块508,还用于按照多项事务在事务区块中的排序依次对各事务进行解析,得到解析的事务对应的事务数据和数字签名数组;解析数字签名数组得到多个数字签名和各数字签名对应的公钥;根据各公钥对相应的数字签名进行解密,得到解密后的数字签名;根据事务数据生成事务哈希值,并基于事务哈希值和各解密后的数字签名,分别对各数字签名进行校验;当校验通过的数字签名的数量达到预设数量阈值时,则判定解析的事务对应的签名校验结果为校验通过。In one of the embodiments, the commit module 508 is also used to parse each transaction in turn according to the ordering of multiple transactions in the transaction block to obtain transaction data and digital signature array corresponding to the parsed transaction; parse the digital signature array to obtain Multiple digital signatures and public keys corresponding to each digital signature; decrypt the corresponding digital signature according to each public key to obtain the decrypted digital signature; generate transaction hash value based on transaction hash value and each decryption After the digital signature, each digital signature is verified separately; when the number of digital signatures that have passed the verification reaches the preset number threshold, it is determined that the signature verification result corresponding to the parsed transaction is the verification passed.
在其中一个实施例中,提交模块508,还用于创建与各校验线程对应的区块缓存队列;将多个事务区块按照预设分配方式分配至各区块缓存队列,作为分配给相应校验线程的事务区块。In one of the embodiments, the submission module 508 is also used to create a block cache queue corresponding to each verification thread; to allocate multiple transaction blocks to each block cache queue according to a preset allocation method, as the allocation to the corresponding school The transaction block of the verification thread.
在其中一个实施例中,提交模块508,还用于按照事务区块序列的顺序,依次对各事务区块中的多项事务执行以下事务多版本检查的步骤:按照多项事务在事务区块中的排序依次对各事务进行解析,得到解析的事务对应的事务数据标识和目标数据版本号;查询与事务数据标识对应的最新数据版本号;当最新数据版本号与目标数据版本号一致时,则判定解析的事务的多版本检查结果为检查通过。In one of the embodiments, the commit module 508 is also used to perform the following transaction multi-version check steps on multiple transactions in each transaction block in sequence according to the order of the transaction block sequence: The sorting in parses each transaction in turn to obtain the transaction data ID and target data version number corresponding to the parsed transaction; query the latest data version number corresponding to the transaction data ID; when the latest data version number is consistent with the target data version number, It is determined that the result of the multi-version check of the parsed transaction is passed.
在其中一个实施例中,提交模块508,还用于当未查询到配置区块时,直接对区块序列中的多个事务区块执行以下事务提交操作:并行地对多个事务区块进行事务签名校验;串行地对各事务区块进行事务多版本检查;将多个事务区块同时写入磁盘中。In one of the embodiments, the commit module 508 is also used to directly perform the following transaction commit operations on multiple transaction blocks in the block sequence when the configuration block is not queried: perform multiple transaction blocks in parallel Transaction signature verification; serially perform transaction multi-version check on each transaction block; write multiple transaction blocks to the disk at the same time.
关于区块处理装置的具体限定可以参见上文中对于区块处理方法的限定,在此不再赘述。上述区块处理装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。For the specific limitation of the block processing device, please refer to the above limitation of the block processing method, which will not be repeated here. Each module in the block processing device described above can be implemented in whole or in part by software, hardware, and a combination thereof. The foregoing modules may be embedded in the form of hardware or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the foregoing modules.
在其中一个实施例中,提供了一种计算机设备,该计算机设备可以是数据节点所对应的服务器,其内部结构图可以如图6所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。该计算机设备的处理器用于提供计算和控制能力。该计算机 设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储区块序列,存储的区块序列中包括配置区块和/或事务区块。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种区块处理方法。In one of the embodiments, a computer device is provided. The computer device may be a server corresponding to a data node, and its internal structure diagram may be as shown in FIG. 6. The computer equipment includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is used to provide calculation and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer readable instructions, and a database. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the non-volatile storage medium. The database of the computer device is used to store a block sequence, and the stored block sequence includes configuration blocks and/or transaction blocks. The network interface of the computer device is used to communicate with an external terminal through a network connection. The computer readable instructions are executed by the processor to realize a block processing method.
本领域技术人员可以理解,图6中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 6 is only a block diagram of part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may Including more or fewer parts than shown in the figure, or combining some parts, or having a different arrangement of parts.
一种计算机设备,包括存储器和一个或多个处理器,存储器中储存有计算机可读指令,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器实现本申请任意一个实施例中提供的区块处理方法的步骤。A computer device including a memory and one or more processors. The memory stores computer readable instructions. When the computer readable instructions are executed by one or more processors, the one or more processors can realize any one of the present application. The steps of the block processing method provided in the embodiment.
一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器实现本申请任意一个实施例中提供的区块处理方法的步骤。在其中一个实施例中在其中一个实施例中One or more non-volatile computer-readable storage media storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors implement any one of the embodiments of the present application. Provides the steps of the block processing method. In one of the embodiments in one of the embodiments
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing relevant hardware through computer-readable instructions, which can be stored in a non-volatile computer. In a readable storage medium, when the computer-readable instructions are executed, they may include the processes of the above-mentioned method embodiments. Any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and/or volatile memory. Non-volatile memory may include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not a limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Channel (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
以上实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction between the combinations of these technical features, they should It is considered as the range described in this specification.
以上所述实施例仅表达了本申请的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本申请构思的前提下,还可以做出若干变形和改进,这些都属于本申请的保护范围。因此,本申请专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the invention patent. It should be pointed out that for those of ordinary skill in the art, without departing from the concept of this application, several modifications and improvements can be made, and these all fall within the protection scope of this application. Therefore, the scope of protection of the patent of this application shall be subject to the appended claims.

Claims (20)

  1. 一种区块处理方法,包括:A block processing method, including:
    获取事务提交指令;Obtain transaction commit instructions;
    根据所述事务提交指令在当前缓存的区块序列中查询配置区块;Query the configuration block in the currently cached block sequence according to the transaction commit instruction;
    当查询到所述配置区块时,以查询到的所述配置区块为分割基准点,将所述区块序列分割为配置区块和事务区块序列;及When the configuration block is queried, the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a division reference point; and
    按照所述区块序列的顺序分别对所述配置区块和所述事务区块序列中的事务区块执行事务提交操作;针对所述事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。A transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence; transaction commit performed on multiple transaction blocks in the transaction block sequence The operations include: performing transaction signature verification on the plurality of transaction blocks in parallel; performing transaction multi-version checking on each of the transaction blocks serially; and simultaneously writing the plurality of transaction blocks to a disk.
  2. 根据权利要求1所述的方法,其特征在于,所述并行地对所述多个事务区块进行事务签名校验,包括:The method according to claim 1, wherein the performing transaction signature verification on the plurality of transaction blocks in parallel comprises:
    根据所述事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量;Determining the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the server corresponding to the transaction block;
    按照所述数量分配多个校验线程;及Allocate multiple verification threads according to the number; and
    通过所述多个校验线程对所述多个事务区块并行地进行事务签名校验。The transaction signature verification is performed on the plurality of transaction blocks in parallel by the plurality of verification threads.
  3. 根据权利要求2所述的方法,其特征在于,所述通过所述多个校验线程对所述多个事务区块并行地进行事务签名校验,包括:The method according to claim 2, wherein said performing transaction signature verification on said plurality of transaction blocks in parallel by said plurality of verification threads comprises:
    将所述多个事务区块分配至所述多个校验线程;Allocating the multiple transaction blocks to the multiple verification threads;
    通过各所述校验线程对自身已分配的事务区块进行解析,得到解析的所述事务区块对应的多项事务;及Analyze the allocated transaction block by each verification thread to obtain multiple transactions corresponding to the analyzed transaction block; and
    按照所述多项事务在所述事务区块中的排序依次对各所述事务进行事务签名校验。According to the order of the multiple transactions in the transaction block, transaction signature verification is performed on each transaction in turn.
  4. 根据权利要求3所述的方法,其特征在于,所述按照所述多项事务在所述事务区块中的排序依次对各所述事务进行事务签名校验,包括:The method according to claim 3, wherein the step of performing transaction signature verification on each of the transactions according to the order of the multiple transactions in the transaction block comprises:
    按照所述多项事务在所述事务区块中的排序依次对各所述事务进行解析,得到解析的所述事务对应的事务数据和数字签名数组;Analyze each of the transactions in turn according to the order of the multiple transactions in the transaction block to obtain transaction data and digital signature arrays corresponding to the analyzed transactions;
    解析所述数字签名数组得到多个数字签名和各所述数字签名对应的公钥;Parsing the digital signature array to obtain multiple digital signatures and public keys corresponding to each of the digital signatures;
    根据各所述公钥对相应的数字签名进行解密,得到解密后的数字签名;Decrypt the corresponding digital signature according to each said public key to obtain the decrypted digital signature;
    根据所述事务数据生成事务哈希值,并基于所述事务哈希值和各所述解密后的数字签名,分别对各所述数字签名进行校验;及Generate a transaction hash value according to the transaction data, and verify each of the digital signatures based on the transaction hash value and each of the decrypted digital signatures; and
    当校验通过的所述数字签名的数量达到预设数量阈值时,则判定解析的所述事务对应的签名校验结果为校验通过。When the number of the digital signatures that have passed the verification reaches a preset number threshold, it is determined that the signature verification result corresponding to the parsed transaction is a verification pass.
  5. 根据权利要求3所述的方法,其特征在于,所述将所述多个事务区块分配至所述多个校验线程,包括:The method according to claim 3, wherein the allocating the plurality of transaction blocks to the plurality of verification threads comprises:
    创建与各所述校验线程对应的区块缓存队列;及Creating a block buffer queue corresponding to each verification thread; and
    将所述多个事务区块按照预设分配方式分配至各所述区块缓存队列,作为分配给相应校验线程的事务区块。The plurality of transaction blocks are allocated to each of the block cache queues according to a preset allocation method as the transaction blocks allocated to the corresponding verification thread.
  6. 根据权利要求1所述的方法,其特征在于,所述串行地对各所述事务区块进行事务多版本检查,包括:The method according to claim 1, wherein the serially performing transaction multi-version checking on each of the transaction blocks comprises:
    按照所述事务区块序列的顺序,依次对各所述事务区块中的多项事务执行以下事务多版本检查的步骤:According to the sequence of the transaction block sequence, the following transaction multi-version checking steps are performed sequentially on multiple transactions in each transaction block:
    按照所述多项事务在所述事务区块中的排序依次对各所述事务进行解析,得到解析的所述事务对应的事务数据标识和目标数据版本号;Analyze each of the transactions in turn according to the order of the multiple transactions in the transaction block to obtain the transaction data identifier and target data version number corresponding to the analyzed transaction;
    查询与所述事务数据标识对应的最新数据版本号;及Query the latest data version number corresponding to the transaction data identifier; and
    当所述最新数据版本号与所述目标数据版本号一致时,则判定解析的所述事务的多版本检查结果为检查通过。When the latest data version number is consistent with the target data version number, it is determined that the parsed multi-version check result of the transaction is passed.
  7. 根据权利要求1至6任一项所述的方法,其特征在于,所述根据所述事务提交指令在当前缓存的区块序列中查询配置区块之后,上述方法还包括:The method according to any one of claims 1 to 6, characterized in that, after the query configuration block in the currently cached block sequence according to the transaction commit instruction, the method further comprises:
    当未查询到所述配置区块时,直接对所述区块序列中的多个事务区块执行以下事务提交操作:When the configuration block is not found, the following transaction commit operations are directly performed on multiple transaction blocks in the block sequence:
    并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。Perform transaction signature verification on the multiple transaction blocks in parallel; perform transaction multi-version checks on each transaction block serially; write the multiple transaction blocks into the disk at the same time.
  8. 一种区块处理装置,其特征在于,所述装置包括:A block processing device, characterized in that the device includes:
    获取模块,用于获取事务提交指令;Obtaining module for obtaining transaction commit instructions;
    查询模块,用于根据所述事务提交指令在当前缓存的区块序列中查询配置区块;The query module is used to query the configuration block in the currently cached block sequence according to the transaction commit instruction;
    分割模块,用于当查询到所述配置区块时,以查询到的所述配置区块为分割基准点,将所述区块序列分割为配置区块和事务区块序列;A segmentation module, configured to, when the configuration block is queried, use the queried configuration block as a segmentation reference point to split the block sequence into a configuration block and a transaction block sequence;
    提交模块,用于按照所述区块序列的顺序分别对所述配置区块和所述事务区块序列中的事务区块执行事务提交操作;针对所述事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。The commit module is configured to perform transaction commit operations on the configuration block and the transaction block in the transaction block sequence according to the sequence of the block sequence; for multiple transaction areas in the transaction block sequence The transaction commit operation performed by the block includes: performing transaction signature verification on the multiple transaction blocks in parallel; performing multi-version check on each transaction block serially; writing the multiple transaction blocks simultaneously Into the disk.
  9. 根据权利要求8所述的装置,其特征在于,所述提交模块,还用于根据所述事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量;按照所述数量分配多个校验线程;及通过所述多个校验线程对所述多个事务区块并行地进行事务签名校验。The device according to claim 8, wherein the commit module is further configured to determine the number of check threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the server corresponding to it; A plurality of verification threads are allocated according to the number; and transaction signature verification is performed on the plurality of transaction blocks in parallel through the plurality of verification threads.
  10. 根据权利要求9所述的装置,其特征在于,所述提交模块,还用于将所述多个事务区块分配至所述多个校验线程;通过各所述校验线程对自身已分配的事务区块进行解析,得到解析的所述事务区块对应的多项事务;及按照所述多项事务在所述事务区块中的排序依次对各所述事务进行事务签名校验。The device according to claim 9, wherein the commit module is further configured to allocate the plurality of transaction blocks to the plurality of verification threads; each verification thread allocates itself to Parse the transaction block to obtain multiple transactions corresponding to the parsed transaction block; and perform transaction signature verification on each transaction in sequence according to the order of the multiple transactions in the transaction block.
  11. 根据权利要求10所述的装置,其特征在于,所述提交模块,还用于按照所述多项事务在所述事务区块中的排序依次对各所述事务进行解析,得到解析的所述事务对应的事务数据和数字签名数组;解析所述数字签名数组得到多个数字签名和各所述数字签名对应的公钥;根据各所述公钥对相应的数字签名进行解密,得到解密后的数字签名;根据所述事务数据生成事务哈希值,并基于所述事务哈希值和各所述解密后的数字签名,分别对各所述数字签名进行校验;及当校验通过的所述数字签名的数量达到预设数量阈值时,则判定解析的所述事务对应的签名校验结果为校验通过。The apparatus according to claim 10, wherein the commit module is further configured to parse each of the transactions in sequence according to the order of the multiple transactions in the transaction block to obtain the parsed Transaction data and digital signature array corresponding to the transaction; parsing the digital signature array to obtain multiple digital signatures and public keys corresponding to each of the digital signatures; decrypting the corresponding digital signatures according to each of the public keys to obtain the decrypted Digital signature; generate a transaction hash value based on the transaction data, and verify each of the digital signatures based on the transaction hash value and each of the decrypted digital signatures; and when the verification passes When the number of the digital signatures reaches the preset number threshold, it is determined that the signature verification result corresponding to the analyzed transaction is passed.
  12. 根据权利要求10所述的装置,其特征在于,所述提交模块,还用于创建与各所述校验线程对应的区块缓存队列;及将所述多个事务区块按照预设分配方式分配至各所述区块缓存队列,作为分配给相应校验线程的事务区块。The device according to claim 10, wherein the submission module is further configured to create a block cache queue corresponding to each of the verification threads; and assign the plurality of transaction blocks according to a preset allocation method Allocate to each of the block cache queues as transaction blocks allocated to the corresponding verification thread.
  13. 根据权利要求8所述的装置,其特征在于,所述提交模块,还用于按照所述事务区块序列的顺序,依次对各所述事务区块中的多项事务执行以下事务多版本检查的步骤:按照所述多项事务在所述事务区块中的排序依次对各所述事务进行解析,得到解析的所述事务对应的事务数据标识和目标数据版本号;查询与所述事务数据标识对应的最新数据版本号;及当所述最新数据版本号与所述目标数据版本号一致时,则判定解析的所述事务的多版本检查结果为检查通过。8. The device according to claim 8, wherein the commit module is further configured to perform the following transaction multi-version checks on multiple transactions in each transaction block in sequence according to the sequence of the transaction block sequence The steps of: parse each of the transactions in turn according to the order of the multiple transactions in the transaction block to obtain the transaction data identifier and target data version number corresponding to the analyzed transaction; query the transaction data Identify the corresponding latest data version number; and when the latest data version number is consistent with the target data version number, it is determined that the parsed multi-version check result of the transaction is passed.
  14. 根据权利要求8至13任一项所述的装置,其特征在于,所述提交模块,还用于当未查询到所述配置区块时,直接对所述区块序列中的多个事务区块执行以下事务提交操作:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。The device according to any one of claims 8 to 13, wherein the submission module is further configured to directly check multiple transaction areas in the block sequence when the configuration block is not found. The block performs the following transaction commit operations: performs transaction signature verification on the multiple transaction blocks in parallel; performs multi-version check on each transaction block serially; writes the multiple transaction blocks simultaneously Disk.
  15. 一种计算机设备,包括存储器和一个或多个处理器,所述存储器中储存有计算机可读指令,所述计算机可读指令被所述一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:A computer device includes a memory and one or more processors. The memory stores computer readable instructions. When the computer readable instructions are executed by the one or more processors, the one or more Each processor performs the following steps:
    获取事务提交指令;Obtain transaction commit instructions;
    根据所述事务提交指令在当前缓存的区块序列中查询配置区块;Query the configuration block in the currently cached block sequence according to the transaction commit instruction;
    当查询到所述配置区块时,以查询到的所述配置区块为分割基准点,将所述区块序列分割为配置区块和事务区块序列;及When the configuration block is queried, the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a division reference point; and
    按照所述区块序列的顺序分别对所述配置区块和所述事务区块序列中的事务区块执行事务提交操作;针对所述事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。A transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence; transaction commit performed on multiple transaction blocks in the transaction block sequence The operations include: performing transaction signature verification on the plurality of transaction blocks in parallel; performing transaction multi-version checking on each of the transaction blocks serially; and simultaneously writing the plurality of transaction blocks to a disk.
  16. 根据权利要求15所述的计算机设备,其特征在于,所述处理器执行所述计算机可读指令时还执行以下步骤:The computer device according to claim 15, wherein the processor further executes the following steps when executing the computer-readable instruction:
    根据所述事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量;Determining the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the server corresponding to the transaction block;
    按照所述数量分配多个校验线程;及Allocate multiple verification threads according to the number; and
    通过所述多个校验线程对所述多个事务区块并行地进行事务签名校验。The transaction signature verification is performed on the plurality of transaction blocks in parallel by the plurality of verification threads.
  17. 根据权利要求16所述的计算机设备,其特征在于,所述通过所述多个校验线程对所述多个事务区块并行地进行事务签名校验,包括:16. The computer device according to claim 16, wherein the performing transaction signature verification on the multiple transaction blocks in parallel by the multiple verification threads comprises:
    将所述多个事务区块分配至所述多个校验线程;Allocating the multiple transaction blocks to the multiple verification threads;
    通过各所述校验线程对自身已分配的事务区块进行解析,得到解析的所述事务区块对应的多项事务;及Analyze the allocated transaction block by each verification thread to obtain multiple transactions corresponding to the analyzed transaction block; and
    按照所述多项事务在所述事务区块中的排序依次对各所述事务进行事务签名校验。According to the order of the multiple transactions in the transaction block, transaction signature verification is performed on each transaction in turn.
  18. 一个或多个存储有计算机可读指令的非易失性计算机可读存储介质,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行以下步骤:One or more non-volatile computer-readable storage media storing computer-readable instructions, which when executed by one or more processors, cause the one or more processors to perform the following steps:
    获取事务提交指令;Obtain transaction commit instructions;
    根据所述事务提交指令在当前缓存的区块序列中查询配置区块;Query the configuration block in the currently cached block sequence according to the transaction commit instruction;
    当查询到所述配置区块时,以查询到的所述配置区块为分割基准点,将所述区块序列分割为配置区块和事务区块序列;及When the configuration block is queried, the block sequence is divided into a configuration block and a transaction block sequence using the queried configuration block as a division reference point; and
    按照所述区块序列的顺序分别对所述配置区块和所述事务区块序列中的事务区块执行事务提交操作;针对所述事务区块序列中的多个事务区块执行的事务提交操作包括:并行地对所述多个事务区块进行事务签名校验;串行地对各所述事务区块进行事务多版本检查;将所述多个事务区块同时写入磁盘中。A transaction commit operation is performed on the configuration block and the transaction block in the transaction block sequence respectively according to the sequence of the block sequence; transaction commit performed on multiple transaction blocks in the transaction block sequence The operations include: performing transaction signature verification on the plurality of transaction blocks in parallel; performing transaction multi-version checking on each of the transaction blocks serially; and simultaneously writing the plurality of transaction blocks to a disk.
  19. 根据权利要求18所述的存储介质,其特征在于,所述计算机可读指令被所述处理器执行时还执行以下步骤:18. The storage medium of claim 18, wherein the following steps are further performed when the computer-readable instructions are executed by the processor:
    根据所述事务区块序列中的事务区块数量和自身对应的服务器的CPU核数确定校验线程的数量;Determining the number of verification threads according to the number of transaction blocks in the transaction block sequence and the number of CPU cores of the server corresponding to the transaction block;
    按照所述数量分配多个校验线程;及Allocate multiple verification threads according to the number; and
    通过所述多个校验线程对所述多个事务区块并行地进行事务签名校验。The transaction signature verification is performed on the plurality of transaction blocks in parallel by the plurality of verification threads.
  20. 根据权利要求19所述的存储介质,其特征在于,所述计算机可读指令被所述处理器执行时还执行以下步骤:The storage medium according to claim 19, wherein the following steps are further executed when the computer-readable instructions are executed by the processor:
    将所述多个事务区块分配至所述多个校验线程;Allocating the multiple transaction blocks to the multiple verification threads;
    通过各所述校验线程对自身已分配的事务区块进行解析,得到解析的所述事务区块对应的多项事务;及Analyze the allocated transaction block by each verification thread to obtain multiple transactions corresponding to the analyzed transaction block; and
    按照所述多项事务在所述事务区块中的排序依次对各所述事务进行事务签名校验。According to the order of the multiple transactions in the transaction block, transaction signature verification is performed on each transaction in turn.
PCT/CN2019/122676 2019-05-20 2019-12-03 Block processing method and apparatus, computer device and storage medium WO2020233086A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910420112.5A CN110245126A (en) 2019-05-20 2019-05-20 Block processes method, apparatus, computer equipment and storage medium
CN201910420112.5 2019-05-20

Publications (1)

Publication Number Publication Date
WO2020233086A1 true WO2020233086A1 (en) 2020-11-26

Family

ID=67884599

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/122676 WO2020233086A1 (en) 2019-05-20 2019-12-03 Block processing method and apparatus, computer device and storage medium

Country Status (2)

Country Link
CN (1) CN110245126A (en)
WO (1) WO2020233086A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110245126A (en) * 2019-05-20 2019-09-17 深圳壹账通智能科技有限公司 Block processes method, apparatus, computer equipment and storage medium
CN111985928A (en) * 2020-09-03 2020-11-24 深圳壹账通智能科技有限公司 Verification method, verification device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107291862A (en) * 2017-06-12 2017-10-24 腾讯科技(深圳)有限公司 Business datum storage method, device, storage medium and electronic equipment
CN109614206A (en) * 2018-10-25 2019-04-12 深圳壹账通智能科技有限公司 Device, method and the storage medium of block chain issued transaction
CN110245126A (en) * 2019-05-20 2019-09-17 深圳壹账通智能科技有限公司 Block processes method, apparatus, computer equipment and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107145768B (en) * 2016-03-01 2021-02-12 华为技术有限公司 Copyright management method and system
EP3382629A1 (en) * 2017-03-31 2018-10-03 Siemens Aktiengesellschaft Procedure and time provider for provision of security-protected time values
CN107070938A (en) * 2017-04-27 2017-08-18 电子科技大学 Data access control system based on block chain
CN107729137B (en) * 2017-09-04 2021-06-22 深圳壹账通智能科技有限公司 Server, block chain signature verification decryption method and storage medium
CN108388989A (en) * 2018-02-26 2018-08-10 深圳智乾区块链科技有限公司 Transaction methods, system and computer readable storage medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107291862A (en) * 2017-06-12 2017-10-24 腾讯科技(深圳)有限公司 Business datum storage method, device, storage medium and electronic equipment
CN109614206A (en) * 2018-10-25 2019-04-12 深圳壹账通智能科技有限公司 Device, method and the storage medium of block chain issued transaction
CN110245126A (en) * 2019-05-20 2019-09-17 深圳壹账通智能科技有限公司 Block processes method, apparatus, computer equipment and storage medium

Also Published As

Publication number Publication date
CN110245126A (en) 2019-09-17

Similar Documents

Publication Publication Date Title
US10439804B2 (en) Data encrypting system with encryption service module and supporting infrastructure for transparently providing encryption services to encryption service consumer processes across encryption service state changes
WO2021218167A1 (en) Data processing model generation method and apparatus and data processing method and apparatus
CN111625593B (en) Block chain-based data processing method and device and computer equipment
WO2019100598A1 (en) Transaction processing method and device, computer equipment, and storage medium
US10615971B2 (en) High integrity logs for distributed software services
TW202034251A (en) Methods and devices for testing signature verification for blockchain system
WO2020224489A1 (en) Blockchain-based bank data sharing method and related apparatus
US20200293663A1 (en) Discovery and Matching of Internet of Things (IoT) Devices and Services Using a Secure Global Registry
CN110781140B (en) Method, device, computer equipment and storage medium for signing data in blockchain
US7318160B2 (en) Cryptographic key setup in queued cryptographic systems
WO2020233086A1 (en) Block processing method and apparatus, computer device and storage medium
US20190044716A1 (en) Encoding process for multiple rsa and ecc keys
CN115604038B (en) Cloud storage data auditing system and method based on blockchain and edge computing
US11917084B2 (en) Cryptographic validation of media integrity
CN110688666A (en) Data encryption and storage method in distributed storage
CN111404892B (en) Data supervision method and device and server
WO2020253380A1 (en) Data encryption method and apparatus, and terminal device
CN114127724A (en) Integrity audit for multi-copy storage
CN114172659B (en) Message transmission method, device, equipment and storage medium in block chain system
CN109284302B (en) Data processing method and device
US20200396054A1 (en) Secure Memory Read
Ma et al. Authenticating query results in data publishing
CN116192395A (en) Trusted system for distributed data storage
US20220345292A1 (en) Method and device for encryption of video stream, communication equipment, and storage medium
CN113452519B (en) Key synchronization method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19929985

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19929985

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/03/2022)

122 Ep: pct application non-entry in european phase

Ref document number: 19929985

Country of ref document: EP

Kind code of ref document: A1