CN116248693A - Light-weight operation method and device for Raft consensus algorithm of block chain - Google Patents

Light-weight operation method and device for Raft consensus algorithm of block chain Download PDF

Info

Publication number
CN116248693A
CN116248693A CN202211726743.8A CN202211726743A CN116248693A CN 116248693 A CN116248693 A CN 116248693A CN 202211726743 A CN202211726743 A CN 202211726743A CN 116248693 A CN116248693 A CN 116248693A
Authority
CN
China
Prior art keywords
node
consensus
raft
blockchain
log
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.)
Pending
Application number
CN202211726743.8A
Other languages
Chinese (zh)
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 Rivtower Technology Co Ltd
Original Assignee
Hangzhou Rivtower Technology Co Ltd
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 Rivtower Technology Co Ltd filed Critical Hangzhou Rivtower Technology Co Ltd
Priority to CN202211726743.8A priority Critical patent/CN116248693A/en
Publication of CN116248693A publication Critical patent/CN116248693A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/04Protocols for data compression, e.g. ROHC
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Retry When Errors Occur (AREA)

Abstract

The embodiment of the specification discloses a lightweight running method and device for a Raft consensus algorithm of a blockchain, wherein a consensus module of a blockchain node of the method supports the Raft consensus algorithm, and a Raft state machine of the node is used for recording transaction consensus state data of the blockchain; comprising the following steps: the Leader node receives the transaction consensus request, generates an operation log, and distributes the operation log to the Follower node; when more than half of the Follower nodes confirm the operation log, the Leader node executes the transaction consensus request and completes block out; recording transaction consensus state data by a RAft state machine of the Leader node, and executing log compression operation on a block operation log smaller than the current block height; when a new node joins the blockchain, a snapshot is generated by the Leader node to the current Raft state machine and sent to the new node. According to the scheme, the cost of the block chain in using the Raft consensus algorithm is effectively reduced by utilizing the Raft log compression and snapshot synchronization mechanism, and the consensus state data synchronization can be rapidly completed.

Description

