Full-process task data tracing method and system facing collaborative and independent design modes

By maintaining a separate state chain and skip list pointer for each task node, combined with anti-tampering anchor points and optimistic locking concurrency control, the problem of node-level traceability and anti-tampering verification in multi-task process systems is solved, achieving efficient data traceability with low storage overhead.

CN123179477APending Publication Date: 2026-11-27CIRCLE POINT DEV LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611398311.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-10
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

Existing technologies struggle to achieve efficient node-level traceability and tamper-proof verification in multi-task workflow systems, and suffer from high storage overhead and low query efficiency.

Method used

Each task node maintains a separate state chain, using a chained data structure and skip list pointers. The integrity of the state record block is verified by the block hash value, and tamper-proof anchor points are used to detect tampering. Combined with optimistic locking concurrency control, node-level state traceability and fast query are achieved.

Benefits of technology

It achieves finer data granularity for node-level status traceability, strong anti-tampering capability, high query efficiency, low storage overhead, and partial reset does not affect other nodes, avoiding the risk and storage cost of global rollback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123179477A_ABST
    Figure CN123179477A_ABST
Patent Text Reader

Abstract

The application discloses a full-process task data tracing method and system facing cooperative and independent double design modes, and relates to the technical field of data processing.The method comprises the following steps: in response to state change of a task node, obtaining the node identifier of the task node and the complete state data after the change; obtaining the current tail block of the state chain corresponding to the task node according to the node identifier; generating a new state record block; and appending the new state record block to the storage medium, so that the new state record block becomes a new tail block of the state chain.The application separately maintains the state chain according to the node, realizes node-level tracing, realizes anti-tampering verification through the block hash value, the previous block hash value and the anti-tampering anchor point, realizes local resetting to append the rollback state record block by using the skip list pointer for rapid positioning, retains the audit track, and adopts the optimistic lock based on the block serial number to guarantee concurrent consistency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, specifically to a method and system for tracing data across the entire process of a task, oriented towards both collaborative and independent design modes. Background Technology

[0002] In systems involving multi-task workflows, it is usually necessary to record the state changes of task nodes in order to ensure the auditability and traceability of data.

[0003] In existing technologies, relational database log tables are typically used to record state changes. However, this approach has a coarse-grained recording granularity and requires additional index maintenance, resulting in low query efficiency and difficulty in supporting efficient node-level tracing and tamper-proof verification. Another approach is to periodically save the overall task state using full snapshots, but this leads to significant storage overhead and makes it difficult to easily implement partial state rollback for individual nodes.

[0004] In a process system containing multiple task nodes, different task nodes may execute independently or they may depend on each other. Existing technologies struggle to achieve efficient traceability and tamper-proof verification at the node-level granularity, and their local reset capabilities are weak.

[0005] Furthermore, while existing chain-hash-based technologies possess tamper-proof capabilities, they typically target global transaction records, leading to high complexity due to the introduction of a global consensus mechanism. Therefore, there is an urgent need for a task data traceability solution that simultaneously satisfies tamper-proof verifiability, fast querying, and low storage overhead. Summary of the Invention

[0006] To address the shortcomings of existing technologies, this invention provides a method and system for tracing end-to-end task data under both collaborative and independent design modes, thus solving the problems mentioned in the background section.

[0007] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a full-process task data traceability method oriented towards both collaborative and independent design modes, comprising the following steps: S1: In response to a state change of a task node, obtain the node identifier of that task node and the complete state data after the change; S2: Based on the node identifier, obtain the current tail block of the state chain corresponding to the task node. The state chain is a chain data structure maintained separately for the task node, which is formed by linking multiple state record blocks in sequence. Each state record block contains a block hash value, which is used to verify whether the state record block has been tampered with. Except for the initial state record block, each state record block contains the hash value of the previous block, which is the hash value of the block immediately preceding the previous state record block; The operation timestamps in the change metadata of each state record block in the state chain are monotonically increasing, and the operation timestamps are generated based on a monotonically increasing sequence; In the state chain, each state record block except the initial state record block contains a skip list pointer. The skip list pointer includes multiple pointers organized hierarchically. The initial state record block does not have a skip list pointer. S3: Generate a new state record block. The new state record block includes the node identifier, the complete state data after the change, the change metadata, the hash value of the previous block, the block number, and the skip list pointer. The skip list pointer includes multiple pointers. For each non-negative integer k, if the block number of the new state record block is greater than 2... k Then set a skip list pointer to point to the block number of the new state record block minus 2. k Historical state record block; The preceding hash value is the block hash value of the current tail block, and the block sequence number is the block sequence number of the current tail block plus one; the change metadata includes the operation timestamp. S4: Append the new state record block to the storage medium, making the new state record block the new tail block of the state chain, so that any modification to any historical state record block in the state chain can be detected by recalculating the block hash value block by block and comparing it with the hash value of the previous block. The block hash value of each state record block is obtained by hashing all fields in the state record block except the block hash value according to a preset fixed field order. It is used to identify the state record block and serve as the basis for the previous block hash value of subsequent state record blocks. All fields include node identifier, complete status data, change metadata, previous block hash value, block sequence number, and skip list pointer.

