Block chain traffic recording method and device, computer equipment and storage medium
By using off-chain nodes to verify and sign transaction information in the decentralized architecture of the blockchain, and separating transaction verification and execution, the reliability of blockchain traffic records and computing resource consumption issues are solved, and efficient and reliable are achieved. Traffic records.
Patent Information
- Application Number
- CN202410808236.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-10-15
AI Technical Summary
Existing technology is difficult to reliably record the source of blockchain traffic under low computing resources in the decentralized architecture of the blockchain, and the traditional architecture increases the computing resources consumed by nodes when broadcasting transactions, resulting in increased network latency.
By signing the transaction information when the user initiates the target transaction and sending it to the off-chain node associated with the target transaction, it is judged whether the transaction information includes the field of the referral object. If it exists, it will be sent to the on-chain node. If it does not exist, it will be sent to the on-chain node. Then it is generated and signed before being sent; when the transaction is successfully executed, the nodes on the chain record the fields, separating transaction verification and execution, reducing the network resource consumption of the nodes on the chain.
It realizes high-reliability blockchain traffic records based on low computing resources, avoids falsification of traffic sources, reduces the consumption of computing resources of nodes on the chain, and improves the reliability and efficiency of records.
Smart Images

Figure CN118784241A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a blockchain traffic recording method, apparatus, computer equipment, and storage medium. Background Art
[0002] Developers and users entering the blockchain system can stimulate the vitality of the blockchain, thereby providing services to a wider range of ordinary people based on the blockchain network. How to record the source of blockchain traffic has become an urgent problem to be solved. In order to record the source of transaction traffic, the physical industry often records the number of user invitations and the source of invitations. However, the servers in the physical industry are opaque, which will reduce the credibility of the source of traffic. In addition, in the decentralized architecture of the blockchain, it is very difficult to use the server to record the source of traffic. Therefore, the relevant technology cannot solve the problem of difficulty and low reliability in recording the source of blockchain traffic. In addition, based on the traditional blockchain architecture, the node records the number of user invitations and the source of invitations while broadcasting and completing transactions. Especially when there are a large number of broadcast transactions, it will increase the computing resources consumed by the node, thereby causing a large network delay.
[0003] There is currently no effective solution to the problem in related technologies that it is impossible to reliably record the source of blockchain traffic based on low computing resources. Summary of the invention
[0004] Based on this, it is necessary to provide a blockchain traffic recording method, device, computer equipment and storage medium that can reliably record the source of blockchain traffic based on low computing resources to address the above technical problems.
[0005] In a first aspect, a blockchain traffic recording method is provided in this embodiment, and the method includes:
[0006] In the case where the user initiates a target transaction, the transaction information of the target transaction is signed and sent to the off-chain node associated with the referral object of the target transaction;
[0007] Determining whether the transaction information includes a field for identifying a referral object of the target transaction;
[0008] If yes, then when it is determined based on the transaction information that the target transaction is valid, the off-chain node sends the transaction information to the on-chain node;
[0009] If not, the field is generated according to the transaction information or the address of the off-chain node, the field is written into the transaction information and the transaction information is signed, and the off-chain node sends the transaction information to the on-chain node;
[0010] When the on-chain node successfully executes the target transaction based on the transaction information, the field is recorded.
[0011] In some embodiments, determining whether the target transaction is valid based on the transaction information includes:
[0012] Obtain the address of the off-chain node;
[0013] In the case where it is determined that the field matches the address of the off-chain node, the target transaction is determined to be valid;
[0014] When it is determined that the field does not match the address of the off-chain node, the target transaction is determined to be invalid.
[0015] In some embodiments, obtaining a field for identifying the referral object according to the transaction information includes:
[0016] Acquire a uniform resource locator used to generate the target transaction from the transaction information;
[0017] The field is generated according to the address in the uniform resource locator.
[0018] In some embodiments, obtaining the address in the uniform resource locator includes:
[0019] Obtaining an identifier in the uniform resource locator and a mapping relationship between the identifier and the address of the referral object;
[0020] The identifier is mapped based on the mapping relationship to obtain the address.
[0021] In some of the embodiments, when the on-chain node successfully executes the target transaction based on the transaction information, before recording the field, the method further includes:
[0022] Determine whether the transaction information containing the field is signed multiple times;
[0023] If so, the signature in the transaction information is verified, and if the signature verification passes, the target transaction is executed.
[0024] In some embodiments, verifying the signature in the transaction information includes:
[0025] Obtaining a public key according to the address information and / or the field in the transaction body of the transaction information;
[0026] Obtaining a first signature value of the transaction information based on the public key and a preset function calculation;
[0027] Obtaining a second signature value in the transaction information;
[0028] If the first signature value matches the second signature value, the signature verification passes;
[0029] If the first signature value does not match the second signature value, the signature verification fails.
[0030] In some of the embodiments, recording the field based on the on-chain node includes:
[0031] Executing the target transaction based on multiple on-chain nodes respectively;
[0032] When a preset number of on-chain nodes successfully execute the target transaction, the field is recorded.
[0033] In the second aspect, a blockchain traffic recording device is provided in this embodiment, and the device includes: an acquisition module, a judgment module and a recording module; wherein,
[0034] The acquisition module, when a user initiates a target transaction, signs the transaction information of the target transaction and sends the transaction information to an off-chain node associated with a referral object of the target transaction;
[0035] The judgment module is used to judge whether the transaction information includes a field for identifying the referral object of the target transaction; if so, the off-chain node sends the transaction information to the on-chain node when the target transaction is determined to be valid based on the transaction information; if not, the field is generated according to the transaction information or the address of the off-chain node, the field is written into the transaction information and the transaction information is signed, and the off-chain node sends the transaction information to the on-chain node;
[0036] The recording module is used to record the field when the on-chain node successfully executes the target transaction based on the transaction information.
[0037] In a third aspect, a computer device is provided in this embodiment, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the blockchain traffic recording method described in the first aspect is implemented.
[0038] In a fourth aspect, a computer-readable storage medium is provided in this embodiment, on which a computer program is stored. When the computer program is executed by a processor, the blockchain traffic recording method described in the first aspect is implemented.
[0039] The above-mentioned blockchain traffic recording method, device, computer equipment and storage medium obtain the user signature field for identifying the referral object according to the transaction information of the target transaction, and the blockchain records the signed field, which not only realizes the recording of blockchain traffic, but also avoids the possibility of on-chain nodes falsifying the source of traffic because the field is signed by the user; and when the transaction information includes the field, the off-chain node verifies the validity of the transaction, so that the on-chain node does not need to verify the validity of the transaction when executing the transaction, thereby reducing the network resources required for the on-chain node to run, and achieving the effect of high-reliability recording of blockchain drainage sources based on low computing resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 A hardware structure block diagram of a terminal of a blockchain traffic recording method in one embodiment;
[0041] Figure 2 A flowchart of a blockchain traffic recording method in one embodiment;
[0042] Figure 3 A schematic diagram of a blockchain recording method of a transaction flow source in one embodiment;
[0043] Figure 4 It is a structural block diagram of a blockchain traffic recording device in one embodiment;
[0044] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0045] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0046] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. For example, running on a terminal, Figure 1 This is a hardware structure diagram of a terminal of a blockchain traffic recording method according to an embodiment of the present application. Figure 1 As shown, the terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 and memory 104 for storing data, wherein processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA. The above terminal may also include a transmission device 106 and an input and output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.
[0047] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the blockchain traffic recording method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0048] The transmission device 106 is used to receive or send data via a network. The above network includes a wireless network provided by the communication provider of the terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0049] In one embodiment, Figure 2 As shown, a blockchain traffic recording method is provided, and the method is applied to Figure 1 The terminal in is used as an example to illustrate, including the following steps:
[0050] Step 202, when the user initiates a target transaction, the transaction information of the target transaction is signed and sent to the off-chain node associated with the referral object of the target transaction.
[0051] The target transaction refers to the transaction initiated by the user based on the referral of the referral object. In order to prevent the field from being tampered with during the transmission process, the transaction information is signed. Optionally, the user signs the field with a private key to prevent the outside from obtaining the traffic source information of the blockchain by reading the characters, ensuring that the blockchain traffic information obtained based on the field record is credible.
[0052] In addition to transaction data such as transaction content, timestamp, and mining fee, the transaction information also includes an identifier for distinguishing the referral object, which can be the address of the recipient, the number or name of the referral object, etc. The referral object can be determined by parsing the transaction information. Optionally, if the user enters data for identifying the referral object, such as an invitation code, the address of the referral object, etc. during the process of initiating the target transaction, the referral object can be determined by the user input data in the transaction information. Alternatively, the referral object can also be determined by the uniform resource locator in the transaction information.
[0053] Transactions initiated based on different referral objects are processed by different off-chain nodes, and the associated off-chain nodes can be determined based on the referral objects in the transaction information. Among them, off-chain nodes refer to nodes that do not perform transaction processing or data storage activities on the main blockchain. Optionally, when the identifier that distinguishes the referral object in the transaction information is the address of the recipient, the address of the recipient in the transaction information is obtained, and the transaction information is sent to the address, and the transaction information can be sent to the off-chain node. When the identifier that distinguishes the referral object in the transaction information is not the address of the referral object, the mapping relationship between the preset identifier of the referral object and the off-chain node can be obtained, so as to obtain the off-chain node corresponding to the identifier of the referral object according to the mapping relationship, and send the transaction information to the address of the off-chain node.
[0054] Step 204: determine whether the transaction information includes a field for identifying a referral object of the target transaction.
[0055] Different referral objects correspond to different fields. Optionally, the field name of the field used to identify the referral object of the target transaction is obtained, and the field name is searched in the transaction information. If the corresponding data is found by searching through the field name, the transaction information includes the field used to identify the referral object of the target transaction; if the corresponding data cannot be found by searching through the field name, the transaction information does not include the field used to identify the referral object of the target transaction.
[0056] Step 206: If yes, then when it is determined based on the transaction information that the target transaction is valid, the off-chain node sends the transaction information to the on-chain node.
[0057] Among them, the on-chain node is the node that executes the target transaction and stores data, and one off-chain node can correspond to one or more on-chain nodes.
[0058] Optionally, verifying the target transaction includes: obtaining a field in the transaction information for identifying the referral object. Determining whether the referral object identified by the field is the same as the referral object corresponding to the off-chain node, if the two are the same, then the target transaction is determined to be valid; if the two are different, then the target transaction is determined to be invalid. Determining the validity of the target transaction based on the field for identifying the referral object can ensure that the blockchain traffic source record is reliable.
[0059] Optionally, verifying the validity of the target transaction through the transaction information also includes: verifying whether the structure of the target transaction complies with the protocol, whether the transaction information is complete, whether the mining fee included in the target transaction meets the network requirements, etc. Judging the validity of the target transaction based on the transaction information can ensure that the on-chain nodes can successfully execute the target transaction based on the transaction information.
[0060] Furthermore, the above two verification methods can be combined so that the off-chain node can determine the validity of the target transaction based on both the field and the transaction information, and only when the target transaction is determined to be valid based on both the field and other transaction information except the field, the step of sending the transaction information to the on-chain node is executed. The off-chain node is responsible for verifying the validity of the target transaction, which can reduce the burden on the network and computing resources of the verification node.
[0061] Step 208: If not, generate a field based on the transaction information or the address of the off-chain node, write the field into the transaction information and sign the transaction information, and the off-chain node sends the transaction information to the on-chain node.
[0062] Optionally, generating a field includes: obtaining data actively input by the user when initiating the target transaction, and saving the user input data in the transaction information. A field for identifying the referral object is obtained based on the user input data in the transaction information. Alternatively, a uniform resource locator for initiating the target transaction is provided to the user, and when the user initiates the target transaction based on the uniform resource locator, the uniform resource locator is saved in the transaction information. The terminal obtains and parses the uniform resource locator in the transaction information, obtains a string in the uniform resource locator for distinguishing the referral object, and uses the string as a field for identifying the referral object. Alternatively, the address of the off-chain node is obtained, and the address of the off-chain node is used as the field. After the field is generated, the transaction information containing the field is signed to protect the transaction information from being tampered with during the process of sending the transaction information from the off-chain node to the on-chain node.
[0063] Step 210, when the on-chain node successfully executes the target transaction based on the transaction information, the field is recorded.
[0064] Among them, the successful execution of the target transaction by the on-chain node based on the transaction information indicates that the blockchain drainage is successful, otherwise, the blockchain drainage fails. Therefore, when the on-chain node successfully executes the target transaction based on the transaction information, the field is recorded; when the on-chain node fails to successfully execute the target transaction based on the transaction information, the field is not recorded. Optionally, if there are multiple on-chain nodes, the multiple on-chain nodes jointly execute the target transaction based on the transaction information, and each node stores the field separately.
[0065] In the above-mentioned blockchain traffic recording method, a field for identifying the referral object is generated according to the transaction information of the target transaction, and the field is recorded by the on-chain node, thereby realizing the recording of the referral source of the target transaction. When the transaction information includes a field for identifying the referral object, the field is signed to prevent the falsification of the field, and avoid the possibility of falsification of the traffic source by the node or external tool, thereby solving the problem of difficulty and low reliability in recording the source of blockchain drainage. When the transaction information includes a field, the off-chain node verifies the transaction validity, so that the on-chain node does not need to verify the transaction validity when executing the transaction, and separates the transaction verification and transaction execution, thereby reducing the network resources required for the on-chain node to run, and realizing the effect of improving the reliability of the blockchain drainage source record. At the same time, regardless of whether there is a field in the original transaction information of the target transaction, the field for identifying the referral object of the target transaction can be obtained according to the transaction information or the off-chain node, and the effect of high reliability recording of the blockchain drainage source based on low computing resources can be achieved in various environments.
[0066] In some of the embodiments, determining whether the target transaction is valid based on the transaction information also includes: obtaining the address of the off-chain node; if it is determined that the field matches the address of the off-chain node, determining that the target transaction is valid; if it is determined that the field does not match the address of the off-chain node, determining that the target transaction is invalid.
[0067] Among them, the address of the off-chain node is the same as the address of the referral object. Optionally, the address of the referral object is obtained based on the referral object identified by the field. If the address obtained based on the field is consistent with the address of the off-chain node, the referral object identified by the field and the referral object corresponding to the on-chain node that executes the target transaction are the same referral object, and the on-chain node can execute the target transaction according to the transaction information; otherwise, the referral object identified by the field and the referral object corresponding to the on-chain node that executes the target transaction are different, and the on-chain node refuses to execute the target transaction according to the transaction information.
[0068] Optionally, when the address of the referral object in the transaction information is used as a field, the address in the field can be directly compared with the address of the off-chain node to see if they are consistent, and if they are consistent, the target transaction is judged to be valid; if they are inconsistent, the target transaction is judged to be invalid.
[0069] In this embodiment, by broadcasting the target transaction to the verification node when the off-chain node verifies that the target transaction is valid, the transaction security can be improved, thereby maintaining the healthy operation of the entire blockchain network.
[0070] In some embodiments, obtaining a field for identifying a referral object according to transaction information includes: obtaining a uniform resource locator for generating a target transaction in the transaction information; and generating a field according to an address in the uniform resource locator. The uniform resource locator is provided by the referral object, and the user initiates the target transaction by interacting with the uniform resource locator.
[0071] The Uniform Resource Locator includes the protocol, host name, port number, path and query string. The field in the Uniform Resource Locator that refers to the host name is used as the field for identifying the referral object. If the host name in the Uniform Resource Locator directly records the address of the referral object, the address can be extracted from the Uniform Resource Locator and used as the field for identifying the referral object.
[0072] Furthermore, if the host name of the uniform resource locator does not directly record the address of the referral object, in one embodiment, obtaining the address in the uniform resource locator includes: obtaining an identifier in the uniform resource locator, and a mapping relationship between the identifier and the address of the referral object; mapping the identifier based on the mapping relationship to obtain the address. The address of the referral object may correspond to one or more identifiers, and an identifier in the uniform resource locator may only correspond to one referral object. The mapping relationship between the identifier and the address of the referral object may be stored by a domain name manager. The domain name in the uniform resource locator is resolved into an IP address by the domain name manager to obtain the address for identifying the referral object, so that when the terminal determines that the target transaction is valid based on the field and transaction information, it can establish a connection with the off-chain node based on the address.
[0073] In this embodiment, because the uniform resource locator is generated according to the address of the referral object, and the addresses of different referral objects will not be repeated, the referral object can be identified based on the uniform resource locator, so that the terminal can determine the referral object of the target transaction according to the transaction information.
[0074] In some of the embodiments, when the on-chain node successfully executes the target transaction based on the transaction information, before recording the field, the method also includes: determining whether the transaction information containing the field is signed multiple times; if so, verifying the signature in the transaction information, and executing the target transaction if the signature verification passes.
[0075] Among them, if the transaction information generated in response to the target transaction initiated by the user does not include a field for identifying the referral object, the transaction information is signed before sending the transaction information to the off-chain node, and the transaction information is signed twice before sending the transaction information to the on-chain node. Conversely, if the transaction information generated in response to the target transaction initiated by the user includes a field for identifying the referral object, the transaction information is signed only once.
[0076] Optionally, check the signature layer in the transaction information. If it contains multiple signature layers, the transaction information is signed multiple times. At this time, first verify the outer signature, where the outer signature refers to the signature of the transaction information before sending the transaction information to the on-chain node. By verifying the outer signature, the integrity of the transaction information sent from the off-chain node to the on-chain node can be ensured. Then verify the inner signature, where the inner signature refers to the signature of the transaction information before sending the transaction information to the off-chain node. By verifying the inner signature, the integrity of the transaction information sent to the off-chain node can be ensured. After sending the transaction information to the on-chain node, verify the two signatures separately to avoid tampering with the referral object or transaction information during the process of generating fields by the off-chain node. Among them, if the on-chain node trusts the off-chain node, it can also choose not to verify the inner signature.
[0077] Furthermore, in one embodiment, verifying the signature in the transaction information includes: obtaining a public key based on the address information and / or field in the transaction body of the transaction information; calculating a first signature value of the transaction information based on the public key and a preset function; obtaining a second signature value in the transaction information; if the first signature value matches the second signature value, the signature verification succeeds; if the first signature value does not match the second signature value, the signature verification fails.
[0078] Wherein, obtaining the public key according to the address information in the transaction body of the transaction information includes: obtaining the public key corresponding to the "from" address in the transaction information from the blockchain. Obtaining the public key according to the field includes: determining the referral object and the address of the referral object according to the field, and obtaining the public key corresponding to the address of the referral object from the blockchain. Optionally, if the outer signature is verified, the public key can be obtained according to the field to facilitate judgment whether the field has been tampered with in the process of sending the transaction information from the off-chain node to the on-chain node. If the inner signature is verified, the public key can be obtained according to the address information in the transaction body to facilitate judgment whether the address information in the transaction body is accurate in the process of sending to the on-chain node. The preset function is obtained according to the existing signature algorithm, and the signature method corresponding to the preset function corresponds to the signature method used in the signing process. The second signature value is the value output after the hash operation is performed on the transaction information during the signing process.
[0079] Optionally, the public key P=d·G is obtained according to the "from" address information in the transaction body of the transaction information, wherein G is the base point of the elliptic curve and d is the private key of the user.
[0080] The preset function is obtained according to the ECDSA signature algorithm, and the first signature value Q is calculated according to the public key and the preset function:
[0081] Q=u1G+u2P
[0082] Where u1=h*s-1 mod n,,u2=r*s -1 mod n,s -1 It is the inverse element of s under modulus (mod) n. h=H(m), the function H(·) is a function obtained based on any existing hash algorithm such as SHA256 algorithm, SHA-3 algorithm, etc., and m is the transaction information to be signed.
[0083] If Q is a point at infinity, the verification fails. If the first signature value is calculated, the second signature value s, r is obtained. Check whether the first signature value matches the second signature value, including: checking whether the horizontal coordinate of Q is equal to r.
[0084] Q=u1G+u2P=h*s -1 *G+r*s -1 *P=h*s -1 *G+r*s -1 *d*G
[0085] =(h+r*d)*s -1 *G=kG
[0086] Among them, k is a random integer selected by the user to sign the transaction based on the private key, k∈[1,n-1], G is the base point of the elliptic curve, n is the order of the elliptic curve, and the user's private key is d. Therefore, the horizontal coordinate of point Q should be equal to r in the correct case.
[0087] So if the horizontal coordinate of Q is equal to r, the signature verification is successful, otherwise the verification fails.
[0088] The second signature value in the transaction information is also obtained according to the ECDSA signature algorithm, as follows:
[0089] Calculate h=H(m) and randomly select an integer k∈[1,n-1].
[0090] Calculate R = k·G, and record r based on the horizontal coordinate of point R; if r = 0, repeat the steps of calculating R = k·G until r is not equal to 0. Calculate s = k -1 (h+rd) mod n; if s=0, repeat the calculation s=k -1 (h+rd) mod n steps, until s is not equal to 0. Complete the signature and obtain the second signature value (r, s).
[0091] In this embodiment, by verifying the signature in the transaction information, it is ensured that the transaction information is a field that has not been tampered with, and the integrity of the data and the reliability of the source are guaranteed, thereby ensuring the accuracy of the blockchain traffic record.
[0092] In some embodiments, recording fields based on on-chain nodes includes: executing target transactions based on multiple on-chain nodes; recording fields when a preset number of on-chain nodes successfully execute the target transaction. The preset number is greater than half of the number of on-chain nodes that execute the target transaction, and can also be modified and set according to application requirements. If the preset number of on-chain nodes successfully execute the target transaction, there are enough nodes to recognize the source of the traffic, and the on-chain nodes that successfully execute the target transaction save the fields and the data in the process of executing the target transaction and add them to the chain to indicate confirmation. Optionally, for on-chain nodes that fail to successfully execute the target transaction, you can try to reconnect to the network, re-download transaction data, or request unconfirmed transaction records, etc., to re-execute the steps of processing the target transaction. Alternatively, you can also detect whether these blockchain nodes are Byzantine nodes through an alarm mechanism such as a Byzantine fault-tolerant consensus algorithm. If these blockchain nodes belong to Byzantine nodes, you can correct or isolate these nodes that fail to successfully execute transactions. Optionally, when the on-chain nodes execute the target transaction, you can also use a consensus mechanism to determine which transactions are included in the block and when to update the status of the blockchain, so as to ensure the immutability of the traffic record.
[0093] In this embodiment, the target transaction is executed by multiple on-chain nodes, thereby increasing the degree of decentralization of the blockchain network and effectively preventing malicious behavior of on-chain nodes, such as forging transactions or modifying historical records, thereby improving the security of the blockchain.
[0094] Furthermore, after executing transaction information based on the on-chain node and recording the fields, the method also includes: counting the referral objects in the transactions executed by the on-chain node based on the fields. Among them, the characters can be directly stored to realize the recording of blockchain traffic, or the characters can be converted into a unified format to realize the recording of blockchain traffic. After recording and counting the referral objects, blockchain resources are allocated to each referral object according to the number of traffic obtained by statistics. Among them, blockchain resources can be access rights, digital currencies, or other blockchain resources with incentive functions. The number of traffic directed to the referral object is positively correlated with the allocated blockchain resources, that is, the more the number of traffic directed, the more blockchain resources are allocated to the referral object; the fewer the number of traffic directed, the fewer the blockchain resources are allocated to the referral object.
[0095] In one embodiment, Figure 3 A schematic diagram of a blockchain recording method for transaction flow sources is provided, such as Figure 3 As shown, the blockchain recording methods include:
[0096] When a user sends a target transaction, the target transaction is first signed. The signature can use the ECDSA algorithm, or other signature algorithms such as the DSA signature algorithm, the RSA signature algorithm, etc. The user signs the transaction information, which can make the transaction information tamper-proof and unreadable.
[0097] Among them, when generating transaction information according to the initiated transaction, a Referral field for uniquely identifying the referrer can be selected to be generated synchronously. Optionally, the Referral field is obtained based on the address associated with the referrer. For example, in the case where the user initiates the target transaction, the user is instructed to actively enter the invitation code provided by the referral object. The preset mapping relationship between the invitation code and the address associated with the referrer is obtained, and the received invitation code is converted into the address associated with the referrer through the preset mapping relationship, and the obtained address is used as the Referral field. Alternatively, a URL (uniform resource locator) is generated according to the address associated with the referrer, and the URL is exposed to the user so that the user can initiate a transaction based on the URL. In the case where the user initiates the target transaction, the address associated with the referrer is obtained by reading the host name in the URL of the user interaction. Among them, if the host name in the URL includes the address associated with the referrer, the address is directly extracted from the URL to obtain the Referral field. If the host name in the URL does not include the address associated with the referrer, the characters in the URL are obtained, and the readable characters are converted into addresses through the domain name management system to obtain the Referral field.
[0098] The signed transaction information is sent to the blockchain node. The transaction information can be directly sent to the on-chain node used to execute the transaction, and the on-chain node verifies the validity of the transaction, executes the transaction, and records the fields. There can be one or more on-chain nodes. If there are multiple on-chain nodes, each on-chain node verifies the validity of the transaction, and if the transaction is verified to be valid, executes the target transaction and field recording steps.
[0099] In order to reduce the network resource consumption of the on-chain nodes, the signed transaction information is first sent to the off-chain nodes, and then the off-chain nodes send the transaction information to the on-chain nodes. Optionally, after the user signs the transaction information containing the field, the transaction information is sent to the address indicated by the corresponding invitation code or the address extracted from the URL. The address is the RPC (Remote Procedure Call) node, that is, the off-chain node in the above embodiment.
[0100] After receiving the transaction, the RPC node will check the validity of the transaction. Optionally, after receiving the transaction, the RPC node will first verify the signature of the transaction. After the signature is verified, checking the validity of the transaction also includes: the RPC node verifies whether the format of the transaction meets the standards specified by the blockchain protocol through the transaction information, and whether the actual cost of executing the transaction is consistent with the cost indicated by the user's wishes. At the same time, the RPC node obtains the address indicated by the field and determines whether the address indicated by the field is consistent with the address of the RPC node. If the format of the transaction meets the standards specified by the blockchain protocol, or the actual cost of the transaction is consistent with the cost indicated by the user's wishes, or the address indicated by the field is consistent with the address of the RPC node, the transaction is judged to be valid. If any of the conditions cannot be obtained, the transaction is judged to be invalid.
[0101] After the validity verification is passed, if the transaction information does not come with a Referral field, the RPC node will attach a Referral field to the user's transaction information. Among them, the Referral field is the node address of the RPC node. At the same time, the RPC node will perform a secondary signature on the transaction information with the Referral field attached. The RPC node broadcasts the transaction after the secondary signature to multiple verification nodes, that is, the on-chain nodes in the above embodiment. After the validity verification is passed, if the transaction information comes with a Referral field, the RPC node directly broadcasts the target transaction to multiple verification nodes.
[0102] The verification node determines how many times the transaction has been signed based on the transaction information, and performs targeted signature verification. Specifically, when the transaction information has two layers of signatures, the Referral field information is used to verify the signature transaction. Among them, if the verification node does not trust the RPC node, both the first signature and the second signature can be verified; if the verification node trusts the RPC node, the first signature can be verified without verification, and only the second signature can be verified. Thus, by separating the RPC node from the verification node, the network and computing resource burden of the verifier can be reduced. Similarly, when there is only one layer of signature, the verification node trusts the RPC node and does not need to verify the first signature. Otherwise, the first signature is verified. When the verification node passes the verification, it executes the target transaction, stores the Referral field, and obtains the source of blockchain traffic. To further ensure the validity and authenticity of the blockchain traffic record, optionally, when the on-chain node executes the transaction and stores the field, a consensus algorithm can be used to ensure the immutability of the traffic record.
[0103] This embodiment supports the process of initiating a target transaction. The user can actively fill in the address information of the referral object to obtain the Referral field that uniquely identifies the referral object, or fill in the address information of the referral object through the RPC node to obtain the Referral field that uniquely identifies the referral object, thereby achieving compatibility with transaction information without a Referral field and with a Referral field. Since the user uses his own private key to sign the transaction after the field is generated, the RPC node or verification node cannot change the Referral field passed by the user, thereby ensuring the validity and authenticity of the blockchain traffic record. In addition, by separating the RPC node from the verification node, the network and computing resource burden of the verifier is reduced, achieving the effect of realizing high-reliability recording of blockchain traffic sources based on low computing resources.
[0104] Based on the same inventive concept, the embodiment of the present application also provides a blockchain traffic recording device for implementing the blockchain traffic recording method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more blockchain traffic recording device embodiments provided below can refer to the limitations of the blockchain traffic recording method above, and will not be repeated here.
[0105] In one embodiment, Figure 4 As shown, a blockchain traffic recording device is provided, including: an acquisition module, a judgment module and a recording module; wherein, the acquisition module, when a user initiates a target transaction, signs the transaction information of the target transaction, and sends the transaction information to an off-chain node associated with the referral object of the target transaction; the judgment module is used to judge whether the transaction information includes a field for identifying the referral object of the target transaction; if so, when the target transaction is judged to be valid based on the transaction information, the off-chain node sends the transaction information to the on-chain node; if not, a field is generated according to the transaction information or the address of the off-chain node, the field is written into the transaction information and the transaction information is signed, and the off-chain node sends the transaction information to the on-chain node; the recording module is used to record the field when the on-chain node successfully executes the target transaction based on the transaction information.
[0106] In some of the embodiments, the judgment module judges whether the target transaction is valid based on the transaction information, including: obtaining the address of the off-chain node; if it is determined that the field matches the address of the off-chain node, judging that the target transaction is valid; if it is determined that the field does not match the address of the off-chain node, judging that the target transaction is invalid.
[0107] In some embodiments, the determination module obtains a field for identifying a referral object according to the transaction information, including: obtaining a uniform resource locator for generating a target transaction in the transaction information; and generating a field according to an address in the uniform resource locator.
[0108] Optionally, the judgment module obtains the address in the uniform resource locator, including: obtaining an identifier in the uniform resource locator and a mapping relationship between the identifier and the address of the referral object; and mapping the identifier based on the mapping relationship to obtain the address.
[0109] In some of the embodiments, when the on-chain node successfully executes the target transaction based on the transaction information, before recording the field, the recording module also includes: determining whether the transaction information containing the field is signed multiple times; if so, verifying the signature in the transaction information, and executing the target transaction if the signature verification passes.
[0110] Optionally, the recording module verifies the signature in the transaction information, including: obtaining a public key based on the address information and / or fields in the transaction body of the transaction information; calculating a first signature value of the transaction information based on the public key and a preset function; obtaining a second signature value in the transaction information; if the first signature value matches the second signature value, the signature verification passes; if the first signature value does not match the second signature value, the signature verification fails.
[0111] In some of the embodiments, the recording module records fields based on on-chain nodes, including: executing target transactions based on multiple on-chain nodes respectively; and recording fields when a preset number of on-chain nodes successfully execute the target transaction.
[0112] Each module in the above-mentioned blockchain traffic recording device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0113] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 5As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store blockchain traffic data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a blockchain traffic recording method is implemented.
[0114] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0115] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0116] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0117] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0118] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0119] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0120] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A blockchain traffic recording method, characterized in that: The method comprises: In the case where the user initiates a target transaction, the transaction information of the target transaction is signed and sent to the off-chain node associated with the referral object of the target transaction; Determining whether the transaction information includes a field for identifying a referral object of the target transaction; If yes, then when it is determined based on the transaction information that the target transaction is valid, the off-chain node sends the transaction information to the on-chain node; If not, the field is generated according to the transaction information or the address of the off-chain node, the field is written into the transaction information and the transaction information is signed, and the off-chain node sends the transaction information to the on-chain node; When the on-chain node successfully executes the target transaction based on the transaction information, the field is recorded.
2. The method according to claim 1, characterized in that Determining whether the target transaction is valid based on the transaction information includes: Obtain the address of the off-chain node; In the case where it is determined that the field matches the address of the off-chain node, the target transaction is determined to be valid; When it is determined that the field does not match the address of the off-chain node, the target transaction is determined to be invalid.
3. The method according to claim 1, characterized in that: The obtaining, according to the transaction information, a field for identifying the referral object includes: Acquire a uniform resource locator used to generate the target transaction from the transaction information; The field is generated according to the address in the uniform resource locator.
4. The method according to claim 3, characterized in that Obtaining the address in the uniform resource locator includes: Obtaining an identifier in the uniform resource locator and a mapping relationship between the identifier and the address of the referral object; The identifier is mapped based on the mapping relationship to obtain the address.
5. The method according to claim 1, characterized in that When the on-chain node successfully executes the target transaction based on the transaction information, before recording the field, the method further includes: Determine whether the transaction information containing the field is signed multiple times; If so, the signature in the transaction information is verified, and if the signature verification passes, the target transaction is executed.
6. The method according to claim 5, characterized in that Verifying the signature in the transaction information, including: Obtaining a public key according to the address information and / or the field in the transaction body of the transaction information; Obtaining a first signature value of the transaction information based on the public key and a preset function calculation; Obtaining a second signature value in the transaction information; If the first signature value matches the second signature value, the signature verification passes; If the first signature value does not match the second signature value, the signature verification fails.
7. The method according to claim 1, characterized in that When the on-chain node successfully executes the target transaction based on the transaction information, the field is recorded, including: Executing the target transaction based on the multiple on-chain nodes respectively; When a preset number of on-chain nodes successfully execute the target transaction, the field is recorded.
8. A blockchain traffic recording device, characterized in that: The device comprises: an acquisition module, a judgment module and a recording module; wherein, The acquisition module, when a user initiates a target transaction, signs the transaction information of the target transaction and sends the transaction information to an off-chain node associated with a referral object of the target transaction; The judgment module is used to judge whether the transaction information includes a field for identifying the referral object of the target transaction; if so, the off-chain node sends the transaction information to the on-chain node when the target transaction is determined to be valid based on the transaction information; if not, the field is generated according to the transaction information or the address of the off-chain node, the field is written into the transaction information and the transaction information is signed, and the off-chain node sends the transaction information to the on-chain node; The recording module is used to record the field when the on-chain node successfully executes the target transaction based on the transaction information.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
