Smart contract packaging consistency control method, system and device and medium
By unifying the running address, time attribute and hash operation of smart contract instances, the problem of inconsistency in the smart contract connection files in the BAAS platform environment is solved, ensuring the ccid consistency of smart contract installation among multiple organizations, and realizing smart contract access in an isolated environment consistency.
Patent Information
- Application Number
- CN202411215537.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-30
AI Technical Summary
In the BAAS platform environment, the content and time attributes of smart contract connection files in isolation states of multiple organizations are inconsistent, resulting in inconsistent ccids when installing smart contracts, making it difficult to achieve file consistency and ccid consistency.
By unifying the running address of the smart contract instance, creating and writing connection files, unifying time attributes, packaging files and generating ccids through hash operations, ensuring that the content and attributes of each organization's smart contract connection files are consistent, and variable replacement and unified time stamps are used to use variables deal with.
In isolation mode, ensure that the smart contract connection files generated by multiple organizations have consistent ccids, ensuring each organization accesses smart contract instances of the same ccid, and solving the problem of inconsistent file and time attributes in the isolation environment.
Smart Images

Figure CN119003470A_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 the BAAS (Blockchain as a Service) platform environment, each organization is isolated from each other and runs its smart contract instance independently. Since the generation of connection files is done by each organization online in real time, this inevitably leads to inconsistencies in the content and time attributes of the connection files. The installation of smart contracts requires that the smart contract connection files must have consistent ccid (smart contract id). Therefore, how to achieve file consistency and ccid consistency when packaging smart contract connection files in the isolated BAAS platform environment has become a problem that needs to be solved urgently. 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: In the first aspect, the present invention proposes a smart contract packaging consistency control method in a different address and different time scenario, comprising: Unify the running address of smart contract instances of each organization; 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 connection files; Package each organization’s smart contract connection files into a package file; 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.
[0006] Furthermore, the running address of each organization’s smart contract instance is unified through variable replacement.
[0007] Furthermore, the owner and permission attributes of the smart contract connection file created for each organization are the same.
[0008] Furthermore, the smart contract connection files of each organization are packaged into a package file, including: Packing the smart contract connection file of each organization into a compressed file; Unifying the time attributes of the compressed files of each organization; The compressed file for each organization is packaged into a package file.
[0009] Furthermore, the time attributes of each organization’s smart contract connection files are unified through a unified timestamp.
[0010] Furthermore, the time attribute includes access time and modification time.
[0011] Furthermore, 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.
[0012] In the second aspect, the present invention proposes a smart contract packaging consistency control system in a different-site and different-time scenario, including: The address unification module is used to unify the running address of each organization's smart contract instance; A smart contract connection file generation module, which is used to create smart contract connection files for each organization separately; An address writing module, used 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; File packaging module, used to package each organization's smart contract connection files into package files; 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.
[0013] In a third aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon. When computer instructions are running, the above-mentioned smart contract packaging consistency control method in different-site and different-time scenarios can be implemented.
[0014] 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.
[0015] Beneficial effects of the present invention: 1. The method of the present invention ensures that the smart contract connection files generated by multiple organizations in an isolated state have consistent CCID by unifying the content, file owner, permission attributes and time attributes of the smart contract connection files, thereby ensuring that each organization can access its own smart contract instance corresponding to the same CCID in the isolated mode.
[0016] 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 a foundation for the subsequent CCID consistency control of smart contract connection files, and meeting the requirements of multiple organizations to go online with the same CCID when they generate their own smart contract files in a completely isolated situation.
[0017] Other features and advantages of the present invention will be described in the following description, and partly become obvious from the description, or be understood by implementing 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
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces 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 creative work.
[0019] 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; Figure 2 The framework diagram of the smart contract packaging consistency control system in the different-site and different-time scenario of the present invention is shown; Figure 3 A schematic diagram of the device structure of the present invention is shown. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are 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 creative work are within the scope of protection of the present invention.
[0021] Before further describing the embodiments of the present invention in detail, the nouns and terms involved in the embodiments of the present invention are described. The nouns and terms involved in the embodiments of the present invention are applicable to the following interpretations: 1. Smart contract: An executable program or container containing a running environment used to operate a blockchain ledger.
[0022] 2. Smart contract connection file: a packaged artifact of a formatted description file used to connect to a smart contract.
[0023] 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.
[0024] 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.
[0025] A file consists of file content and file attributes. File attributes include permission attributes, time attributes, etc. Permission attributes include owner, group, other (owner, group members, others), etc. Time attributes include access time and modification time, etc.
[0026] If the smart contract connection file is to form the same ccid, the files inside it 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. Refer to the instruction manual Figure 1 As shown, a smart contract packaging consistency control method in a different address and different time scenario specifically includes the following steps: S1. Unify the running address of smart contract instances of each organization; In step S1, the running address of each organization's smart contract instance can be unified through variable replacement. By replacing variables, the formal consistency of the running addresses of smart contract instances of different organizations is ensured, thereby ensuring the consistency of the content of the generated smart contract connection file, laying the foundation for the subsequent ccid consistency control of the smart contract connection file.
[0027] S2. Create smart contract connection files for each organization respectively; In step S2, the owner and permission attributes of the smart contract connection file created for each organization are the same. Creating a smart contract connection file for each organization separately ensures that each organization has a corresponding connection file to connect to its smart contract instance.
[0028] S3. Write the running address of each organization's smart contract instance into the corresponding organization's smart contract connection file; 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.
[0029] S4. Unify the time attributes of each organization’s smart contract connection files; In step S4, the time attributes include access time and modification time, and the time attributes of each organization's smart contract connection files can be unified by unifying the timestamp. Unifying the time attributes of each organization's smart contract connection files can eliminate the ccid inconsistency caused by time differences, ensuring that even if the connection files are created or modified at different times, their time attributes are completely consistent.
[0030] S5. Package the smart contract connection files of each organization into a package file; Step S5, packaging the smart contract connection files of each organization into a package file; as a preferred embodiment, in a complex scenario, compressed files of other description files may also be involved. Therefore, packaging the smart contract connection files of each organization into a package file specifically includes the following steps: S501, packaging each organization’s smart contract connection file into a compressed file; S502, unifying the time attributes of the compressed files of each organization; S503, packaging the compressed files of each organization into a package file; 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.
[0031] 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 ccid of each organization's packaged file.
[0032] In step S6, the hash value of the file stream of the packaged file of each organization is calculated by hash operation, which specifically includes the following steps: S601, read the package file of each organization; S602: Calculate the file stream of each organization's packaged file through hash operation to obtain a hash value.
[0033] 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.
[0034] Among them, the domain name of org1 is org1.com.
[0035] The domain name of org2 is org2.com.
[0036] The running address of the smart contract instance under org1 is mycc.org1.com:9999.
[0037] The smart contract connection file conn.json of org1 contains the running address of the smart contract instance of mycc, that is, address:mycc.org1.com:9999.
[0038] The running address of the smart contract instance under org2 is mycc.org2.com:9999.
[0039] The smart contract connection file conn.json of org2 contains the running address of the smart contract instance of mycc, that is, address:mycc.org2.com:9999.
[0040] As can be seen from the above, the instance running addresses of the smart contract connection files of org1 and org2 are not consistent, which will cause the contents of the directly generated smart contract connection file conn.json to be different, thus affecting the consistency of their smart contract IDs (ccid).
[0041] Org1 generates smart contract connection file steps: 1. Replace the variable of the smart contract instance running address address:mycc.org1.com:9999 with address:mycc.{{orgname}}.com:9999; 2. Create the smart contract connection file conn.json of org1. The smart contract connection file conn.json of org1 contains the running address of mycc, that is, the address is mycc.org1.com:9999; 3. Write the variable-substituted address:mycc.{{orgname}}.com:9999 into the smart contract connection file conn.json; 4. Reset the atime and mtime of the smart contract connection file conn.json to UTC: 1970-01-01:00:00:00; 5. Package the smart contract connection file conn.json into a compressed file conn.tgz; 6. Reset the atime and mtime of the compressed file conn.tgz to UTC: 1970-01-01:00:00:00; 7. Package the compressed file conn.tgz into a packaged file mycc.tgz; 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.
[0042] Org2 generates smart contract connection file steps: 1. Replace the variable of the smart contract instance running address address:mycc.org2.com:9999 with address:mycc.{{orgname}}.com:9999; 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 3. Write the variable-substituted address:mycc.{{orgname}}.com:9999 into the smart contract connection file conn.json; 4. Reset the atime and mtime of the smart contract connection file conn.json to UTC: 1970-01-01:00:00:00; 5. Package the smart contract connection file conn.json into a compressed file conn.tgz; 6. Reset the atime and mtime of the compressed file conn.tgz to UTC: 1970-01-01:00:00:00; 7. Package the compressed file conn.tgz into a packaged file mycc.tgz; 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.
[0043] It can be seen from the above that 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 organization org1 and organization org2 is completely consistent and has the same hash value. The hash value is used as the ccid of the packaged file, which meets the conditions for the subsequent launch of the smart contract.
[0044] 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: Address unification module 11, used to unify the running address of smart contract instances of each organization; A smart contract connection file generation module 12, used to create a smart contract connection file for each organization respectively; An address writing module 13, used to write the running address of the smart contract instance of each organization into the smart contract connection file of the corresponding organization; A time attribute unification module 14, used to unify the time attributes of the smart contract connection files of each organization; A file packaging module 15, used to package the smart contract connection files of each organization into a package file; 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.
[0045] Based on the same inventive concept, the present invention also proposes a computer-readable storage medium having computer instructions stored thereon. When computer instructions are running, the above-mentioned smart contract packaging consistency control method in different-site and different-time scenarios can be implemented.
[0046] 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.
[0047] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0048] 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 substitutions for some of the technical features therein; and these modifications or substitutions do not make the essence of the corresponding technical solutions 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, It is characterized in that include: Unify the running address of smart contract instances of each organization; 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 connection files; Package the smart contract connection files of each organization into a package file; 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.
2. According to the method for controlling the consistency of smart contract packaging in a different-site and different-time scenario according to claim 1, It is characterized in that Unify the running address of each organization's smart contract instance through variable replacement.
3. According to the method for controlling the consistency of smart contract packaging in a different-site and different-time scenario according to claim 1, It is characterized in that The owner and permission attributes of the smart contract connection file created for each organization are the same.
4. According to the method for controlling the consistency of smart contract packaging in a different-site and different-time scenario according to claim 1, It is characterized in that Package each organization’s smart contract connection files into a package file, including: Packing the smart contract connection file of each organization into a compressed file; Unifying the time attributes of the compressed files of each organization; The compressed file for each organization is packaged into a package file.
5. According to claim 4, a smart contract packaging consistency control method in a different-site and different-time scenario, It is characterized in that Unify the time attributes of each organization’s smart contract-connected files through a unified timestamp.
6. According to claim 5, a smart contract packaging consistency control method in a different-site and different-time scenario, It is characterized in that The time attributes include access time and modification time.
7. According to claim 1, a smart contract packaging consistency control method in a different-site and different-time scenario, It 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.
8. A smart contract packaging consistency control system in different locations and different times. It is characterized in that include: The address unification module is used to unify the running address of each organization's smart contract instance; A smart contract connection file generation module, which is used to create smart contract connection files for each organization separately; An address writing module, used 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; File packaging module, used to package each organization's smart contract connection files into package files; 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.
9. A computer-readable storage medium having computer instructions stored thereon, It is 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 7 can be implemented.
10. A device comprising a memory and a processor, wherein the memory stores computer instructions that can be executed on the processor, It is 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 7.
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
Decentralized shipping network using blockchains
US20200311675A1
