Internet of Things system state conflict resolution method and device based on intelligent contract variable

By introducing ExState smart contract variables and related modules, the uncertainty problem caused by changes in the state of the Internet of Things system is solved, and the consistency and accuracy of the state sequence in the blockchain network is achieved, and the system stability and reliability are ensured.

CN119484579APending Publication Date: 2025-02-18CHENGDU UNIV OF INFORMATION TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411643765.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-18
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

When existing smart contracts deal with uncertainty problems caused by changes in the state of the IoT system, they fail to provide deterministic results, resulting in inconsistent state sequences and affect system stability and reliability.

Method used

Introduce a new smart contract variable ExState, which contains 6 member variables, to detect and handle abnormalities in the status of the Internet of Things system, and ensure consistency of the status through modules such as state encapsulation, data transmission, verification, error detection and processing, and state management. Sex and accuracy.

Benefits of technology

Ensure that in the blockchain network, the state sequences obtained by all nodes are consistent, effectively manage and synchronize the changing states in external systems, and solve the state conflicts when smart contracts interact with IoT systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119484579A_ABST
    Figure CN119484579A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for solving state conflicts in an Internet of Things system based on an intelligent contract variable, and the method comprises the steps: customizing an intelligent contract variable which has the capability of filtering a state designated by a user; for an illegal state, the system triggers an automatic error processing mechanism; and for the state change which is determined to be legal, the intelligent contract variable converts the state change into a traceable state sequence, and then the sequence is packaged into the block chain by the node with the bookkeeping right. And each node realizes state consistency by updating the local block chain. According to the method, through deep interaction between the smart contract and the Internet of Things system, state conflicts are effectively processed in the data uplink process by using the variable of the smart contract, and it is ensured that all nodes can quickly reach a consensus. The mechanism significantly improves the security and stability of the block chain, provides a more efficient management and control means for the application of the Internet of Things, and promotes the wide application of the smart contract in the field of the Internet of Things.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Internet of Things, and in particular to a method and device for resolving Internet of Things system state conflicts based on smart contract variables. Background Art

[0002] Smart contracts are self-executing protocols based on blockchain technology that enable automated interactions between parties without an intermediary. Smart contracts automatically execute specific operations when preset conditions are met, improving the accuracy, speed, and overall efficiency of transactions. Smart contracts are widely used in various fields, especially in the interaction between blockchain and Internet of Things (IoT) devices, which can automatically process device status, sensor data, and response events. Their immutability and transparency ensure the authenticity of transaction records and reduce the risk of fraud. With the development of blockchain technology, the application prospects of smart contracts are becoming more and more extensive, playing an important role in improving system security and automation. Existing smart contracts have not yet provided an effective method to ensure deterministic results when dealing with uncertainty problems caused by changes in the state of IoT systems. This is because the state in the IoT system is constantly changing, and different nodes may obtain external data at different times and in different ways, which will lead to inconsistent state sequences when smart contracts are executed, resulting in uncertainty.

[0003] Cross-chain technology, with the diversification of different blockchain systems, the interoperability between blockchains has become particularly important. The emergence of cross-chain technology solves the problem that a single chain cannot directly share data and assets, promotes the intercommunication of data and assets between blockchains, and improves the overall performance of the system. Common cross-chain technologies include: notary mechanism, hash locking, side chain / relay and distributed private key control. The current cross-chain technology mainly focuses on the functional realization of asset and data exchange, and lacks sufficient research on the processing of cross-chain state changes. Especially in cross-chain transactions, state changes may lead to inconsistent data between different chains, thus affecting the stability and reliability of the system.

[0004] Interaction with non-blockchain systems (NBS), NBS (non-blockchain system) is usually managed by a single entity or organization, which is opposite to the decentralized nature of blockchain systems. Although NBS has a large amount of important data, this data is often stored on centralized servers or cloud platforms, so there is a greater trust risk. In order to take advantage of the decentralized, tamper-proof, and transparent characteristics of blockchain, the data in NBS can be interacted with the blockchain to improve the reliability and security of the data. Although the interaction between blockchain and NBS can ensure the security and transparency of data, there is still a problem of inconsistent state due to the time difference in nodes obtaining data, especially when the external state continues to change. Summary of the invention