Light-weight operation method and device for Raft consensus algorithm of block chain
Technical Field
The present disclosure relates to the field of computer software technologies, and in particular, to a lightweight running method, device, electronic apparatus, and storage medium for a Raft consensus algorithm of a blockchain.
Background
The Raft consensus algorithm is a fault tolerance algorithm commonly used in distributed systems, and is widely applied to various distributed systems because of reliability, safety and easy understanding. For a blockchain system, particularly in an application scene of a alliance chain, based on a stronger trust assumption, the Raft consensus algorithm can well meet the requirements of the alliance chain system, and most of alliance chain implementations also support the Raft consensus algorithm. Because in the general application of Raft, a node can save a history log, and copy the history log to other nodes when needed to maintain data consistency among the nodes, if the data volume of the log is too large, the state machine is snapshot, and then the outdated log is discarded. However, in the application of the blockchain, the Raft only needs to be used as a consensus module to constantly consensus new blocks among nodes, and the blockchain has a data synchronization mechanism to ensure the data consistency among the nodes, so that the Raft is not only unnecessary to save history logs, but also can influence the performance of the system: firstly, the memory cost during operation is increased when the history log is stored, and the history log needs to be recovered after restarting, so that the history log is continuously persisted, and the I/O cost of a hard disk is increased; secondly, restarting or newly joining nodes need to synchronize all history logs to work normally, and when the data volume is large or the network condition is poor, the process is long, and the usability of the system is affected. Therefore, when the Raft consensus algorithm is used for blockchain application, how to reduce log storage overhead and realize rapid synchronization of node state logs is a technical problem to be solved.
Disclosure of Invention
An object of the embodiments of the present specification is to provide a light-weight running apparatus method, apparatus, electronic device, and storage medium for a Raft consensus algorithm of a blockchain, in view of the above-described problems.
In order to solve the above technical problems, the embodiments of the present specification are implemented as follows:
in a first aspect, a light-weight operation method for a Raft consensus algorithm of a blockchain is provided, wherein a consensus module of a blockchain node supports the Raft consensus algorithm, and a Raft state machine of the node is used for recording transaction consensus state data of the blockchain; the method comprises the following steps:
the Leader node receives the transaction consensus request, generates an operation log, and distributes the operation log to the Follower node;
when more than half of the Follower nodes confirm the operation log, the Leader node executes a transaction consensus request and completes block out;
the Lift state machine of the Leader node records the transaction consensus state data and executes log compression operation on a block operation log smaller than the current block height;
when a new node joins the blockchain and/or the existing nodes of the blockchain are restarted, the Leader node generates a snapshot of the current Raft state machine and sends the snapshot to the nodes.
Further, the transaction consensus status data includes a current consensus node list and/or a Raft operating status.
Further, the Raft running state includes current state data of a Raft state machine, and the Leader node and the Follower node information participating in the present Raft consensus.
Further, the method further comprises the following steps: and after receiving and recovering the snapshot of the Raft state machine, the node acquires the current transaction consensus state data and completes state synchronization operation according to the current transaction consensus state data.
In a second aspect, a light-weight running device for a Raft consensus algorithm of a blockchain is provided, a consensus module of a blockchain node supports the Raft consensus algorithm, and a Raft state machine of the node is used for recording state data related to the blockchain consensus; the device comprises:
the first module is used for receiving the transaction consensus request and generating an operation log by the Leader node and distributing the operation log to the Follower node;
the second module is used for executing a transaction consensus request and completing block out when more than half of the Follower nodes confirm the operation log;
the third module is used for recording the transaction consensus state data by the RAft state machine of the Leader node and executing log compression operation on the block operation log smaller than the current block height;
and a fourth module, configured to generate a snapshot for the current Raft state machine by the Leader node when a new node joins the blockchain and/or the existing node of the blockchain is restarted, and send the snapshot to the node.
Further, the transaction consensus status data includes a current consensus node list and/or a Raft operating status.
Further, the Raft running state includes current state data of a Raft state machine, and the Leader node and the Follower node information participating in the present Raft consensus.
Further, the method further comprises the following steps:
and a fifth module, configured to obtain current transaction consensus status data after the node receives and restores the snapshot of the Raft state machine, and complete a status synchronization operation according to the current transaction consensus status data.
In a third aspect, an electronic device is provided, which includes:
a processor; and
a memory arranged to store computer executable instructions that when executed cause the processor to perform the method of lightweight operation of a Raft consensus algorithm for blockchain of the first aspect.
In a fourth aspect, a computer readable storage medium is provided, where the computer readable storage medium stores one or more programs, which when executed by an electronic device including a plurality of application programs, cause the electronic device to perform the method for lightweight operation of a Raft consensus algorithm for blockchains according to the first aspect.
The specification can achieve at least the following technical effects:
the scheme of the invention effectively reduces the memory and hard disk I/O overhead of the blockchain when the blockchain is operated by using the Raft consensus algorithm by utilizing the Raft log compression and snapshot synchronization mechanism, and can enable a new node to join the blockchain or quickly complete the consensus state data synchronization after the existing nodes of the blockchain are restarted.
Drawings
In order to more clearly illustrate the embodiments of the present description or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some of the embodiments described in the present description, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a lightweight method of operating a Raft consensus algorithm for blockchain according to an embodiment of the present disclosure.
FIG. 2 is a schematic diagram of a second exemplary method for lightweight operation of a Raft consensus algorithm for blockchain according to an embodiment of the present disclosure.
FIG. 3 is a third exemplary diagram of a lightweight method of operating a Raft consensus algorithm for blockchain according to an embodiment of the present disclosure.
FIG. 4 is a schematic diagram of a lightweight running device for a Raft consensus algorithm for blockchain according to an embodiment of the present disclosure.
FIG. 5 is a schematic diagram of a lightweight running device for a block chain of the Raft consensus algorithm according to the present disclosure.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
Key terms
The Raft consensus algorithm: the distributed consensus algorithm with wider strong consistency, decentralization and high availability is used, namely, under the conditions of partial node faults, network delay and network segmentation, a plurality of nodes agree on a certain thing. The Raft protocol is a Leader-based consensus algorithm, so the core of the Raft protocol is composed of three sub-problems: electing a Leader selection, log replication and security. The three parts jointly realize the consensus and fault tolerance mechanism of the Raft core. For the election process, which node makes the Leader is voted for by everyone, each Leader node works for a period of time, and then a new Leader node is selected to continue to be responsible. This is much like the election of democratic society, and each new performance period is called a term. Therefore, the Raft protocol strongly depends on the Leader node to ensure consistency of cluster data, i.e. data sent by the client all reach the Leader node first.
Raft log compression mechanism: the Raft cannot keep the history log without stop, and when the log data volume reaches a certain size, the log can be cleaned up through log compression, namely a log compression mechanism. The snapshot is written into the current state machine data state and some of the Raft metadata, and is persisted for use in restarting recovery, the saved log applied to the state machine is discarded, and a new log is re-recorded. In general applications, the data size of the state machine may be large, and taking a snapshot of the state machine consumes more time and resources, so that the log compression mechanism is reasonably utilized, and if the snapshot is created too frequently, a great amount of disk bandwidth and other resources are wasted; if the snapshot is created too infrequently, the risk of exhausting storage capacity is sustained, as well as increasing the time to reconstruct from the log.
Raft synchronization mechanism: the Raft is a common-knowledge algorithm based on a replication state machine, namely, the final state consistency of each node can be ensured as long as the initial state of each node is ensured to be the same, and then each node applies the same log according to the same sequence. When a restarting or newly added node joins the cluster, the cluster Leader checks its consistency, finds its last log identical to the Leader, and copies its lagged log entries to it, so that it can work normally if it successfully completes synchronization, which is called log synchronization. However, because of the log compression mechanism, the log required by the new node may be compressed, and the Leader may generate a snapshot of the current state to send to the new node, which is different from the log synchronization, which is called snapshot synchronization. Lift will take as much log synchronization as possible and snapshot synchronization will take place if and only if the log needed for the new node is compressed, since the state machine data state is typically much more data than the log entries.
A lightweight operating scheme of a Raft consensus algorithm for blockchain according to the present specification is described in detail below by way of specific examples.
The invention aims at solving the problems that when the Raft consensus algorithm is used for block chain application, the log storage overhead can be reduced and the rapid synchronization of the node state log can be realized. The Raft is used as a common fault tolerance algorithm in a distributed system, is developed from a Paxos consensus algorithm, and can cope with the situations that no more than half of nodes in a cluster are down, network delay and the like are not in Bayesian and busy errors. The method is reliable, safe and easy to understand, and is widely applied to various distributed systems. Because the blockchain is also a distributed system, and the blockchain system constructed by a plurality of nodes with mutually known identities is called a alliance chain, unlike a public chain which can be accessed by people, the alliance chain is generally only opened for members in the alliance, so that the application scene naturally has stronger trust assumption, the Bayesian error can be assumed to be not generated in the system according to actual conditions, the Raft consensus algorithm can well meet the requirements of the alliance chain system, and in fact, most of the alliance chain implementations also support the Raft consensus algorithm. The operational principle of Raft is that a client initiates a data writing operation to a server loader, the loader adds the operation to a log and copies the operation to all follow, and when more than half nodes are confirmed, the operation can be applied to a state machine. In the general application of Raft, a node will save a history log, copy it to other nodes when needed to maintain data consistency among nodes, and discard outdated logs after snapshot the state machine if the data amount of the log is too large. However, in the application of the blockchain, the Raft only needs to be used as a consensus module to constantly consensus new blocks among nodes, and the blockchain has a data synchronization mechanism to ensure the data consistency among the nodes, so that the Raft is not only unnecessary to save history logs, but also can influence the performance of the system: firstly, the memory cost during operation is increased when the history log is stored, and the history log needs to be recovered after restarting, so that the history log is continuously persisted, and the I/O cost of a hard disk is increased; secondly, restarting or newly joining nodes need to synchronize all history logs to work normally, and when the data volume is large or the network condition is poor, the process consumes a long time, so that the usability of the system is affected.
Example 1
The technical idea of the light weight running scheme of the shift consensus algorithm for the blockchain is that in the application of the blockchain, a shift state machine usually only stores data related to a consensus state, such as a current consensus node list and the like, and the data is usually lighter and smaller than the data quantity of one empty block, under the condition that the expenditure of snapshot synchronization is far smaller than the expenditure of log synchronization, the characteristics of the blockchain system and a log synchronization mechanism are fully utilized, and the log synchronization process can be bypassed; for example, a method of performing log compression once for each block is adopted, and history logs are cleaned in time, so that a snapshot synchronization method can be adopted when a new node is added; specifically, on the premise that data of the Raft state machine is only related to the blockchain consensus state, each new block is compressed by using a log compression mechanism, so that a log required by a new node is always compressed, and a snapshot synchronization mode is adopted when the data is synchronized, thereby realizing a synchronization process which is better, faster and lighter than that of the traditional log synchronization.
For this reason, fig. 1 is a schematic diagram of a lightweight operation method of a Raft consensus algorithm for a blockchain according to an embodiment of the present invention. Firstly, a consensus module of a block chain node needs to support a Raft consensus algorithm; meanwhile, the Raft state machine of the node is used for recording transaction consensus state data of the blockchain, rather than recording data irrelevant to consensus, otherwise, the data quantity of the state machine is excessively heavy. The method comprises the following steps:
s1: the Leader node receives the transaction consensus request and generates an operation log, and distributes the operation log to the follow node.
Optionally, the transaction consensus status data comprises a current consensus node list and/or a Raft operating status.
Optionally, the Raft running state includes current state data of a Raft state machine, and the header node and the Follower node information participating in the present Raft consensus.
S2: and when more than half of the Follower nodes confirm the operation log, the Leader node executes a transaction consensus request and completes block out.
S3: and recording the transaction consensus state data by a RAft state machine of the Leader node, and executing log compression operation on a block operation log smaller than the current block height.
S4: when a new node joins the blockchain and/or the existing nodes of the blockchain are restarted, the Leader node generates a snapshot of the current Raft state machine and sends the snapshot to the nodes.
FIG. 2 is a schematic diagram of another implementation of a light-weight operation method of a Raft consensus algorithm for blockchains according to an embodiment of the present invention. The method further comprises the steps of:
s5: and after receiving and recovering the snapshot of the Raft state machine, the node acquires the current transaction consensus state data and completes state synchronization operation according to the current transaction consensus state data.
The application scenario shown in fig. 3 is specifically described. In FIG. 3, when an existing node reboots to rejoin the blockchain system, a consensus state synchronization is required to the running existing node in the blockchain system. Taking a Leader node as an example of a synchronization node, since the scheme of the embodiment of the present invention adopts each new out Block, i.e. the common state log of the existing Block lower than the height of the Block is compressed, the latest Block of the current Leader node is Block1014, and the Block1013 and the previous Block log are already compressed. In the case of the restarting node, the current Block before the restarting is Block112, and if the log synchronization mechanism is adopted, the restarting node cannot obtain the common log of Block1013 and cannot perform log synchronization because the Block1013 already performs log compression. At this time, the fast state machine of the Leader node is subjected to snapshot operation, and because the fast state machine records necessary information for consensus, including a consensus node list and a fast running state, current state data of the fast state machine and information of the Leader node and the Follower node participating in the current fast consensus are also included in the fast state machine, the restarting node can quickly realize consensus state synchronization by obtaining and recovering the snapshot of the Leader node state machine, so that the node is added into a block chain again to participate in transaction consensus.
According to the embodiment, by introducing a Raft log compression and snapshot synchronization mechanism, memory and hard disk I/O overhead of a blockchain when the Raft consensus algorithm is used for running is effectively reduced, and a new node can be added into the blockchain or the existing nodes of the blockchain are restarted to bypass a traditional log synchronization process, so that consensus state data synchronization is rapidly completed.
Example two
Fig. 4 is a schematic structural diagram of a light-weight running device 400 for a Raft consensus algorithm of a blockchain according to an embodiment of the present disclosure. Referring to fig. 4, in an embodiment of a lightweight running device 400 for a Raft consensus algorithm of a blockchain, a consensus module of a blockchain node supports the Raft consensus algorithm, and a Raft state machine of the node is used for recording state data related to the blockchain consensus; the device comprises:
a first module 401, configured to receive a transaction consensus request and generate an operation log by a Leader node, and distribute the operation log to a Follower node.
A second module 402, configured to execute a transaction consensus request and complete block out when more than half of the Follower nodes acknowledge the operation log.
A third module 403, configured to record the transaction consensus status data by using a Raft state machine of the Leader node, and perform a log compression operation on a block operation log smaller than the current block height.
And a fourth module 404, configured to generate a snapshot for the current Raft state machine by the Leader node when a new node joins the blockchain and/or the existing blockchain node restarts, and send the snapshot to the node.
As shown in fig. 5, another implementation manner of the light-weight running device 400 for a Raft consensus algorithm for a blockchain according to an embodiment of the present invention further includes:
and a fifth module 405, configured to obtain current transaction consensus status data after the node receives and restores the snapshot of the Raft state machine, and complete a state synchronization operation according to the current transaction consensus status data.
It should be understood that, the light-weight running device 400 for a Raft consensus algorithm for a blockchain according to the embodiments of the present disclosure may also perform the method performed by the light-weight running device (or apparatus) for a blockchain in fig. 1 to 3, and implement the functions of the light-weight running device (or apparatus) for a blockchain in the examples shown in fig. 1 to 3, which are not described herein.
Example III
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present specification. Referring to fig. 6, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 6, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs, and forms a shared resource access control device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
the consensus module of the block chain node supports a shift consensus algorithm, and a shift state machine of the node is used for recording transaction consensus state data of the block chain; comprising the following steps:
the Leader node receives the transaction consensus request, generates an operation log, and distributes the operation log to the Follower node;
when more than half of the Follower nodes confirm the operation log, the Leader node executes a transaction consensus request and completes block out;
the Lift state machine of the Leader node records the transaction consensus state data and executes log compression operation on a block operation log smaller than the current block height;
when a new node joins the blockchain and/or the existing nodes of the blockchain are restarted, the Leader node generates a snapshot of the current Raft state machine and sends the snapshot to the nodes.
The light-weight running method of the Raft consensus algorithm for the blockchain disclosed in the embodiment shown in fig. 1 to 3 of the present specification can be applied to a processor or implemented by the processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic blocks disclosed in the embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present specification may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
Of course, in addition to the software implementation, the electronic device of the embodiments of the present disclosure does not exclude other implementations, such as a logic device or a combination of software and hardware, that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Example IV
The present embodiments also provide a computer readable storage medium storing one or more programs, the one or more programs including instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform a method of lightweight operation of a Raft consensus algorithm for a blockchain of the embodiments shown in fig. 1-3, and in particular to perform the method of:
the consensus module of the block chain node supports a shift consensus algorithm, and a shift state machine of the node is used for recording transaction consensus state data of the block chain; comprising the following steps:
the Leader node receives the transaction consensus request, generates an operation log, and distributes the operation log to the Follower node;
when more than half of the Follower nodes confirm the operation log, the Leader node executes a transaction consensus request and completes block out;
the Lift state machine of the Leader node records the transaction consensus state data and executes log compression operation on a block operation log smaller than the current block height;
when a new node joins the blockchain and/or the existing nodes of the blockchain are restarted, the Leader node generates a snapshot of the current Raft state machine and sends the snapshot to the nodes.
In summary, the foregoing description is only a preferred embodiment of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the protection scope of the present specification.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.