[0008] Preferably, after obtaining the current tail block and before generating a new state record block, the block hash value of the current tail block is verified, and the block hash values ​​are verified sequentially forward based on the hash value of the previous block until the initial state record block is reached. The block hash value of the current tail block is compared with the latest tail block hash benchmark value of the state chain stored in the anti-tampering anchor point. The anti-tampering anchor point is an anti-tampering storage area independent of the storage medium, used to store the latest tail block hash benchmark value of the state chain. If the verified value of the block hash value of any state record block is inconsistent with the stored value, or if the block hash value of the current tail block is inconsistent with the benchmark value, it is determined that the state chain has been tampered with, and subsequent processing is terminated. After the new state record block is successfully appended and written, the block hash value of the new state record block is updated in the anti-tampering anchor point. If the update fails, a retry is performed or the state chain is marked as abnormal to avoid misjudgment in subsequent verification.

[0009] Preferably, it also includes a traceability query step: Receive the target block sequence number or target time point for the task node; If the target is the target block number and the target block number is less than 0 or greater than the block number of the current tail block, then an error message is returned; If the target is a target time point and the target time point is earlier than the operation timestamp of the initial state record block, then no query results will be returned. Positioning starts from the current tail block: If the target is the target block number, then repeat the following process: if the current tail block number is equal to the target block number, the location is complete; otherwise, in the jump list pointers of the current tail block, select the pointer whose block number of the historical state record block is not less than the target block number and has the smallest block number, and jump to it; if no such pointer exists, then locate and obtain the previous state record block based on the hash value of the previous block. If the target is the target time point, then repeat the following process: if the operation timestamp of the current tail block is not later than the target time point, then the location is complete; otherwise, in the jump list pointers of the current tail block, select the pointer that points to the historical state record block whose operation timestamp is later than the target time point and has the largest block number, and jump to it; if no such pointer exists, then locate and obtain the previous state record block based on the hash value of the previous block. Starting from the location of the completed state record block, the system traverses backwards based on the hash value of the previous block until the initial state record block is reached. The system outputs the complete state data and change metadata of each state record block during the traversal, forming the state tracing sequence for this task node. The output can be sorted in ascending order of block number to form a forward-order state tracing sequence from the initial state record block to the target block.

[0010] Preferably, the method further includes a partial reset step: in response to a reset request for a task node, the reset request including a target block number or a target time point; locating the target historical state record block using the trace query step as described in claim 3; generating a rollback state record block, copying the complete state data from the target historical state record block to the complete state data of the rollback state record block, and marking it as a reset operation in the change metadata of the rollback state record block; setting the previous block hash value of the rollback state record block as the block hash value of the current tail block of the state chain, and setting the block number as the current tail block number plus one; setting a skip list pointer for the rollback state record block in the same manner as in claim 1; the block hash value of the rollback state record block is obtained by hashing all fields in the rollback state record block except for the block hash value, and all fields include node identifier, complete state data, change metadata, previous block hash value, block number, and skip list pointer; appending the rollback state record block to the state chain, making the rollback state record block the new tail block.

[0011] Preferably, when appending a new status record block, optimistic locking concurrency control based on the block sequence number is adopted; the optimistic locking concurrency control includes: recording the block sequence number when the current tail block is acquired; verifying whether the block sequence number of the current tail block is still equal to the recorded value when committing the write; if not, re-executing the steps starting from acquiring the current tail block; the process of generating a new status record block and appending the write is executed in a database transaction.

[0012] Secondly, this invention provides a full-process task data traceability system oriented towards both collaborative and independent design modes, including: The acquisition module is used to respond to changes in the status of a task node and obtain the node identifier and the complete status data after the change. The management module is used to obtain the current tail block of the state chain corresponding to the task node based on the node identifier. The state chain is a chain-like data structure maintained separately for the task node, formed by linking multiple state record blocks sequentially. Each state record block contains a block hash value, which is used to verify whether the state record block has been tampered with. Except for the initial state record block, each state record block contains the hash value of the previous block, which is the hash value of the block immediately preceding the previous state record block. The operation timestamps in the change metadata of each state record block in the state chain are monotonically increasing, and the operation timestamps are generated based on a monotonically increasing sequence. Except for the initial state record block, each state record block in the state chain contains a skip list pointer, which includes multiple pointers organized hierarchically. The initial state record block does not have a skip list pointer. The generation module is used to generate new state record blocks. The new state record block includes node identifier, complete state data after the change, change metadata, hash value of the previous block, block sequence number, and skip list pointer. The skip list pointer includes multiple pointers. For level k, if the block number of the new state record block is greater than 2... k Then set a skip list pointer to point to the block number of the new state record block minus 2. k Historical state record block; The preceding hash value is the block hash value of the current tail block, and the block sequence number is the block sequence number of the current tail block plus one; the change metadata includes the operation timestamp. The write module is used to append new state record blocks to the storage medium, making the new state record block the new tail block of the state chain, so that any modification to any historical state record block in the state chain can be detected by recalculating the block hash value block by block and comparing it with the hash value of the previous block. The block hash value of each state record block is obtained by hashing all fields in the state record block except for the block hash value. It is used to identify the state record block and serve as the basis for the previous block hash value of subsequent state record blocks. All fields include node identifier, complete state data, change metadata, previous block hash value, block sequence number, and skip list pointer.