[0005] In view of the shortcomings of the prior art, the present invention proposes a method for solving the state conflict of the Internet of Things based on smart contract variables. The state conflict solution method of the present invention defines a new smart contract variable, which includes 6 member variables, can interact with other functions, and uses the smart contract variables to detect the state to detect whether the state is abnormal; the state data of the Internet of Things system is encapsulated by the state encapsulation module and passed to the data transmission module, the data transmission module updates the state data in the blockchain node, the state verification module verifies the received state data and outputs it to the error detection module, the error detection module performs preliminary screening on the state data, marks the error data and outputs it to the error processing module, the error processing module processes the data marked as errors, the state management module receives the state repaired by the error processing module or the state that is correct itself and adds it to the state sequence, the updated state sequence and the previous state are input into the state management module of the smart contract, the state module sorts out the final state sequence and inputs it into the packaging module to distribute it to the node, and the specific method includes:

[0006] Step 1: The state encapsulation module of the smart contract encapsulates the state data from the IoT system into a standardized format suitable for blockchain node parsing;

[0007] Step 2: The data transmission module of the smart contract obtains the changing real-time status data from the IoT system through the real-time communication mechanism or the node's periodic request, and inputs the real-time status data into the status verification module in the smart contract for processing;

[0008] Step 3: The error detection module of the smart contract detects the real-time status data obtained from step 2, detects whether an error occurs in the status sequence ID, status owner, and timestamp, and updates the value of the error flag; if an error occurs, the value of the error flag is modified to true, if correct, the value of the error flag is changed to false, and the error flag is input into the error handling module of the smart contract for processing;

[0009] Step 4: The error handling module of the smart contract receives the error flag obtained from step 3 and determines whether the value of the error flag is true. If the error flag is true, the error handling code is executed to try to correct the erroneous data; if the data is successfully repaired, the cache flag value is false; if the data cannot be repaired, the cache flag value is set to true, and the processing result is input into the storage management module in the smart contract for processing;

[0010] Step 5: The storage management module of the smart contract obtains the cache flag value from step 4 and determines whether the cache flag value is true. If the cache flag value is true, the storage release logic is executed, the state data that cannot be repaired is deleted, and the space release feedback information is input into the state management module of the smart contract;

[0011] Step 6: The state management module of the smart contract obtains the state that the data has been successfully repaired or is correct from step 4 or step 5, then adds the state to the state sequence and sets the current state as the previous state to facilitate the continuous recording of subsequent state data, and inputs the updated state sequence and the previous state into the state management module of the smart contract;

[0012] Step 7: After the contract reaches the preset termination condition, the state management module sorts out the final state sequence from the state processed by the above steps, and inputs the final state sequence into the packaging module;

[0013] Step 8: The node with accounting rights in the packaging module will write the final state sequence obtained from step 7 into the blockchain and broadcast the data to the blockchain network to ensure the consistency of nodes in the entire network.

[0014] According to a preferred embodiment, the six variables of the customized smart contract variables include:

[0015] A member variable called state sequence. If there are multiple changing states that need to be recorded, these states should be recorded as a state sequence;

[0016] A member variable named state owner is used to verify whether the state owners of the same group of states are the same;

[0017] A member variable named state sequence ID, which is used to verify whether the sequence IDs in the same state sequence are the same;

[0018] A member variable named previous state, which is used to indicate the state before the current state. The previous state is the previously recorded state.

[0019] A member variable named error flag, which is used to identify whether the current status is correct or wrong, and the value is of bool type;

[0020] A member variable named cache identifier, which is used to identify whether the variable storage space should be released. The value is of bool type.

[0021] The present invention also proposes an IoT state conflict resolution device based on smart contract variables, and the conflict resolution device includes the following modules:

[0022] The state encapsulation module is used to encapsulate the state data from the IoT system into a standardized format suitable for blockchain node parsing;

[0023] The data transmission module is used to timely update the status data in the blockchain node through a real-time communication mechanism or regular node requests, ensuring that the blockchain system can obtain the latest status of the Internet of Things at any time;

[0024] The status verification module is used by blockchain nodes to verify the integrity and legitimacy of the received status data to ensure the authenticity and consistency of the data;

[0025] The error detection module is used to check whether there are errors in key fields such as state sequence ID, timestamp and state owner in the state data;

[0026] The error handling module is used to process data marked as errors and try to correct the abnormal state through data repair or retry mechanism;

[0027] The state management module is used to obtain the state that has been successfully repaired or is correct and add it to the state sequence, and set the current state to the previous state, and input the updated state sequence and the previous state into the state management module of the smart contract;

[0028] The packaging module is used by nodes with accounting rights to record legal status data in smart contract variables and package them into the blockchain to form blocks; the verified status data is permanently recorded on the blockchain so that it can be shared by the entire network to ensure the ultimate consistency of the system.

[0029] Compared with the prior art, the present invention has the following beneficial effects:

[0030] 1. Through strictly defined logic and rules, this invention makes ExState better suited for the interaction between smart contracts and IoT and related systems. ExState is not only suitable for processing state changes in non-blockchain systems, but also can effectively record state changes in cross-chain systems.

[0031] 2. The present invention can ultimately ensure that the state sequences obtained by different nodes in the blockchain network are consistent. Through the use of ExState, the constantly changing states in the external system can be effectively managed and synchronized on the blockchain, thereby solving the state conflict problem that may occur when the smart contract interacts with the IoT system.

[0032] 3. The present invention proposes that in a scenario where the status of the external system is frequently updated, the blockchain can be used to actively obtain the status from the external system, so as to reduce the number of interactions and processing times between the blockchain and the external system, thereby reducing network congestion. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 It is a flow chart of the method of recording the external state and packaging it on the chain by the smart contract variable ExState of the present invention.

[0034] Figure 2 This is a structural diagram of the smart contract variable device of the present invention. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concept of the present invention.

[0036] The following is a detailed description with reference to the accompanying drawings.

[0037] The present invention mainly solves the problem of inconsistent states generated when the blockchain interacts with the Internet of Things system, especially the uncertainty problem caused by the constantly changing state of the Internet of Things system. The blockchain system can ensure the consistency of the state sequence of nodes within the chain, but due to the dynamic changes of external data and the bifurcation of chains in cross-chain operations, different nodes may obtain different state information, resulting in inconsistent state sequences. This uncertainty not only affects the consistency within the blockchain, but also affects the coordination and consistency between different chains in cross-chain transactions, making it impossible for the blockchain to reach a consensus. It will also affect data consistency, transaction validity and network security, affecting the credibility and reliability of the blockchain.

[0038] The present invention proposes for the first time to introduce variables in smart contracts to record state changes in non-blockchain systems and cross-chains. This innovation provides a new solution to the state management problem in the interaction between smart contracts and external systems. The present invention introduces a smart contract variable containing six member variables, which correspond to the core dimensions of the state changes of the Internet of Things, realizing the unified management and storage of multi-dimensional states. The processing method of the present invention allows loosely coupled communication between IoT devices and blockchain nodes, and not only supports real-time state synchronization, but also supports ensuring state consistency through periodic requests. The present invention ensures the legitimacy and consistency of IoT state data before it is uploaded to the chain through the verification logic of the smart contract, effectively reducing the generation of state conflicts and illegal states.

[0039] Figure 1 The process of using the smart contract variable ExState to record external status and package it on the chain is demonstrated, and the six member variables in the smart contract variable ExState are fully utilized.