Claims (10)

1. A lightweight operation method of a shift consensus algorithm for a block chain is characterized in that a consensus module of a block chain node supports the shift consensus algorithm, and a shift state machine of the node is used for recording transaction consensus state data of the block chain; the method comprises the following steps:
the Leader node receives the transaction consensus request, generates an operation log, and distributes the operation log to the Follower node;
when more than half of the Follower nodes confirm the operation log, the Leader node executes a transaction consensus request and completes block out;
the Lift state machine of the Leader node records the transaction consensus state data and executes log compression operation on a block operation log smaller than the current block height;
when a new node joins the blockchain and/or the existing nodes of the blockchain are restarted, the Leader node generates a snapshot of the current Raft state machine and sends the snapshot to the nodes.
2. The method of claim 1, wherein the transaction consensus status data comprises a current consensus node list and/or a Raft operating status.
3. The method for lightweight operation of a block chain shift keying algorithm of claim 2, wherein said shift keying state comprises shift keying state machine current state data and said header node and said follow node information.
4. The method for lightweight operation of a Raft consensus algorithm for a blockchain of claim 1, further comprising: and after receiving and recovering the snapshot of the Raft state machine, the node acquires the current transaction consensus state data and completes state synchronization operation according to the current transaction consensus state data.
5. A lightweight running device for a block chain consensus algorithm is characterized in that a consensus module of a block chain node supports the block chain consensus algorithm, and a Raft state machine of the node is used for recording state data related to the block chain consensus; the device comprises:
the first module is used for receiving the transaction consensus request and generating an operation log by the Leader node and distributing the operation log to the Follower node;
the second module is used for executing a transaction consensus request and completing block out when more than half of the Follower nodes confirm the operation log;
the third module is used for recording the transaction consensus state data by the RAft state machine of the Leader node and executing log compression operation on the block operation log smaller than the current block height;
and a fourth module, configured to generate a snapshot for the current Raft state machine by the Leader node when a new node joins the blockchain and/or the existing node of the blockchain is restarted, and send the snapshot to the node.
6. The lightweight operational device for a block chain of a Raft consensus algorithm as claimed in claim 5, wherein the transaction consensus status data comprises a current consensus node list and/or a Raft operational status.
7. The device for lightweight operation of a block chain shift keying algorithm of claim 6, wherein said shift keying state comprises shift keying state machine current state data and said header node and said follow node information.
8. The Raft consensus algorithm lightweight running device for a blockchain of claim 5, further comprising:
and a fifth module, configured to obtain current transaction consensus status data after the node receives and restores the snapshot of the Raft state machine, and complete a status synchronization operation according to the current transaction consensus status data.
9. An electronic device, comprising:
a processor; and
a memory arranged to store computer executable instructions that when executed cause the processor to perform the method of lightweight operation of a Raft consensus algorithm for a blockchain as claimed in any one of claims 1 to 4.
10. A computer-readable storage medium storing one or more programs that, when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of lightweight operation of a Raft consensus algorithm for blockchain of any of claims 1 to 4.
CN202211726743.8A 2022-12-29 2022-12-29 Light-weight operation method and device for Raft consensus algorithm of block chain Pending CN116248693A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211726743.8A CN116248693A (en) 2022-12-29 2022-12-29 Light-weight operation method and device for Raft consensus algorithm of block chain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211726743.8A CN116248693A (en) 2022-12-29 2022-12-29 Light-weight operation method and device for Raft consensus algorithm of block chain

