CN118093557B - Block chain node state data processing method, electronic device and storage medium - Google Patents

Block chain node state data processing method, electronic device and storage medium Download PDF

Info

Publication number
CN118093557B
CN118093557B CN202410519478.9A CN202410519478A CN118093557B CN 118093557 B CN118093557 B CN 118093557B CN 202410519478 A CN202410519478 A CN 202410519478A CN 118093557 B CN118093557 B CN 118093557B
Authority
CN
China
Prior art keywords
state
blockchain node
data
node
pruning
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410519478.9A
Other languages
Chinese (zh)
Other versions
CN118093557A (en
Inventor
汪小益
张启锐
黄伟
刘敬
张帅
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou High Tech Zone Binjiang Blockchain And Data Security Research Institute
Original Assignee
Hangzhou High Tech Zone Binjiang Blockchain And Data Security Research Institute
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou High Tech Zone Binjiang Blockchain And Data Security Research Institute filed Critical Hangzhou High Tech Zone Binjiang Blockchain And Data Security Research Institute
Priority to CN202410519478.9A priority Critical patent/CN118093557B/en
Publication of CN118093557A publication Critical patent/CN118093557A/en
Application granted granted Critical
Publication of CN118093557B publication Critical patent/CN118093557B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a block chain link point state data processing method, an electronic device and a storage medium, wherein a plurality of monitoring parameters are obtained by scanning a state change set of block chain nodes; judging whether any one of the monitoring parameters hits the triggering condition; under the condition that any monitoring parameter hits the triggering condition, carrying out persistence operation on the state data of the blockchain node according to the state change set; the influence of the blockchain state pruning on the normal service performance is improved.

Description

Block chain node state data processing method, electronic device and storage medium
Technical Field
The present application relates to the field of blockchain technologies, and in particular, to a blockchain link point state data processing method, an electronic device, and a storage medium.
Background
A blockchain is a distributed database or ledger, which is formed by linking a series of ordered blocks (blocks) through hash pointers, forming a non-tamperable chained structure. Each block contains transactions (transactions) that record events such as asset transfer, intelligent contract invocation, etc. in the system. When a block link point performs a transaction, state change information is generated, and the set of state change information is called a state change set. The state tree (STATE TREE) is a data structure in the blockchain system for storing the current global state, and is mainly used for recording all accounts and their related state information.
State expansion is one of the factors affecting the performance of a blockchain system, and state trees account for a significant proportion. In executing transactions at blockchain points, access to the data of the state tree is required, which can lead to greater disk loading pressures for blockchain systems with relatively high TPS (Transactions Per Second transactions per second).
To address the state expansion problem, blockchains have introduced state pruning techniques. State pruning is essentially a pruning of the historical data of the blockchain state tree so that blockchain nodes can only hold state data within a certain range in the near future, thereby reducing the hardware resource requirements required by some types of blockchain nodes. When pruning is performed on the state tree of the blockchain node, if the cutting time is not proper, the service performance of the blockchain node is affected.
Aiming at the problem that the pruning of the block chain state in the related technology can influence the performance of normal service, no effective solution is proposed at present.
Disclosure of Invention
In this embodiment, a blockchain node status data processing method, an electronic device and a storage medium are provided to solve the problem that blockchain status pruning in the related art may affect the performance of normal services.
In a first aspect, in this embodiment, there is provided a blockchain node status data processing method, including:
Scanning a state change set of the block chain nodes to obtain a plurality of monitoring parameters;
judging whether any one of the monitoring parameters hits the triggering condition;
and under the condition that any monitoring parameter hits the triggering condition, carrying out persistence operation on the state data of the block chain node according to the state change set.
In one embodiment, the monitored parameters include at least one of:
A time driving parameter, wherein the time driving parameter is used for representing the time interval of last persistence operation on the state data of the blockchain node in the current time distance;
a transaction accumulation parameter that characterizes a number of blocks that have been newly increased since a last persistence operation was performed on state data of the blockchain node;
And the data capacity parameter is used for representing the data quantity of the state data of the blockchain node to be subjected to the persistence operation at the current time.
In one embodiment, the state data of the blockchain nodes is stored in a tree structure to a persistent storage space to form a state tree, and each child node in the state tree has only one unique parent node.
In one embodiment, the state change set includes a write set and a clip set generated for a state tree node when the blockchain node performs a blocktransaction; and under the condition that any monitoring parameter hits the triggering condition, performing persistence operation on the state data of the blockchain node according to the state change set, wherein the persistence operation comprises the following steps:
Deleting data in the clip set in the state tree, and inserting data in the write set in the state tree.
In one embodiment, prior to persisting the state data of the blockchain node according to the set of state changes, the method further comprises:
Writing the state change set into a pruning log;
and respectively performing persistent storage and cache on the pruning log, and setting an index for the pruning log according to the block number of the execution block.
In one embodiment, after persisting the state data of the blockchain node according to the set of state changes, the method further comprises:
and deleting the pruning log corresponding to the current state change set of the blockchain node.
In one embodiment, the method further comprises:
when the block link point executes the block transaction, accessing the cached pruning log according to the index, and searching a state value required by executing the transaction from the cached pruning log;
And if the state value does not exist in the cache, searching the state value required by executing the transaction from the state tree.
In one embodiment, the method further comprises:
And under the condition that any monitoring parameter does not hit the triggering condition, scanning the state change set of the block chain node after a preset time interval to obtain a plurality of new monitoring parameters.
In a second aspect, in this embodiment, there is provided an electronic device including a memory having a computer program stored therein and a processor configured to run the computer program to perform the blockchain node status data processing method of the first aspect.
In a third aspect, in this embodiment, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the blockchain node status data processing method of the first aspect described above.
According to the method, the electronic device and the storage medium for processing the state data of the block chain node, in the process of changing the state of the block chain link point, the key parameters are quantitatively monitored based on a plurality of dimensions to obtain a plurality of monitoring parameters, and under the condition that any monitoring parameter hits a triggering condition, the state data of the block chain node is subjected to lasting operation according to the state change set, so that the dynamic state of a pruning mechanism is realized, the pruning opportunity is conveniently found, pruning is reasonable, and the influence of the state pruning of the block chain on normal service performance is improved.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the other features, objects, and advantages of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this specification, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute a limitation on the application. In the drawings:
FIG. 1 is a block diagram of a hardware architecture of a terminal of a block chain node state data processing method in one embodiment;
FIG. 2 is a flow diagram of a block chain node state data processing method in one embodiment;
FIG. 3 is a block chain system architecture diagram in one embodiment;
FIG. 4 is a flow diagram of the operation of the block chain system in one embodiment;
fig. 5 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
The present application will be described and illustrated with reference to the accompanying drawings and examples for a clearer understanding of the objects, technical solutions and advantages of the present application.
Unless defined otherwise, technical or scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terms "a," "an," "the," "these" and similar terms in this application are not intended to be limiting in number, but may be singular or plural. The terms "comprising," "including," "having," and any variations thereof, as used herein, are intended to encompass non-exclusive inclusion; for example, a process, method, and system, article, or apparatus that comprises a list of steps or modules (units) is not limited to the list of steps or modules (units), but may include other steps or modules (units) not listed or inherent to such process, method, article, or apparatus. The terms "connected," "coupled," and the like in this disclosure are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The term "plurality" as used herein means two or more. "and/or" describes an association relationship of an association object, meaning that there may be three relationships, e.g., "a and/or B" may mean: a exists alone, A and B exist together, and B exists alone. Typically, the character "/" indicates that the associated object is an "or" relationship. The terms "first," "second," "third," and the like, as referred to in this disclosure, merely distinguish similar objects and do not represent a particular ordering for objects.
The method embodiments provided in the present embodiment may be executed in a terminal, a computer, or similar computing device. For example, running on a terminal, fig. 1 is a block diagram of a hardware architecture of a terminal of a blockchain node status data processing method according to an embodiment of the present application. As shown in fig. 1, the terminal may include one or more (only one is shown in fig. 1) processors 101 and a memory 102 for storing data, wherein the processors 101 may include, but are not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA. The terminal may further include a transmission device 103 for a communication function and an input-output device 104. It will be appreciated by those skilled in the art that the structure shown in fig. 1 is merely illustrative and is not intended to limit the structure of the terminal. For example, the terminal may also include more or fewer components than shown in fig. 1, or have a different configuration than shown in fig. 1.
The memory 102 may be used to store computer programs, such as software programs of application software and modules, such as computer programs corresponding to the blockchain node status data processing method in the present embodiment, and the processor 101 executes the computer programs stored in the memory 102 to perform various functional applications and data processing, i.e., implement the above-described method. Memory 102 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 102 may further include memory remotely located with respect to the processor 101, which may be connected to the terminal via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 103 is used to receive or transmit data via a network. The network includes a wireless network provided by a communication provider of the terminal. In one example, the transmission device 103 includes a network adapter (Network Interface Controller, simply referred to as NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the transmission device 103 may be a Radio Frequency (RF) module, which is used to communicate with the internet wirelessly.
In one embodiment, as shown in fig. 2, a flowchart of a blockchain node status data processing method is provided, and the method is applied to the terminal in fig. 1 for illustration, and includes the following steps:
step S201, scanning a state change set of the block chain node to obtain a plurality of monitoring parameters.
One of the core works of the blockchain in running is to continuously execute the transaction in the new block, and apply the transaction execution result to the world state of the current ledger to obtain the new world state. The state change set generated by each block can be recorded by taking the block as a dimension, and pruning is performed according to the sets. Each time a blockchain node completes a transaction, the blockchain node will change state, generate state change information, write the state change information into the set, and obtain a state change set. The state data of the blockchain nodes are stored in a tree structure to the persistent storage space to form a state tree, and each child node in the state tree has only one unique parent node. The state change may include creating, deleting or adjusting several Merkle paths from the root node to the leaf nodes. The state tree may store data of the current global state in the blockchain to record all accounts in the blockchain and their associated state information.
In some embodiments, the state change Set includes a Write Set (Write Set) and a clip Set (Prune Set) for the state tree node that are generated when the block link point performs the block transaction. Wherein the writeset and the tailors represent different types of operation records that the blockchain node performs on a state tree (STATE TREE) node when executing a new block, respectively. The write set contains the new or updated operations performed on the state tree nodes during the execution of the current block, and the clip set contains the state tree nodes identified as no longer requiring reservation or safe deletion during the execution of the current block. The write set and the cut set are two components of the state change set, and correspond to the addition/update operation and the deletion/discard operation of the state tree node respectively. These two parts are used to describe the specific change of ledger world state relative to the previous state after the new block is executed. In practical application, the writing set and the cutting set are packaged into a state change set and are respectively stored as a pruning log and recorded in a memory cache in a lasting manner so as to facilitate subsequent state recovery, state searching and pruning optimization operation.
Step S202, judging whether any one of the monitoring parameters hits the triggering condition.
The monitoring parameters are parameters obtained by quantitatively monitoring key parameters in the block chain link point state changing process from multiple dimensions. For example, the monitoring parameters may be determined from any two or three of time driven, transaction accumulated, and data capacity. In particular, the time driven dimension may comprise a time interval, the transaction accumulation dimension may comprise a cumulative block number, and the data capacity dimension may comprise a size of accumulating state data to be refreshed. The monitoring parameters may be considered as "pruning trigger conditions" or "persistence trigger indicators," and together, the plurality of monitoring parameters form a set of quantization criteria that determine when to initiate a persistence operation for directing the pruning thread to perform a pruning (i.e., persistence) task at an appropriate point in time. The pruning thread is a thread started in the blockchain system and is used for executing state pruning. The blockchain system also includes a transaction thread for executing transactions in the blockchain.
A corresponding threshold range may be set for each monitoring parameter, and it is determined whether the monitoring parameter falls within the corresponding threshold range.
Step S203, when any monitoring parameter hit trigger condition is judged, the state data of the blockchain node is subjected to persistence operation according to the state change set.
In this embodiment, if any one of the monitoring parameters falls within the corresponding threshold range, it is determined that the trigger condition is hit, and at this time, the state change set persistence operation may be started. The persistence operation refers to operating on the state data based on the state change set, for example, deleting the data of the cutting set in the state change set on the physical account book, inserting the data of the writing set in the state change set on the physical account book, and reflecting the data on the state tree or pruning the state tree so as to reduce the physical storage space.
In some cases, it is a time-driven parameter hit trigger condition; in some cases, it is the transaction accumulation parameter hit trigger condition; in some cases, a data capacity parameter hit trigger condition; in some cases, the time-driven parameter and the transaction accumulation parameter together hit a trigger condition; in some cases, the transaction accumulation parameter and the data capacity parameter together hit a trigger condition, and so on, and are not described in detail herein. That is, the monitored parameters of the hit trigger conditions at different times are not fixed for the entire blockchain, and may be changed, so the pruning mechanism is dynamically changed. Compared with the traditional fixed pruning mechanism, the embodiment can start from multiple dimensions and hit the triggering conditions in a reasonable range, so that pruning time is reasonable.
Based on the pruning mechanism, each block generates a state change set, and pruning threads need to apply the state change sets to the physical account book at proper time so as to achieve the effect of reducing the physical storage space. In the above steps S201 to S203, in the process of changing the state of the block link point, the key parameters thereof are quantitatively monitored based on a plurality of dimensions to obtain a plurality of monitored parameters, and in the case that any monitored parameter hits the triggering condition, the state data of the block chain node is subjected to the persistence operation according to the state change set, so that the dynamic state of the pruning mechanism is realized, so as to facilitate the search of pruning time, rationalize pruning, and improve the influence of the state pruning of the block chain on the normal service performance.
In one embodiment, comparing each monitored parameter to a corresponding threshold value may be accomplished by:
And under the condition that any monitoring parameter is not lower than the corresponding threshold value, judging the hit triggering condition. The monitoring parameters may include any two or three of a time driven parameter, a transaction accumulation parameter, a data capacity parameter. The time driving parameter is used for representing the time interval of last persistence operation of the state data of the blockchain node in the current time distance; the transaction accumulation parameter is used for representing the number of blocks newly increased since the last time the state data of the blockchain node is subjected to the persistence operation; the data capacity parameter is used to characterize the data amount of the state data of the current time blockchain node to be subjected to the persistence operation. Accordingly, the threshold value of the time driving parameter may be a time threshold value; the threshold for transaction accumulation parameters may be a block number threshold; the threshold value of the data capacity parameter may be a data amount threshold value.
In this embodiment, the consideration of the above three dimensional parameters is as follows:
Time driving parameters: by monitoring the parameter, the time interval between the last time of the block chain node and the current time of the persistent account can be kept within a certain range, and the operation of the account is convenient. The method is beneficial to periodically performing operations such as running state checking, version upgrading, snapshot generation, verification and the like on the blockchain node.
Transaction accumulation parameters: by monitoring the parameter, the interval between the block height of the last lasting ledger of the blockchain node and the current block height can be kept within a certain range, and the ledger operation is convenient. The method is beneficial to carrying out operations such as running state inspection, version upgrading, snapshot generation, verification and the like on the chain link points at regular intervals in a certain block quantity.
Data capacity parameters: due to the characteristics of a Key value storage engine (Key-Value Storage Engine, KV), when the total size of data of a brushing disc exceeds a certain threshold value, the instantaneous performance is reduced. By monitoring the parameter, the size of the data of the persistent state to be performed each time can be controlled within a certain range, so that the instantaneous performance of the block chain system is ensured.
Optionally, when the monitored parameters are compared with the corresponding thresholds, when the occurrence time driving parameter is not lower than a preset time threshold, that is, the time interval indicating that the current time distance last performs the persistence operation on the state data of the blockchain node is not lower than the time threshold, the hit triggering condition of the blockchain node can be determined.
Optionally, when each monitoring parameter is compared with the corresponding threshold, when the transaction accumulation parameter is not lower than the preset block number threshold, that is, the number of newly increased blocks is not lower than the block number threshold since the last time the state data of the blockchain node is subjected to the persistence operation, the hit triggering condition can be determined.
Optionally, when the monitored parameters are compared with the corresponding thresholds, when the data capacity parameter is not lower than a preset data amount threshold, namely the data amount of the state data to be subjected to the persistence operation of the current time blockchain node is not lower than the data amount threshold, the hit triggering condition of the current time blockchain node can be judged.
In some embodiments, when each monitored parameter is compared with a corresponding threshold, when a plurality of monitored parameters are not lower than the corresponding threshold, a hit trigger condition can be determined. It will be appreciated that the hit trigger condition is not unique and will not be described in detail herein.
In the related art, a state tree is built by using an ethernet, at present, a common pruning mechanism is an offline pruning mechanism, when the ethernet node prunes, the service of the current node needs to be stopped, and after pruning is completed, the service can be restarted, so that the blockchain node can not provide normal business service for the outside in a period of time. Because for MPT (Merkle Patricia Tree) trees used by ethernet, a clipping set cannot be accurately generated after a block is executed, because there may be a case where multiple paths share one leaf node on a physical disk in the same MPT tree, even if a reference to a certain leaf node is cancelled on a certain path, it cannot be determined whether it can be truly pruned at the physical level, which is also a main reason that ethernet cannot prune at runtime. Specifically, in the MPT tree of the ethernet, a node may have multiple parent nodes, and when the state update of each block is performed, and when the MPT is used as the state tree, to determine whether an old node can be cut, a reference count is needed to confirm that the node is not referenced by any other parent node, so that it can be cut. In the continuously expanding blockchain system, the reference count cannot be maintained for the node of each tree in the memory, and the branches cannot be pruned naturally in the running process.
To address this problem, in one embodiment, the state data of blockchain nodes is stored in a tree structure to persistent storage space to form a state tree, with each child node in the state tree having only one unique parent node. The persistent storage space is a physical disk, that is, in the same state tree, there is no case that multiple paths share a leaf node on the physical disk, and since each node has only a unique parent node, all nodes on the old path can be directly deleted when updating the Merkle path where the node is located. Thus, after the current block is executed, those leaf nodes that are dereferenced may be recorded within the clipping set. Illustratively, the present embodiment may employ a JMT (jelyfish MERKLE TREE) tree, and since there is no case that multiple paths share one leaf node on the physical disk in the same JMT tree, the clipping mechanism used by the ethernet may need to be stopped and reference counted, while the clipping mechanism of the present embodiment may occur in a block link point running state, and does not need reference counting, so the JMT tree may just as well be applied to the dynamic pruning mechanism proposed in the above embodiment.
In one embodiment, prior to persisting state data for the blockchain node according to the set of state changes, the method further comprises: writing the state change set into a pruning log; and respectively performing persistent storage and cache on the pruning log, and setting an index for the pruning log according to the block number of the execution block. For example, when a blockchain node performs a blocktransaction, a write set and a clip set generated by the current block for the state tree node are recorded to form a state change set for the current block. The state change set is packaged into a pruning log for persistent storage, and the pruning log is recorded in a memory cache and can be accessed by taking the block number as an index. The pruning log can cope with the recovery situation after the abnormal crash of the node process, and the index is convenient for searching the data.
In one embodiment, when a blockchain node executes a blocktransaction, accessing a cached pruning log according to an index, and searching a state value required for executing the transaction from the cached pruning log; if no state value exists in the cache, the state value required for executing the transaction is searched from the state tree. For example, when the blockchain node executes the next block, if the execution layer finds that the state change set exists in the cache, the blockchain node indexes back from large to small preferentially according to the number of the block, and sequentially tries to find the state value required for executing the transaction from the cached state change set. If the required state value cannot be found in all the cached state change sets, the state value is indicated to be unchanged in the blocks, and the state tree is searched.
In one embodiment, when it is determined that any one of the monitoring parameters hits the triggering condition, and the state data of the blockchain node is subjected to a persistence operation according to the state change set, deleting the data in the clipping set in the state tree, and inserting the data in the writing set in the state tree. For example, when the blockchain node starts, a pruning thread is started in the background, and according to the pruning mechanism of the above embodiment, the pruning thread can sequentially refresh the state data of the blockchain node based on the state change set according to the index from small to large of the blocknumber, that is, delete the data in the clipping set in the state tree, and insert the data in the writing set in the state tree.
In one embodiment, after performing a persistence operation on state data of a blockchain node according to a state change set, a pruning log corresponding to the state change set of the current blockchain node is deleted. By the arrangement, the total capacity of the state change set piled up in the memory can be reduced, and meanwhile, the clipping operation really occurs on the state tree stored in the persistence mode.
In one embodiment, under the condition that any one monitoring parameter hit trigger condition is not judged for a plurality of monitoring parameters, after a preset time interval, a state change set of the block chain node is scanned, and a plurality of new monitoring parameters are obtained. For example, the pruning thread periodically scans all state change sets existing on the current node, and if the condition of brushing is not met (i.e. a trigger condition), waits for the next round of scanning to be performed.
In one embodiment, a blockchain system is also provided. FIG. 3 is a schematic diagram of a block chain system according to the present embodiment, as shown in FIG. 3, the system includes: the system comprises a blockchain, a first execution module and a second execution module; wherein the blockchain includes a plurality of blockchain nodes; the first execution module is used for executing block transaction on the block chain link points; and the second execution module is used for executing the block chain node state data processing method of the embodiment on the block chain link points.
Illustratively, in a blockchain system, a blockchain node may correspond to a blockchain process on a machine, the state tree being a data structure used by the storage module of the blockchain process, the state tree node representing a constituent element on the data structure. Each blockchain node is provided with a first execution module and a second execution module, wherein the first execution module is used for being responsible for transaction threads, and the second execution module is used for being responsible for pruning threads.
Although the present application provides the method operational steps as described in the above embodiments or shown in the drawings, more or less operational steps may be included in the method, either on a routine or non-inventive basis. In the steps where there is logically no necessary causal relationship, the execution order of the steps is not limited to the execution order provided by the embodiment of the present application. For example, in one embodiment, FIG. 4 provides a flow chart of the operation of a blockchain system, as shown in FIG. 4, where the blockchain runtime will continually execute transactions in new blocks, and apply the results of the transaction execution to the world state of the current ledger, resulting in new world state. The block can be used as dimension, the state change information generated by each block is recorded to form a state change set, pruning is carried out according to the state change set, and the specific flow is as follows:
step S301, starting a current block chain link point, and starting a transaction thread and a pruning thread in the background respectively, wherein the current block chain node transaction thread is used for executing block transaction, and recording a writing set and a cutting set of a state tree node generated by a current block to form a state change set of the current block. The state change set is packaged into a pruning log for persistent storage, and the pruning log is recorded in a memory buffer and accessed by taking the block number as an index. The pruning log can cope with the situation that the node process is recovered after abnormal breakdown. The state data of the blockchain nodes are stored in a tree structure to the persistent storage space to form a state tree, and each child node in the state tree has only one unique parent node. For example, the state tree takes the form of a JMT tree.
In step S302, when executing to the next blockchain node, if the execution layer finds that the state change set exists in the cache, the state change set is indexed back from large to small preferentially according to the block number, and the state values required for executing the transaction are tried to be found sequentially from the state change sets. If the required state value cannot be found in all state change sets, the state value is not changed in the blocks, and the state tree is searched.
Step S303, the pruning thread scans the state change set of the current blockchain node to obtain a plurality of monitoring parameters.
Step S304, judging whether any hit trigger condition exists in the monitoring parameters; if yes, go to step S305; if not, return to step S303.
Step S305, according to the forward indexes of the block numbers from small to large, refreshing state data of the block chain nodes based on the state change set. Namely, deleting data in the clip set in the state tree, and inserting data in the write set in the state tree.
Step S306, deleting the pruning log corresponding to the state change set of the current blockchain node. Thus, the total size of the state change set piled up in the memory is reduced, and meanwhile, the clipping operation really occurs on the block chain state tree stored in the persistence mode.
Based on the pruning mechanism, each block generates a state change set, and pruning threads need to apply the state change sets to the physical account book at proper time so as to achieve the effect of reducing the physical storage space. The embodiment comprehensively considers three dimensions of time driving, transaction accumulation and data capacity, and a specific pruning mechanism is realized as follows:
The pruning thread periodically scans all state change sets existing on the current node, and if the state change sets do not meet the condition of brushing the wire rods, the next round of scanning is waited to be carried out. When the pruning thread scans that any monitoring parameter falls into a corresponding threshold range, the triggering condition is hit. Namely: when the occurrence time driving parameter is not lower than a preset time threshold, the time interval of last persistence operation of the state data of the blockchain node in the current time distance is not lower than the time threshold, and the triggering condition is hit. Or when the transaction accumulation parameter is not lower than the preset block number threshold, the number of the newly increased blocks is not lower than the block number threshold since the last time of carrying out the persistence operation on the state data of the blockchain node, and the trigger condition is hit. Or when the data capacity parameter is not lower than a preset data quantity threshold, indicating that the data quantity of the state data of the blockchain node to be subjected to the persistence operation is not lower than the data quantity threshold at the current time, and hitting the triggering condition.
In this embodiment, the state tree is supported to be continuously cut during the block link point operation without stopping cutting. Meanwhile, a dynamic change cutting mechanism is supported, so that the nodes reach proper conditions and then cut, the cutting accuracy is ensured, and the influence of cutting operation on the normal service performance of the block chain link point can be reduced to the greatest extent.
There is also provided in this embodiment an electronic device comprising a memory having stored therein a computer program and a processor arranged to run the computer program to perform the steps of any of the method embodiments described above.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, where the transmission device is connected to the processor, and the input/output device is connected to the processor.
Alternatively, in the present embodiment, the above-described processor may be configured to execute the following steps by a computer program:
Scanning a state change set of the block chain nodes to obtain a plurality of monitoring parameters;
judging whether any one of the monitoring parameters hits the triggering condition;
and under the condition that any monitoring parameter hits the triggering condition, carrying out persistence operation on the state data of the blockchain node according to the state change set.
It should be noted that, specific examples in this embodiment may refer to examples described in the foregoing embodiments and alternative implementations, and are not described in detail in this embodiment.
In addition, in combination with the blockchain node status data processing method provided in the above embodiment, a storage medium may also be provided for implementation in the present embodiment. The storage medium has a computer program stored thereon; the computer program, when executed by a processor, implements any of the block link state data processing methods of the above embodiments.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 5. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing a set of state changes for blockchain nodes. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a blockchain node state data processing method.
It will be appreciated by those skilled in the art that the structure shown in FIG. 5 is merely a block diagram of some of the structures associated with the present inventive arrangements and is not limiting of the computer device to which the present inventive arrangements may be applied, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
It should be understood that the particular embodiments described above are illustrative only and not limiting upon the application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure in accordance with the embodiments provided herein.
It is to be understood that the drawings are merely illustrative of some embodiments of the present application and that it is possible for those skilled in the art to adapt the present application to other similar situations without the need for inventive work. In addition, it should be appreciated that while the development effort might be complex and lengthy, it would nevertheless be a routine undertaking of design, fabrication, or manufacture for those of ordinary skill having the benefit of this disclosure, and thus should not be construed as a departure from the disclosure.
The term "embodiment" in this disclosure means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive. It will be clear or implicitly understood by those of ordinary skill in the art that the embodiments described in the present application can be combined with other embodiments without conflict.
The user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party. The embodiment of the application relates to the acquisition, storage, use, processing and the like of data, which all meet the relevant regulations of national laws and regulations.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The above examples merely represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the patent claims. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.

Claims (8)

1. A method for processing block link point state data, comprising:
Scanning a state change set of the block chain nodes to obtain a plurality of monitoring parameters;
judging whether any one of the monitoring parameters hits the triggering condition;
under the condition that any monitoring parameter hits the triggering condition, carrying out persistence operation on the state data of the block chain node according to the state change set;
wherein the monitoring parameters include at least one of:
A time driving parameter, wherein the time driving parameter is used for representing the time interval of last persistence operation on the state data of the blockchain node in the current time distance;
a transaction accumulation parameter that characterizes a number of blocks that have been newly increased since a last persistence operation was performed on state data of the blockchain node;
a data capacity parameter, the data capacity parameter being used to characterize the data amount of state data of the blockchain node to be subjected to a persistence operation at a current time;
Wherein the state change set comprises a write set and a cut set for the state tree node generated when the blockchain node executes blocktransaction; and under the condition that any monitoring parameter hits the triggering condition, performing persistence operation on the state data of the blockchain node according to the state change set, wherein the persistence operation comprises the following steps:
Deleting data in the clip set in the state tree, and inserting data in the write set in the state tree.
2. The blockchain node state data processing method of claim 1, wherein the blockchain node state data is stored in a tree structure to a persistent storage space to form a state tree, and each child node in the state tree has only one unique parent node.
3. The blockchain node state data processing method of claim 1, wherein prior to persisting the blockchain node state data according to the set of state changes, the method further comprises:
Writing the state change set into a pruning log;
and respectively performing persistent storage and cache on the pruning log, and setting an index for the pruning log according to the block number of the execution block.
4. The blockchain node state data processing method of claim 3, wherein after the persisting operation of the blockchain node state data according to the set of state changes, the method further comprises:
and deleting the pruning log corresponding to the current state change set of the blockchain node.
5. The blockchain node status data processing method of claim 3, further comprising:
when the block link point executes the block transaction, accessing the cached pruning log according to the index, and searching a state value required by executing the transaction from the cached pruning log;
And if the state value does not exist in the cache, searching the state value required by executing the transaction from the state tree.
6. The blockchain node status data processing method of claim 1, further comprising:
And under the condition that any monitoring parameter does not hit the triggering condition, scanning the state change set of the block chain node after a preset time interval to obtain a plurality of new monitoring parameters.
7. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, the processor being arranged to run the computer program to perform the blockchain node status data processing method of any of claims 1 to 6.
8. A computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the steps of the blockchain node state data processing method of any of claims 1 to 6.
CN202410519478.9A 2024-04-28 2024-04-28 Block chain node state data processing method, electronic device and storage medium Active CN118093557B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410519478.9A CN118093557B (en) 2024-04-28 2024-04-28 Block chain node state data processing method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410519478.9A CN118093557B (en) 2024-04-28 2024-04-28 Block chain node state data processing method, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN118093557A CN118093557A (en) 2024-05-28
CN118093557B true CN118093557B (en) 2024-08-27

Family

ID=91161943

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410519478.9A Active CN118093557B (en) 2024-04-28 2024-04-28 Block chain node state data processing method, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN118093557B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651498A (en) * 2020-05-20 2020-09-11 链石(上海)信息科技有限公司 Efficient retrieval method and device for block chain data
CN113630398A (en) * 2021-07-28 2021-11-09 上海纽盾科技股份有限公司 Joint anti-attack method, client and system in network security

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10789222B2 (en) * 2019-06-28 2020-09-29 Alibaba Group Holding Limited Blockchain-based hierarchical data storage
CN116701414A (en) * 2022-02-24 2023-09-05 腾讯科技(深圳)有限公司 Block chain-based data processing method, device, equipment and readable storage medium
CN115221176A (en) * 2022-07-29 2022-10-21 蚂蚁区块链科技(上海)有限公司 Block chain data storage method and device and electronic equipment
CN117076563A (en) * 2023-08-21 2023-11-17 中国建设银行股份有限公司 Pruning method and device applied to blockchain

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111651498A (en) * 2020-05-20 2020-09-11 链石(上海)信息科技有限公司 Efficient retrieval method and device for block chain data
CN113630398A (en) * 2021-07-28 2021-11-09 上海纽盾科技股份有限公司 Joint anti-attack method, client and system in network security

Also Published As

Publication number Publication date
CN118093557A (en) 2024-05-28

Similar Documents

Publication Publication Date Title
KR102564170B1 (en) Method and device for storing data object, and computer readable storage medium having a computer program using the same
EP2735978B1 (en) Storage system and management method used for metadata of cluster file system
CN111309720B (en) Time sequence data storage and reading method and device, electronic equipment and storage medium
US20150006495A1 (en) Methods and apparatuses to optimize updates in a file system based on birth time
CN110196847A (en) Data processing method and device, storage medium and electronic device
CN107526550B (en) Two-stage merging method based on log structure merging tree
CN110555001B (en) Data processing method, device, terminal and medium
US20190087437A1 (en) Scheduling database compaction in ip drives
CN111881092B (en) Method and device for merging files based on cassandra database
CN108874930A (en) File attribute information statistical method, device, system, equipment and storage medium
CN116204130A (en) Key value storage system and management method thereof
CN108021562B (en) Disk storage method and device applied to distributed file system and distributed file system
CN113253932B (en) Read-write control method and system for distributed storage system
CN115408149A (en) Time sequence storage engine memory design and distribution method and device
CN117633105A (en) Time-series data storage management method and system based on time partition index
US20230252029A1 (en) On-board data storage method and system
CN118093557B (en) Block chain node state data processing method, electronic device and storage medium
CN112711564B (en) Merging processing method and related equipment
CN111694806A (en) Transaction log caching method, device, equipment and storage medium
CN111752941A (en) Data storage method, data access method, data storage device, data access device, server and storage medium
CN115469810A (en) Data acquisition method, device, equipment and storage medium
US10762139B1 (en) Method and system for managing a document search index
CN114461635A (en) MySQL database data storage method and device and electronic equipment
CN116820323A (en) Data storage method, device, electronic equipment and computer readable storage medium
CN115904211A (en) Storage system, data processing method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant