Data processing method and device based on block chain and readable storage medium

By replacing large blockchain addresses with smaller address indexes using an address index table in the blockchain, the problem of insufficient blockchain storage space is solved, achieving storage space savings and cost reduction.

CN122064675APending Publication Date: 2026-05-19TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2024-11-18
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Blockchain has limited storage space, and as data increases, it faces the problem of insufficient storage space.

Method used

By using an address index table in the blockchain, large blockchain addresses can be replaced with smaller address indexes, which are then stored in a designated location, thus reducing storage space consumption.

Benefits of technology

It effectively reduces the storage space consumption of the blockchain and lowers storage space costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122064675A_ABST
    Figure CN122064675A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data processing method and device based on a block chain and a readable storage medium. The method comprises the steps of obtaining an address writing parameter of an address writing instruction; the address writing parameter comprises a first storage position and a first block chain address; obtaining a first address index table according to the address writing instruction; the first address index table comprises a total block chain address in the block chain and an address index corresponding to each block chain address; querying the first block chain address in a first address index table, if the first address index table contains the first block chain address, obtaining a first address index corresponding to the first block chain address in the first address index table, and storing the first address index to a first storage position; wherein the occupied space corresponding to the first address index is smaller than the occupied space corresponding to the first block chain address. By adopting the method and the device, the storage space consumption of the block chain can be reduced, so that the storage space cost can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and in particular to a data processing method, device and readable storage medium based on blockchain. Background Technology

[0002] With the rapid development of network technology and enterprises' emphasis on data security, blockchain has received great attention and application.

[0003] For a credible blockchain, its storage space is limited. As the blockchain continues to operate, the amount of data it stores will continue to increase. At this point, the blockchain will face the dilemma of insufficient storage space. Summary of the Invention

[0004] This application provides a data processing method, device, and readable storage medium based on blockchain, which can reduce the storage space consumption of blockchain and thus reduce storage space costs.

[0005] This application provides, in one aspect, a blockchain-based data processing method, which is executed by a first blockchain node and includes:

[0006] Obtain the address write parameters for the address write instruction; the address write parameters include the first storage location and the first blockchain address;

[0007] Based on the address write instruction, obtain the first address index table; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address.

[0008] The first blockchain address is queried in the first address index table. If the first blockchain address is contained in the first address index table, the first address index corresponding to the first blockchain address in the first address index table is obtained and the first address index is stored in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0009] One embodiment of this application provides a blockchain-based data processing device, which operates on a first blockchain node, and the device includes:

[0010] The acquisition module is used to acquire the address write parameters of the address write instruction; the address write parameters include the first storage location and the first blockchain address;

[0011] The acquisition module is also used to acquire a first address index table based on the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address;

[0012] The storage module is used to query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, the module obtains the first address index corresponding to the first blockchain address in the first address index table and stores the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0013] In one possible implementation, the acquisition module obtains the address write parameters of the address write instruction and uses them to perform the following operations:

[0014] Read the first instruction identifier from the instruction stack, and retrieve the first instruction that has a mapping relationship with the first instruction identifier from the instruction mapping table;

[0015] If the first instruction is an address write instruction, then read the address write parameters from the instruction stack.

[0016] In one possible implementation, the storage module is also used to perform the following operations:

[0017] If the first address index table does not contain the first blockchain address, then determine the maximum address index in the first address index table;

[0018] Generate a first address index that is greater than the maximum address index, and construct an index relationship between the first address index and the first blockchain address in the first address index table.

[0019] In one possible implementation, the module is also used to perform the following operations:

[0020] Read the second instruction identifier from the instruction stack, and retrieve the second instruction that has a mapping relationship with the second instruction identifier from the instruction mapping table;

[0021] If the second instruction is an address read instruction, then the address read parameters in the instruction stack are read; the address read parameters include the second storage location;

[0022] Based on the second storage location and the first address index table, obtain the second blockchain address and return the second blockchain address to the top of the instruction stack.

[0023] In one possible implementation, the acquisition module obtains the second blockchain address based on the second storage location and the first address index table, and uses it to perform the following operations:

[0024] Read the second address index stored in the second storage location, and look up the second address index in the first address index table;

[0025] If the first address index table does not contain the second address index, then an invalid value is returned;

[0026] If the first address index table contains the second address index, then obtain the second blockchain address corresponding to the second address index in the first address index table.

[0027] In one possible implementation, the storage location containing the first address index is used to instruct the first address index to be written into the first state Merkle tree corresponding to the blockchain;

[0028] The storage module is also used to perform the following operations:

[0029] When block-producing permission is granted, the first transaction is executed, the execution result of the first transaction is obtained, and the first transaction and its execution result are packaged together to obtain the initial block.

[0030] The first address index table is updated based on the execution result of the first transaction to obtain the second address index table; the second address index table contains the first address index table, and the number of first rows contained in the first address index table is less than or equal to the number of second rows contained in the second address index table.

[0031] The first state Merkle tree is updated based on the execution result of the first transaction to obtain the second state Merkle tree;

[0032] Based on the second state Merkle tree, the second address index table, and the initial block, a first block awaiting consensus is generated, and consensus processing is performed on the first block awaiting consensus.

[0033] In one possible implementation, the storage module updates the first address index table based on the result of the first transaction to obtain a second address index table, which is then used to perform the following operations:

[0034] If the first transaction contains a third blockchain address that does not belong to the full set of blockchain addresses, then when the execution result of the first transaction is a successful transaction execution result, the maximum address index in the first address index table is determined.

[0035] Generate a third address index that is greater than the maximum address index. Add the index key generated by the third address index and the index value generated by the third blockchain address to the first address index table to obtain the second address index table.

[0036] In one possible implementation, the storage module generates a first block to be reached for consensus based on the second state Merkle tree, the second address index table, and the initial block, for performing the following operations:

[0037] The second address index table is hashed to obtain the table hash value. The second row number and the table hash value are combined to form the first index root of the second address index table.

[0038] Obtain the Merkle root of the second-state Merkle tree, add the first index root and the Merkle root to the block header of the initial block, and obtain the first block to be reached for consensus.

[0039] In one possible implementation, the module is also used to perform the following operations:

[0040] Obtain the second block awaiting consensus broadcast by the second blockchain node with block-producing authority, execute the second transaction in the second block awaiting consensus, and obtain the execution result of the second transaction;

[0041] Based on the execution result of the second transaction, the first address index table is updated to obtain the third address index table;

[0042] Based on the third address index table, generate an index root to be verified, and perform legality verification on the second consensus block based on the index root to be verified to obtain the block verification result;

[0043] The block verification result is returned to the second blockchain node so that the second blockchain node can store and process the second block to be reached for consensus based on the block verification result.

[0044] In one possible implementation, the acquisition module verifies the legitimacy of the second consensus block based on the index root to be verified, and obtains the block verification result, which is then used to perform the following operations:

[0045] Obtain the second index root from the block header of the second block to be reached for consensus, and compare the index root to be verified with the second index root.

[0046] If the index root to be verified is the same as the second index root, then the legality of the second block to be reached is verified, and the block verification result is obtained.

[0047] If the index root to be verified is different from the second index root, then the block abnormal result is determined as the block verification result of the second block to be reached for consensus.

[0048] In one possible implementation, the module is also used to perform the following operations:

[0049] If the block verification result is an abnormal result, then the target block is obtained; the target block refers to the block with the highest block height in the blockchain.