[0013] This invention provides a method and system for end-to-end task data traceability oriented towards both collaborative and independent design modes. Compared with existing technologies, it has the following advantages: By maintaining a separate state chain for each task node, node-level state traceability is achieved, data granularity is fine, and coupling of global states is avoided.

[0014] The state chain only allows append writes. The block hash value of each state record block covers all key fields, and subsequent state record blocks contain the hash value of the previous block. Any modification to historical state record blocks will be detected, providing tamper-proof verifiability. Combined with the tamper-proof anchor point storing the latest tail block hash, it is possible to further detect a complete reconstruction of the entire chain.

[0015] Using skip list pointers enables fast location, significantly improving query efficiency in most cases; in the worst case, it degenerates into linear block-by-block backtracking, still ensuring accurate location. When it's impossible to continue jumping using the skip pointer, it backtracks block by block along the previous pointer, ensuring accurate location. Simultaneously, the skip list pointers participate in block hash value calculation, so any tampering with the skip pointers will be detected, enhancing overall tamper resistance.

[0016] Partial reset is achieved by appending rollback state record blocks without deleting or modifying historical state record blocks, thus preserving the complete audit trail and not affecting the state chain of other nodes, avoiding the large-scale impact and potential risks of global rollback.

[0017] Optimistic locking concurrency control based on block sequence number is adopted to avoid the overhead of global locks, while ensuring the consistency of the writing order of the state chain of the same node.

[0018] By maintaining the state chain individually for each node, only the complete state data of the node that has changed is appended each time, instead of saving duplicate snapshots of all nodes globally. The storage overhead is linearly related to the sum of the number of state changes of each node, which significantly reduces storage costs compared to full snapshots. Attached Figure Description

[0019] Figure 1 This is a system block diagram of the end-to-end task data traceability system of the present invention, which is designed for both collaborative and independent modes.

[0020] Figure 2 This is a schematic diagram of the append writing process of the full-process task data traceability method of the present invention, which is oriented towards both collaborative and independent dual design modes.

[0021] Figure 3 This is a schematic diagram of the traceability query process of the full-process task data traceability method of the present invention, which is oriented towards both collaborative and independent design modes. Detailed Implementation

[0022] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0023] In this invention, the dual design pattern of collaboration and independence means that nodes in the task flow can operate as either independent units or dependent units. This method supports the independent mode through node-level independent state chains, and supports the collaborative mode through state chain referencing or triggering mechanisms.

[0024] Please see Figure 1 and Figure 2 As shown, the embodiments of the present invention provide the following technical solutions: As an embodiment of the present invention: This invention provides a full-process task data traceability method oriented towards both collaborative and independent design modes, comprising the following steps: S1: In response to a state change of a task node, obtain the node identifier of that task node and the complete state data after the change.

[0025] A task node is the smallest unit of execution in a task process, such as a process node in a collaborative design task or an independent application design task.

[0026] A node identifier is a unique identifier that distinguishes different nodes.

[0027] Complete status data refers to all current status parameters of a node, such as status name, completion percentage, operator, and remarks.

[0028] State change refers to a node's state changing from never started to in progress, or from in progress to completed, or other state parameter modifications.

[0029] The complete status data after the change is the complete set of status parameters of the node after the change, not just the changed fields.

[0030] S2: Based on the node identifier, obtain the current tail block of the state chain corresponding to the task node.

[0031] In this embodiment, the state chain is a chain-like data structure maintained separately for each task node, which logically only allows appending and writing, and does not allow modification or deletion of existing blocks; The storage medium itself does not restrict the physical modification or deletion of written state record blocks, but any modification to a historical state record block will cause a change in the block hash value of that state record block, which will be detected through the linking of the hash values ​​of preceding and following blocks and the verification of tamper-proof anchor points. The current tail block refers to the last state record block written in this chain.

[0032] The first state record block in the state chain is called the initial state record block. The hash value of the previous block can be set to empty or a preset value. The block number of the initial state record block is 0, and there is no skip list pointer.

[0033] Except for the initial state record block, each state record block contains the previous block hash value obtained directly from the block hash value of the immediately preceding state record block, and contains a skip list pointer, thus forming a chain dependency.

[0034] The current tail block refers to the last state record block written in the state chain.