Publications (1)

Publication Number Publication Date
CN116248693A true CN116248693A (en) 2023-06-09

Family

ID=86634176

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211726743.8A Pending CN116248693A (en) 2022-12-29 2022-12-29 Light-weight operation method and device for Raft consensus algorithm of block chain

Country Status (1)

Country Link
CN (1) CN116248693A (en)

Similar Documents

Publication Publication Date Title
CN108648078B (en) Transaction preprocessing method and device and electronic equipment
CN106776130B (en) Log recovery method, storage device and storage node
US10831741B2 (en) Log-shipping data replication with early log record fetching
CN111383031B (en) Intelligent contract execution method and system in block chain and electronic equipment
CN109783014B (en) Data storage method and device
CN106873902B (en) File storage system, data scheduling method and data node
CN110121694B (en) Log management method, server and database system
CN115408411A (en) Data writing method and device, electronic equipment and storage medium
CN115168322A (en) Database system, main library election method and device
CN110737716B (en) Data writing method and device
JP2021528884A (en) Memory of dynamic blockchain data based on error correction code
CN113806143B (en) Remote disaster recovery method, system and electronic equipment
CN110196788B (en) Data reading method, device and system and storage medium
CN111046004B (en) Data file storage method, device, equipment and storage medium
US9003018B2 (en) System and method for data set synchronization and replication
CN116248693A (en) Light-weight operation method and device for Raft consensus algorithm of block chain
CN115470041A (en) Data disaster recovery management method and device
CN115629901A (en) Log playback method and device, data recovery method and device and electronic equipment
CN115698955A (en) Fault tolerance of transaction images
CN114077517A (en) Data processing method, equipment and system
CN112988469B (en) State backup method and device in alliance chain and electronic equipment
US11960502B2 (en) Byzantine fault tolerance protocol for backing up blockchains
CN115955504A (en) State synchronization middleware implementation method and device for stateful service
US11734230B2 (en) Traffic redundancy deduplication for blockchain recovery
CN115437850A (en) Block chain link point backup method and device

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