[0050] Get the historical index root in the block header of the target block, and get the number of historical rows in the historical index root;

[0051] Determine the number of rows to be deleted in the third address index table that is greater than the number of historical rows; associate the blockchain address and address index located at the number of rows to be deleted with the second block to be reached for consensus;

[0052] Delete the blockchain address and its index located in the row to be deleted in the third address index table to obtain the first address index table.

[0053] This application provides a computer device, including: a processor, a memory, and a network interface;

[0054] The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to call the computer programs so that the computer device executes the methods in the embodiments of this application.

[0055] One aspect of this application provides a computer-readable storage medium storing a computer program adapted for loading by a processor and executing the methods described in this application.

[0056] One aspect of this application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the method described in this application.

[0057] In this embodiment, the first blockchain node obtains the address write parameters of the address write instruction, which include a first storage location and a first blockchain address. Based on the address write instruction, it obtains a first address index table, which includes all blockchain addresses and the address index corresponding to each blockchain address. It queries the first address index table for the first blockchain address; if the first address index table contains the first blockchain address, it obtains the first address index corresponding to the first blockchain address in the first address index table and stores the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address. As can be seen, by replacing the blockchain address with a smaller address index and storing the address index in a designated storage location (i.e., writing the world state corresponding to the blockchain), the storage space consumption of the blockchain can be reduced, thus reducing storage space costs. Attached Figure Description

[0058] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0059] Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application;

[0060] Figure 2 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 1 ;

[0061] Figure 3 This application provides an example of a blockchain-based data processing scenario. Figure 1 ;

[0062] Figure 4 This application provides an example of a blockchain-based data processing scenario. Figure 2 ;

[0063] Figure 5 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 2 ;

[0064] Figure 6 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 3 ;

[0065] Figure 7 This application provides an example of a blockchain-based data processing scenario. Figure 3 ;

[0066] Figure 8 This application provides an example of a blockchain-based data processing scenario. Figure 4 ;

[0067] Figure 9 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 4 ;

[0068] Figure 10 This is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of this application;

[0069] Figure 11 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0070] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0071] Please see Figure 1 , Figure 1 This is a schematic diagram of a system architecture provided in an embodiment of this application. For example... Figure 1 As shown, the system architecture can be a blockchain network 10, which may include a witness network 10a (also called a business network) and a consensus network 10b. Nodes in the witness network 10a can be called business nodes, possessing some data. Business nodes primarily perform business execution and do not participate in the accounting consensus. They obtain block header data and some authorized visible data from the consensus network 10b through identity authentication. The consensus network 10b can also be called the core network and accounting network. Nodes in the consensus network 10b can be called consensus nodes, possessing all the data. The witness network 10a and the consensus network 10b operate in different network environments. Typically, the witness network 10a is in a public network, while the consensus network 10b is in a private network, and the two interact through a routing boundary.

[0072] Please see again. Figure 1 Witness network 10a may include business node 101a, business node 102a, business node 103a, ..., business node 104a. It is understood that witness network 10a may include one or more witness networks. In practical applications, due to different application scenarios, one or more types of witness networks can be set up; the number of witness networks is not limited here. Witness network 10a may include one or more business nodes; the number of business nodes is not limited here.

[0073] Please see again. Figure 1 Consensus network 10b may include consensus node 101b, consensus node 102b, consensus node 103b, ..., consensus node 104b. It is understood that the aforementioned consensus network 10b may include one or more consensus networks. In practical applications, due to different application scenarios, one or more types of consensus networks can be set up; the number of consensus networks will not be limited here. The aforementioned consensus network 10b may include one or more consensus nodes; the number of consensus nodes will not be limited here.

[0074] Each blockchain node (including consensus nodes in consensus network 10b and business nodes in witness network 10a) can receive business transactions (hereinafter referred to as transactions) sent by clients during normal operation, generate blocks based on the received business transactions, and then perform block on-chain processing. It is understood that in the specific embodiments of this application, data related to user information (such as business transactions) is involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant regions.

[0075] To ensure data communication between blockchain nodes, data connections can exist between each blockchain node. For example, there is a data connection between business node 101a and business node 102a, a data connection between business node 101a and business node 103a, and a data connection between consensus node 101b and consensus node 104b.

[0076] Furthermore, there are data connections between witness network 10a and consensus network 10b. For example, there are data connections between business node 101a and consensus node 102b, business node 101a and consensus node 103b, and consensus node 101b and business node 104a.

[0077] It is understandable that blockchain nodes can transmit data or blocks through the aforementioned data connections. These data connections between blockchain nodes can be based on node identifiers. Each blockchain node in the blockchain network 10 has a corresponding node identifier, and each blockchain node can store the node identifiers of other blockchain nodes that are connected to it. This allows it to broadcast acquired data or generated blocks to other blockchain nodes based on their node identifiers. For example, business node 101a can maintain a node identifier list as shown in Table 1, which stores the node names and node identifiers of other blockchain nodes.

[0078] Table 1

[0079]

[0080]

[0081] The node identifier can be an Internet Protocol (IP) address used for interconnecting networks, or any other information that can be used to identify a blockchain node in a blockchain network.

[0082] Assuming the node identifier of business node 101a is FFFFF, business node 101a can send a transaction to be uploaded to the blockchain to consensus node 104b through the node identifier CCCCC. Consensus node 104b can determine that the transaction to be uploaded to the blockchain was sent by business node 101a through the node identifier FFFFF. Similarly, consensus node 104b can send a block consensus request to consensus node 102b through the node identifier BBBBB. Consensus node 102b can determine that the block consensus request was sent by consensus node 104b through the node identifier CCCCC. Data transmission between other blockchain nodes is also in the same way, so it will not be elaborated on one by one.

[0083] It is understood that the above data connection is not limited to the connection method. It can be connected directly or indirectly through wired communication, or directly or indirectly through wireless communication, or through other connection methods. This application does not impose any restrictions on this.

[0084] Among them, such as Figure 1 The business nodes 101a, 102a, 103a, consensus nodes 101b, and 104b shown can each have a one-to-one correspondence with the corresponding roles (i.e., entity objects in the corresponding business scenarios) that need to access the blockchain network. These business scenarios can specifically include resource issuance scenarios, resource transfer scenarios, and payment scenarios. In this case, the business data information under the corresponding business scenario can specifically include resource issuance information in the resource issuance scenario, resource transfer information in the resource transfer scenario, and asset transfer records in the payment scenario. The specific content of the business data information under the corresponding business scenarios will not be listed here.

[0085] The blockchain-based data processing method provided in this application can be executed by computer devices, including but not limited to business nodes (which can be terminal devices or business servers) or consensus nodes (which can be terminal devices or business servers). The aforementioned business server can be an independent physical server, a server cluster composed of multiple physical servers, or a distributed system. It can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The aforementioned terminal devices include, but are not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The terminal devices and business servers can be directly or indirectly connected via wired or wireless means; this application does not impose any restrictions on this.

[0086] Further, please see Figure 2 , Figure 2 This is a flowchart illustrating a blockchain-based data processing method provided in an embodiment of this application. Figure 1 This blockchain-based data processing method can be executed by the first blockchain node in the blockchain network, where the first blockchain node can be any blockchain node in the blockchain network. For example... Figure 2 As shown, the data processing method may include at least the following steps S101-S103.