[0040] The state conflict resolution method of the present invention defines a new smart contract variable, which includes 6 member variables, can interact with other functions, and use the smart contract variable to detect the state to detect whether the state is abnormal; the state data of the Internet of Things system is encapsulated by the state encapsulation module and passed to the data transmission module, the data transmission module updates the state data in the blockchain node, the state verification module verifies the received state data and outputs it to the error detection module, the error detection module performs a preliminary screening of the state data, marks the error data and outputs it to the error handling module, the error handling module processes the data marked as errors, the state management module receives the state repaired by the error handling module or correct in itself and adds it to the state sequence, the updated state sequence and the previous state are input into the state management module of the smart contract, the state module sorts out the final state sequence and inputs it into the packaging module to distribute it to the nodes.

[0041] This invention defines a new smart contract variable named ExState, which includes:

[0042] A member variable named stateSequence is defined. If there are multiple changing states that need to be recorded, these states should be recorded as a state sequence.

[0043] A member variable named state owner is defined to verify whether the owners of the same set of states are the same.

[0044] A member variable named status sequence ID (statusID) is defined to verify whether the sequence IDs in the same status sequence are the same.

[0045] A member variable named previous state (preState) is defined to indicate the state before the current state. The previous state is the previously recorded state.

[0046] A member variable named error flag (hasError) is defined to identify whether all current states are correct or wrong, and the value is of bool type.

[0047] A member variable named cache flag (clearCache) is defined to indicate whether the variable storage space should be released, and the value is of bool type.

[0048] The status is checked through smart contract variables to detect whether there is any abnormality in the status.

[0049] If the state is deemed illegal, the smart contract will execute the error handling logic after detecting the error state or illegal state transition.

[0050] If the state is deemed legal, the smart contract variable will process the legal state change into a state sequence, which will be packaged into the blockchain by the miners. Each node will achieve consistency of node state by updating the local blockchain.

[0051] Step 1: The state encapsulation module encapsulates the state data from the IoT system into a standardized format suitable for blockchain node parsing. The IoT system encapsulates the state data into a specific format (such as JSON, XML, etc.) to facilitate blockchain node parsing and processing.

[0052] Step 2: The data transmission module obtains the real-time status data of the changes from the IoT system (non-blockchain system and cross-chain system) through the real-time communication mechanism or the node's regular request, and inputs the status data into the status verification module in the smart contract for processing. The IoT system then transmits the encapsulated status data to the node through the real-time communication mechanism.

[0053] When the state of the IoT system changes, the new state is actively transmitted to the blockchain node in real time;

[0054] Instead of relying on real-time transmission with the IoT system, nodes can actively request the latest status data from the IoT system regularly through a preset API interface to ensure the robustness of status synchronization.

[0055] The real-time status data of the IoT system includes the status sequence ID, status generation time, status owner ID, data content, etc. The role of step 2 is to capture and collect status changes in the IoT system in real time to ensure the integrity of the data chain.

[0056] Step 3: The error detection module detects whether the state data obtained from step 2: state sequence ID, state owner, timestamp, has any errors, and updates the value of the error flag; if an error occurs, the value of the error flag is changed to true, if correct, the value of the error flag is changed to false. The error flag is input into the smart contract error handling module for processing. The purpose of step 3 is to initially filter abnormal data to ensure that the data input into the blockchain is accurate and reliable.

[0057] Specifically: When the state owner value does not match the expected value, the error indicator value should be set to true.

[0058] If the state sequence ID value of a state does not match that of other states, it means that they do not belong to the same state sequence, and the error indicator value should be set to true.

[0059] The timestamps in the state are inconsistent with the expected order, that is, the timestamp of the current state is earlier than the timestamp of the previous state; or conflict with other known state timestamps in the system, that is, the timestamps of the two states are the same, indicating that an error has occurred and the error flag is set to true.

[0060] When the error flag is true, error handling needs to be performed.

[0061] After the blockchain node receives the status data of the IoT system, it first performs data integrity verification to ensure that the data has not been tampered with or lost during transmission.

[0062] Verification methods include hash verification and data signature verification to ensure that the source of the status is credible.