[0035] The operation timestamps in the change metadata of each state record block in the state chain are monotonically increasing, meaning that the operation timestamp of a state record block written later is always later than that of a state record block written earlier.

[0036] In this embodiment, the operation timestamp is generated by a pre-configured monotonically increasing logic clock, Lamport logic clock, or hybrid logic clock; in a standalone environment, it can also be generated by a monotonically increasing counter. Monotonically increasing operation timestamps mean that within the same state chain, the timestamp value written after the operation timestamp of each state record block is greater than the timestamp value written earlier. The operation timestamps are not required to satisfy a monotonically increasing relationship between state chains of different task nodes. In a distributed environment, the monotonicity of timestamps within the same node's state chain is ensured by a monotonically increasing logic clock or hybrid logic clock.

[0037] S3: Generate a new state record block.

[0038] The new state record block includes the node identifier, the complete state data after the change, the change metadata, the hash value of the previous block, the block number, and the skip list pointer.

[0039] Complete state data refers to the complete set of attributes of a task node at a given moment. Because the state chain is maintained individually for each node, only the complete state of the node that has changed needs to be appended each time, without having to save the state of all nodes globally.

[0040] Change metadata includes information such as operator identifier, operation type, operation timestamp, and reason for change. The operation timestamp is used for time-based location during traceability queries and satisfies a monotonically increasing constraint.

[0041] The previous block hash value is the block hash value of the current tail block, that is, the block hash value stored in the current tail block is directly used as the previous block hash value of the new state record block.

[0042] The block hash value of the current tail block is calculated and stored when the state record block is generated.

[0043] The block number is the block number of the current last block plus one.

[0044] The initial state record block number is defined as 0, and subsequent blocks are incremented sequentially.

[0045] Skip list pointer settings: For level k, k≥0, if the block number of the new state record block is greater than 2 k ,2 k If the value is a power of 2, then a skip list pointer is set to point to the block number of the new state record block minus 2. k The historical state record block; wherein, the initial state record block does not have a skip list pointer; the block number of the state chain is a continuous integer sequence starting from the initial state record block 0.

[0046] For example, for a new state record block with block number 10, since 10 is greater than 1, 2, 4, and 8, pointers to historical state record blocks with block numbers 9, 8, 6, and 2 are set respectively; if 10 ≥ 16, the setting stops. This setting rule ensures that the number of jump pointers for each state record block is logarithmic to the base 2. Each jump list pointer can store the block number or block hash value of the historical state record block it points to, used for quickly locating that state record block in the storage medium.

[0047] The block hash value of each state record block is calculated as follows: All fields in the state record block except the block hash value are serialized and concatenated in a preset order. A preset hash algorithm is then applied to the concatenated byte stream to obtain a hash value of fixed length, which is used as the block hash value of the state record block.

[0048] All fields include node identifier, complete status data, change metadata, previous block hash value, block sequence number, and skip list pointer.

[0049] The initial state record block has no skip list pointer, and the skip list pointer field is not included when calculating its block hash value.

[0050] The hash value of this block is used to uniquely identify the state record block and serves as the basis for the hash value of the previous block in subsequent state record blocks.

[0051] In collaborative mode, if the task node has dependencies, the new state record block also includes dependency information: dependent node identifier, dependent node block number, and dependent node block hash value. Specifically, the dependent node identifier is the node identifier of the task node being depended upon, the dependent node block number is the block number of the current tail block in the state chain of the task node being depended upon, and the dependent node block hash value is the block hash value of the current tail block in the state chain of the task node being depended upon.

[0052] S4: Append the new state record block to the storage medium, making the new state record block the new tail block of the state chain.

[0053] In this embodiment, the storage medium is selected from any one of a relational database, a key-value database, a file system, or distributed storage.

[0054] Appending a new state record block means persisting it as the tail of the state chain without overwriting existing state record blocks. After the write is complete, this new state record block becomes the current tail block.

[0055] In this embodiment, the integrity of the new state record block is also checked: after the current tail block is obtained and before the new state record block is generated, the block hash value of the current tail block is checked, and the block hash value of the previous state record block is checked sequentially according to the hash value of the previous block until the initial state record block is reached.

[0056] The specific method is as follows: For the current tail block, re-serialize all fields in the state record block except for the block hash value according to the preset order, execute the preset hash algorithm on the concatenated byte stream to obtain the verification hash value, and compare the verification hash value with the block hash value recorded in the current tail block. If the verification hash value and the block hash value are inconsistent, the state chain is determined to have been tampered with, and subsequent processing is terminated.

[0057] If the verification hash value and the block hash value are consistent, then the previous state record block is obtained based on the hash value of the previous block of the current tail block, and the above verification process is repeated until the initial state record block is reached.

[0058] As a second embodiment of the present invention: In specific implementation, compared with Embodiment 1, the only difference between the technical solution of this embodiment and Embodiment 1 is that: in this embodiment, the block hash value of the current tail block is compared with the latest tail block hash base value of the state chain stored in the anti-tampering anchor point; If there is a discrepancy, it is determined that the state chain may have been completely reconstructed, and subsequent processing is terminated.