[0087] Step S101: Obtain the address write parameters of the address write instruction; the address write parameters include the first storage location and the first blockchain address.

[0088] Specifically, the first instruction identifier is read from the instruction stack, and the first instruction that has a mapping relationship with the first instruction identifier is obtained from the instruction mapping table; if the first instruction is an address write instruction, the address write parameter is read from the instruction stack.

[0089] To facilitate understanding, the following brief explanations are provided for some of the terms:

[0090] Blockchain: In a narrow sense, blockchain is a chain-like data structure with blocks as the basic unit. The blocks use digital digests to verify the previously obtained transaction history, which is suitable for the needs of anti-tampering and scalability in distributed ledger scenarios. In a broad sense, blockchain also refers to the distributed ledger technology implemented by the blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technology, network protocols, smart contracts, etc.

[0091] The goal of blockchain is to create a distributed data ledger that allows only additions and not deletions. The underlying structure of the ledger is a linear linked list. This list consists of interconnected "blocks," with each subsequent block recording the hash value of its predecessor. The validity of each block (and the transactions within it) can be quickly verified by calculating the hash value. If a node in the network proposes adding a new block, the block must be confirmed through a consensus mechanism.

[0092] Blockchain Nodes: Blockchain networks classify nodes into consensus nodes (also known as core nodes) and synchronization nodes (which may include data nodes and light nodes). Consensus nodes are responsible for the consensus process across the entire blockchain network; in this embodiment, a consensus node with block-producing authority (i.e., generating blocks awaiting consensus) is referred to as a block-producing node. Synchronization nodes are responsible for synchronizing the ledger information of the consensus nodes, i.e., synchronizing the latest block data.

[0093] Both consensus nodes and synchronization nodes include network communication components in their internal structure. This is because a blockchain network is essentially a peer-to-peer network, requiring communication with other nodes in the blockchain network through peer-to-peer components. Resources and services in a blockchain network are distributed across various nodes, and information transmission and service implementation occur directly between nodes without the need for intermediaries or centralized servers (third parties).

[0094] A blockchain address is a public key hash value used to store digital resources. It is a string of numbers and letters that uniquely identifies the owner of a digital resource. Blockchain addresses are typically derived from the public key using cryptographic algorithms to ensure the identity of business entities participating in the blockchain and the security of business transactions. Each blockchain address is unique and irreversible.

[0095] A smart contract is a computer protocol designed to disseminate, verify, or execute contracts in an informational manner. In a blockchain system, a smart contract (or simply contract) is code that all nodes on the blockchain can understand and execute, capable of performing arbitrary logic and producing results. In practical applications, smart contracts are managed and tested through transactions on the blockchain. Each transaction is equivalent to a Remote Procedure Call (RPC) request to the blockchain system. If a smart contract is like an executable program, the blockchain is like the operating system providing the runtime environment. A blockchain can contain multiple contracts, distinguished by contract identity (ID), identifier, or name.

[0096] A major category of smart contract state storage in blockchain systems is address type, where the blockchain address (representing an account) is a variable. Address variables are widely used to store the owner of assets and the holder of permissions; that is, the state of a digital resource can be represented by the blockchain address that holds it. For example, when a resource issuer issues unique and non-fungible digital resources on the blockchain, such as digital resources corresponding to electronic images or physical buildings, the issuer considers the holder of the digital resource (i.e., the blockchain address) as a variable. For instance, if blockchain address 111 obtains an electronic image from the resource issuer, the electronic image belongs to blockchain address 111. Subsequently, blockchain address 111 transfers the electronic image to blockchain address 112. For the electronic image, the blockchain address to which it belongs is a variable.

[0097] This application mainly describes the scenario of using a blockchain address as a variable (state). However, a blockchain address is a large integer, such as 160 bits, which occupies a large amount of space. Moreover, due to different business needs, multiple blockchain addresses are often redundantly stored. For example, different business contracts may redundantly store multiple blockchain addresses. For example, when the owners of different unique digital resources are the same blockchain address, the blockchain address needs to be stored repeatedly, which further exacerbates the space storage cost.

[0098] To address the issue of redundant on-chain storage of blockchain addresses and thus reduce blockchain storage space consumption, this application proposes an efficient blockchain state storage technology based on address indexing. Please also refer to... Figure 3 , Figure 3 This application provides an example of a blockchain-based data processing scenario. Figure 1 .like Figure 3 As shown, the first blockchain node 20a provides a smart contract virtual machine. The smart contract virtual machine refers to the environment in which blockchain smart contracts run. It has multiple preset instructions that can directly operate on the underlying database and change the storage.

[0099] The first blockchain node 20a reads the first instruction identifier from the instruction stack 20b through the smart contract virtual machine. Instruction stack 20b is a stack (or simply stack) used to store instruction identifiers. It has the basic properties of a stack: data can be inserted or deleted at the top, while the bottom is fixed and data insertion or deletion is not allowed. Instruction stack 20b also has the Last-In-First-Out (LIFO) property. Therefore, the first instruction identifier is the instruction identifier at the top of instruction stack 20b, such as... Figure 3 The example instruction identifier 1.1, instruction stack 20b also includes instruction identifier 1.2, ..., instruction identifier 1.n.

[0100] The first blockchain node 20a calls the instruction mapping table 20c, which includes all the instructions in the smart contract virtual machine and the instruction identifier corresponding to each instruction. Figure 3 Example instruction mapping table 20c contains instruction identifier 1.1 and address write instruction that is mapped to instruction identifier 1.1, instruction identifier 1.2 and address read instruction that is mapped to instruction identifier 1.2, ..., instruction identifier 1.n and address unregister instruction that is mapped to instruction identifier 1.n. Figure 3 In the example, the first instruction is identified as instruction identifier 1.1. Through the instruction mapping table 20c, the first blockchain node 20a can obtain the first instruction that has a mapping relationship with instruction identifier 1.1, that is... Figure 3Example of an address write instruction. This application embodiment adds a system-level address write instruction, denoted as ADDRSTORE, to the blockchain smart contract. The function of the address write instruction is to write the state of an address type variable when writing the world state.

[0101] Furthermore, the first blockchain node 20a reads the address from the instruction stack 20b and writes it to parameter 20e, which is the element at the top of the stack. Figure 3 The example consists of two elements: position 1 for the first storage location and address 1 for the first blockchain address.

[0102] Step S102: Obtain the first address index table according to the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address.

[0103] Specifically, since blockchain addresses occupy a large amount of space and may be stored repeatedly in actual applications, resulting in greater storage space consumption, this application embodiment replaces the blockchain address that needs to be stored with a corresponding address index that occupies less space when it receives the address write instruction, in order to reduce storage space.

[0104] Please see again. Figure 3 The first blockchain node 20a, based on the address write instruction, calls the first address index table 20d. Figure 3 Example: The total number of blockchain addresses in the current blockchain is m, where m is a positive integer greater than 1. The first address index table 20d includes index keys generated by address indexes and index values ​​generated by blockchain addresses. Figure 3 Example: The first address index table 20d contains m index key-value pairs. The first index key-value pair contains the address index with a value of 0 and its corresponding blockchain address, i.e. Figure 3 In the address 0, the second index key-value pair contains the address index with a value of 1 and its corresponding blockchain address, that is... Figure 3 Address 1 in the database, the third index key-value pair contains the address index with a value of 2 and its corresponding blockchain address, that is... Figure 3 In the database, the m-th index key-value pair contains the address index with a value of m-1 and its corresponding blockchain address, i.e. Figure 3 The address m-1 in the memory.