[0063] After verifying the legitimacy of the data, the smart contract is triggered to perform further logical processing to ensure that the status is consistent with the predetermined logical rules.

[0064] Step 4: The error handling module receives the error flag obtained from step 3 and determines whether the value of the error flag is true (i.e., an error is detected). If the error flag is true, the error handling code is executed (such as retrying to obtain data or calling a data repair function) to try to correct the erroneous data. If the data is repaired successfully, the value of the cache flag is false; if the data cannot be repaired, the cache flag value is set to true, and the processing result is input into the storage management module in the smart contract for processing. The purpose of step 4 is to process abnormal data to minimize data loss.

[0065] If the state is detected to be illegal, error handling is performed, including: after the smart contract detects an error state or an illegal state transition, it executes error handling logic, such as requesting state history from an external system, cross-chain requesting data from the current main chain, etc.; each state sequence is stored in a separate process. If the error is an unrecoverable error, the cache flag value is set to true. In order to prevent different state sequences from competing for the same storage space, the storage location of the state sequence should be released to avoid unnecessary resource occupation and subsequent interactions.

[0066] If the value of the error flag is true, the methods that trigger error handling include:

[0067] The node requests the non-blockchain system again to obtain the correct state history and modify the erroneous state to ensure the correctness of the state sequence;

[0068] When the cross-chain encounters an attack that causes the node to obtain inconsistent status, the node requests the main chain again to obtain the trusted status to ensure that it can be restored to a consistent state when an error occurs;

[0069] In some cases, it is necessary to reset the state to the last known good state;

[0070] In the event of failure of some nodes, the network can be restored to a consistent state by re-executing the consensus mechanism.

[0071] Step 5: The storage management module obtains the cache flag from step 4 and determines whether the value of the cache flag is true. If the cache flag is true, the storage release logic is executed to delete the state data that cannot be repaired to release storage space. The space release feedback information is input into the state management module of the smart contract. The purpose of step 5 is to ensure that the storage space is used efficiently and to avoid erroneous data occupying resources for a long time.

[0072] Step 6: If the smart contract state management module obtains the state that the data has been successfully repaired or is correct from step 4 or step 5, it will add the state to the state sequence and set the current state to the previous state to facilitate the continuous recording of subsequent state data. The updated state sequence and the previous state are input into the state management module of the smart contract. The purpose of step 6 is to maintain the continuity of the state sequence and ensure that the historical state can be traced.

[0073] Smart contracts perform logical verification on the incoming state according to the set rules. For example, the contract will check whether the timestamp of the state meets the sequence requirements and whether there is any state conflict.

[0074] If the status is illegal, error handling is performed, such as requesting status history, ending the execution of the smart contract, etc.

[0075] If the state is legal, the smart contract records the state in the stateSequence member variable of the smart contract variable, and stores the recording time of the state, the state owner and other information. The legal state is recorded in the state sequence of the smart contract variable defined in the present invention, which is then stored on the blockchain, and the node can update the local state.

[0076] Step 7: After the contract is completed, the state management module sorts out the final state sequence from the state processed by the above steps; the final state sequence is input into the packaging module. The purpose of step 7 is to ensure that the data to be uploaded to the chain has passed the complete verification and formed a consistent final data package.

[0077] After verifying each state processed by the smart contract, the miner node packages it into the blockchain to form an unalterable state record;

[0078] When the smart contract reaches the predetermined termination condition (for example, the number of states in the state sequence reaches the user-set number or the time window is closed), when the contract ends execution, the final state sequence will be added to the blockchain along with the new block. At this time, the state update will be synchronized on all nodes, and each node can access and use these states, thereby ensuring that the smart contract data of all nodes in the blockchain network is consistent. The miner node packages the final state sequence into the blockchain to complete the final consistency update of the data.

[0079] Step 8: The node with accounting rights in the packaging module writes the state sequence obtained from step 7 into the blockchain and broadcasts the data to the blockchain network to ensure the consistency of all nodes in the network. The purpose of step 7 is to ensure that the state data is consistent among all nodes in the network and share the final state sequence.