[0059] The tamper-proof anchor point is a tamper-proof storage area independent of the main storage medium of the state chain, used to store the latest tail block hash base value of the state chain; wherein, the tamper-proof storage area can be a protected storage area in a Trusted Execution Environment (TEE), a Hardware Security Module (HSM), or a remote trusted server. Initially, after the initial state record block is generated, its block hash value is used as the initial anchor value.

[0060] After a new state record block is successfully appended, the system updates the block hash value of the new state record block to the anti-tampering anchor. If the update fails, retry or mark the state chain as abnormal. The retry methods are as follows: If the anti-tampering anchor update fails, wait for a preset time interval, reread the current tail block, recalculate the block hash value of the current tail block, and write the recalculated block hash value into the anti-tampering anchor. If the write fails again, repeat step one until the preset maximum number of retries is reached. If the write still fails after the maximum number of retries is reached, mark the state chain as abnormal, suspend the write operation on the state chain, and generate an alarm notification. When recovering from the abnormality, the administrator manually confirms the integrity of the state chain, manually recalculates the block hash value of the current tail block and updates it to the anti-tampering anchor, then clears the abnormal mark and resumes normal write operation.

[0061] After an anomaly is marked, the block hash value of the current tail block can be recalculated manually and the anchor point updated, or the system can automatically reread the current tail block of the state chain, recalculate the block hash value, and update the anchor point to restore normal verification.

[0062] For state record blocks containing dependency information in collaborative mode, the dependency node identifier, dependency node block sequence number, and dependency node block hash value are also used as fields of the state record block in the block hash value calculation and are verified together during the full chain verification.

[0063] By using this full-chain verification and anchor point comparison, illegal modifications and systemic reconstructions at the storage medium level can be detected in a timely manner, enhancing the anti-tampering capability.

[0064] As an embodiment of the present invention: In its specific implementation, compared to Embodiment 1 and Embodiment 2, this embodiment further includes a traceability query step, as detailed below: When you need to query the status of a task node at a target time point or target block number, perform the following steps: Receive the target block sequence number or target time point; If the target is the target block number and the target block number is less than 0 or greater than the block number of the current tail block, then an error message is returned; If the target is a target time point and the target time point is earlier than the operation timestamp of the initial state record block, then no query results will be returned. Starting from the current tail block, the current tail block is used as the current state record block for positioning: If the target is the target block number, then repeat the following process: if the block number of the current state record block is equal to the target block number, the location is complete, and the current state record block is the latest state record block corresponding to the target time point; otherwise, in the skip list pointers of the current state record block, select the pointer that points to the historical state record block with a block number not less than the target block number and the smallest block number, and jump to it; if no such pointer exists, locate and obtain the previous state record block based on the hash value of the previous block, and use the previous state record block as the current state record block; If the target is the target time point, then repeat the following process: if the operation timestamp of the current state record block is not later than the target time point, then the location is complete; otherwise, in the jump list pointers of the current state record block, select the pointer that points to the historical state record block whose operation timestamp is later than the target time point and has the largest block number, and jump to it; if no such pointer exists, then locate and obtain the previous state record block based on the hash value of the previous block, and use the previous state record block as the current state record block; In this embodiment, the pointer selection method based on the target time point is as follows: Get the set of all skip list pointers for the current tail block; traverse the set and filter out the subset of pointers whose operation timestamps are later than the target time point; select the pointer with the largest block number in the subset as the jump target; if the subset is empty, that is, there is no such pointer, then locate and get the previous state record block based on the hash value of the previous block.

[0065] Starting from the state record block that has been located, the system traverses forward sequentially according to the hash value of the previous block, reading the hash value of the previous block of each state record block and obtaining the previous state record block, until the initial state record block is reached. Output the complete state data and change metadata for each state record block during the traversal process, forming the state tracing sequence for this task node. The output can be sorted in ascending order of block number to form a forward-order state tracing sequence from the initial state record block to the target block.

[0066] When outputting the trace sequence, if the state record block contains dependency information, the dependency node identifier, dependency node block number, and dependency node block hash value are output simultaneously.

[0067] Because of the skip list pointers, the location process typically does not require traversing the entire chain, improving query efficiency. When it is impossible to continue jumping using the skip pointers, backtracking block by block ensures that the correct block is located, guaranteeing the accuracy of tracing. When locating by time, the algorithm always jumps or backtracks between blocks whose operation timestamp is greater than the target time point until it encounters the first block whose operation timestamp is no later than the target time point. This block is the latest state record block corresponding to the target time point, thus avoiding missing the correct state record block due to excessively large skip pointer spans.

