Ordinal number management system and ordinal number management method of cryptocurrency
By segmenting and encoding the output currency sequence range in the blockchain system, and generating shard sequence coded data, the problem of low management efficiency of the minimum currency unit sequence in the blockchain system is solved, and the system's operating efficiency and query speed are improved.
Patent Information
- Application Number
- CN202410856399.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-11-08
AI Technical Summary
When the existing blockchain system manages the minimum currency unit ordinal number of cryptocurrencies, as the number of transactions increases, the ordinal number becomes disordered, resulting in a degradation in database performance and low query efficiency, affecting the system operation efficiency.
By dividing the output currency ordinal range into a subset of continuous ordinal ranges, and encoding the starting point and end point ordinal numbers, the fragmented ordinal numbers are generated, and the number of fragmented ordinal numbers is saved uniformly to reduce the number of ordinal records, and then quickly find the corresponding currency ordinal range through decoding. .
The ordinal range is effectively compressed, the database performance requirements are reduced, and the operation efficiency and query speed of the blockchain system are improved.
Smart Images

Figure CN118917842A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of this specification belong to the field of blockchain technology, and more particularly to an ordinal management system and an ordinal management method for cryptocurrency. Background Art
[0002] Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. In the blockchain system, data blocks are combined into a chain data structure in a sequential manner according to chronological order, and a distributed ledger that cannot be tampered with or forged is guaranteed by cryptography.
[0003] Cryptocurrency can be circulated in the current blockchain system. In such blockchain systems based on the UTXO (Unspent Transaction Outputs) model, the circulating cryptocurrency can be traced based on the reference relationship between transactions. Such cryptocurrency can be composed of the smallest currency unit. The related technology proposes the Ordinals protocol for numbering the smallest currency unit, but the industry currently lacks effective implementation and application of the Ordinals protocol.
[0004] In order to accurately distinguish each minimum currency unit, a globally unique currency ordinal number (or ordinal number, serial number, serial number, serial number, etc.) can be assigned to each minimum currency unit in circulation and managed. The relevant technology will save the ordinal value of each minimum currency unit owned by the account or the ordinal range composed of multiple minimum currency units.
[0005] However, as the number of transactions executed on the blockchain increases, the smallest currency unit owned by each account gradually becomes discrete, and accordingly, the currency ordinal of the smallest currency unit gradually becomes disordered, that is, the currency ordinal shows an entropy increase trend. Therefore, the ordinal management method in the relevant technology needs to save a large number of ordinal records, which not only has high requirements on database performance, but also takes a lot of time to query in subsequent use, which will seriously affect the operating efficiency of the blockchain system. Summary of the invention
[0006] The purpose of the present invention is to provide an ordinal management system and an ordinal management method for cryptocurrency, so as to efficiently manage the ordinals of each minimum currency unit circulating on the blockchain system through sharding and encoding / decoding.
[0007] According to a first aspect of one or more embodiments of this specification, a method for managing ordinal numbers of cryptocurrency is proposed, which is applied to an ordinal number management system corresponding to a blockchain system, wherein the blockchain system is implemented based on an unspent transaction output (UTXO) model, and the cryptocurrency circulating in the blockchain system is composed of minimum currency units, each of which has a globally unique currency ordinal number, and the method includes:
[0008] For each current UTXO generated by the current transaction, determine the output currency ordinal range corresponding to the current UTXO, and the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range;
[0009] According to the continuous currency ordinal ranges included in the output currency ordinal range, the output currency ordinal range is divided into at least one ordinal range subset, wherein each ordinal range subset includes at least one continuous currency ordinal range;
[0010] The starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset are respectively encoded to generate the shard ordinal encoding data of each ordinal range subset respectively, and the output ordinal encoding data corresponding to the current UTXO composed of the shard ordinal encoding data of each ordinal range subset is saved.
[0011] According to a second aspect of one or more embodiments of this specification, an ordinal management system is proposed. The blockchain system corresponding to the ordinal management system is implemented based on the UTXO model. The cryptocurrency circulating in the blockchain system is composed of minimum currency units, and each minimum currency unit has a globally unique currency ordinal. The system is used to:
[0012] For each current UTXO generated by the current transaction, determine the output currency ordinal range corresponding to the current UTXO, and the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range;
[0013] According to the continuous currency ordinal ranges included in the output currency ordinal range, the output currency ordinal range is divided into at least one ordinal range subset, wherein each ordinal range subset includes at least one continuous currency ordinal range;
[0014] The starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset are respectively encoded to generate the shard ordinal encoding data of each ordinal range subset respectively, and the output ordinal encoding data corresponding to the current UTXO composed of the shard ordinal encoding data of each ordinal range subset is saved.
[0015] According to a third aspect of one or more embodiments of this specification, an electronic device is proposed, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements the steps of the method described in the first aspect by running the executable instructions.
[0016] According to a fourth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect are implemented.
[0017] According to a fifth aspect of one or more embodiments of the present specification, a computer program product is proposed, comprising a computer program / instruction, which implements the steps of the method described in the first aspect when executed by a processor.
[0018] In the embodiment of the present specification, the cryptocurrency circulated in the blockchain system corresponding to the ordinal management system is composed of the smallest currency unit and each smallest currency unit has a globally unique currency ordinal. For each current UTXO generated by the current transaction, first determine the output currency ordinal range corresponding to the current UTXO, and then divide it into at least one ordinal range subset according to the continuous currency ordinal range contained in the output currency ordinal range, wherein each ordinal range subset contains at least one continuous currency ordinal range; then encode the starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset, respectively, to generate the shard ordinal encoding data of each ordinal range subset, and finally save the output ordinal encoding data corresponding to the current UTXO composed of the shard ordinal encoding data of each ordinal range subset.
[0019] It can be understood that the output currency ordinal ranges corresponding to each current UTXO together constitute the output currency ordinal range of the current transaction. Accordingly, each minimum currency unit whose currency ordinal is within these output currency ordinal ranges is all the currency units transferred when the blockchain network executes the current transaction, and the sum of the values of these minimum currency units is the value transferred when the blockchain network executes the current transaction.
[0020] For each current UTXO and its output currency ordinal range, this solution divides the range into at least one ordinal range subset (each subset contains at least one continuous currency ordinal range), and generates the shard ordinal encoding data of the current UTXO only according to the starting ordinal and ending ordinal encodings of the continuous currency ordinal ranges contained in each subset, and then saves the output ordinal encoding data composed of each shard ordinal encoding data. In this way, the ordinal management system realizes the compression of ordinals by encoding multiple ordinals or continuous currency ordinal ranges, thereby compressing the scattered ordinal ranges into a shard ordinal encoding data (which can be regarded as a data file) for unified storage, greatly reducing the number of ordinal records that need to be maintained and reducing the requirements for database performance. Moreover, when the ordinal is used in the future, the corresponding currency ordinal range can be quickly found through the corresponding decoding method or even a certain ordinal can be accurately located, which helps to ensure that the blockchain system achieves a higher operating efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 It is a schematic diagram of an ordinal management system provided by an exemplary embodiment.
[0022] Figure 2 It is a flowchart of a method for managing ordinal numbers of a cryptocurrency provided by an exemplary embodiment.
[0023] Figure 3 It is a schematic diagram of input and output of a transaction provided by an exemplary embodiment.
[0024] Figure 4 It is a schematic diagram of a currency ordinal range splitting process provided by an exemplary embodiment.
[0025] Figure 5 It is a schematic diagram of a range segmentation and ordinal encoding process provided by an exemplary embodiment.
[0026] Figure 6 It is a structural schematic diagram of a device provided by an exemplary embodiment.
[0027] Figure 7 It is a block diagram of an ordinal number management device for a cryptocurrency provided by an exemplary embodiment. DETAILED DESCRIPTION
[0028] In order to solve the above problems existing in the related art, this specification proposes an ordinal management system and an ordinal management solution implemented by the system, so as to efficiently manage the ordinal of each minimum currency unit circulating on the blockchain system through sharding and encoding / decoding. The solution is described in detail below with reference to the accompanying drawings.
[0029] See also Figure 1 , Figure 1FIG. 1 is a schematic diagram of an ordinal management system provided by an exemplary embodiment. Figure 1 As shown, the ordinal management system 101 is connected to the blockchain network 103 through the blockchain client 102, and the ordinal management system 101 includes multiple functional modules, such as a block processing module 1011, a transaction processing module 1012, an ordinal encoding module 1013 and a persistence module 1014.
[0030] During the operation of the blockchain network 103, the blockchain nodes can initiate and execute transactions, as well as package the executed transactions to generate blocks and add them to the end of the chain structure (i.e., block on-chain). The blockchain client 102 has the ability to access the blockchain network 103. Users can initiate transactions to the blockchain network 103 through the client, or they can query the on-chain data through the client. For example, the ordinal management system 101 can synchronize the generated blocks from the chain through the client, which have not yet been uploaded to the chain or have been uploaded to the chain, so as to process the synchronized blocks using the ordinal management scheme described in this specification. Of course, this specification does not limit the specific way in which the ordinal management system 101 accesses the blockchain network 103, such as through Figure 1 In addition to accessing the network in the manner shown, in some embodiments, the ordinal management system 101 can also directly connect to the blockchain node in the blockchain network 103 and access the network (in this case, the network can be accessed without going through the aforementioned blockchain client 102).
[0031] The block processing module 1011 is used to perform preliminary processing on the blocks obtained from the blockchain network 103, such as parsing each transaction in the blockchain, determining the execution order of each transaction and marking it, etc. In addition, it can also be used to determine whether the most recently obtained block (hereinafter referred to as the local latest block) is the latest block on the chain generated by the blockchain network 103 (such as the block with the largest block height on the aforementioned chain structure): when the local latest block is not the latest block on the chain (that is, the block height of the local latest block is less than the maximum block height on the chain, or the block is lagging behind), the block processing module 1011 can trigger the ordinal management system 101 to continue to obtain blocks with a larger block height from the blockchain network 103; and when the local latest block is the latest block on the chain, it can wait for a preset time or continue to obtain the latest block on the chain from the blockchain network 103 after receiving the latest block on-chain notification issued by the blockchain network 103.
[0032] The transaction processing module 1012 is used to execute each transaction serially or in parallel according to the reference relationship of each transaction in the same block, wherein multiple transactions that do not have a reference relationship between each other can be executed in parallel by multiple threads; and multiple transactions that have a reference relationship between each other can be executed serially (or sequentially) by one thread, so as to ensure the order of transaction execution while improving the overall execution efficiency of all transactions in the block. By executing any transaction, the previous UTXO referenced by the transaction and the current UTXO generated by the transaction can be determined. It can be understood that, unlike the process of executing the transaction by the blockchain node in the blockchain network 103 (on-chain execution), the transaction processing module 1012 executes any transaction in the process of completing the transaction off-chain (off-chain execution), which can be regarded as replaying the transaction on the chain off-chain. It can be understood that the replayed blockchain transaction is a historical transaction that has been executed on the chain. The reason why this scheme replays the blockchain transaction off-chain is to complete the relevant calculation of the currency ordinal involved in UTXO without affecting the on-chain transaction.
[0033] The transaction processing module 1012 may include a transaction separator and a transaction executor (not shown in the figure), wherein the transaction separator is used to determine the execution mode (serial execution or parallel execution) and execution order of each transaction according to the reference relationship between each transaction in the block; the transaction executor may include a serial executor and a parallel executor, wherein the serial executor may serially execute multiple transactions with dependencies through a single thread, and the parallel executor may parallelly execute multiple transactions without dependencies through multiple threads. Any of the executions may specifically include an ordinal collector, an ordinal distributor, and an ordinal verifier, which cooperate with each other to complete the currency ordinal management scheme described in the embodiments of this specification, as detailed in the embodiments below, which will not be repeated here.
[0034] The ordinal encoding module 1013 is used to determine the output currency ordinal range corresponding to each current UTXO generated by the current transaction in the manner described in the embodiments below, and encode the starting ordinal and ending ordinal of the continuous currency ordinal range contained in the ordinal range subset obtained by segmentation to generate corresponding shard ordinal encoding data. For details, please refer to the detailed description of the embodiments below, which will not be repeated here.
[0035] The persistence module 1014 can be used to persist the output ordinal coded data, such as persisting the ordinal coded data of each shard determined by the ordinal coding module 1013 as the output ordinal coded data in a preset storage space (such as the local storage space of the ordinal management system 101 or a pre-associated external database), which will not be repeated here. Based on the above-mentioned output ordinal coded data that has been saved, the ordinal management system can query the ordinal range or at least one currency ordinal at any subsequent time. In addition, the persistence module 1014 can also be used to save transaction records, such as saving the block itself obtained from the blockchain network 103 and the execution results of each transaction therein.
[0036] In one embodiment, in addition to Figure 1 In addition to the various functional modules shown, the ordinal management system 101 may also include a query module (used to respond to a request to query the currency ordinal, block or transaction execution results, etc. in the aforementioned output ordinal encoded data that has been persistently saved), a token engraving module (used to complete the token engraving process in response to a token engraving request) and other functional modules. The specific functional implementation process of each module can be found in the embodiments below and will not be repeated here.
[0037] It should be noted that the blockchain system described in the embodiments of this specification (such as Figure 1 The blockchain network 103 shown is implemented based on the UTXO (Unspent Transaction Output) model. In the UTXO model, each transaction generates one or more UTXOs, which can be referenced by subsequent transactions. In layman's terms, UTXO can be regarded as coins, each of which has its own denomination and owner. When a transaction is made, an appropriate number of coins are selected for payment, and then new coins are generated as change. In this way, the entire transaction process is similar to the process of using coins for payment and change. Unlike the account model, the UTXO model is more flexible because it does not require the maintenance of account balances, but instead implements transaction verification and recording by tracking the ownership of each UTXO. The design of this model makes the blockchain network easier to expand and more suitable for processing a large number of transactions.
[0038] The cryptocurrency circulating in the blockchain system is composed of the smallest currency unit, and each smallest currency unit has a globally unique currency ordinal, that is, each currency ordinal is used to represent a smallest currency unit. Among them, the currency ordinal of each smallest currency unit increases in sequence according to the order in which the smallest currency unit is generated. In addition, any unit of cryptocurrency is composed of one or more smallest currency units, that is, there is a fixed conversion multiple between cryptocurrency and the smallest currency unit.
[0039] This specification does not limit the type of cryptocurrency circulating in the blockchain system, that is, the embodiments of this specification do not limit the type of blockchain network, such as BTC (Bitcoin), BCH (Bitcoin Cash), LTC (Litecoin), etc. It should also be noted that when using the solution described in the embodiments of this specification to manage the currency ordinal of the smallest currency unit circulating in the blockchain network, necessary measures should be taken to ensure that the use process does not violate the law, social morality or harm the public interest.
[0040] When implementing the ordinal management solution described in the embodiments of this specification, the ordinal management system 101 may:
[0041] For each current UTXO generated by the current transaction, determine the output currency ordinal range corresponding to the current UTXO, and the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range;
[0042] According to the continuous currency ordinal ranges included in the output currency ordinal range, the output currency ordinal range is divided into at least one ordinal range subset, wherein each ordinal range subset includes at least one continuous currency ordinal range;
[0043] The starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset are respectively encoded to generate the shard ordinal encoding data of each ordinal range subset respectively, and the output ordinal encoding data corresponding to the current UTXO composed of the shard ordinal encoding data of each ordinal range subset is saved.
[0044] Among them, the current block described in the embodiment of this specification can be any block obtained by the ordinal management system from the blockchain network, and the current transaction can be any transfer transaction in the block. It should be noted that the current transaction may contain multiple transactions, which can be divided into two categories: ordinary transfer transactions and block reward transactions, and any transaction described in this specification is any ordinary transfer transaction. Among them, the ordinary transfer transaction is a transaction that transfers cryptocurrency between different addresses. The blockchain system executes the transaction to transfer a certain value of cryptocurrency (including at least one minimum currency unit) from at least one transfer-out address to at least one transfer-in address (i.e., currency transfer) so that the monetary value of this part of the cryptocurrency circulates between different addresses (i.e., value circulation). The block reward transaction is used to allocate a corresponding number of cryptocurrency to the preset address (bound to the blockchain node that packages and generates the current block), that is, to allocate the monetary value (of this part of the cryptocurrency) created by the system to the preset address. In addition, the block reward transaction can also be used to transfer the cryptocurrency corresponding to the handling fee of each ordinary transfer transaction in the block from the corresponding address (such as the address pre-specified by the transaction initiator) to the preset address, so as to reward the aforementioned blockchain node for packaging the ordinary transfer transactions into the current block (this behavior usually consumes some resources of the node). The above addresses are all registered addresses in the blockchain network, which can be regarded as accounts for carrying cryptocurrency.
[0045] It can be understood that the output currency ordinal ranges corresponding to each current UTXO determined in sequence according to the generation order of each current UTXO together constitute the output currency ordinal range of the current transaction, and all the minimum currency units whose currency ordinals are within this range together constitute the cryptocurrency transferred when the blockchain network executes the transaction, and the sum of the values of this part of the minimum currency units is the value transferred when the transaction is executed. In addition, the ordinal management system processes each transaction in the current block separately through the scheme of this specification, and can save the output currency ordinal ranges corresponding to each current UTXO generated by each exchange; and processes each block in the distributed ledger maintained by the blockchain network separately, and can save the output currency ordinal ranges corresponding to each current UTXO generated by each exchange in each block. By saving the above-mentioned output currency ordinal range, the ordinal management system can maintain the currency ordinal of the minimum currency unit corresponding to the transferred value, so as to trace and manage the circulation process of a specific minimum currency unit in the future.
[0046] See also Figure 2 , Figure 2This is a flowchart of a method for managing the ordinal number of a cryptocurrency provided by an exemplary embodiment. The method is applied to the ordinal number management system corresponding to the blockchain system, the blockchain system is implemented based on the unspent transaction output UTXO model, and the cryptocurrency circulating in the blockchain system is composed of the smallest currency unit, and each smallest currency unit has a globally unique currency ordinal number. Figure 2 As shown, the method includes steps 202-206.
[0047] Step 202, for each current UTXO generated by the current transaction, determine the output currency ordinal range corresponding to the current UTXO, and the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range.
[0048] In one embodiment, the ordinal management system can obtain the current block (i.e., the block at the current exchange) from the blockchain network. For example, the ordinal management system can obtain all blocks in the blockchain ledger maintained by the blockchain network from the blockchain network at any time, and then receive the latest block pushed by the currency ordinal range (i.e., the new block added to the end of the blockchain ledger after any of the aforementioned moments); or it can also request the currency ordinal range to obtain the latest block in the cycle according to a fixed query cycle (i.e., the new block added to the end of the blockchain ledger within a cycle after any of the aforementioned moments). For another example, it is also possible to traverse and process the old blocks that have been obtained while obtaining new blocks, such as after obtaining block i (i.e., the block with a block height of i, the same below), process the block as the current block, and obtain block i+1 while processing; and then continue to process block i+1 after completing the processing of block i.
[0049] For multiple blocks obtained from the blockchain network, these blocks can be traversed and processed in the order in which they were generated (i.e., in order of block height from small to large). When processing any of the blocks, the block is used as the "current block" described in the embodiment of this specification. Furthermore, the execution order of each transaction in the current block can be determined first, and then each transaction can be traversed and processed in sequence according to the execution order. When processing any of the transactions, the transaction is used as the current transaction described in the embodiment of this specification, and the process of processing the transaction is as follows. Figure 2 As shown in the various steps. In addition, as mentioned above, the current transaction can be any common transfer transaction in the current block.
[0050] In a blockchain system based on the UTXO model, any transaction transfer needs to reference at least one UTXO (i.e., unspent transaction output) generated by a previous transaction (executed before the transaction); accordingly, executing the transaction will generate at least one new UTXO. For the current transaction, each UTXO referenced by it is equivalent to the input of the transaction, hereinafter referred to as the previous UTXO; at least one new UTXO generated by executing the transaction is equivalent to the output of the transaction, hereinafter referred to as the current UTXO.
[0051] Among them, any previous UTXO belongs to and only belongs to one previous transaction, that is, any previous UTXO is generated by a previous transaction. The current transaction can reference at least one previous UTXO, and these referenced previous UTXOs can belong to the same previous transaction, or can also belong to multiple previous transactions. In other words, if the m1 previous UTXOs referenced by the current transaction belong to m2 previous transactions, then m1 and m2 are both positive integers, and m1 is greater than or equal to m2.
[0052] In addition, as mentioned above, the previous transaction of the current transaction will be executed before the current transaction (i.e., the previous transaction is executed first and the current transaction is executed later). In the case of referencing the previous UTXO in at least one previous transaction, at least one of these previous transactions may belong to the current block, i.e., the current transaction and at least one previous transaction referenced by it are in the same block - in this case, the execution timing of this at least one previous transaction in the current block must be earlier than the current transaction. And / or, at least one of these previous transactions may belong to the previous block of the current block, and the block height of the previous block is lower than the block height of the current block, i.e., the previous block is executed first and added to the end of the blockchain ledger, and the current block is executed and added to the end of the blockchain ledger (where "executing any block" means executing each transaction in the block), so each transaction in the previous block will be executed before the current transaction, and the previous transaction in the previous block referenced by the current transaction must also be executed before the current transaction.
[0053] It should be noted that the "execution" of any previous transaction and the current transaction mentioned here should be understood as the on-chain execution completed by the blockchain node as mentioned above, rather than the off-chain execution performed by the ordinal management system. Therefore, when multiple blocks are obtained, for two blocks or two transactions that do not have a reference relationship with each other, the ordinal management system can also flexibly choose the order of executing the two off-chain, or even execute them in parallel, to improve processing efficiency.
[0054] In addition, to ensure that after replaying (i.e., executing off-chain) each transaction, the same execution result as that of each transaction executed on-chain can be obtained, the ordinal management system shall execute each transaction in the current block in the corresponding execution order when replaying each transaction off-chain. For example, before executing each transaction off-chain, it can be determined whether there is a dependency relationship between any two transactions based on the UTXO referenced by each transaction and the generated UTXO: if there is no dependency relationship between any two transactions, the two transactions can be executed in parallel to improve transaction execution efficiency; if there is a dependency relationship between any two transactions, it means that one of the transactions needs to rely on the execution result of another transaction to be successfully executed, so the two transactions need to be executed serially, that is, the other transaction is executed first and then the one transaction is executed.
[0055] In one embodiment, the previous UTXO and current UTXO of any transaction will be recorded in the transaction content of the transaction (i.e., the source code of the transaction), so the ordinal management system can read the transaction content to determine at least one previous UTXO referenced by the transaction and at least one current UTXO generated by the transaction. For example, the block processing module in the ordinal management system can read the transaction content during the execution of the current transaction to determine (or extract) the at least one previous UTXO and the at least one current UTXO.
[0056] In one embodiment, when the current transaction contains vin and vout fields, at least one previous UTXO referenced by the transaction can be extracted from the vin field of the current transaction, and at least one current UTXO generated by the transaction can be extracted from the vout field of the current transaction. It can be understood that extracting the corresponding UTXO in any field means reading the description information of the corresponding UTXO in the field content (or value) contained in the field. Exemplarily, the source code of the current transaction in the current block is as follows:
[0057]
[0058]
[0059] It can be seen from the above source code that the vin field of the current transaction contains a previous UTXO (referenced by the transaction), where the transaction id of the previous transaction is "7957a35fe64f80d234d76d83a2a8f...", and the previous UTXO referenced is the UTXO with index number 0 in the vout field of the previous transaction. In addition, the vout field of the current transaction contains two current UTXOs (generated by the transaction), where the currency value of the current UTXO with index number 0 is 0.15 cryptocurrency and the currency value of the current UTXO with index number 1 is 0.85 cryptocurrency. As mentioned above, the cryptocurrency described in this specification is composed of one or more minimum currency units, and there is a fixed conversion multiple between the cryptocurrency and the minimum currency unit, so the above 0.15 cryptocurrency should be understood as the cryptocurrency is composed of 0.15*10^8 minimum currency units, that is, the sum of the values of these minimum currency units is equal to the value of the 0.15 cryptocurrency.
[0060] Similarly, the referenced previous transaction also includes vin and vout fields. Among them, when any previous transaction is an ordinary transfer transaction, the transaction can further reference the UTXO generated by other transactions; or, when any previous transaction is a block reward transaction, the transaction does not reference the UTXO generated by other transactions (it does not have a vin field or the value of the vin field is empty). In this way, any UTXO referenced or generated by any exchange in the blockchain network can be traced back to the block reward transaction according to the reference relationship between transactions, that is, the cryptocurrencies circulating on the chain are all generated by the allocation of blockchain nodes with a currency ordinal range of the packaged block. Of course, in some other embodiments, the cryptocurrencies circulating on the chain can also be generated according to the off-chain resources of corresponding value, such as the participants in the blockchain can exchange the corresponding amount of cryptocurrencies according to their own available off-chain assets (such as cash currency, fixed assets, etc.) in order to participate in on-chain transactions, which will not be repeated.
[0061] Through the above method, at least one previous UTXO referenced by the current transaction and at least one current UTXO generated by the transaction can be determined. It is explained that when there are multiple previous UTXOs, any two of them can belong to the same address or different addresses. Figure 3As shown, the current transaction references m previous UTXOs (i.e., UTXO_in1 to UTXO_inm) and generates n current UTXOs (i.e., UTXO_out1 to UTXO_outn). Among them, any previous UTXO belongs to a previous transaction, and different previous UTXOs can belong to the same or different previous transactions, such as UTXO_in1 and UTXO_inx belong to previous transactions Tx1 and Txx respectively (the arrow from UTXO_in1 to previous transaction Tx1 is used to indicate that previous transaction Tx1 generates UTXO_in1, that is, UTXO_in1 belongs to previous transaction Tx1, and the same applies to other arrows).
[0062] As mentioned above, the current transaction will generate at least one current UTXO. For this, the ordinal management system can determine the output currency ordinal range corresponding to each current UTXO. It can be understood that the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range, that is, the currency value that needs to be transferred to the account address corresponding to the current UTXO.
[0063] In addition, the current transaction may reference at least one previous UTXO generated by the previous transaction. In one embodiment, when determining the output currency ordinal range corresponding to each current UTXO, the previous currency ordinal ranges corresponding to each previous UTXO may be first obtained, and the obtained ordinal ranges are arranged in order to form a transaction ordinal queue; then, according to the index of the current UTXO in each current UTXO generated by the current transaction, the output currency ordinal range corresponding to the current UTXO is determined from the transaction ordinal queue.
[0064] Among them, the ordinal management system can obtain the previous currency ordinal ranges corresponding to each previous UTXO referenced by the current transaction in a variety of ways. For example, in the case where the ordinal management system maintains at least one previous currency ordinal range corresponding to each UTXO generated by the previous transaction, the previous currency ordinal ranges corresponding to each previous UTXO can be queried from these previous currency ordinal ranges. For example, the ordinal management system can maintain the location information of each UTXO generated by the previous transaction and at least one corresponding currency ordinal range. In this scenario, taking the previous transaction belonging to the previous block as an example, the ordinal management system can save the currency ordinal range and its location information in a preset storage space (such as the local storage of the ordinal management system or a preset database) after processing the previous transaction in the previous block to obtain its currency ordinal range (the range can be regarded as the current currency ordinal range of the previous transaction itself). Among them, the above-mentioned currency ordinal range and its position information can be saved in the same record table, or the position information of the above-mentioned currency ordinal range can be saved in the ordinal position record table, and the corresponding currency ordinal range (actually the description information of the range) can be saved in the ordinal range record table. Based on this, in the process of processing the current transaction, for each current UTXO generated by the transaction, the previous transaction that generated the current UTXO and the target position information of the current UTXO can be determined first; then, in the location information of the previous transaction maintained and at least one corresponding currency ordinal range, the target position information and at least one corresponding currency ordinal range are queried; and the queried currency ordinal ranges are the previous currency ordinal ranges corresponding to the current UTXO. In this way, the ordinal management system can accurately and quickly obtain the previous currency ordinal ranges corresponding to each previous UTXO referenced by the current transaction in the above-mentioned information maintained by itself.
[0065] In another embodiment, in the case where the ordinal management system maintains the output ordinal encoding data corresponding to each UTXO generated by the previous transaction, the previous ordinal encoding data corresponding to each previous UTXO can be queried from these output ordinal encoding data; then for the previous output ordinal encoding data corresponding to each previous UTXO: the previous output ordinal encoding data is decoded to obtain at least one pair of previous starting point ordinal and previous end point ordinal, and the corresponding previous continuous currency ordinal range is determined according to each pair of previous starting point ordinal and previous end point ordinal, and the determined previous continuous currency ordinal ranges together constitute the previous currency ordinal range corresponding to the previous UTXO. In this embodiment, the ordinal management system has used the embodiment of this specification to encode the previous currency ordinal ranges corresponding to each UTXO generated by the previous transaction before processing the current transaction, and saved the previous ordinal encoding data obtained by the encoding process. Based on this, when processing the current transaction, the corresponding pre-order starting point ordinal and pre-order end point ordinal can be obtained by decoding the saved pre-order ordinal coded data, and the corresponding pre-order continuous currency ordinal range can be restored accordingly, and these ordinal ranges are arranged in order to jointly constitute the pre-order currency ordinal range corresponding to the pre-order UTXO. It can be seen that the ordinal management system can encode the currency ordinal range into the corresponding ordinal coded data through encoding processing, and restore the ordinal coded data into the corresponding currency ordinal range through decoding processing.
[0066] In one embodiment, the blockchain node that generates the current block of the current exchange may be bound to a preset address. In addition to the ordinary transfer transaction including the current transaction, the current block may also include a block reward transaction (such as a coinbase transaction) that allocates rewards to the preset address, that is, the current transaction is different from the block reward transaction. In addition, as mentioned above, the pre-order currency ordinal ranges corresponding to each pre-order UTXO obtained can be arranged in order to form a transaction ordinal queue, and the currency ordinal ranges of the outputs corresponding to each current UTXO can be obtained in order from the transaction ordinal queue. In this regard, after obtaining the output currency ordinal ranges corresponding to each current UTXO generated by the current transaction from the transaction ordinal queue, if there is at least one remaining currency ordinal range in the transaction ordinal queue, the at least one currency ordinal range can be assigned a corresponding range number according to the position of the at least one currency ordinal range in the transaction ordinal queue, and the at least one currency ordinal range can be recorded in the block ordinal queue of the current block with the transaction identifier of the current transaction and the range number as an index, so as to determine the output currency ordinal range corresponding to the block reward transaction.
[0067] It is understandable that, when there is at least one remaining currency ordinal range in the transaction ordinal queue, the minimum currency unit corresponding to these currency ordinal ranges is the minimum currency unit corresponding to each previous UTXO that has not been allocated to any account address corresponding to the current UTXO, and recording this part of the remaining at least one currency ordinal range in the block ordinal queue of the current block for determining the output currency ordinal range corresponding to the block reward transaction is actually using this part of the remaining minimum currency unit as the handling fee (or fee) of the current transaction. Figure 4 As shown, assuming that the value to be output of the first current UTXO (sat_uid is 3456) is 600 sats, after the above split is completed, there will be a remaining currency ordinal range with a currency value of 400 sats in the transaction ordinal queue. For this, the currency ordinal range can be recorded in the transaction ordinal queue of the current transaction to determine the 400 sats corresponding to the currency ordinal range as the handling fee of the current transaction. Exemplarily, the above at least one currency ordinal range (i.e., the currency ordinal range corresponding to the minimum currency unit used as the handling fee of the transaction) can be written to the end of the block ordinal queue of the current block, so that the above handling fee can be subsequently allocated to the preset address corresponding to the block reward transaction.
[0068] In one embodiment, for the block reward transaction in the current block, the ordinal management system can determine the transaction currency ordinal ranges corresponding to the transaction fees of each transaction in the current block except the block reward transaction; it can also calculate the reward value corresponding to the current block according to the block height of the current block, and allocate the corresponding reward currency ordinal range to the reward value; at this time, the reward currency ordinal range and the transaction currency ordinal range are arranged in order to form the output currency ordinal range corresponding to the block reward transaction.
[0069] Exemplarily, when traversing to the block reward transaction, the ordinal management system can first calculate the reward value Reward corresponding to the transaction according to the block height (such as 50 cryptocurrencies, 25 cryptocurrencies or 12.5 cryptocurrencies, etc.), and then assign it a corresponding reward currency ordinal range, and write the range to the end of the block ordinal queue. Then start traversing and processing each ordinary transfer transaction. For any ordinary transfer transaction traversed (such as the current transaction mentioned above), the above embodiment can be used to process it to determine the output currency ordinal range corresponding to each current UTXO generated by the transaction and the handling fee of the transaction, where the handling fee of any transaction can be zero or greater than zero. In the case where the handling fee of the current transaction is greater than zero, the handling currency ordinal range corresponding to the handling fee can be written to the end of the block ordinal queue mentioned above. Until all ordinary transfer transactions in the current block are traversed and processed, the block ordinal queue will store the reward currency ordinal range of the block reward transaction and the procedure currency ordinal range of each ordinary transfer transaction in the order of execution of each transaction. These currency ordinal ranges are arranged in order to constitute the output currency ordinal range corresponding to the block reward transaction.
[0070] The output currency ordinal range corresponding to each current UTXO can be determined by the above method, where any output currency ordinal range contains at least one continuous currency ordinal range. The so-called continuous currency ordinal range is the ordinal range composed of continuous currency ordinals, such as Figure 4 As shown in the figure, (0,1999), (3000,4999) and (5000,5999) are three different continuous currency ordinal ranges. It should be noted that if the output currency ordinal range corresponding to any current UTXO contains an isolated currency ordinal (that is, it is not adjacent to other currency ordinals in the range), then the currency ordinal should also be regarded as a continuous currency ordinal range (but its "continuous" length is 1).
[0071] like Figure 5As shown, the current transaction references a total of m previous UTXOs (i.e., UTXO_in1 to UTXO_inm) and generates n current UTXOs (i.e., UTXO_out1 to UTXO_outn). The output currency ordinal range corresponding to each current UTXO determined by the aforementioned method, such as the output currency ordinal range corresponding to UTXO_out1 contains a continuous currency ordinal range, namely (sat_s11, sat_n11), where sat_s11 is the starting ordinal of the range and sat_n11 is the ending ordinal of the range, the same below; for example, the output currency ordinal range corresponding to UTXO_out2 contains y continuous currency ordinal ranges, namely (sat_s21, sat_n21)...(sat_s2y, sat_n2y); the output currency ordinal range corresponding to UTXO_outn contains two continuous currency ordinal ranges, namely (sat_sn1, sat_nn1) and (sat_sn2, sat_nn2).
[0072] Step 204: divide the output currency ordinal range into at least one ordinal range subset according to the continuous currency ordinal ranges included in the output currency ordinal range, wherein each ordinal range subset includes at least one continuous currency ordinal range.
[0073] As mentioned above, the output currency ordinal range corresponding to each current UTXO determined may include at least one continuous currency ordinal range. The following only takes any current UTXO (hereinafter referred to as the current UTXO) as an example for explanation. In this regard, the ordinal management system can divide the output currency ordinal range into at least one ordinal range subset (each subset includes at least one continuous currency ordinal range) according to the continuous currency ordinal range included in the output currency ordinal range corresponding to the current UTXO.
[0074] In one embodiment, in view of the fact that the range lengths of different continuous currency ordinal ranges (i.e., the number of currency ordinals contained in the range) may vary greatly, in order to make the number of minimum currency units (i.e., the number of currency ordinals) corresponding to each subsequently generated shard ordinal encoding data as stable as possible for storage and subsequent query, at least one quantity threshold may be pre-set for the shard ordinal encoding data, and each quantity threshold corresponds to a corresponding length level. Based on this, when the output currency ordinal range corresponding to the current UTXO is segmented, for at least one continuous currency ordinal range contained in the output currency ordinal range, the number of currency ordinals contained in each continuous currency ordinal range may be determined first, and then the output currency ordinal range may be segmented according to the number to obtain at least one ordinal range subset, and the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold. In this way, the output currency ordinal range corresponding to the current UTXO may be segmented into ordinal range subsets that meet the length level corresponding to the length threshold.
[0075] like Figure 5 As shown, taking the current UTXO UTXO_out2 as an example, let's assume that y=5, that is, the output currency ordinal range corresponding to UTXO_out2 contains a total of 5 continuous currency ordinal ranges, namely L21~L25. Among them, L21 (sat_s21, sat_n21) contains the number of sats Q21=15W (that is, the range of L21 contains a total of 150,000 continuous currency ordinals, the same below), L22 (sat_s22, sat_n22) contains the number of sats Q22=35W, L23 (sat_s23, sat_n23) contains the number of sats Q23=3.5W, L24 (sat_s24, sat_n24) contains the number of sats Q24=6W, and L25 (sat_s25, sat_n25) contains the number of sats Q25=90W. In addition, the sat quantity threshold may be preset to 10W, 50W, 100W, etc. In this regard, the output currency ordinal range may be segmented according to the sat quantity respectively included in L21 to L25.
[0076] The output currency ordinal range can be segmented according to different segmentation principles to achieve different segmentation effects. For example, each continuous currency ordinal range can be divided into corresponding ordinal range subsets in order, provided that each continuous currency ordinal range remains continuous and the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold. This method can divide each continuous currency ordinal range into corresponding ordinal range subsets, provided that the continuous currency ordinal range is not further segmented. Figure 5In the embodiment shown, given that Q21 and Q33 are both less than 10W, and the sum of the two is exactly equal to 50W, L21 and L22 can be divided into ordinal range subset 1 (the quantity threshold corresponding to this range is 50W). Given that the sum of Q23, Q24 and Q25 is relatively close to 100W (the sum of the three is 99.5W, and the difference between it and 100W is less than Q23, which is the smallest of the three), all three can be divided into ordinal range subset 2 (the quantity threshold corresponding to this range is 100W, which is used as an example below). Alternatively, given that the sum of Q23 and Q24 is also less than 10W, L23 and L24 can also be divided into ordinal range subset 2 (the quantity threshold corresponding to this range is 10W), and L25 can be divided into ordinal range subset 3 (the quantity threshold corresponding to this range is 100W), which will not be repeated.
[0077] For another example, the number of currency ordinals contained in each ordinal range subset may be divided into corresponding ordinal range subsets in order, provided that the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold. This method can further divide the continuous currency ordinal range so that the number of currency ordinals actually contained in each ordinal range subset obtained by division is equal to or close to the corresponding quantity threshold. Figure 5 In the embodiment shown, as indicated by the dotted arrows, L25 can be divided into two continuous currency ordinal sub-ranges L251 (sat_s25, x) and L252 (x+1, sat_n25), and the number of currency ordinals contained in the two sub-ranges is Q251=40W and Q252=50W respectively. At this time, L23, L24 and L251 can be divided into LL2 (the corresponding quantity threshold of this range is 50W at this time), and L252 can be divided into LL3 (the corresponding quantity threshold of this range is 50W at this time).
[0078] Step 206, respectively encode the starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset to generate the shard ordinal encoding data of each ordinal range subset respectively, and save the output ordinal encoding data corresponding to the current UTXO which is jointly constituted by the shard ordinal encoding data of each ordinal range subset.
[0079] Each ordinal range subset obtained by the aforementioned segmentation contains at least one continuous currency ordinal range, wherein each continuous currency ordinal range has a corresponding starting ordinal and an ending ordinal. In this regard, the ordinal management system can encode the starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset to generate the shard ordinal encoding data of the ordinal range subset. Furthermore, for the shard ordinal encoding data of each ordinal range subset generated by encoding, the output ordinal encoding data of the current UTXO composed of these shard ordinal encoding data can be saved.
[0080] It can be understood that for each current UTXO and its output currency ordinal range, this solution divides the range into at least one ordinal range subset (each subset contains at least one continuous currency ordinal range), and generates the shard ordinal encoding data of the current UTXO only according to the starting ordinal and ending ordinal encodings of the continuous currency ordinal ranges contained in each subset, and then saves the output ordinal encoding data composed of each shard ordinal encoding data. In this way, the ordinal management system realizes the compression of ordinals by encoding multiple ordinals or continuous currency ordinal ranges, thereby compressing the scattered ordinal ranges into a shard ordinal encoding data (which can be regarded as a data file) for unified storage, greatly reducing the number of ordinal records that need to be maintained and reducing the requirements for database performance. Moreover, when the ordinal is used in the future, the corresponding currency ordinal range can be quickly found through the corresponding decoding method or even a certain ordinal can be accurately located, which helps to ensure that the blockchain system achieves a higher operating efficiency.
[0081] like Figure 5 As shown, after encoding the starting ordinal and ending ordinals contained in ordinal range subset 1 and ordinal range subset 2, respectively, shard ordinal encoding data 1 and shard ordinal encoding data 2 can be obtained. In this regard, the ordinal management system can directly save these two data as the output ordinal encoding data corresponding to the current UTXO. Compared with the related technology that needs to save the 5 currency ordinal ranges corresponding to UTXO_out2 and the various currency ordinals contained therein, this solution greatly reduces the number of data records that the system needs to save and manage through encoding processing.
[0082] In one embodiment, when encoding the starting ordinal and ending ordinal of the continuous currency ordinal range contained in any ordinal range subset to generate the fragmented ordinal encoding data of the ordinal range subset, the starting ordinal and ending ordinal of each continuous currency ordinal range can be determined respectively for at least one continuous currency ordinal range contained in the said any ordinal range subset; then, the obtained starting ordinal and ending ordinal are encoded, and the corresponding encoding results are sequentially spliced according to the arrangement order of each continuous currency ordinal range to obtain the fragmented ordinal encoding data of the said any ordinal range subset. Figure 5 As shown, ordinal range subset 1 includes L21 and L22, wherein the starting ordinal and the ending ordinal of L21 are sat_s21 and sat_n21, respectively, and the starting ordinal and the ending ordinal of L22 are sat_s22 and sat_n22, respectively. Exemplarily, sat_s21, sat_n21, sat_s22 and sat_n22 can be encoded to obtain corresponding values Ds21, Dn21, Ds22 and Dn22, respectively, and then these values are sequentially concatenated in the aforementioned order to obtain the final encoding result, i.e., the fragment ordinal encoding data 1. The process of encoding the starting ordinal and the ending ordinal contained in ordinal range subset 2 to obtain the fragment ordinal encoding data 2 can be similar to this, and will not be repeated.
[0083] When encoding the starting ordinal number and the ending ordinal number of any continuous currency ordinal range, the starting ordinal number and the ending ordinal number of any continuous currency ordinal range can be encoded as a character string of a preset length as the corresponding encoding result. Exemplarily, the starting ordinal number and the ending ordinal number of any continuous currency ordinal range can be encoded as a character string of a preset length, and then the two character strings are concatenated to obtain the corresponding encoding result. Figure 5 As shown, the length L of a string is the preset length, such as 8 bytes. At this time, sat_s21 can be encoded as a string Ds21 with a length of 8 bytes, and sat_n21 can be encoded as a string Dn21 with a length of 8 bytes; similarly, the lengths of Ds22 and Dn22 are also 8 bytes respectively. In this way, when decoding the ordinal range subset 1, the 8 bytes can be decoded as a whole to obtain the corresponding starting ordinal or end ordinal; then, the decoding results of every 16 bytes from left to right constitute a set of starting ordinal and end ordinal numbers, and a set of ordinals can be used to restore a continuous currency ordinal range. Of course, the above-mentioned preset length can also be reasonably set according to actual conditions such as accuracy requirements and computing power resources, and the embodiments of this specification do not limit this.
[0084] In addition, in order to distinguish the slice ordinal coded data from other data stored in the ordinal management system, a preset file check code, such as "00" or "11" with a length of 2 bytes, may be added to the header of each slice ordinal coded data. In addition, when decoding any slice ordinal coded data, if its length is long (i.e., the amount of data stored is large), after removing the file check code at its header (of course, if the check code is not added during encoding, it does not need to be removed), the remaining data may be segmented according to even multiples of the aforementioned preset length, and the multiple data segments obtained by segmentation may be decoded in parallel to improve decoding efficiency.
[0085] The shard ordinal encoding data of each ordinal range subset can be generated by the aforementioned method, and at this time, these shard ordinal encoding data can be persisted and saved. For example, each shard ordinal encoding data can be saved separately, and the saved shard ordinal encoding data together constitute the output ordinal encoding data corresponding to the current UTXO. For another example, the shard ordinal encoding data corresponding to each ordinal range subset can be spliced in sequence according to the position order of each ordinal range subset in the output currency ordinal range before segmentation to obtain the output ordinal encoding data corresponding to the current UTXO, and then the output ordinal encoding data can be saved. This method can ensure that each shard ordinal encoding data corresponding to the same current UTXO can be saved in adjacent storage space in an ordinal set, which is convenient for ordinal query and retrieval after saving.
[0086] In one embodiment, the shard information table corresponding to each ordinal range subset and the shard meta information table corresponding to the current UTXO can be saved, and the shard information table corresponding to each ordinal range subset records the subset identifier and shard ordinal encoding data of the ordinal range subset, and the shard meta information table records the output identifier of the current UTXO and the subset identifier of the shard information table corresponding to each ordinal range subset. In this way, not only the output ordinal encoding data (and the ordinal encoding data of each shard constituting the data) can be saved, but also the corresponding identification information can be saved for subsequent query. It can be understood that, when the output currency ordinal range of the current UTXO is divided into s ordinal range subsets, each ordinal range subset corresponds to a shard information table (i.e., a total of s shard information tables are saved for the UTXO), and the shard meta information table corresponding to the UTXO will record the subset identifiers of the s s shard information tables. In the query stage after saving, the subset identifier can be used to accurately locate a certain shard information table in the shard meta information table.
[0087] The subset identifier of each ordinal range subset recorded in the shard information table corresponding to the subset is used to uniquely identify the subset within the range of all ordinal range subsets corresponding to the current UTXO. The subset identifier of any ordinal range subset can be a hash value corresponding to the subset (which can be obtained by performing a hash operation on the shard ordinal encoding data of the subset), a random number or a serial number. Figure 5As shown, the subset identifier of the ordinal range subset 1 can be the hash value of the shard ordinal encoding data 1, or a random number generated for the subset, or a sequential number "1", etc., which will not be repeated here. In addition, the output identifier of the current UTXO recorded in the shard meta information table is used to globally locate the UTXO in the blockchain system. Therefore, the transaction id (and / or transaction hash) of the current transaction and the index of the UTXO in each current UTXO generated by the current transaction can be used together as the output identifier of the current UTXO, wherein the transaction id is used to locate the current transaction from multiple transactions, and the index is used to locate the current UTXO in multiple UTXOs of the current transaction. In addition to recording the above-mentioned output identifier and subset identifier, the shard meta information table also records the subset identifiers of the shard information table corresponding to each ordinal range subset, and these subset identifiers actually constitute an identifier set. In addition, the shard meta information table can also record the number of ordinal range subsets obtained by segmentation and the number of currency ordinals actually contained in each ordinal range subset (such as Figure 5 The sum of Q21 and Q22 shown, etc.).
[0088] In one embodiment, the shard ordinal coded data and / or the output ordinal coded data may be compressed, and the compressed coded data may be saved. For example, the shard ordinal coded data of each ordinal range subset may be compressed separately using compression commands such as gzip, and then the compressed shard ordinal coded data may be saved. Of course, when querying the ordinal or ordinal range corresponding to a certain UTXO, it is necessary to first decompress the compressed and saved data before querying, which will not be described in detail. In this way, the amount of data to be saved can be further compressed on the basis of coding compression, further reducing the requirements for storage space.
[0089] Generally, the probability of a later transaction in a blockchain's chained ledger referencing a previous transaction increases as the height difference between the blocks where the two transactions are located decreases. For example, for any transaction 1 in block n (i.e., the previous transaction) and any transaction 2 in block n+x (i.e., the later transaction), the larger the value of x, the smaller the probability that transaction 2 refers to transaction 1 (i.e., transaction 2 uses the UTXO generated by transaction 1 as its own input); conversely, the smaller the value of x, the greater the probability that transaction 2 refers to transaction 1. Based on the above general rules, after determining the output currency ordinal range corresponding to the current UTXO, the ordinal management system can temporarily save the data in memory (i.e., cache the data first). Thus, in the process of replaying transactions contained in other subsequent blocks that are close to the current block (such as at least one block whose block height is greater than the current block and whose height difference with the current block is less than a threshold, which is equivalent to the current transaction belonging to block n and other subsequent transactions belonging to block n+x), if the transaction references the current UTXO, then when determining the output currency ordinal range corresponding to the UTXO generated by the transaction, the output currency ordinal range corresponding to the current UTXO can be directly queried from the above cache as the previous currency ordinal range of the transaction. Through the cache mechanism, the ordinal management system does not need to perform cumbersome decoding processing when processing the current transaction that references transactions in adjacent blocks, but directly determines the output currency ordinal range corresponding to the UTXO generated by the transaction from the cached currency ordinal range, thereby speeding up the determination of the currency range.
[0090] In one embodiment, the shard ordinal encoding data and output ordinal encoding data corresponding to each current UTXO of the current transaction that have been saved can be queried by the user. For example, the ordinal management system can respond to the data query request initiated by the blockchain client, and query the shard information table corresponding to any current UTXO in the saved shard meta information table according to the index information carried in the request (such as block height, transaction id, transaction hash and output index, etc.), and then query a certain shard information table through the subset identifier recorded in the table, and read the shard ordinal encoding data or output ordinal encoding data recorded therein, and then return the reading result to the user for viewing.
[0091] In one embodiment, token (or token) inscription can be implemented based on the above-mentioned ordinal management scheme to issue NFT (Non-Fungible Token) assets based on the blockchain system. For example, a user can initiate a token inscription transaction to the blockchain network through a blockchain client, and the transaction carries the target content (i.e., the content to be inscribed, such as pictures, text, video, audio, etc.). In the process of executing the transaction, the blockchain network can initiate a token inscription request carrying the target content to the ordinal management system, so that the ordinal management system can respond to the request, determine the target currency ordinal corresponding to the request, and associate and save the target currency ordinal and the target content carried in the token inscription request. It can be seen that the so-called token inscription is to bind a specific target content to a specific currency ordinal (i.e., the target currency ordinal), that is, to bind the target content to the minimum currency unit represented by the target currency ordinal. Among them, the above-mentioned target content can be saved in the script of the isolated witness area of the token inscription transaction, and it is bound to the target currency ordinal. The target currency ordinal number may be one or more (i.e., an ordinal set), which may be specifically specified by a user, assigned by a blockchain node, or assigned by an ordinal management system, etc., and the embodiments of this specification are not limited to this.
[0092] Figure 6 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 6 At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608, and a non-volatile memory 610, and may also include hardware required for other functions. One or more embodiments of this specification may be implemented based on software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into the memory 608 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0093] like Figure 7 As shown, Figure 7 is a block diagram of a device for managing ordinal numbers of a cryptocurrency provided by this specification according to an exemplary embodiment. The device can be applied to Figure 6 The device is used in the ordinal management system corresponding to the blockchain system, the blockchain system is implemented based on the unspent transaction output UTXO model, the cryptocurrency circulating in the blockchain system is composed of the smallest currency unit, and each smallest currency unit has a globally unique currency ordinal, and the device includes:
[0094] The range determination module 701 is configured to determine, for each current UTXO generated by the current transaction, an output currency ordinal range corresponding to the current UTXO, wherein the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range;
[0095] The range segmentation module 702 is configured to segment the output currency ordinal range into at least one ordinal range subset according to the continuous currency ordinal ranges included in the output currency ordinal range, wherein each ordinal range subset includes at least one continuous currency ordinal range;
[0096] The ordinal encoding module 703 is configured to encode the starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset, respectively, to generate the shard ordinal encoding data of each ordinal range subset, respectively, and save the output ordinal encoding data corresponding to the current UTXO which is jointly constituted by the shard ordinal encoding data of each ordinal range subset.
[0097] Optionally, the current transaction references at least one previous UTXO generated by a previous transaction, and the range determination module 701 is specifically configured as follows:
[0098] Get the previous currency ordinal ranges corresponding to each previous UTXO, and arrange the obtained previous currency ordinal ranges in order to form a transaction ordinal queue;
[0099] According to the index of the current UTXO in each current UTXO generated by the current transaction, the output currency ordinal range corresponding to the current UTXO is determined from the transaction ordinal queue.
[0100] Optionally, the range determination module 701 is specifically configured as follows:
[0101] In the case where the ordinal management system maintains the output ordinal encoding data corresponding to each UTXO generated by the previous transaction, the previous ordinal encoding data corresponding to each previous UTXO is queried from these output ordinal encoding data; for the previous output ordinal encoding data corresponding to each previous UTXO: the previous output ordinal encoding data is decoded to obtain at least one pair of previous starting point ordinal and previous end point ordinal, and the corresponding previous continuous currency ordinal range is determined according to each pair of previous starting point ordinal and previous end point ordinal, and each determined previous continuous currency ordinal range together constitutes the previous currency ordinal range corresponding to the previous UTXO; or,
[0102] In the case where the ordinal management system maintains at least one previous currency ordinal range corresponding to each UTXO generated by the previous transaction, the previous currency ordinal range corresponding to each previous UTXO is queried from these previous currency ordinal ranges.
[0103] Optionally, a blockchain node generating a current block where the current transaction is located is bound to a preset address, the current block includes a block reward transaction that allocates a reward to the preset address, the current transaction is different from the block reward transaction, and the device further includes:
[0104] The remaining range recording module 704 is configured to, after obtaining the output currency ordinal ranges corresponding to each current UTXO generated by the current transaction from the transaction ordinal queue, if there is at least one remaining currency ordinal range in the transaction ordinal queue, assign a corresponding range number to the at least one currency ordinal range according to the position of the at least one currency ordinal range in the transaction ordinal queue, and record the at least one currency ordinal range in the block ordinal queue of the current block using the transaction identifier of the current transaction and the range number as an index, so as to determine the output currency ordinal range corresponding to the block reward transaction.
[0105] Optionally, at least one of the preceding transactions belongs to the current block; and / or,
[0106] At least one of the previous transactions belongs to a previous block of the current block, and the block height of the previous block is lower than the block height of the current block.
[0107] Optionally, the range segmentation module 702 is specifically configured as follows:
[0108] For at least one continuous currency ordinal number range included in the output currency ordinal number range, determine the number of currency ordinals included in each continuous currency ordinal number range;
[0109] The output currency ordinal range is segmented according to the quantity to obtain at least one ordinal range subset, wherein the quantity of currency ordinals respectively included in each ordinal range subset is not greater than a corresponding quantity threshold.
[0110] Optionally, the range segmentation module 702 is specifically configured as follows:
[0111] On the premise that each of the continuous currency ordinal ranges remains continuous and the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold, each of the continuous currency ordinal ranges is divided into corresponding ordinal range subsets in order; or,
[0112] On the premise that the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold, multiple continuous currency ordinal subranges obtained by dividing at least one continuous currency ordinal range are divided into corresponding ordinal range subsets in order.
[0113] Optionally, the ordinal encoding module 703 is specifically configured as follows:
[0114] For at least one continuous currency ordinal range included in any one of the ordinal range subsets, respectively determine the starting ordinal number and the ending ordinal number of each continuous currency ordinal range;
[0115] The obtained starting ordinal numbers and end ordinal numbers are encoded, and the corresponding encoding results are sequentially spliced according to the arrangement order of each continuous currency ordinal range to obtain the fragmented ordinal encoding data of any ordinal range subset.
[0116] Optionally, the ordinal encoding module 703 is specifically configured to: encode the starting ordinal and the ending ordinal of any continuous currency ordinal range into a character string of a preset length as a corresponding encoding result.
[0117] Optionally, the ordinal encoding module 703 is specifically configured to: in accordance with the position order of the ordinal range subsets in the output currency ordinal range before splitting, sequentially splice the shard ordinal encoding data corresponding to each ordinal range subset respectively to obtain the output ordinal encoding data corresponding to the current UTXO.
[0118] Optionally, the ordinal encoding module 703 is specifically configured to: save the shard information tables corresponding to the respective ordinal range subsets and the shard meta information table corresponding to the current UTXO, wherein the shard information table corresponding to each ordinal range subset records the subset identifier and shard ordinal encoding data of the ordinal range subset, and the shard meta information table records the output identifier of the current UTXO and the subset identifiers of the shard information tables corresponding to the respective ordinal range subsets.
[0119] Optionally, it also includes: a token engraving module 705, which is configured to respond to a token engraving request initiated by the blockchain system, determine the target currency ordinal corresponding to the token engraving request, and associate and save the target currency ordinal and the target token carried in the token engraving request.
[0120] Based on the same concept as the above method, this specification also provides an electronic device, including: a processor; a memory for storing processor executable instructions; wherein the processor implements the steps of the method described in any of the above embodiments by running the executable instructions.
[0121] Based on the same concept as the above method, this specification also provides a computer-readable storage medium on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in any of the above embodiments are implemented.
[0122] Based on the same concept as the above method, this specification also provides a computer program product, including a computer program / instruction, which implements the steps of the method described in any of the above embodiments when executed by a processor.
Claims
1. A method for managing the ordinal number of a cryptocurrency, applied to an ordinal number management system corresponding to a blockchain system, wherein the blockchain system is implemented based on an unspent transaction output (UTXO) model, wherein the cryptocurrency circulating in the blockchain system is composed of minimum currency units, and each minimum currency unit has a globally unique currency ordinal number, wherein the method comprises: For each current UTXO generated by the current transaction, determine the output currency ordinal range corresponding to the current UTXO, and the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range; According to the continuous currency ordinal ranges included in the output currency ordinal range, the output currency ordinal range is divided into at least one ordinal range subset, wherein each ordinal range subset includes at least one continuous currency ordinal range; The starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset are respectively encoded to generate the shard ordinal encoding data of each ordinal range subset respectively, and the output ordinal encoding data corresponding to the current UTXO composed of the shard ordinal encoding data of each ordinal range subset is saved.
2. According to the method of claim 1, the current transaction references at least one previous UTXO generated by the previous transaction, and the determining of the output currency ordinal range corresponding to the current UTXO comprises: Get the previous currency ordinal ranges corresponding to each previous UTXO, and arrange the obtained previous currency ordinal ranges in order to form a transaction ordinal queue; According to the index of the current UTXO in each current UTXO generated by the current transaction, the output currency ordinal range corresponding to the current UTXO is determined from the transaction ordinal queue.
3. According to the method of claim 2, obtaining the range of the preceding currency ordinal numbers corresponding to each preceding UTXO referenced by the current transaction comprises: In the case where the ordinal management system maintains the output ordinal encoding data corresponding to each UTXO generated by the previous transaction, the previous ordinal encoding data corresponding to each previous UTXO is queried from these output ordinal encoding data; for the previous output ordinal encoding data corresponding to each previous UTXO: the previous output ordinal encoding data is decoded to obtain at least one pair of previous starting point ordinal and previous end point ordinal, and the corresponding previous continuous currency ordinal range is determined according to each pair of previous starting point ordinal and previous end point ordinal, and each determined previous continuous currency ordinal range together constitutes the previous currency ordinal range corresponding to the previous UTXO; or, In the case where the ordinal management system maintains at least one previous currency ordinal range corresponding to each UTXO generated by the previous transaction, the previous currency ordinal ranges corresponding to each previous UTXO are queried from these previous currency ordinal ranges.
4. The method according to claim 2, wherein the blockchain node generating the current block of the current transaction is bound to a preset address, the current block includes a block reward transaction that allocates a reward to the preset address, the current transaction is different from the block reward transaction, and the method further includes: After obtaining the output currency ordinal ranges corresponding to each current UTXO generated by the current transaction from the transaction ordinal queue, if there is at least one remaining currency ordinal range in the transaction ordinal queue, a corresponding range number is assigned to the at least one currency ordinal range according to the position of the at least one currency ordinal range in the transaction ordinal queue, and the at least one currency ordinal range is recorded in the block ordinal queue of the current block with the transaction identifier of the current transaction and the range number as an index, so as to determine the output currency ordinal range corresponding to the block reward transaction.
5. The method according to any one of claims 2 to 4, At least one of the preceding transactions belongs to the current block; and / or, At least one of the previous transactions belongs to a previous block of the current block, and the block height of the previous block is lower than the block height of the current block.
6. The method according to claim 1, wherein the step of dividing the output currency ordinal range into at least one ordinal range subset according to the continuous currency ordinal range contained in the output currency ordinal range comprises: For at least one continuous currency ordinal number range included in the output currency ordinal number range, determine the number of currency ordinals included in each continuous currency ordinal number range; The output currency ordinal range is segmented according to the quantity to obtain at least one ordinal range subset, wherein the quantity of currency ordinals respectively included in each ordinal range subset is not greater than a corresponding quantity threshold.
7. The method according to claim 6, wherein the step of segmenting the output currency ordinal range according to the quantity to obtain at least one ordinal range subset comprises: On the premise that each continuous currency ordinal range remains continuous and the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold, each continuous currency ordinal range is divided into corresponding ordinal range subsets in order; or, On the premise that the number of currency ordinals contained in each ordinal range subset is not greater than the corresponding quantity threshold, multiple continuous currency ordinal subranges obtained by dividing at least one continuous currency ordinal range are divided into corresponding ordinal range subsets in order.
8. The method according to claim 1, encoding the starting ordinal and the ending ordinal of the continuous currency ordinal range contained in any ordinal range subset to generate the fragmented ordinal encoding data of the ordinal range subset, comprising: For at least one continuous currency ordinal range included in any one of the ordinal range subsets, respectively determine the starting ordinal number and the ending ordinal number of each continuous currency ordinal range; The obtained starting ordinal numbers and end ordinal numbers are encoded, and the corresponding encoding results are sequentially spliced according to the arrangement order of each continuous currency ordinal range to obtain the fragmented ordinal encoding data of any ordinal range subset.
9. The method according to claim 8, encoding the starting ordinal number and the ending ordinal number of any continuous currency ordinal range, comprising: The starting point ordinal number and the ending point ordinal number of any continuous currency ordinal range are encoded into a character string of a preset length as a corresponding encoding result.
10. According to the method of claim 1, generating the output sequence number encoding data corresponding to the current UTXO includes: According to the position order of each ordinal range subset in the output currency ordinal range before splitting, the shard ordinal encoding data corresponding to each ordinal range subset are sequentially spliced to obtain the output ordinal encoding data corresponding to the current UTXO.
11. According to the method of claim 1, the output ordinal encoding data corresponding to the current UTXO, which is composed of the shard ordinal encoding data of each ordinal range subset, includes: The shard information tables corresponding to the respective ordinal range subsets and the shard meta information table corresponding to the current UTXO are saved, wherein the shard information table corresponding to each ordinal range subset records the subset identifier and shard ordinal encoding data of the ordinal range subset, and the shard meta information table records the output identifier of the current UTXO and the subset identifiers of the shard information tables corresponding to the respective ordinal range subsets.
12. The method according to claim 1, further comprising: In response to a token inscription request initiated by the blockchain system, a target currency ordinal number corresponding to the token inscription request is determined, and the target currency ordinal number and the target token carried in the token inscription request are associated and saved.
13. An ordinal management system, wherein the blockchain system corresponding to the ordinal management system is implemented based on the UTXO model, the cryptocurrency circulating in the blockchain system is composed of minimum currency units, each minimum currency unit has a globally unique currency ordinal, and the system is used to: For each current UTXO generated by the current transaction, determine the output currency ordinal range corresponding to the current UTXO, and the cryptocurrency value of the current UTXO is equal to the sum of the values of the smallest currency units represented by each currency ordinal within the output currency ordinal range; According to the continuous currency ordinal ranges included in the output currency ordinal range, the output currency ordinal range is divided into at least one ordinal range subset, wherein each ordinal range subset includes at least one continuous currency ordinal range; The starting ordinal and the ending ordinal of the continuous currency ordinal range contained in each ordinal range subset are respectively encoded to generate the shard ordinal encoding data of each ordinal range subset respectively, and the ordinal encoding data corresponding to the current UTXO formed by the shard ordinal encoding data of each ordinal range subset is saved.
14. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 12 by running the executable instructions.
15. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 12.
16. A computer program product, comprising a computer program and / or instructions, wherein the computer program and / or instructions, when executed by a processor, implement the steps of the method according to any one of claims 1 to 12.
Citation Information
Cited By
Ordinal management for cryptocurrency
WO2025180476A1