[0080] The present invention also proposes an IoT system state conflict resolution device based on smart contract variables. Figure 2 The connection relationship between the modules in the device is shown. The conflict resolution device includes the following modules:

[0081] The state encapsulation module is used to encapsulate the state data from the IoT system into a standardized format suitable for blockchain node parsing. This ensures that the state data of the IoT system remains consistent during the transmission process, making it easier for blockchain nodes to identify and parse it.

[0082] The data transmission module is used to timely update the status data in the blockchain node through a real-time communication mechanism or regular node requests, ensuring that the blockchain system can obtain the latest status of the Internet of Things at any time.

[0083] The status verification module is used by blockchain nodes to verify the integrity and legality of the received status data to ensure the authenticity and consistency of the data. It verifies and filters illegal or abnormal data to ensure that the data entering the blockchain is reliable and trustworthy.

[0084] The error detection module is used to check whether there are errors in key fields such as the state sequence ID, timestamp, and state owner in the state data. It performs a preliminary screening of the state data and marks potential error data, laying the foundation for further processing.

[0085] The error handling module is used to process data marked as errors and try to correct abnormal conditions through data repair or retry mechanisms. It tries to repair recoverable data and reduce the impact of invalid data on the system.

[0086] The state management module is used to obtain the state that has been successfully repaired or is correct in itself and add it to the state sequence, set the current state to the previous state, and input the updated state sequence and the previous state into the state management module of the smart contract.

[0087] The packaging module is used by nodes with accounting rights to record legal status data in smart contract variables and package them into the blockchain to form blocks. The verified status data is permanently recorded on the blockchain so that it can be shared by the entire network to ensure the final consistency of the system.

[0088] The method for solving state conflicts in an Internet of Things system based on smart contract variables provided by the present invention screens and processes the state in the Internet of Things system through smart contract variables, screens the state according to the logic specified by the user, and organizes the state into a state sequence and records it in the smart contract variables, which can effectively manage and synchronize the changing state in the system on the blockchain. The miner packages data such as the state sequence into the blockchain to ensure that even if the state is changing, the final state sequence obtained by each node can be consistent, ensuring that each node can obtain the same final result. Thereby solving the state conflict problem that may occur when the smart contract interacts with the Internet of Things system. The smart contract variables correspond to the core dimensions of the change of the Internet of Things state, and realize the unified management and storage of multi-dimensional states. The processing method of the present invention allows loosely coupled communication between the Internet of Things device and the blockchain node, not only supports real-time state synchronization, but also supports obtaining the state from the Internet of Things system by means of periodic requests. The present invention ensures the legitimacy and consistency of the Internet of Things state data on the chain through the verification logic of the smart contract, and effectively reduces the generation of state conflicts and illegal states.

[0089] It should be noted that the above specific embodiments are exemplary, and those skilled in the art can come up with various solutions inspired by the disclosure of the present invention, and these solutions also belong to the disclosure scope of the present invention and fall within the protection scope of the present invention. Those skilled in the art should understand that the present invention description and its drawings are illustrative and do not constitute a limitation of the claims. The protection scope of the present invention is defined by the claims and their equivalents.

Claims