[0068] As an embodiment of the present invention: In its specific implementation, compared to Embodiments 1, 2, and 3, this embodiment further includes partial reset and concurrency control steps. The partial reset method is as follows: When it is necessary to roll back a task node to a certain historical state, the system performs the following steps: Receive a reset request, which includes the node identifier and the target block number or target time point; The target historical status record block can be located using the above traceability query steps; Generate a rollback status record block, and copy the complete status data from the target historical status record block to the complete status data of the rollback status record block as the complete status data of the rollback status record block. In the change metadata of the rollback status record block, mark the operation type as "reset" and record the reset reason, operator, and operation timestamp; Set the hash value of the previous block of the rollback state record block to the block hash value of the current tail block of the state chain, and set the block number to the current tail block number plus one; Set the skip table pointer for the rollback state record block in the same way as the aforementioned new state record block; wherein, the block number of the rollback state record block is the block number of the current tail block plus one, and its skip table pointer is recalculated according to the skip table pointer generation rules based on the new block number, rather than reusing the skip table pointer of the target historical state record block; Serialize all fields in the rollback state record block except for the block hash value according to the preset order, and perform a preset hash algorithm on the concatenated byte stream to obtain the block hash value of the rollback state record block; all fields include node identifier, complete state data, change metadata, previous block hash value, block sequence number and skip list pointer; The rollback state record block is appended to the state chain, making it the new tail block.

[0069] By appending a rollback state record block, the node's state logically reverts to the state corresponding to the target historical state record block. However, the historical state record block is not modified or deleted, and the state chains of other nodes remain completely unaffected, achieving a local reset of a single node. Since the complete state data is complete, it can be directly restored to the target state after reset without the need for additional merging or replaying.

[0070] In collaborative mode, if the complete state data of the rollback state record block contains dependency information, the dependency information in the target historical state record block is copied. When the rollback state record block is used as a collaborative mode state record block, its dependent node identifier, dependent node block sequence number, and dependent node block hash value participate in the block hash value calculation.

[0071] The concurrency control method is as follows: In a multi-threaded or distributed environment, to prevent the state chain of the same node from being written concurrently, leading to chain forking or overwriting, this invention adopts optimistic locking concurrency control based on block sequence numbers. The specific process is as follows: Before writing, read the current last block and its block number, and record it as the first block number; Generate a new state record block; When committing a write operation, verify whether the current actual tail block's block number is still equal to the first block's block number. If they are equal, the new state record block is atomically appended and the commit is successful. If they are not equal, it means that other writes have already occurred during the period. In this case, the new state record block is discarded, and the entire process is restarted from reading the current tail block.

[0072] The process of generating new state record blocks and appending them can be placed within a database transaction, utilizing row-level locking or optimistic locking mechanisms to ensure atomicity. This concurrency control directly uses the block sequence number of the state chain as the version number, eliminating the need for additional coordination components.

[0073] As a fifth embodiment of the present invention: In specific implementation, compared with Embodiment 1, Embodiment 2, Embodiment 3 and Embodiment 4, the technical solution of this embodiment is to combine the solutions of Embodiment 1, Embodiment 2, Embodiment 3 and Embodiment 4. This embodiment also provides a full-process task data traceability system for collaborative and independent dual design modes. The system is used to execute the full-process task data traceability method for collaborative and independent dual design modes. The system includes a collection module, a management module, a generation module, a writing module, as well as a verification module, a traceability module, a reset module and a control module.

[0074] The acquisition module is used to execute step S1 in Embodiment 1, the management module is used to execute step S2 in Embodiment 1, the generation module is used to execute step S3 in Embodiment 1, and the writing module is used to execute step S4 in Embodiment 1.

[0075] The verification module is used to verify the block hash value of the current tail block after obtaining the current tail block and before generating a new state record block, and to verify the block hash value of each block forward according to the previous block hash value until the initial state record block is reached. The first hash value is used to locate the block immediately preceding the previous state record. The block hash value of the current tail block is compared with the latest tail block hash benchmark value of the state chain stored in the anti-tampering anchor. The anti-tampering anchor is an anti-tampering storage area independent of the storage medium, used to store the latest tail block hash benchmark value of the state chain. If the block hash value check value of any state record block is inconsistent with the stored value, or if the block hash value of the current tail block is inconsistent with the benchmark value, the state chain is determined to have been tampered with, and subsequent processing is terminated. After the new state record block is successfully appended, the block hash value of the new state record block is updated in the anti-tampering anchor. If the update fails, a retry is performed or the state chain is marked as abnormal.