[0105] Step S103: Query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, obtain the first address index corresponding to the first blockchain address in the first address index table and store the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0106] Specifically, if the first address index table does not contain the first blockchain address, then the maximum address index in the first address index table is determined; a first address index greater than the maximum address index is generated, and an index relationship between the first address index and the first blockchain address is constructed in the first address index table.

[0107] Please see again. Figure 3 The first blockchain node 20a queries the first blockchain address in the first address index table 20d, that is... Figure 3 Example address 1, because Figure 3 The example's first address index table 20d contains address 1, therefore the first blockchain node 20a obtains the first address index 20f in the first address index table 20d that has an index relationship with address 1, that is... Figure 3 The example in the text shows an address index with a value of 1. In this embodiment, the first blockchain node 20a does not write address 1 from the address writing parameters (including position 1 and address 1) to position 1, but instead writes the first address index 20f, which has an index relationship with address 1, to position 1. This can be understood as writing the world state of the blockchain not to the large blockchain address, but to the small address index that has a mapping relationship with the blockchain address. Since the address index occupies little space, storage space can be saved. If there is redundant storage address index, the use of storage space is further reduced, thus further reducing storage space costs.

[0108] The preceding text describes the scenario where the first address index table contains the first blockchain address; the following text describes the scenario where the first address index table does not contain the first blockchain address. Please refer to both descriptions. Figure 3 as well as Figure 4 , Figure 4 This application provides an example of a blockchain-based data processing scenario. Figure 2 .like Figure 4 As shown, the address write parameter 20e includes position 1 for the example first storage location and address 1 for the example first blockchain address.

[0109] The first blockchain node 20a calls the first address index table 20f according to the address write instruction. Figure 4 Example: The number of full blockchain addresses in the current blockchain is m, where m is a positive integer greater than 1. Figure 4 Example: The first address index table 20f contains m index key-value pairs. The first index key-value pair contains the address index with a value of 0 and its corresponding blockchain address, i.e. Figure 3 In the address 0, the second index key-value pair contains the address index with a value of 3 and its corresponding blockchain address, that is... Figure 3 Address 3 in the database, the third index key-value pair contains the address index with a value of 2 and its corresponding blockchain address, that is... Figure 3 In the database, the m-th index key-value pair contains the address index with value m and its corresponding blockchain address, i.e. Figure 3 The address m in the memory.

[0110] First blockchain node 20a queries the first blockchain address in the first address index table 20f. Assume the first address index table 20f does not contain the first blockchain address, for example... Figure 4 Given address 1 in the example, the maximum address index in the first address index table 20f is determined. Figure 4 In the example, the address index with value m is the maximum address index. The first blockchain node 20a generates a first address index 20g that is greater than the maximum address index, such as... Figure 4 In the context of m+1, further, an index relationship is constructed between the first address index 20g and the first blockchain address in the first address index table 20f, that is, an index is added to the first address index table 20f with the first address index 20g ( Figure 4 The index key generated by the example (m+1), and the first blockchain address ( Figure 4 The example is the index value generated from address 1), such as... Figure 4 The example first address index table 20h is shown. Subsequently, the first blockchain node 20a stores address 1 and writes it to position 1.

[0111] In this embodiment, the first blockchain node obtains the address write parameters of the address write instruction, which include a first storage location and a first blockchain address. Based on the address write instruction, it obtains a first address index table, which includes all blockchain addresses and the address index corresponding to each blockchain address. It queries the first address index table for the first blockchain address; if the first address index table contains the first blockchain address, it obtains the first address index corresponding to the first blockchain address in the first address index table and stores the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address. As can be seen, by replacing the blockchain address with a smaller address index and storing the address index in a designated storage location (i.e., writing the world state corresponding to the blockchain), the storage space consumption of the blockchain can be reduced, thus reducing storage space costs.

[0112] Further, please see Figure 5 , Figure 5 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 2 This blockchain-based data processing method can be executed by the first blockchain node in the blockchain network, where the first blockchain node can be any blockchain node in the blockchain network. For example... Figure 5As shown, the data processing method may include at least the following steps S201-S206.

[0113] Step S201: Obtain the address write parameters of the address write instruction; the address write parameters include the first storage location and the first blockchain address.

[0114] Specifically, in the smart contract virtual machine, the first blockchain node reads the instruction identifier corresponding to the program counter from the instruction stack, and maps the instruction identifier to the corresponding preset instruction according to the instruction mapping table. For the address write instruction ADDRSTORE, it is as follows:

[0115] 0x instruction identifier → ADDRSTORE[STACK_TOP]

[0116] For example, if 0xFE is the instruction identifier, then when the smart contract virtual machine reads that the instruction identifier corresponding to the program counter is 0xFE, it maps it into the AADDRSTORE instruction, whose parameter is STACK_TOP, which is the content of the element at the top of the virtual machine stack. The smart contract virtual machine reads the two elements at the top of the stack and parses them into address write parameters according to the following tuple, as follows:

[0117] ADDRSTORE_PARA=<Key,Value>

[0118] ADDRSTORE_PARA is the address to be written carried by the ADDRSTORE instruction. The Key and Value in the tuple correspond to the key and value of the SSTORE instruction in smart contract technology, respectively. The SSTORE instruction is used to store data into the smart contract's storage slot. Specifically, it accepts two parameters: the address of the storage slot and the value to be stored. The execution result of the SSTORE instruction is to write the new value into the specified storage slot.

[0119] Step S202: Obtain the first address index table according to the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address.

[0120] Step S203: Query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, obtain the first address index corresponding to the first blockchain address in the first address index table and store the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0121] Specifically, in conjunction with steps S202 and S203, the smart contract's instruction executor searches the global address index (i.e., the first address index table) to see if the first blockchain address already exists in the first address index table, and then further queries its corresponding first address index. The entire process can be described by the following formula (1):

[0122] Row=QUERY(“SELECT ID WHERE ADDR=Value”) (1)

[0123] Taking a query using a relational database such as MySQL as a global address index table as an example, Row represents the rows retrieved, and QUERY is a function that executes a query on the MySQL database. Inside QUERY is a MySQL statement. If the first blockchain address value exists, its ID is returned as the result set of Row.

[0124] If the length of Row is 0, then the ID does not exist. The first blockchain node retrieves the highest address index from the first address index table, records it as MaxID, and writes (MaxID+1) and Value into the first address index table. Inserting (MaxID+1) and Value can be represented by the following formula (2):

[0125] QUERY("INSERT ID=(MaxID+1),ADDR=Value") (2)

[0126] Furthermore, the first blockchain node uses the newly generated (MaxID+1) as the first address index to execute the address write instruction, thus writing the first address index to the first storage location.

[0127] In summary, the blockchain address, originally written to the world state, is the high-order bits (e.g., 160 bits). In this embodiment, it is shortened to a low-order bits (e.g., 16 bits) address index, and the blockchain address is stored only once, that is, associated with the corresponding address index and stored in the address index table. Subsequently, in other businesses (or other assets, copyrights, etc.) involving this blockchain address, the low-order bits (which occupy less space) address index are redundantly stored. Therefore, when enough redundancy is stored, theoretically, the storage space saved in the blockchain should approach (160-16) / 160 = 90%, significantly reducing the address type's footprint in world state storage.