1. A solution to the IoT state conflict based on smart contract variables, characterized in that: The state conflict resolution method of the present invention defines a new smart contract variable, which includes 6 member variables, can interact with other functions, and uses the smart contract variable to detect the state to detect whether the state is abnormal; the state data of the Internet of Things system is encapsulated by the state encapsulation module and passed to the data transmission module, the data transmission module updates the state data in the blockchain node, the state verification module verifies the received state data and outputs it to the error detection module, the error detection module performs preliminary screening on the state data, marks the error data and outputs it to the error processing module, the error processing module processes the data marked as errors, the state management module receives the state repaired by the error processing module or the state that is correct itself and adds it to the state sequence, the updated state sequence and the previous state are input into the state management module of the smart contract, the state module sorts out the final state sequence and inputs it into the packaging module to distribute it to the node, and the specific method includes: Step 1: The state encapsulation module of the smart contract encapsulates the state data from the IoT system into a standardized format suitable for blockchain node parsing; Step 2: The data transmission module of the smart contract obtains the changing real-time status data from the IoT system through the real-time communication mechanism or the node's periodic request, and inputs the real-time status data into the status verification module in the smart contract for processing; Step 3: The error detection module of the smart contract detects the real-time status data obtained from step 2, detects whether an error occurs in the status sequence ID, status owner, and timestamp, and updates the value of the error flag; if an error occurs, the value of the error flag is modified to true, if correct, the value of the error flag is changed to false, and the error flag is input into the error handling module of the smart contract for processing; Step 4: The error handling module of the smart contract receives the error flag obtained from step 3 and determines whether the value of the error flag is true. If the error flag is true, the error handling code is executed to try to correct the erroneous data; if the data is successfully repaired, the cache flag value is false; if the data cannot be repaired, the cache flag value is set to true, and the processing result is input into the storage management module in the smart contract for processing; Step 5: The storage management module of the smart contract obtains the cache flag value from step 4 and determines whether the cache flag value is true. If the cache flag value is true, the storage release logic is executed, the state data that cannot be repaired is deleted, and the space release feedback information is input into the state management module of the smart contract; Step 6: The state management module of the smart contract obtains the state that the data has been successfully repaired or is correct from step 4 or step 5, then adds the state to the state sequence and sets the current state as the previous state to facilitate the continuous recording of subsequent state data, and inputs the updated state sequence and the previous state into the state management module of the smart contract; Step 7: After the contract reaches the preset termination condition, the state management module sorts out the final state sequence from the state processed by the above steps, and inputs the final state sequence into the packaging module; Step 8: The node with accounting rights in the packaging module will write the final state sequence obtained from step 7 into the blockchain and broadcast the data to the blockchain network to ensure the consistency of nodes in the entire network.

2. The conflict resolution method according to claim 1, characterized in that: The six custom smart contract variables include: A member variable called state sequence. If there are multiple changing states that need to be recorded, these states should be recorded as a state sequence; A member variable named state owner is used to verify whether the state owners of the same group of states are the same; A member variable named state sequence ID, which is used to verify whether the sequence IDs in the same state sequence are the same; A member variable named previous state, which is used to indicate the state before the current state. The previous state is the previously recorded state. A member variable named error flag, which is used to identify whether the current status is correct or wrong, and the value is of bool type; A member variable named cache identifier, which is used to identify whether the variable storage space should be released. The value is of bool type.

3. An IoT state conflict resolution device based on smart contract variables, characterized in that: The conflict resolution device comprises the following modules: The state encapsulation module is used to encapsulate the state data from the IoT system into a standardized format suitable for blockchain node parsing; The data transmission module is used to timely update the status data in the blockchain node through a real-time communication mechanism or regular node requests, ensuring that the blockchain system can obtain the latest status of the Internet of Things at any time; The status verification module is used by blockchain nodes to verify the integrity and legitimacy of the received status data to ensure the authenticity and consistency of the data; The error detection module is used to check whether there are errors in key fields such as state sequence ID, timestamp and state owner in the state data; The error handling module is used to process data marked as errors and try to correct the abnormal state through data repair or retry mechanism; The state management module is used to obtain the state that has been successfully repaired or is correct and add it to the state sequence, and set the current state to the previous state, and input the updated state sequence and the previous state into the state management module of the smart contract; The packaging module is used by nodes with accounting rights to record legal status data in smart contract variables and package them into the blockchain to form blocks; the verified status data is permanently recorded on the blockchain so that it can be shared by the entire network to ensure the ultimate consistency of the system.

Citation Information

Cited By

  • On-chain parallel reasoning task execution method and system based on embedded smart contract

    CN122334518A