[0076] The traceability module is used to receive the target block sequence number or target time point for the task node; If the target is the target block number and the target block number is less than 0 or greater than the block number of the current tail block, then an error message is returned; If the target is a target time point and the target time point is earlier than the operation timestamp of the initial state record block, then no query results will be returned. Positioning starts from the current tail block: If the target is the target block number, then repeat the following process: if the current tail block number is equal to the target block number, the location is complete, and the current state record block is the latest state record block corresponding to the target time point; otherwise, in the jump list pointers of the current tail block, select the pointer whose block number of the historical state record block it points to is not less than the target block number and has the smallest block number, and jump to it; if no such pointer exists, then locate and obtain the previous state record block based on the hash value of the previous block. If the target is the target time point, then repeat the following process: if the operation timestamp of the current tail block is not later than the target time point, then the location is complete; otherwise, in the jump list pointers of the current tail block, select the pointer that points to the historical state record block whose operation timestamp is later than the target time point and has the largest block number, and jump to it; if no such pointer exists, then locate and obtain the previous state record block based on the hash value of the previous block. Starting from the state record block that has been located, the system traverses backwards according to the hash value of the previous block until the initial state record block is reached. The system outputs the complete state data and change metadata of each state record block during the traversal.

[0077] The reset module responds to reset requests for task nodes, including target block number or target time point; it uses the tracing module to locate the target historical state record block; it generates a rollback state record block, copies the complete state data from the target historical state record block to the complete state data of the rollback state record block, marks it as a reset operation in the change metadata of the rollback state record block, sets the hash value of the previous block of the rollback state record block as the block hash value of the current tail block of the state chain, and sets the block number to the current tail block number plus one; it sets a skip list pointer for the rollback state record block based on the new block number of the rollback state record block; the block hash value of the rollback state record block is obtained by hashing all fields in the rollback state record block except the block hash value, including node identifier, complete state data, change metadata, previous block hash value, block number, and skip list pointer; and it appends the rollback state record block to the state chain, making the rollback state record block the new tail block. The control module is used to employ optimistic locking concurrency control based on block sequence number when appending to and writing a new status record block. This includes: recording the block sequence number when the current tail block is obtained; verifying whether the block sequence number of the current tail block is still equal to the recorded value when committing the write; if not, re-executing the steps starting from obtaining the current tail block; and executing the process of generating a new status record block and appending to it within a database transaction.

[0078] Meanwhile, in this embodiment, there are dependencies between task nodes: the status record block is added with the dependent node identifier, dependent node block number, and dependent node block hash value; after the dependent node generates a new status record block, the dependent node generates a reference-type status record block through a triggering mechanism; during tracing, the corresponding status record block of the dependent node is located based on the dependency field.

[0079] Furthermore, any content not described in detail in this specification is existing technology known to those skilled in the art.

[0080] 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, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0081] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

[0082] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A full-process task data traceability method oriented towards both collaborative and independent design modes, characterized in that, Includes the following steps: In response to a change in the state of a task node, obtain the node identifier of that task node and the complete state data after the change; Based on the node identifier, obtain the current tail block of the state chain corresponding to the task node. The state chain is a chain-like data structure maintained separately for this task node, formed by linking multiple state record blocks sequentially. Each state record block contains a block hash value. Except for the initial state record block, each state record block contains the hash value of the previous block, which is the hash value of the block immediately preceding the previous state record block. The operation timestamps in the change metadata of each state record block in the state chain monotonically increase. Except for the initial state record block, each state record block in the state chain contains a skip list pointer, which includes multiple pointers organized hierarchically. The initial state record block does not have a skip list pointer. A new state record block is generated, which includes the node identifier, the complete state data after the change, the change metadata, the hash value of the previous block, the block number, and the skip list pointer. The hash value of the previous block is the block hash value of the current tail block, and the block number is the block number of the current tail block plus one. The change metadata includes the operation timestamp. The block hash value of each state record block is obtained by hashing all fields in the state record block except for the block hash value. A new state record block is appended to the storage medium, making it the new tail block of the state chain. This allows any modification to a historical state record block in the state chain to be detected by recalculating the block hash value block by block and comparing it with the hash value of the previous block.

2. The end-to-end task data traceability method based on collaborative and independent dual design modes according to claim 1, characterized in that, If the new state record block is the initial state record block, then no skip list pointer is set; otherwise, the skip list pointer includes multiple pointers. For level k, k≥0, if the block number of the new state record block is greater than 2... k Then set a skip list pointer to point to the block number of the new state record block minus 2. k Historical state record block; All fields of the status record block include node identifier, complete status data, change metadata, previous block hash value, block sequence number, and skip list pointer. The initial status record block does not have a skip list pointer.

3. The end-to-end task data traceability method based on collaborative and independent dual design modes according to claim 1, characterized in that, After obtaining the current tail block and before generating a new state record block, the block hash value of the current tail block is verified, and the previous state record block is located based on the hash value of the previous block of the current tail block. The block hash values ​​are verified block by block forward in sequence until the initial state record block is reached. The current tail block's block hash value is compared with the latest tail block hash benchmark value of the state chain stored in the anti-tampering anchor; where the anti-tampering anchor is an anti-tampering storage area independent of the storage medium, used to store the latest tail block hash benchmark value of the state chain; If the block hash value of any state record block is inconsistent with the stored value, or if the block hash value of the current tail block is inconsistent with the base value, the state chain is determined to have been tampered with, and subsequent processing is terminated. After a new state record block is successfully appended, the block hash value of the new state record block is updated in the anti-tampering anchor; if the update fails, a retry is performed or the state chain is marked as abnormal.