[0128] Step S204: Read the second instruction identifier from the instruction stack and obtain the second instruction that has a mapping relationship with the second instruction identifier from the instruction mapping table.

[0129] Step S205: If the second instruction is an address read instruction, then read the address read parameters in the instruction stack; the address read parameters include the second storage location.

[0130] Specifically, in conjunction with steps S204 and S205, when the smart contract virtual machine executes a transaction, the second instruction identifier corresponding to the program counter is read from the instruction stack, and the second instruction identifier is mapped to the corresponding preset instruction according to the instruction mapping table. For the address read instruction ADDRLOAD, it is as follows:

[0131] 0x instruction identifier → ADDRLOAD[STACK_TOP]

[0132] For example, if 0xFF is the second instruction identifier, then when the smart contract virtual machine reads that the instruction corresponding to the program counter is 0xFF, it will map it into the ADDRLOAD instruction, which is used to read the blockchain address.

[0133] The parameter of the address read instruction is STACK_TOP, which is the content of the element at the top of the virtual machine stack, as shown below:

[0134] ADDRLOAD_PARA = <key>

[0135] The function is to read the stored data at the specified KEY location.

[0136] Step S206: Obtain the second blockchain address based on the second storage location and the first address index table, and return the second blockchain address to the top of the instruction stack.

[0137] Specifically, the second address index stored in the second storage location is read, and the second address index is queried in the first address index table; if the first address index table does not contain the second address index, an invalid value is returned; if the first address index table contains the second address index, the second blockchain address corresponding to the second address index in the first address index table is obtained.

[0138] As can be seen from step S203, the data written to the world state is an address index; for example, the data written to the first storage location is the first address index. Therefore, the first blockchain node reads the second address index stored in the second storage location.

[0139] The smart contract's instruction executor searches the global address index (referred to as the address index table in this application) to see if the second address index exists in the first address index table. If the second address index exists in the first address index table, it queries the corresponding second blockchain address ADDR. This process can be represented by the following formula (3):

[0140] Row=QUERY(""SELECT ADDR WHERE ID=ID' ””) (3)

[0141] In formula (3), ID' represents the second address index. If Row has a value, the second blockchain address ADDR is returned to the instruction executor. If Row has no value, an empty value is returned, i.e., a zero address, ADDR = 0, which can also be understood as the second blockchain address being an invalid value.

[0142] After reading the second blockchain address, the first blockchain node returns the second blockchain address to the top of the stack using the stack's Push function, as shown in formula (4) below:

[0143] STACK = STACK.Push(ADDR) (4)

[0144] As mentioned above, by replacing large blockchain addresses with smaller address indexes and storing the address indexes in a designated storage location, i.e., writing the corresponding world state of the blockchain, the storage space consumption of the blockchain can be reduced, thus reducing storage space costs.

[0145] Further, please see Figure 6 , Figure 6 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 3 This blockchain-based data processing method can be executed by the first blockchain node in the blockchain network, where the first blockchain node can be any blockchain node in the blockchain network. For example... Figure 6 As shown, the data processing method may include at least the following steps S301-S307.

[0146] Step S301: Obtain the address write parameters of the address write instruction; the address write parameters include the first storage location and the first blockchain address.

[0147] Step S302: Obtain the first address index table according to the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address.

[0148] Step S303: Query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, obtain the first address index corresponding to the first blockchain address in the first address index table and store the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0149] For the specific implementation process of steps S301-S303, please refer to the above text. Figure 2 The descriptions in steps S101-S103 are not repeated here.

[0150] Step S304: When block production permission is granted, execute the first transaction, obtain the execution result of the first transaction, and package the first transaction and its execution result into an initial block.

[0151] Specifically, a block is a data packet that carries transaction data on a blockchain network. It is a data structure that is marked with a timestamp and the hash value corresponding to the previous block. The transactions in the block are verified and confirmed by the network's consensus mechanism.

[0152] A block consists of a block header and a block body. The block header records metadata about the current block, including the current version number, the hash value of the previous block, a timestamp, a random number, and the hash value of the Merkle root. The block body records detailed data generated over a period of time, including all verified transactions and other information generated during the block creation process; it can be understood as a form of ledger representation. Furthermore, the detailed data in the block body may include a unique Merkle root recorded in the block header, generated through a Merkle tree hashing process.

[0153] Please see also Figure 7 , Figure 7 This application provides an example of a blockchain-based data processing scenario. Figure 3 .like Figure 7 As shown, the first blockchain node 20a stores a first address index table 20d. For a description of the first address index table 20d, please refer to the above text. Figure 3 The description of the first address index table 20d is omitted here. The first blockchain node 20a with block production authority refers to the blockchain node that has obtained the right to record transactions. Therefore, the first blockchain node 20a can obtain a batch of transactions to be uploaded to the chain from the transaction pool 30a.

[0154] Figure 7 Example transaction pool 30a contains transactions 31, 32, 33, ..., 3n. Example first transaction includes transactions 31, 32, and 33 from transaction pool 30a. First blockchain node 20a executes each transaction in the first transaction, i.e., first blockchain node 20a executes... Figure 7 For example, in transaction 31, we obtain the execution result corresponding to transaction 31. Figure 7 Abbreviated as execution result 41, execution Figure 7 Example transaction 32, obtain the transaction execution result corresponding to transaction 32. Figure 7 Abbreviated as execution result 42, execution Figure 7 For example, in transaction 33, we obtain the execution result corresponding to transaction 33. Figure 7 This is referred to as Execution Result 43. This application embodiment does not limit the content of the transaction; it can be set according to the actual application scenario.

