A smart contract packaging consistency control method, system, device and medium
By unifying the running address and time attributes of smart contract instances and combining hash operations, the inconsistency problem of smart contract connection files in an isolated environment is solved, the consistency of CCID is achieved, and the consistency of smart contract installation and access is ensured.
Patent Information
- Application Number
- CN202411215537.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2044-08-30
AI Technical Summary
In the BAAS platform environment, when multiple organizations are isolated, the content and time attributes of smart contract connection files are inconsistent, resulting in inconsistent CCIDs, which affects the consistency of smart contract installation.
By unifying the smart contract instance running address, creating and writing the connection file, unifying the time attribute, and calculating the hash value of the file stream through hash operation, a consistent CCID is generated.
It ensures that the smart contract connection files generated by each organization in an isolated state have consistent CCID, guarantees access to the smart contract instances corresponding to the same CCID, and solves the problem of inconsistent file content and time attributes.
Smart Images

Figure CN119003470B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of blockchain technology, and in particular relates to a smart contract packaging consistency control method, system, device and medium. Background Art
[0002] In the blockchain engine, the installation method of smart contracts depends on the smart contract connection file. When multiple organizations need to install the same smart contract, they need these connection files to obtain connection information to access the smart contract instance.
[0003] However, in a Blockchain as a Service (BAAS) platform environment, each organization is isolated and independently runs its own smart contract instance. Since connection files are generated online and in real time by each organization, this inevitably leads to inconsistencies in the connection file content and time attributes. Smart contract installation requires that smart contract connection files have consistent CCIs (smart contract IDs). Therefore, achieving file and CCI consistency when packaging smart contract connection files in an isolated BAAS platform environment has become a pressing challenge. Summary of the Invention
[0004] In response to the problems in the background technology, the present invention proposes a smart contract packaging consistency control method, system, device and medium to ensure that the smart contract connection files generated by multiple organizations in an isolated state have consistent CCID, thereby ensuring that each organization can access its own smart contract instance corresponding to the same CCID in the isolated mode.
[0005] In order to achieve the above object, the present invention adopts the following technical solutions:
[0006] In a first aspect, the present invention proposes a smart contract packaging consistency control method in a different-site and different-time scenario, comprising:
[0007] Unify the running address of each organization's smart contract instance;
[0008] Create smart contract connection files for each organization separately;
[0009] Write the running address of the smart contract instance of each organization into the smart contract connection file of the corresponding organization;
[0010] Unify the time attributes of each organization's smart contract connection files;
[0011] Package each organization's smart contract connection files into a package file;
[0012] The hash value of the file stream of each organization's packaged file is calculated by hash operation, and the hash value is used as the ccid of each organization's packaged file.
[0013] Furthermore, the running address of each organization's smart contract instance is unified through variable replacement.
[0014] Furthermore, the owner and permission attributes of the smart contract connection file created for each organization are the same.
[0015] Furthermore, the smart contract connection files of each organization are packaged into a package file, including:
[0016] Packaging the smart contract connection files of each organization into a compressed file;
[0017] Unifying the time attributes of the compressed files of each organization;
[0018] The compressed file for each organization is packaged into a package file.
[0019] Furthermore, the time attributes of each organization's smart contract connection files are unified through a unified timestamp.
[0020] Furthermore, the time attributes include access time and modification time.
[0021] Furthermore, the hash value of the file stream of each organization's packaged file is calculated through hash operation, including:
[0022] Reading the package file of each organization;
[0023] The file stream of the packaged file of each organization is calculated by hash operation to obtain a hash value.
[0024] In a second aspect, the present invention proposes a smart contract packaging consistency control system in a different-site and different-time scenario, comprising:
[0025] The address unification module is used to unify the running addresses of smart contract instances of each organization;
[0026] Smart contract connection file generation module, used to create smart contract connection files for each organization separately;
[0027] An address writing module, configured to write the running address of the smart contract instance of each organization into the smart contract connection file of the corresponding organization;
[0028] A time attribute unification module is used to unify the time attributes of each organization's smart contract connection files;
[0029] The file packaging module is used to package the smart contract connection files of each organization into a package file;
[0030] The hash calculation and ccid generation module calculates the hash value of the file stream of each organization's packaged file through hash operation, and uses the hash value as the ccid of each organization's packaged file.
[0031] In a third aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon.
[0032] When computer instructions are running, the above-mentioned smart contract packaging consistency control method in different-site and different-time scenarios can be implemented.
[0033] In a fourth aspect, the present invention proposes a device comprising a memory and a processor, wherein the memory stores computer instructions that can be run on the processor, and when the processor runs the computer instructions, it executes the above-mentioned smart contract packaging consistency control method in the different-site and different-time scenarios.
[0034] Beneficial effects of the present invention:
[0035] 1. The method of the present invention ensures that smart contract connection files generated by multiple organizations in an isolated state have consistent CCIDs by unifying the content, file owner, permission attributes, and time attributes of smart contract connection files. This ensures that each organization can access its own smart contract instance corresponding to the same CCID in the isolated mode.
[0036] 2. The method of the present invention unifies the content and time attributes of smart contract connection files through variable replacement and unified timestamp methods, laying the foundation for the subsequent CCID consistency control of smart contract connection files. It also meets the requirement of multiple organizations to go online with the same CCID when generating smart contract files in a completely isolated situation.
[0037] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0039] Figure 1 The flowchart of the smart contract packaging consistency control method in the scenario of different locations and different times of the present invention is shown;
[0040] Figure 2 The following figure shows the framework diagram of the smart contract packaging consistency control system in the different-site and different-time scenario of the present invention;
[0041] Figure 3 Shown is a schematic diagram of the device structure of the present invention. DETAILED DESCRIPTION
[0042] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0043] Before further explaining the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are explained. The nouns and terms involved in the embodiments of the present invention are subject to the following interpretations:
[0044] 1. Smart contract: An executable program or container containing a running environment used to operate a blockchain ledger.
[0045] 2. Smart contract connection file: A packaged artifact of a formatted description file used to connect to a smart contract.
[0046] 3. CCID (smart contract ID): The unique ID corresponding to the smart contract connection file is used to identify the uniqueness of this smart contract. The ID is obtained by performing a hash operation on its content stream.
[0047] The present invention proposes a smart contract packaging consistency control method in a different-site and different-time scenario, which solves the problems of inconsistent content and inconsistent time attributes of smart contract connection files in a multi-organization environment.
[0048] A file consists of its content and attributes, which include permissions and time attributes. Permission attributes include owner, group, and other (owner, group members, and others). Time attributes include access time and modification time.
[0049] If the smart contract connection files are to form the same CCID, the files inside them must be completely consistent. This consistency includes both the file content and the file attributes. Otherwise, it is impossible to calculate a completely consistent hash value (i.e. CCID) from the final file.
[0050] Refer to the instruction manual Figure 1As shown in FIG, a smart contract packaging consistency control method in a different-site and different-time scenario specifically includes the following steps:
[0051] S1. Unify the running address of each organization's smart contract instance;
[0052] In step S1, variable replacement can be used to unify the running addresses of each organization's smart contract instances. This ensures the consistency of the formality of the running addresses of smart contract instances across different organizations, thereby ensuring the consistency of the content of the generated smart contract connection files, laying the foundation for subsequent CCID consistency control of smart contract connection files.
[0053] S2. Create smart contract connection files for each organization.
[0054] In step S2, each organization's smart contract connection file is created with the same owner and permissions. Creating a separate smart contract connection file for each organization ensures that each organization has a corresponding connection file to connect to its smart contract instance.
[0055] S3. Write the running address of each organization’s smart contract instance into the corresponding organization’s smart contract connection file;
[0056] In step S3, the running address of each organization's smart contract instance is written into the corresponding organization's smart contract connection file to ensure the consistency of the smart contract connection file at the content level.
[0057] S4. Unify the time attributes of each organization’s smart contract connection files;
[0058] In step S4, time attributes include access time and modification time, and the time attributes of each organization's smart contract connection files can be unified by using a unified timestamp. Unifying the time attributes of each organization's smart contract connection files eliminates CCID inconsistencies caused by time differences, ensuring that even connection files created or modified at different times have completely consistent time attributes.
[0059] S5. Package the smart contract connection files of each organization into a package file;
[0060] Step S5: Packing the smart contract connection files of each organization into a package file. As a preferred embodiment, in complex scenarios, compressed files of other description files may also be involved. Therefore, packing the smart contract connection files of each organization into a package file specifically includes the following steps:
[0061] S501, packaging each organization’s smart contract connection file into a compressed file;
[0062] S502, unifying the time attributes of the compressed files of each organization;
[0063] S503, packaging the compressed files of each organization into a package file;
[0064] In step S502 , the time attributes include access time and modification time, and the time attributes of the compressed files of each organization can be unified by unifying the timestamp.
[0065] S6. Calculate the hash value of the file stream of each organization's packaged file through hash operation, and use the hash value as the CCI of each organization's packaged file.
[0066] In step S6, a hash value of the file stream of each organization's packaged file is calculated by hash operation, which specifically includes the following steps:
[0067] S601, read the package file of each organization;
[0068] S602: Calculate the file stream of each organization's packaged file through hash operation to obtain a hash value.
[0069] In a specific embodiment, there are two organizations, org1 and org2, and organizations org1 and org2 need to complete the packaging operation of the smart contract connection file conn.json of the smart contract mycc.
[0070] The domain name of org1 is org1.com.
[0071] The domain name of org2 is org2.com.
[0072] The running address of the smart contract instance under org1 is mycc.org1.com:9999.
[0073] The smart contract connection file conn.json of org1 contains the running address of the mycc smart contract instance, that is, address:mycc.org1.com:9999.
[0074] The running address of the smart contract instance under org2 is mycc.org2.com:9999.
[0075] The smart contract connection file conn.json of org2 contains the running address of the mycc smart contract instance, that is, address:mycc.org2.com:9999.
[0076] As can be seen from the above, the instance running addresses of the smart contract connection files of org1 and org2 are inconsistent, which will cause the contents of the directly generated smart contract connection file conn.json to be different, thereby affecting the consistency of their smart contract IDs (ccid).
[0077] Steps for org1 to generate smart contract connection files:
[0078] 1. Replace the variable address of the smart contract instance running address address:mycc.org1.com:9999 with address:mycc.{{orgname}}.com:9999;
[0079] 2. Create the smart contract connection file conn.json for org1. The conn.json file for org1 contains the running address of mycc, that is, the address is mycc.org1.com:9999;
[0080] 3. Write the variable-substituted address:mycc.{{orgname}}.com:9999 into the smart contract connection file conn.json;
[0081] 4. Reset the atime and mtime of the smart contract connection file conn.json to UTC: 1970-01-01:00:00:00;
[0082] 5. Package the smart contract connection file conn.json into a compressed file conn.tgz;
[0083] 6. Reset the atime and mtime of the compressed file conn.tgz to UTC: 1970-01-01:00:00:00;
[0084] 7. Package the compressed file conn.tgz into a packaged file mycc.tgz;
[0085] 8. Read the packaged file mycc.tgz, perform hash operation on the file stream of the packaged file mycc.tgz, obtain the hash value, and use the hash value as the ccid of the packaged file mycc.tgz.
[0086] Steps for org2 to generate smart contract connection files:
[0087] 1. Replace the variable address of the smart contract instance running address address:mycc.org2.com:9999 with address:mycc.{{orgname}}.com:9999;
[0088] 2. Create the smart contract connection file conn.json of org2. The smart contract connection file conn.json of org2 contains the running address of mycc, that is, address:mycc.org2.com:9999
[0089] 3. Write the variable-substituted address:mycc.{{orgname}}.com:9999 into the smart contract connection file conn.json;
[0090] 4. Reset the atime and mtime of the smart contract connection file conn.json to UTC: 1970-01-01:00:00:00;
[0091] 5. Package the smart contract connection file conn.json into a compressed file conn.tgz;
[0092] 6. Reset the atime and mtime of the compressed file conn.tgz to UTC: 1970-01-01:00:00:00;
[0093] 7. Package the compressed file conn.tgz into a packaged file mycc.tgz;
[0094] 8. Read the packaged file mycc.tgz, perform hash operation on the file stream of the packaged file mycc.tgz, obtain the hash value, and use the hash value as the ccid of the packaged file mycc.tgz.
[0095] As can be seen from the above, after the above packaging consistency control method is used for organizations org1 and org2, the content and time attributes of the packaged file mycc.tgz of organization org1 and organization org2 are unified. The content of organizations org1 and org2 is completely consistent and has the same hash value. This hash value is used as the ccid of the packaged file, meeting the conditions for the subsequent launch of the smart contract.
[0096] Refer to the instruction manual Figure 2 As shown, based on the same inventive concept, the present invention also proposes a smart contract packaging consistency control system in a different-site and different-time scenario, including:
[0097] Address unification module 11, used to unify the running address of smart contract instances of each organization;
[0098] A smart contract connection file generation module 12, used to create a smart contract connection file for each organization;
[0099] An address writing module 13 is used to write the running address of the smart contract instance of each organization into the smart contract connection file of the corresponding organization;
[0100] A time attribute unification module 14 is used to unify the time attributes of each organization’s smart contract connection files;
[0101] A file packaging module 15 is used to package the smart contract connection files of each organization into a package file;
[0102] The hash calculation and ccid generation module 16 is used to calculate the hash value of each organization's packaged file through file stream hash operation, and use the hash value as the ccid of each organization's packaged file.
[0103] Based on the same inventive concept, the present invention also proposes a computer-readable storage medium having computer instructions stored thereon.
[0104] When computer instructions are running, the above-mentioned smart contract packaging consistency control method in different-site and different-time scenarios can be implemented.
[0105] Refer to the instruction manual Figure 3 As shown, based on the same inventive concept, the present invention also proposes a device, including a memory and a processor, wherein the memory stores computer instructions that can be run on the processor, and when the processor runs the computer instructions, it executes the above-mentioned smart contract packaging consistency control method in the different-site and different-time scenarios.
[0106] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements, but also other elements that are not explicitly listed, or elements that are inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device that includes the element.
[0107] Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A smart contract packaging consistency control method in a different-site and different-time scenario, characterized in that: include: Unify the running address of each organization's smart contract instance through variable replacement; Create smart contract connection files for each organization separately; Write the running address of the smart contract instance of each organization into the smart contract connection file of the corresponding organization; Unify the time attributes of each organization's smart contract-connected files through a unified timestamp; Packaging the smart contract connection files of each organization into a packaged file, including: packaging the smart contract connection files of each organization into a compressed file; unifying the time attributes of the compressed files of each organization; and packaging the compressed files of each organization into a packaged file; The hash value of the file stream of each organization's packaged file is calculated through hash operation, and the hash value is used as the smart contract ID of each organization's packaged file.
2. The method for controlling smart contract packaging consistency in a different-site, different-time scenario according to claim 1 is characterized in that: The owner and permission attributes of the smart contract connection file created for each organization are the same.
3. The method for controlling smart contract packaging consistency in a different-site, different-time scenario according to claim 1 is characterized in that: The time attributes include access time and modification time.
4. The method for controlling smart contract packaging consistency in a different-site, different-time scenario according to claim 1 is characterized in that: The hash value of the file stream of each organization's packaged file is calculated through hash operation, including: Reading the package file of each organization; The file stream of the packaged file of each organization is calculated by hash operation to obtain a hash value.
5. A smart contract packaging consistency control system in a different-site and different-time scenario, characterized by: include: The address unification module is used to unify the running address of each organization's smart contract instance through variable replacement; Smart contract connection file generation module, used to create smart contract connection files for each organization separately; An address writing module, configured to write the running address of the smart contract instance of each organization into the smart contract connection file of the corresponding organization; The time attribute unification module is used to unify the time attributes of each organization's smart contract connection files through a unified timestamp; A file packaging module, configured to package each organization's smart contract connection files into a packaged file, including: packaging each organization's smart contract connection files into a compressed file; unifying the time attributes of each organization's compressed files; and packaging each organization's compressed files into a packaged file; The hash calculation and smart contract ID generation module calculates the hash value of the file stream of each organization's packaged file through hash operation, and uses the hash value as the smart contract ID of each organization's packaged file.
6. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed, the smart contract packaging consistency control method in the different-site and different-time scenarios described in any one of claims 1 to 4 can be implemented.
7. A device comprising a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, characterized in that: When the processor runs the computer instructions, it executes the smart contract packaging consistency control method in the different-site and different-time scenarios described in any one of claims 1 to 4.
Citation Information
Patent Citations
Blockchain net type database comprising smart contract and work method
CN107103098A
Consistency detection method and device for intelligent contract calling, equipment and storage medium
CN110335041A