4. The end-to-end task data traceability method based on collaborative and independent dual design modes according to claim 1, characterized in that, It also includes a traceability query step: Receive the target block sequence number or target time point for the task node; If the target is the target block number and the target block number is less than 0 or greater than the block number of the current tail block, then an error message is returned; If the target is a target time point, and the target time point is earlier than the operation timestamp of the initial state record block, then no query results will be returned. If the target time point is later than the operation timestamp of the current tail block, then the current tail block will be used as the status record block for location completion. Starting from the current tail block, the current tail block is used as the current state record block for positioning: If the target is the target block number, then repeat the following process: if the block number of the current state record block is equal to the target block number, the location is complete, and the current state record block is the latest state record block corresponding to the target time point; otherwise, in the skip list pointers of the current state record block, select the pointer that points to the historical state record block with a block number not less than the target block number and the smallest block number, and jump to it; if no such pointer exists, locate and obtain the previous state record block based on the hash value of the previous block, and use the previous state record block as the current state record block; If the target is the target time point, then repeat the following process: if the operation timestamp of the current state record block is not later than the target time point, then the location is complete; otherwise, in the jump list pointers of the current state record block, select the pointer that points to the historical state record block whose operation timestamp is later than the target time point and has the largest block number, and jump to it; if no such pointer exists, then locate and obtain the previous state record block based on the hash value of the previous block, and use the previous state record block as the current state record block; Starting from the state record block where the location is completed, the system traverses backwards according to the hash value of the previous block until the initial state record block is reached. Output the complete state data and change metadata of each state record block during the traversal process to form the state traceability sequence of this task node.

5. The end-to-end task data traceability method based on collaborative and independent dual design modes according to claim 4, characterized in that, It also includes a partial reset step: In response to a reset request for a task node, the reset request may include the target block number or the target time point; The target historical state record block is located using the traceability query steps as described in claim 4; Generate a rollback status record block, copy the complete status data from the target historical status record block to the complete status data of the rollback status record block, and mark it as a reset operation in the change metadata of the rollback status record block; Set the hash value of the previous block of the rollback state record block to the block hash value of the current tail block of the state chain, and set the block number to the current tail block number plus one; Set the skip table pointer for the rollback state record block in the same manner as in claim 2; The block hash value of the rollback status record block is obtained by hashing all fields in the rollback status record block except for the block hash value. All fields include node identifier, complete status data, change metadata, previous block hash value, block sequence number and skip list pointer; The rollback state record block is appended to the state chain, making the rollback state record block the new tail block.

6. The end-to-end task data traceability method based on collaborative and independent dual design modes according to claim 1, characterized in that, When appending new state record blocks, optimistic locking concurrency control based on block sequence numbers is used; the optimistic locking concurrency control method is as follows: Record the block number when acquiring the current tail block; When committing a write operation, verify that the block number of the current tail block is still equal to the recorded value. If they are not equal, return to the step of obtaining the current tail block of the state chain corresponding to the task node based on the node identifier; The process of generating a new state record block and appending it to the new state record block is executed within a database transaction.

7. A full-process task data traceability system for both collaborative and independent design modes, the system being used to execute the full-process task data traceability method for both collaborative and independent design modes as described in any one of claims 1-6, characterized in that, The system includes: The data acquisition module is used to obtain the node identifier and complete status data of the task node when the status of the task node changes. The management module is used to obtain the current tail block of the state chain corresponding to the task node based on the node identifier; the state chain is a chain-like data structure maintained separately for the task node. The generation module is used to generate new state record blocks; the new state record block includes node identifier, complete state data after changes, change metadata, hash value of the previous block, block sequence number, and skip list pointer; The write module is used to append new state record blocks to the storage medium, making the new state record block the new tail block of the state chain.

8. The end-to-end task data traceability system oriented towards both collaborative and independent design modes as described in claim 7, characterized in that, Also includes: The verification module is used to verify the block hash values ​​of the current tail block and the entire chain before generating a new state record block, compare them with the latest tail block hash benchmark value of the state chain stored in the anti-tampering anchor, and update the anti-tampering anchor after the new state record block is appended. If the update fails, it will retry or mark the state chain as abnormal.

9. The end-to-end task data traceability system oriented towards both collaborative and independent design modes as described in claim 7, characterized in that, Also includes: The traceability module is used to locate the historical state record block based on the skip list pointer and the target block sequence number or the target time point and output the traceability sequence. It also returns the corresponding prompt when the target time is earlier than the initial state record block or the target block sequence number is invalid.

10. The end-to-end task data traceability system oriented towards both collaborative and independent design modes according to claim 9, characterized in that, Also includes: The reset module is used to generate and append rollback status record blocks. The rollback status record blocks contain skip list pointers and participate in the block hash value calculation. The control module is used to perform optimistic locking concurrency control based on block sequence numbers.