Synchronization method and system for verification node set and electronic equipment
Technical Field
The embodiment of the specification relates to the technical field of networks, in particular to a synchronization method and system for a verification node set and an electronic device.
Background
When a common identification chain (assumed to be a block chain A) based on Byzantine fault tolerance is subjected to chain crossing, a hand chain (assumed to be a block chain B) needs to synchronize and save a verification node set of the block chain A; and the effective synchronization of the verification node set is the guarantee of cross-chain safety.
In the process of chain crossing, the verification node set of the blockchain A can change along with time, and when the verification node set synchronously stored by the blockchain B is inconsistent with the blockchain A, the chain crossing is easy to attack. For example, at some point, the set of verification nodes for blockchain a is {1,2,3,4}, and blockchain B holds the set of verification nodes for blockchain a as {1,2,3,4 }; then, when the verification node set of the blockchain A is changed from {1,2,3,4} to {1,5,6,7 }; block chain B is not updated synchronously in time, and is still {1,2,3,4 }. In the consensus process based on Byzantine fault tolerance, the consensus can be realized if the verification nodes exceeding 2/3 are honest; but after the verification node is replaced, there may be any behavior, in other words, the nodes 2,3,4 of the blockchain a may be dishonest at this time. But the set of verification nodes recorded by blockchain B is still {1,2,3,4}, and the cross-chain transactions signed by verification nodes exceeding 2/3 in the set are all valid. If the node 2,3,4 with the changed blockchain a signs the fake cross-chain transaction and forwards the fake cross-chain transaction to the blockchain B, the fake cross-chain transaction will take effect in the blockchain B.
In order to avoid the above attack, in the current cross-chain process, the relay can synchronize the verification node set. However, it is considered that the relay may not forward the message that the verification node set of blockchain a is changed, so that the verification node set recorded by blockchain B is inconsistent with the current verification node set of blockchain a, thereby causing a cross-chain attack.
Disclosure of Invention
Embodiments of the present specification provide a synchronization method, system and electronic device for verifying a node set, so as to solve the problem of cross-link insecurity caused by relay operation badness in the prior art.
In order to solve the above technical problem, the embodiments of the present specification adopt the following technical solutions:
in a first aspect, a synchronization method for verifying a node set is provided, and is applied in a blockchain cross-chain transaction process, the method includes:
after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, starting a timer by the first block chain;
within the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain;
if the synchronization is successful, the first block chain restarts a timer;
if the synchronization fails, the relay re-executes the synchronization operation;
if the timer times out, the first blockchain suspends cross-chain transactions and waits for synchronization.
In a second aspect, provide
A synchronization system for verifying a set of nodes for use during a blockchain cross-chain transaction, the system comprising: a first block chain, a second block chain and a relay; wherein,
the first block chain is used for starting a timer after the first block chain initially synchronizes the verification node set of the latest block of the second block chain;
the relay is configured to synchronize the verification node set of the current latest block of the second block chain to the first block chain within the timing time period of the timer;
the first blockchain is further used for restarting the timer if the synchronization is successful;
the relay is also used for re-executing the synchronization operation if the synchronization fails;
the first blockchain is further used for suspending cross-chain transaction and waiting for synchronization if the timer is overtime.
In a third aspect, an electronic device is provided, including: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor to:
after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, starting a timer by the first block chain;
within the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain;
if the synchronization is successful, the first block chain restarts a timer;
if the synchronization fails, the relay re-executes the synchronization operation;
if the timer times out, the first blockchain suspends cross-chain transactions and waits for synchronization.
In a fourth aspect, a computer-readable storage medium is provided that stores one or more programs that, when executed by an electronic device that includes a plurality of application programs, cause the electronic device to:
after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, starting a timer by the first block chain;
within the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain;
if the synchronization is successful, the first block chain restarts a timer;
if the synchronization fails, the relay re-executes the synchronization operation;
if the timer times out, the first blockchain suspends cross-chain transactions and waits for synchronization.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
according to the technical scheme, after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, the first block chain starts a timer; in the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain; if the synchronization is successful, the first block chain restarts the timer; if the synchronization fails, the relay re-executes the synchronization operation; if the timer times out, the first blockchain suspends cross-chain transactions, waiting for synchronization. Therefore, the trust of the relay is decoupled, the effective synchronization of the verification node set is realized through the timer in the block chain and the condition of the updating synchronization mechanism, and the safety of the cross-chain is ensured.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present specification, and for those skilled in the art, other drawings can be obtained according to the drawings without any creative efforts.
Fig. 1 is a schematic diagram illustrating steps of a synchronization method for verifying a node set according to an embodiment of the present disclosure.
Fig. 2 is a schematic structural diagram of an electronic device provided in an embodiment of the present specification.
Fig. 3 is a schematic structural diagram of a synchronization system for verifying a node set according to an embodiment of the present disclosure.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the embodiments in the present specification.
The technical solutions provided by the embodiments of the present description are described in detail below with reference to the accompanying drawings.
Considering that in the current chain crossing scheme based on the relay implementation, both the consensus chain and the hand chain (i.e. two objects of the chain crossing) need to grant a large trust cost to the relay, which results in the possibility of the relay being malicious. Therefore, the embodiment of the present specification provides a new synchronization scheme for a verification node set, which decouples trust of relays, and implements effective synchronization of the verification node set through a timer in a blockchain and an update synchronization mechanism condition, thereby ensuring cross-chain security.
Example one
Referring to fig. 1, a schematic diagram of steps of a synchronization method for verifying a node set provided in an embodiment of the present specification, where the synchronization method may be applied in a blockchain cross-chain transaction process, and the method may include the following steps:
step 102: after the first blockchain initially synchronizes the set of verification nodes for the latest block of the second blockchain, the first blockchain starts a timer.
It should be understood that in the embodiments of the present specification, when the first blockchain initially synchronizes the set of verification nodes of the newest block of the second blockchain, it may be specifically implemented as: the first blockchain records a set of verification nodes of the latest block of the second blockchain acquired by an own operator.
In specific implementation, an operator of a first blockchain as a bracelet acquires a verification node set of a second blockchain as a consensus chain, and triggers the first blockchain to record an initial value as a current verification node set of the second blockchain in an input manner, for example, the initial value can be recorded in a certain storage space and is recorded as sync _ vs. After the first blockchain initially synchronizes the set of verification nodes of the latest block of the second blockchain, the first blockchain starts a timer whose timing period may be set to a countdown, e.g., …..5, 4, 3, 2, 1; a normal timing scheme may also be provided, for example, 1,2,3,4, 5 …. The description is not intended to limit the scope of the invention. The timing period of the timer can be recorded as a first period, for example, denoted by timeV.
It should be understood that, in the embodiment of the present specification, in the second blockchain, the verification nodes in the verification node set are obtained by the respective nodes through competitive election in a manner of paying a deposit. When the verification node in the verification node set in the second blockchain is changed, the deposit of the replaced verification node cannot be unlocked and returned immediately, and a delay time is required to be recorded as a second time period, which may be represented by, for example, time s.
In fact, when the transaction set is submitted, the second blockchain records the timestamp of the block generation, for example, timestamp pa, and the hash value calculated by all the verification nodes in the current verification node set through the hash algorithm, for example, may be recorded as vs _ hash. Wherein the timestamp may be on the order of milliseconds or seconds; when the hash value is calculated by the hash algorithm, the hash value may be obtained by performing various processing (e.g., combining) based on all the verification nodes in the verification node set; moreover, the hash algorithm may be any usable hash algorithm, and this specification does not limit this.
Similarly, the first block chain also records the timestamp of block generation, for example, denoted as timestamp b.
It is to be understood that the first time period should be less than the second time period, i.e., timeV < timeS.
Step 104: within the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain;
if the synchronization is successful, step 106 is performed, and if the synchronization is failed, step 108 is performed.
Optionally, in an embodiment of this specification, in a timing period of a timer of a first block chain, relaying synchronization of a verification node set of a current latest block of the second block chain to the first block chain specifically includes: the relay synchronizes the transaction corresponding to the verification node set change in the second blockchain to the first blockchain; and synchronizing the set of verification nodes of the current latest block in the second block chain to the first block chain.
Therefore, when the set of the relay synchronous verification nodes is used, the transaction corresponding to the updated verification node in the second blockchain is synchronized to the first blockchain, specifically, a label of the synchronous transaction is used, so that when the cross-chain transaction is executed, the first blockchain can use the updated set of the verification node to process the correct transaction.
Optionally, in an embodiment of the present specification, the condition that the first blockchain synchronization is successful includes:
the absolute value of the difference between a first timestamp of the current latest block in the first block chain when generated and a second timestamp of the current latest block in the second block chain when generated is not more than a time threshold; and the number of the first and second groups,
and the hash value corresponding to the verification node set recorded in the first block chain is equal to the hash value recorded in the block head of the second block chain synchronized to the first block chain.
The above condition is considered to be that, during inter-chain, it is only necessary to verify that at least 2/3 verification nodes in the node set are honest and effective, in other words, after the first blockchain synchronizes the verification node set in the second blockchain, when the inter-chain transaction is performed, the verification nodes in the verification node set of the first blockchain are completely the same as the verification nodes in the current verification node set of the second blockchain, or the verification nodes in the verification node set of the first blockchain are nearly the same as the verification nodes in the current verification node set of the second blockchain, but at least 2/3 verification nodes are guaranteed to be the same, which is guaranteed by the difference between the timestamps when the blocks are generated. Meanwhile, the comparison of the hash values can ensure that the transaction executed by the first blockchain is the transaction corresponding to the verification node set updated by the second blockchain of the first blockchain.
Thus, it should be appreciated that the above time threshold may ensure that at least 2/3 of the set of authentication nodes in the first blockchain are identical to the authentication nodes in the second blockchain current set of authentication nodes when the cross-chain transaction is performed.
Optionally, in an embodiment of the present specification, the time threshold is not greater than a difference between the first time period and the second time period; the second time period is a time period from the time when the node serving as the verification node in the second block chain is replaced to the time when the node competitively selects the verification node, the payment of the deposit is refunded; the first time period is a timing time period of a timer in the first blockchain.
Step 106: the first blockchain restarts a timer.
Therefore, the first block chain can be ensured to be always synchronized to the updated verification node set in the second block chain, and the cross-chain safety is improved.
Step 108: the relay re-performs the synchronization operation.
During a timing period, before synchronization is not successful, the relay will repeatedly perform synchronization operation until synchronization is successful or timing is over.
Step 110: if the timer times out, the first blockchain suspends cross-chain transactions and waits for synchronization.
If the timer is over time, the first blockchain suspends the cross-chain transaction, because there is no way to ensure that the synchronization is at least 2/3 honest and effective verification nodes, in order to ensure the cross-chain security, the cross-chain transaction needs to be suspended, and after the operator of the first blockchain re-initializes the latest verification node set of the second blockchain, the cross-chain transaction is executed.
In the above scheme, if the relay forwards the message within the timed period of the timer, the set of authentication nodes of the first blockchain is updated, then it is safe to cross the chain. The reason is that: in the initial synchronization state, the verification node set stored in the first block chain is consistent with that in the second block chain; during the timeev time, the set of verification nodes of the second blockchain changes but is not synchronized to the first blockchain, at which point the set of verification nodes has a short inconsistency. Because timeV < timeS, the deposit of the replaced verification node of the second block chain is not unlocked, and the replaced verification node cannot forge cross-chain transaction, the cross-chain is safe; after the timeV time, the relay has updated the first blockchain, at which point the set of verification nodes is consistent or nearly consistent, so it is still secure across the chain. If the relay update times out, at which point the set of authentication nodes of the first blockchain may be inconsistent with the latest set of authentication nodes of the second blockchain (the inconsistent ratio of authentication nodes is at least greater than 1/3), then there may be a security problem. At the moment, the first block chain suspends the cross-chain transaction in time, so that the safety problem is avoided. After the operator of the first blockchain re-initially synchronizes the latest verification node set of the second blockchain, the verification node sets are kept consistent, and chain crossing can be safely continued.
According to the technical scheme, after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, the first block chain starts a timer; in the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain; if the synchronization is successful, the first block chain restarts the timer; if the synchronization fails, the relay re-executes the synchronization operation; if the timer times out, the first blockchain suspends cross-chain transactions, waiting for synchronization. Therefore, the trust of the relay is decoupled, the effective synchronization of the verification node set is realized through the timer in the block chain and the condition of the updating synchronization mechanism, and the safety of the cross-chain is ensured.
Example two
Fig. 2 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. Referring to fig. 2, at a hardware level, the electronic device includes a processor, and optionally further includes 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, such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (peripheral component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 2, but this does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form the shared resource access control device on the logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, starting a timer by the first block chain;
within the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain;
if the synchronization is successful, the first block chain restarts a timer;
if the synchronization fails, the relay re-executes the synchronization operation;
if the timer times out, the first blockchain suspends cross-chain transactions and waits for synchronization.
The synchronization method for verifying node sets disclosed in the embodiment of fig. 1 in this specification can be applied to or implemented by a 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 instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various 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 a hardware decoding processor, or in a combination of hardware and software modules in the decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The electronic device may further execute the method in fig. 1, and implement the functions of the synchronization system for verifying a node set in the embodiment shown in fig. 1, which are not described herein again in this specification.
Of course, besides the software implementation, the electronic device of the embodiment of the present disclosure does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
According to the technical scheme, after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, the first block chain starts a timer; in the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain; if the synchronization is successful, the first block chain restarts the timer; if the synchronization fails, the relay re-executes the synchronization operation; if the timer times out, the first blockchain suspends cross-chain transactions, waiting for synchronization. Therefore, the trust of the relay is decoupled, the effective synchronization of the verification node set is realized through the timer in the block chain and the condition of the updating synchronization mechanism, and the safety of the cross-chain is ensured.
EXAMPLE III
Embodiments of the present specification also propose a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, are capable of causing the portable electronic device to perform the method of the embodiment shown in fig. 1, and in particular for performing the method of:
after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, starting a timer by the first block chain;
within the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain;
if the synchronization is successful, the first block chain restarts a timer;
if the synchronization fails, the relay re-executes the synchronization operation;
if the timer times out, the first blockchain suspends cross-chain transactions and waits for synchronization.
According to the technical scheme, after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, the first block chain starts a timer; in the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain; if the synchronization is successful, the first block chain restarts the timer; if the synchronization fails, the relay re-executes the synchronization operation; if the timer times out, the first blockchain suspends cross-chain transactions, waiting for synchronization. Therefore, the trust of the relay is decoupled, the effective synchronization of the verification node set is realized through the timer in the block chain and the condition of the updating synchronization mechanism, and the safety of the cross-chain is ensured.
Example four
Fig. 3 is a schematic structural diagram of a synchronization system 300 for verifying a node set according to an embodiment of the present disclosure. Referring to FIG. 3, in one software implementation, a system 300 for verifying synchronization of a set of nodes may include: a first blockchain 302, a second blockchain 304, and a relay 306; wherein,
the first blockchain 302 is configured to start a timer after the first blockchain 302 initially synchronizes the verification node set of the latest block of the second blockchain 304;
the relay 306 is configured to synchronize the set of verification nodes of the current latest block of the second blockchain 304 to the first blockchain 302 within the timing period of the timer;
the first blockchain 302 is further configured to restart a timer if the synchronization is successful;
the relay 306 is further configured to re-execute the synchronization operation if the synchronization fails;
the first blockchain 302 is further configured to suspend a cross-chain transaction and wait for synchronization if the timer expires.
Optionally, the first blockchain 302, when initially synchronizing the verification node set of the latest block of the second blockchain 304, is specifically configured to: recording a set of verification nodes of the latest block of the second block chain acquired by an own operator.
In a specific implementation manner of the embodiment of this specification, when synchronizing the set of verification nodes adjacent to the latest block of the second blockchain 304 to the first blockchain 302, the relay 306 is specifically configured to: synchronizing the transaction corresponding to the verification node set change in the second blockchain to the first blockchain; and synchronizing the updated set of verification nodes in the second blockchain to the first blockchain.
In another specific implementation manner of the embodiment of the present specification, the conditions met by successful synchronization include:
the absolute value of the difference between a first timestamp of the current latest block in the first block chain when generated and a second timestamp of the current latest block in the second block chain when generated is not more than a time threshold;
and the hash value corresponding to the verification node set recorded in the first block chain is equal to the hash value recorded in the block head of the second block chain synchronized to the first block chain.
In another particular implementation of the embodiments of the present description, the time threshold is not greater than a difference between the first time period and the second time period;
the first time period is a time period from the time when a node serving as a verification node in the first block chain is replaced to the time when the node competitively selects the verification node, and the payment is refunded;
the second time period is a timing time period of a timer in the second blockchain.
According to the technical scheme, after the first block chain initially synchronizes the verification node set of the latest block of the second block chain, the first block chain starts a timer; in the timing time period of the timer, the relay synchronizes the verification node set of the current latest block of the second block chain to the first block chain; if the synchronization is successful, the first block chain restarts the timer; if the synchronization fails, the relay re-executes the synchronization operation; if the timer times out, the first blockchain suspends cross-chain transactions, waiting for synchronization. Therefore, the trust of the relay is decoupled, the effective synchronization of the verification node set is realized through the timer in the block chain and the condition of the updating synchronization mechanism, and the safety of the cross-chain is ensured.
It should be understood that the synchronization system for verifying a node set according to the embodiment of the present disclosure may also perform the method performed by the apparatus (or device) for packaging a transaction in fig. 1, and implement the functions of the synchronization system for verifying a node set according to the embodiment shown in fig. 1, which are not described herein again.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present specification shall be included in the protection scope of the present specification.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, 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 computer storage media 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 that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
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 an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.