[0155] Furthermore, the first blockchain node 20a packages the first transaction and its execution result into an initial block 30b. The initial block 30b includes a block body and a block header. In this embodiment, the block body has the same structure as a regular block, i.e., it includes the first transaction (e.g., ...). Figure 7 Example transactions 31, 32, and 33), the result of the first transaction execution (e.g. Figure 7 The example execution results 41, 42, and 43 are shown. The block header structure in this embodiment is not entirely the same as that of a regular block; it will not be described in detail here. Please refer to the description of step S307 below. For example... Figure 7 Example initial block 30b contains the parent block hash, that is, the hash value corresponding to the predecessor block.

[0156] Step S305: Update the first address index table according to the first transaction execution result to obtain the second address index table; the second address index table contains the first address index table, and the number of first rows contained in the first address index table is less than or equal to the number of second rows contained in the second address index table.

[0157] Specifically, if the first transaction contains a third blockchain address that does not belong to the full set of blockchain addresses, then when the execution result of the first transaction is a successful transaction, the maximum address index in the first address index table is determined; a third address index greater than the maximum address index is generated, and the index key generated by the third address index and the index value generated by the third blockchain address are added to the first address index table to obtain the second address index table.

[0158] The first address index table 20d contains all the blockchain addresses in the blockchain before the first transaction was executed, such as... Figure 7 In the example, addresses 0, 1, 2, ..., m-1, when the first transaction is executed, may affect several address indices, which can be represented by the following formula (5):

[0159] AddrIndexes2=Exec(AddrIndexes1,TXs) (5)

[0160] In formula (5), Exec is the function of the accounting program to execute transactions, AddrIndexes1 is the first address index table before the execution of the first transaction, and AddrIndexes2 is the second address index table after the execution of the transaction.

[0161] Please see again. Figure 7 , Figure 7 The example first transaction (including transactions 31, 32, and 33) contains a third blockchain address 30c, i.e. Figure 7 The third blockchain address 30c does not belong to the first address index table 20d, meaning the third blockchain address 30c does not belong to the full blockchain addresses before the execution of the first transaction. Therefore, the first blockchain node 20a obtains the maximum address index 30d in the first address index table 20d, i.e. Figure 7 Example m-1 generates a third address index 30e that is greater than the maximum address index 30d, such as Figure 7 Example m. The first blockchain node 20a adds the index key generated by the third address index 30e and the index value generated by the third blockchain address 30c to the first address index table 20d, resulting in the second address index table 30f. Obviously, the second address index table 30f contains the first address index table 20d, and also contains the newly added third address index 30e and the third blockchain address 30c.

[0162] Step S306: Update the first state Merkle tree according to the execution result of the first transaction to obtain the second state Merkle tree.

[0163] Specifically, the storage location containing the first address index is used to instruct the first address index to be written into the first state Merkle tree corresponding to the blockchain.

[0164] A Merkle tree can be understood as the world state of a blockchain, that is, the set of states arranged according to the Merkle-Patricia tree for the actual execution of transactions. In this embodiment, when the blockchain address is used as a variable, in order to save storage space, the blockchain address is only stored once, that is, stored in the address index table, and the address index that has a mapping relationship with the blockchain address is written into the world state, that is, stored.

[0165] Step S307: Generate a first consensus block based on the second state Merkle tree, the second address index table, and the initial block, and perform consensus processing on the first consensus block.

[0166] Specifically, the second address index table is hashed to obtain the table hash value. The second row number and the table hash value are combined to form the first index root of the second address index table. The Merkle root of the second state Merkle tree is obtained. The first index root and the Merkle root are added to the block header of the initial block to obtain the first block to be reached for consensus.

[0167] A hash value, also known as an information feature value or characteristic value, is generated by converting input data of arbitrary length into cryptographic data and producing a fixed output using a hash algorithm. The original input data cannot be retrieved by decrypting the hash value; it is a one-way cryptographic function. In a blockchain, each block (except the initial block) contains the hash values ​​of its predecessor blocks. The hash value is a core and crucial aspect of blockchain technology, preserving the authenticity of recorded and viewed data, as well as the integrity of the blockchain as a whole.

[0168] As shown above, the address index is established by the blockchain node's own smart contract virtual machine. If the address index stored by the node differs from that stored by other blockchain nodes, it will affect the consistency and security of the blockchain system. Current blockchain consensus mechanisms can only verify the consistency of the world state and lack consensus on address index storage. To address this issue, this application proposes a global address consensus and rollback technology based on address index roots to reduce storage space costs and improve the security of the address index.

[0169] In this embodiment of the application, the index root is defined as a binary tuple, as shown in the following formula (6):

[0170] AddrIndexRoot =<Len(AddrIndexes),SHA256(AddrIndexes)> (6)

[0171] In formula (6), Len is a function to obtain the number of rows in the index table, and SHA256 is a hash function, which refers to the function that hashes the index table.

[0172] Please see also Figure 7 as well as Figure 8 , Figure 8 This application provides an example of a blockchain-based data processing scenario. Figure 4 .like Figure 8 As shown, the first blockchain node 20a performs hash processing on the second address index table 30f to obtain the table hash value 30g. Figure 8 For example, given Cc1...wd, retrieve the second row number 30h from the second address index table 30f. Figure 8 The example is m+1, that is, from 0, 1, 2, 3 to m. As shown in formula (6), the first blockchain node 20a combines the table hash value 30g and the second row number 30h into the first index root of the second address index table 30f, and adds the first index root and the Merkle tree root to the second address index table 30f. Figure 7 From the initial block 30b, the first consensus block 30i is obtained.

[0173] The first blockchain node performs consensus processing on the first block awaiting consensus, which involves broadcasting the first block to the blockchain network so that blockchain nodes with consensus permissions can verify its legitimacy. This application embodiment does not describe in detail the process of blockchain nodes with consensus permissions verifying the legitimacy of the first block; please refer to the following text. Figure 9 Description of the corresponding embodiments.

[0174] Understandably, if the consensus result of the first block to be reached is a consensus pass, the first blockchain node will put the first block to be reached on the chain, that is, store the first block to be reached. If the consensus result of the first block to be reached is a consensus failure, the first blockchain node will discard the first block to be reached.

[0175] As described above, by replacing large-space blockchain addresses with smaller-space address indexes and storing the address indexes in a designated storage location (i.e., writing the corresponding world state of the blockchain), the storage space consumption of the blockchain can be reduced, thus lowering storage costs. Furthermore, this embodiment generates a binary index root and writes it into the block header, thereby achieving global address consensus for the address index root and improving the security of global address index consensus.

[0176] Further, please see Figure 9 , Figure 9 This is a flowchart illustrating a data processing method provided in an embodiment of this application. Figure 4 This blockchain-based data processing method can be executed by the first blockchain node in the blockchain network, where the first blockchain node can be any blockchain node in the blockchain network. For example... Figure 9 As shown, the data processing method may include at least the following steps S401-S407.

[0177] Step S401: Obtain the address write parameters of the address write instruction; the address write parameters include the first storage location and the first blockchain address.

[0178] Step S402: Obtain the first address index table according to the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address.

[0179] Step S403: Query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, obtain the first address index corresponding to the first blockchain address in the first address index table and store the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0180] For the specific implementation process of steps S401-S403, please refer to the above text. Figure 2 The descriptions in steps S101-S103 are not repeated here.

[0181] Step S404: Obtain the second consensus block broadcast by the second blockchain node with block production authority, execute the second transaction in the second consensus block, and obtain the execution result of the second transaction.

[0182] Specifically, the second blockchain node with block-producing permissions in this application embodiment can be equivalent to the one described above. Figure 6 The first blockchain node in the corresponding embodiment, therefore, the understanding of the second consensus block can be found in the first consensus block described above.

[0183] As the first blockchain node with consensus authority, its execution process for the second transaction is similar to the above. Figure 6 The execution process of the first transaction described in step S304 of the corresponding embodiment is the same, so it will not be repeated here.

[0184] Step S405: Based on the execution result of the second transaction, update the first address index table to obtain the third address index table.

[0185] Specifically, the process by which the first blockchain node, possessing consensus authority, updates the first address index table is similar to the above. Figure 6 The update process of the first address index table described in step S305 of the corresponding embodiment is the same, so it will not be repeated here.

[0186] Step S406: Generate an index root to be verified based on the third address index table, and perform legality verification on the second consensus block based on the index root to be verified to obtain the block verification result.

[0187] Specifically, the second index root in the block header of the second block to be reached for consensus is obtained, and the index root to be verified is compared with the second index root. If the index root to be verified is the same as the second index root, the legality of the second block to be reached for consensus is verified, and the block verification result is obtained. If the index root to be verified is different from the second index root, the abnormal result of the block is determined as the block verification result of the second block to be reached for consensus.

[0188] It is understandable that if the index root to be verified is the same as the second index root, then the remaining verification content of the second block to be reached for consensus is the same as the verification content of a regular block. Therefore, storage will not be elaborated upon, and the verification content and method can be set according to the actual application scenario.

[0189] Step S407: Return the block verification result to the second blockchain node so that the second blockchain node can store and process the second block to be reached for consensus based on the block verification result.

[0190] Specifically, if the block verification result is an abnormal result, the target block is obtained; the target block refers to the block with the highest block height in the blockchain; the historical index root in the block header of the target block is obtained, and the historical row number in the historical index root is obtained; the number of rows to be deleted in the third address index table that is greater than the number of historical rows is determined; the blockchain address and address index located at the number of rows to be deleted are associated with the second block to be reached for consensus; the blockchain address and address index located at the number of rows to be deleted in the third address index table are deleted to obtain the first address index table.

[0191] The embodiments of this application are mainly divided into two parts: one is the address variable index storage read / write technology based on address read / write instructions, and the other is the global address consensus and rollback technology based on address index roots. These two parts together constitute a high-efficiency blockchain state storage technology based on a global address index.

[0192] As described above, by replacing large-space blockchain addresses with smaller-space address indexes and storing the address indexes in a designated storage location (i.e., writing the corresponding world state of the blockchain), the storage space consumption of the blockchain can be reduced, thus lowering storage costs. Furthermore, this embodiment generates a binary index root and writes it into the block header, thereby achieving global address consensus for the address index root and improving the security of global address index consensus.

[0193] Further, please see Figure 10 , Figure 10 This is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of this application. Figure 10 As shown, the blockchain-based data processing device 1 can run on a blockchain node. The aforementioned blockchain-based data processing device 1 can be a computer program (including program code) running on a computer device; for example, the data processing device is an application software. This data processing device can be used to execute the corresponding steps in the methods provided in the embodiments of this application. Figure 10 As shown, the blockchain-based data processing device 1 may include an acquisition module 11 and a storage module 12.

[0194] The acquisition module 11 is used to acquire the address write parameters of the address write instruction; the address write parameters include the first storage location and the first blockchain address;

[0195] The acquisition module 11 is also used to acquire a first address index table based on the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address;

[0196] The storage module 12 is used to query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, the first address index corresponding to the first blockchain address in the first address index table is obtained and the first address index is stored in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0197] In one possible implementation, module 11 acquires the address write parameters of the address write instruction and uses them to perform the following operations:

[0198] Read the first instruction identifier from the instruction stack, and retrieve the first instruction that has a mapping relationship with the first instruction identifier from the instruction mapping table;

[0199] If the first instruction is an address write instruction, then read the address write parameters from the instruction stack.

[0200] In one possible implementation, the storage module 12 is also used to perform the following operations:

[0201] If the first address index table does not contain the first blockchain address, then determine the maximum address index in the first address index table;

[0202] Generate a first address index that is greater than the maximum address index, and construct an index relationship between the first address index and the first blockchain address in the first address index table.

[0203] In one possible implementation, module 11 is also used to perform the following operations:

[0204] Read the second instruction identifier from the instruction stack, and retrieve the second instruction that has a mapping relationship with the second instruction identifier from the instruction mapping table;

[0205] If the second instruction is an address read instruction, then the address read parameters in the instruction stack are read; the address read parameters include the second storage location;

[0206] Based on the second storage location and the first address index table, obtain the second blockchain address and return the second blockchain address to the top of the instruction stack.

[0207] In one possible implementation, the acquisition module 11 obtains the second blockchain address based on the second storage location and the first address index table, and performs the following operations:

[0208] Read the second address index stored in the second storage location, and look up the second address index in the first address index table;

[0209] If the first address index table does not contain the second address index, then an invalid value is returned;

[0210] If the first address index table contains the second address index, then obtain the second blockchain address corresponding to the second address index in the first address index table.

[0211] In one possible implementation, the storage location containing the first address index is used to instruct the first address index to be written into the first state Merkle tree corresponding to the blockchain;

[0212] Storage module 12 is also used to perform the following operations:

[0213] When block-producing permission is granted, the first transaction is executed, the execution result of the first transaction is obtained, and the first transaction and its execution result are packaged together to obtain the initial block.

[0214] The first address index table is updated based on the execution result of the first transaction to obtain the second address index table; the second address index table contains the first address index table, and the number of first rows contained in the first address index table is less than or equal to the number of second rows contained in the second address index table.

[0215] The first state Merkle tree is updated based on the execution result of the first transaction to obtain the second state Merkle tree;

[0216] Based on the second state Merkle tree, the second address index table, and the initial block, a first block awaiting consensus is generated, and consensus processing is performed on the first block awaiting consensus.

[0217] In one possible implementation, the storage module 12 updates the first address index table based on the first transaction execution result to obtain a second address index table, which is then used to perform the following operations:

[0218] If the first transaction contains a third blockchain address that does not belong to the full set of blockchain addresses, then when the execution result of the first transaction is a successful transaction execution result, the maximum address index in the first address index table is determined.

[0219] Generate a third address index that is greater than the maximum address index. Add the index key generated by the third address index and the index value generated by the third blockchain address to the first address index table to obtain the second address index table.

[0220] In one possible implementation, storage module 12 generates a first consensus block based on the second state Merkle tree, the second address index table, and the initial block, for performing the following operations:

[0221] The second address index table is hashed to obtain the table hash value. The second row number and the table hash value are combined to form the first index root of the second address index table.

[0222] Obtain the Merkle root of the second-state Merkle tree, add the first index root and the Merkle root to the block header of the initial block, and obtain the first block to be reached for consensus.

[0223] In one possible implementation, module 11 is also used to perform the following operations:

[0224] Obtain the second block awaiting consensus broadcast by the second blockchain node with block-producing authority, execute the second transaction in the second block awaiting consensus, and obtain the execution result of the second transaction;

[0225] Based on the execution result of the second transaction, the first address index table is updated to obtain the third address index table;

[0226] Based on the third address index table, generate an index root to be verified, and perform legality verification on the second consensus block based on the index root to be verified to obtain the block verification result;

[0227] The block verification result is returned to the second blockchain node so that the second blockchain node can store and process the second block to be reached for consensus based on the block verification result.

[0228] In one possible implementation, the acquisition module 11 verifies the legitimacy of the second consensus block based on the index root to be verified, and obtains the block verification result, which is used to perform the following operations:

[0229] Obtain the second index root from the block header of the second block to be reached for consensus, and compare the index root to be verified with the second index root.

[0230] If the index root to be verified is the same as the second index root, then the legality of the second block to be reached is verified, and the block verification result is obtained.

[0231] If the index root to be verified is different from the second index root, then the block abnormal result is determined as the block verification result of the second block to be reached for consensus.

[0232] In one possible implementation, module 11 is also used to perform the following operations:

[0233] If the block verification result is an abnormal result, then the target block is obtained; the target block refers to the block with the highest block height in the blockchain.

[0234] Get the historical index root in the block header of the target block, and get the number of historical rows in the historical index root;

[0235] Determine the number of rows to be deleted in the third address index table that is greater than the number of historical rows; associate the blockchain address and address index located at the number of rows to be deleted with the second block to be reached for consensus;

[0236] Delete the blockchain address and its index located in the row to be deleted in the third address index table to obtain the first address index table.

[0237] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0238] As described above, by replacing large-space blockchain addresses with smaller-space address indexes and storing the address indexes in a designated storage location (i.e., writing the corresponding world state of the blockchain), the storage space consumption of the blockchain can be reduced, thus lowering storage costs. Furthermore, this embodiment generates a binary index root and writes it into the block header, thereby achieving global address consensus for the address index root and improving the security of global address index consensus.

[0239] Further, please see Figure 11 , Figure 11 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Figure 11 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU; at least one network interface 1004; a user interface 1003; a memory 1005; and at least one communication bus 1002. The communication bus 1002 is used to enable communication between these components. In some embodiments, the user interface 1003 may include a display screen and a keyboard, and the network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be high-speed RAM or non-volatile memory, such as at least one disk storage device. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. Figure 11 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application program.

[0240] exist Figure 11 In the computer device 1000 shown, the network interface 1004 provides network communication functionality; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:

[0241] Obtain the address write parameters for the address write instruction; the address write parameters include the first storage location and the first blockchain address;

[0242] Based on the address write instruction, obtain the first address index table; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address.

[0243] The first blockchain address is queried in the first address index table. If the first blockchain address is contained in the first address index table, the first address index corresponding to the first blockchain address in the first address index table is obtained and the first address index is stored in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

[0244] It should be understood that the computer device 1000 described in the embodiments of this application can perform the data processing methods or apparatus described in the preceding embodiments, and will not be repeated here. Furthermore, the beneficial effects of using the same methods will also not be repeated.

[0245] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same methods will also not be repeated.

[0246] The aforementioned computer-readable storage medium can be an internal storage unit of the data processing apparatus or computer device provided in any of the foregoing embodiments, such as a hard disk or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.

[0247] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, enabling the computer device to perform the data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated here.

[0248] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.

[0249] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.

[0250] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.< / key>

Claims

1. A data processing method based on blockchain, characterized in that, The method is executed by the first blockchain node, and the method includes: Obtain the address write parameters of the address write instruction; the address write parameters include a first storage location and a first blockchain address; According to the address write instruction, a first address index table is obtained; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address. The first blockchain address is queried in the first address index table. If the first address index table contains the first blockchain address, the first address index corresponding to the first blockchain address in the first address index table is obtained and the first address index is stored in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

2. The method according to claim 1, characterized in that, The address write parameters for the obtained address write instruction include: Read the first instruction identifier from the instruction stack, and retrieve the first instruction that has a mapping relationship with the first instruction identifier from the instruction mapping table; If the first instruction is an address write instruction, then the address write parameters in the instruction stack are read.

3. The method according to claim 1, characterized in that, The method further includes: If the first address index table does not contain the first blockchain address, then determine the maximum address index in the first address index table; Generate a first address index that is greater than the maximum address index, and construct an index relationship between the first address index and the first blockchain address in the first address index table.

4. The method according to claim 1, characterized in that, The method further includes: Read the second instruction identifier from the instruction stack, and retrieve the second instruction that has a mapping relationship with the second instruction identifier from the instruction mapping table; If the second instruction is an address read instruction, then the address read parameters in the instruction stack are read; the address read parameters include a second storage location; Based on the second storage location and the first address index table, obtain the second blockchain address and return the second blockchain address to the top of the instruction stack.

5. The method according to claim 4, characterized in that, The step of obtaining the second blockchain address based on the second storage location and the first address index table includes: Read the second address index stored in the second storage location, and look up the second address index in the first address index table; If the first address index table does not contain the second address index, then an invalid value is returned; If the first address index table contains the second address index, then obtain the second blockchain address corresponding to the second address index in the first address index table.

6. The method according to claim 1, characterized in that, The storage location containing the first address index is used to indicate that the first address index is written into the first state Merkle tree corresponding to the blockchain; The method further includes: When block creation permission is granted, the first transaction is executed, the first transaction execution result is obtained, and the first transaction and the first transaction execution result are packaged together to obtain the initial block. The first address index table is updated based on the first transaction execution result to obtain a second address index table; the second address index table contains the first address index table, and the number of first rows contained in the first address index table is less than or equal to the number of second rows contained in the second address index table; The first state Merkle tree is updated based on the execution result of the first transaction to obtain the second state Merkle tree; Based on the second state Merkle tree, the second address index table, and the initial block, a first consensus block is generated, and consensus processing is performed on the first consensus block.

7. The method according to claim 6, characterized in that, The step of updating the first address index table based on the first transaction execution result to obtain the second address index table includes: If the first transaction contains a third blockchain address that does not belong to the full set of blockchain addresses, then when the execution result of the first transaction is a successful transaction execution result, the maximum address index in the first address index table is determined. A third address index greater than the maximum address index is generated. The index key generated by the third address index and the index value generated by the third blockchain address are added to the first address index table to obtain a second address index table.

8. The method according to claim 6, characterized in that, The step of generating the first consensus block based on the second state Merkle tree, the second address index table, and the initial block includes: The second address index table is hashed to obtain a table hash value, and the second row number and the table hash value are combined to form the first index root of the second address index table. Obtain the Merkle root of the second state Merkle tree, add the first index root and the Merkle root to the block header of the initial block, and obtain the first block to be reached for consensus.

9. The method according to claim 1, characterized in that, The method further includes: Obtain the second block awaiting consensus broadcast by the second blockchain node with block-producing authority, execute the second transaction in the second block awaiting consensus, and obtain the execution result of the second transaction; Based on the execution result of the second transaction, the first address index table is updated to obtain the third address index table; Based on the third address index table, an index root to be verified is generated. Based on the index root to be verified, the legality of the second block to be consensus is verified to obtain the block verification result. The block verification result is returned to the second blockchain node so that the second blockchain node can store and process the second block to be reached for consensus based on the block verification result.

10. The method according to claim 9, characterized in that, The step of verifying the legitimacy of the second consensus block based on the index root to be verified, and obtaining the block verification result, includes: Obtain the second index root in the block header of the second block to be consensused, and compare the index root to be verified with the second index root; If the index root to be verified is the same as the second index root, then the legality of the second consensus block is verified to obtain the block verification result. If the index root to be verified is different from the second index root, then the block anomaly result is determined as the block verification result of the second consensus block.

11. The method according to claim 9, characterized in that, Also includes: If the block verification result is an abnormal result, then the target block is obtained; the target block refers to the block with the highest block height in the blockchain. Obtain the historical index root in the block header of the target block, and obtain the historical row number in the historical index root; The number of rows to be deleted that is greater than the number of historical rows in the third address index table is determined; the blockchain address and address index located at the number of rows to be deleted are associated with the second block to be reached for consensus. The blockchain address and address index located at the number of rows to be deleted in the third address index table are deleted to obtain the first address index table.

12. A data processing device based on blockchain, characterized in that, The device operates on a first blockchain node, and the device includes: The acquisition module is used to acquire the address write parameters of the address write instruction; the address write parameters include a first storage location and a first blockchain address; The acquisition module is further configured to acquire a first address index table according to the address write instruction; the first address index table includes all blockchain addresses in the blockchain and the address index corresponding to each blockchain address. The storage module is used to query the first blockchain address in the first address index table. If the first address index table contains the first blockchain address, the module obtains the first address index corresponding to the first blockchain address in the first address index table and stores the first address index in the first storage location. The space occupied by the first address index is less than the space occupied by the first blockchain address.

13. A computer device, characterized in that, include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to invoke the computer programs to cause the computer device to perform the method according to any one of claims 1 to 11.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-11.

15. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, the computer program being adapted to be read and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-11.