WO2023024821A1 - Data processing method, system and apparatus, computer device, and storage medium - Google Patents

Data processing method, system and apparatus, computer device, and storage medium Download PDF

Info

Publication number
WO2023024821A1
WO2023024821A1 PCT/CN2022/108710 CN2022108710W WO2023024821A1 WO 2023024821 A1 WO2023024821 A1 WO 2023024821A1 CN 2022108710 W CN2022108710 W CN 2022108710W WO 2023024821 A1 WO2023024821 A1 WO 2023024821A1
Authority
WO
WIPO (PCT)
Prior art keywords
node device
tee
log
node
ree
Prior art date
Application number
PCT/CN2022/108710
Other languages
French (fr)
Chinese (zh)
Inventor
张明阳
程烁
刘勋
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023024821A1 publication Critical patent/WO2023024821A1/en

Links

Images

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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The present application belongs to the technical field of blockchains, and discloses a data processing method, system and apparatus, a computer device and a storage medium. In the present method, a log is generated by means of a TEE of a node device in a blockchain system, and an REE of the node device sends the log generated by the TEE to other node devices in the blockchain system, so that the other node devices reach a consensus on the log. Since the TEE is protected by hardware and will do no harm, the purpose of using TEE to protect a consensus process can be achieved, and Byzantine faults can be prevented from occurring in the blockchain system.

Description

数据处理方法、系统、装置、计算机设备以及存储介质Data processing method, system, device, computer equipment and storage medium
本申请要求于2021年08月26日提交的申请号为202110989279.0、发明名称为“数据处理方法、系统、装置、计算机设备以及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202110989279.0 and the invention title "data processing method, system, device, computer equipment and storage medium" filed on August 26, 2021, the entire contents of which are incorporated by reference in In this application.
技术领域technical field
本申请涉及区块链技术领域,特别涉及一种数据处理方法、系统、装置、计算机设备以及存储介质。The present application relates to the technical field of blockchain, in particular to a data processing method, system, device, computer equipment and storage medium.
背景技术Background technique
区块链是分布式数据存储、点对点传输、共识机制、加密算法等计算机技术的新型应用模式,区块链凭借去中心化、去信任、集体维护、可靠数据库等特性被广泛应用在对数据安全存储有较高要求的领域。Blockchain is a new application model of computer technology such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm. Blockchain is widely used in data security due to its characteristics of decentralization, trustlessness, collective maintenance, and reliable database. Areas with high storage requirements.
区块链系统中的共识节点可以通过共识协议对区块进行共识,并将共识通过的区块存储在区块链上。目前的共识协议包括崩溃容错协议(crash fault tolerant,CFT)类共识协议,例如Paxos共识算法和Raft共识算法。CFT类共识协议能够解决由网络故障或节点崩溃所导致的节点消息延时、丢失、重复等问题,因此,在采用CFT类共识协议的区块链系统中,即使部分节点出现网络故障或者节点崩溃,依然能够保证区块链系统的正常运行。The consensus nodes in the blockchain system can agree on the blocks through the consensus protocol, and store the blocks passed by the consensus on the blockchain. Current consensus protocols include crash fault tolerant (crash fault tolerant, CFT) consensus protocols, such as the Paxos consensus algorithm and the Raft consensus algorithm. The CFT consensus protocol can solve the problems of node message delay, loss and repetition caused by network failure or node crash. Therefore, in the blockchain system using the CFT consensus protocol, even if some nodes experience network failure or node crash , can still guarantee the normal operation of the blockchain system.
但是,CFT类共识协议无法解决拜占庭错误(Byzantine fault),例如伪造节点消息、篡改节点消息或恶意响应等错误行为。而拜占庭错误可能会引发区块链系统出现共识错误,区块链系统无法正常工作等情况,因此,亟需一种能够减少区块链系统出现拜占庭错误的数据处理方法。However, CFT consensus protocols cannot solve Byzantine faults, such as false behaviors such as falsifying node messages, tampering with node messages, or malicious responses. Byzantine errors may cause consensus errors in the blockchain system, and the blockchain system cannot work normally. Therefore, there is an urgent need for a data processing method that can reduce Byzantine errors in the blockchain system.
发明内容Contents of the invention
本申请实施例提供了一种数据处理方法、系统、装置、计算机设备以及存储介质,能够减少了区块链系统中出现的拜占庭错误。该技术方案如下:Embodiments of the present application provide a data processing method, system, device, computer equipment, and storage medium, which can reduce Byzantine errors in a blockchain system. The technical solution is as follows:
第一方面,提供了一种数据处理方法,所述方法由区块链系统中的第一节点设备执行,所述第一节点设备包括可信执行环境TEE和富执行环境REE;所述方法包括:In a first aspect, a data processing method is provided, the method is executed by a first node device in a blockchain system, and the first node device includes a Trusted Execution Environment TEE and a Rich Execution Environment REE; the method includes :
所述TEE基于所述REE中的区块,生成所述区块的日志,向所述REE发送所述日志,所述日志中以所述区块的标识指代所述区块;The TEE generates a log of the block based on the block in the REE, and sends the log to the REE, wherein the block is referred to by the block identifier in the log;
所述REE接收所述日志,向所述区块链系统中的第二节点设备发送第一请求,所述第一请求携带所述日志,所述第一请求指示所述第二节点设备处理所述日志。The REE receives the log, sends a first request to the second node device in the blockchain system, the first request carries the log, and the first request instructs the second node device to process the log.
其中,所述日志包括所述区块的标识,但不包括所述区块,并以所述区块的标识指代所述区块,例如,所述区块的标识包括所述区块的哈希值和所述区块的区块号中的至少一个,当然,该日志的标识也可以是除区块的哈希值或者区块号以外的其他表示方式,在此本申请对该日志的标识不做限定。Wherein, the log includes the identification of the block, but does not include the block, and refers to the block with the identification of the block, for example, the identification of the block includes the identification of the block At least one of the hash value and the block number of the block. Of course, the logo of the log can also be expressed in other ways than the hash value of the block or the block number. Herein, the application for the log The logo of is not limited.
由于本申请中的日志以区块的标识指代该区块,因此,本申请中的日志不包括该区块。而相关技术中的日志没有采用区块的标识来指代日志,而是直接将区块添加在日志中,也即是相关技术中的日志包括区块。或者也可以理解为,本申请将相关技术中日志内的区块用成区块的标识来替代。而区块的标识相对于整个区块来而言数据量会更小,因此,与相关技术中的日志相比,本申请中的日志的数据量更小。Since the log in the present application refers to the block with the identifier of the block, the log in the present application does not include the block. However, the log in the related art does not use the identifier of the block to refer to the log, but directly adds the block to the log, that is, the log in the related art includes the block. Or it can also be understood that the present application replaces the blocks in the log in the related art with block identifiers. Compared with the whole block, the identification of the block will have a smaller data volume. Therefore, compared with the log in the related art, the data volume of the log in the present application is smaller.
本方法通过区块链系统中节点设备的TEE生成日志,该节点设备的REE向区块链系统中的其他节点设备发送该TEE所生成的日志,以便其他节点设备对该日志进行共识。由于TEE受硬件的保护,不会作恶,因此,能够实现使用TEE保护共识流程目的,能够防止区块链系统中出现拜占庭错误。并且,日志中以区块的标识来指代区块,日志无须携带区块,从而降低了日志的数据量。This method generates a log through the TEE of the node device in the blockchain system, and the REE of the node device sends the log generated by the TEE to other node devices in the blockchain system, so that other node devices can reach a consensus on the log. Since TEE is protected by hardware and will not do evil, it can achieve the purpose of using TEE to protect the consensus process and prevent Byzantine errors in the blockchain system. Moreover, the block is referred to by the block identifier in the log, and the log does not need to carry the block, thereby reducing the data volume of the log.
在一种可能的实现方式中,所述第一请求还携带所述区块,所述第一请求指示所述第二节点设备处理所述日志以及所述区块;所述向所述区块链系统中的第二节点设备发送第一请求之后,所述方法还包括:In a possible implementation manner, the first request also carries the block, and the first request instructs the second node device to process the log and the block; After the second node device in the chain system sends the first request, the method further includes:
所述TEE通过所述REE接收多个第一响应,每个第一响应指示一个第二节点设备是否已经同意接收所述日志;The TEE receives a plurality of first responses through the REE, each first response indicating whether a second node device has agreed to receive the log;
在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,所述TEE基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , the TEE notifies the REE to submit the block to the local blockchain ledger of the blockchain system based on the identification of the block in the log.
在一种可能的实现方式中,所述TEE基于所述REE中的区块,生成日志之前,所述方法还包括:In a possible implementation, the TEE is based on blocks in the REE, and before generating a log, the method further includes:
所述TEE通过所述REE向所述区块链系统中的第二节点设备发送第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;The TEE sends a second request to the second node device in the blockchain system through the REE, and the second request indicates that the first node device becomes the leader node in the blockchain system. vote;
所述TEE通过所述REE接收多个第二响应,每个第二响应指示一个第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点;The TEE receives a plurality of second responses through the REE, and each second response indicates whether a second node device agrees with the first node device to become the leader node in the blockchain system;
在所述区块链系统中半数或多数第二节点设备的第二响应通过了所述TEE的验证,且通过验证的每个所述第二响应指示一个第二节点设备赞同所述第一节点设备成为所述区块链系统中的领导节点的情况下,所述TEE将所述第一节点设备的节点状态切换为领导状态。In the blockchain system, half or most of the second responses of the second node devices have passed the verification of the TEE, and each of the verified second responses indicates that a second node device agrees with the first node When the device becomes the leader node in the blockchain system, the TEE switches the node status of the first node device to the leader status.
在一种可能的实现方式中,所述TEE将所述第一节点设备的节点状态切换为领导状态之后,所述方法还包括:In a possible implementation manner, after the TEE switches the node state of the first node device to the leader state, the method further includes:
所述TEE生成通知消息,所述通知消息指示所述第一节点设备为所述区块链系统中的领导节点;The TEE generates a notification message, and the notification message indicates that the first node device is a leader node in the blockchain system;
所述TEE通过所述REE向所述区块链系统中的第二节点设备发送所述通知消息。The TEE sends the notification message to the second node device in the blockchain system through the REE.
在一种可能的实现方式中,所述通知消息可以是心跳消息或者其他类型的消息。In a possible implementation manner, the notification message may be a heartbeat message or other types of messages.
在一种可能的实现方式中,所述方法还包括:In a possible implementation, the method further includes:
在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,所述TEE通过所述REE向所述区块链系统中的第二节点设备发送第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , the TEE sends a third request to the second node device in the blockchain system through the REE, and the third request instructs the second node device to submit the block to the local The blockchain ledger of the blockchain system.
在一种可能的实现方式中,所述第三请求可以是心跳消息或者其他类型的消息。In a possible implementation manner, the third request may be a heartbeat message or other types of messages.
在一种可能的实现方式中,所述方法还包括:In a possible implementation, the method further includes:
所述TEE对日志序列中已提交的多个日志进行截断,得到所述日志序列的快照,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识;The TEE truncates multiple logs submitted in the log sequence to obtain a snapshot of the log sequence, and the snapshot includes a first identifier and a second identifier, wherein the first identifier is the An identifier of the block corresponding to the start log, the second identifier being the identifier of the block corresponding to the termination log in the plurality of logs;
所述TEE向所述REE发送所述快照;the TEE sends the snapshot to the REE;
所述REE接收所述快照,基于所述快照中的所述第一标识和所述第二标识,从本地的所述区块链系统的区块链账本中获取所述多个日志所对应的多个区块,向所述区块链系统中的第二节点设备发送第四请求,所述第四请求携带所述快照以及所述多个区块,所述第四请求指示所述第二节点设备基于所述快照将所述多个区块提交至本地的所述区块链账本。The REE receives the snapshot, and based on the first identifier and the second identifier in the snapshot, obtains the corresponding logs from the local blockchain ledger of the blockchain system. A plurality of blocks, sending a fourth request to the second node device in the blockchain system, the fourth request carries the snapshot and the plurality of blocks, the fourth request indicates that the second The node device submits the multiple blocks to the local blockchain ledger based on the snapshot.
其中,所述日志序列中的每个日志包括一个区块的标识以及一个日志的索引,该日志序列中的各个日志按照索引从小到大的顺序依次排列。可选地,每个日志还包括区块链系统中领导节点的任期。Wherein, each log in the log sequence includes an identifier of a block and an index of a log, and the logs in the log sequence are arranged in descending order of the index. Optionally, each log also includes the tenure of the leader node in the blockchain system.
在一种可能的实现方式中,所述第四请求可以是心跳消息或者其他类型的消息。In a possible implementation manner, the fourth request may be a heartbeat message or other types of messages.
第二方面,提供了一种数据处理方法,所述方法由区块链系统中的第二节点设备执行,所述第二节点设备包括可信执行环境TEE和富执行环境REE;所述方法包括:In a second aspect, a data processing method is provided, the method is executed by a second node device in a blockchain system, and the second node device includes a trusted execution environment TEE and a rich execution environment REE; the method includes :
所述REE接收来自所述区块链系统中第一节点设备的第一请求,所述第一请求携带区块的日志,所述日志中以所述区块的标识指代所述区块,所述第一请求指示所述第二节点设备处理所述日志;The REE receives a first request from a first node device in the blockchain system, the first request carries a log of a block, and the block is referred to by the identifier of the block in the log, The first request instructs the second node device to process the log;
所述REE向所述TEE发送所述日志;the REE sends the log to the TEE;
在所述日志通过了所述TEE的验证的情况下,所述TEE存储所述日志,通过所述REE向所述第一节点设备发送第一响应,所述第一响应指示所述第二节点设备已经同意接收所述日志。If the log has passed the verification of the TEE, the TEE stores the log, and sends a first response to the first node device through the REE, and the first response indicates that the second node The device has agreed to receive said logs.
在一种可能的实现方式中,所述第一请求还携带所述区块,所述REE接收来自所述区块链系统中第一节点设备的第一请求之后,所述方法还包括:In a possible implementation, the first request also carries the block, and after the REE receives the first request from the first node device in the blockchain system, the method further includes:
所述REE缓存所述区块;the REE caches the blocks;
所述通过所述REE向所述第一节点设备发送第一响应之后,所述方法还包括:After sending the first response to the first node device through the REE, the method further includes:
所述TEE通过所述REE接收来自所述第一节点设备的第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本;The TEE receives a third request from the first node device through the REE, and the third request instructs the second node device to submit the block to the block of the local block chain system Chain ledger;
在所述第三请求通过了所述TEE的验证的情况下,所述TEE基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本上。In the case that the third request passes the verification of the TEE, the TEE notifies the REE to submit the block to the local blockchain based on the identification of the block in the log on the blockchain ledger of the system.
在一种可能的实现方式中,所述REE接收来自所述区块链系统中第一节点设备的第一请求之前,所述方法还包括:In a possible implementation, before the REE receives the first request from the first node device in the blockchain system, the method further includes:
所述TEE通过所述REE接收来自所述第一节点设备的第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;The TEE receives a second request from the first node device through the REE, and the second request indicates to vote for the first node device to become the leader node in the blockchain system;
在所述第二请求通过了所述TEE的验证的情况下,所述TEE通过所述REE向所述第一节点设备发送第二响应,所述第二响应指示所述第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点。If the second request is verified by the TEE, the TEE sends a second response to the first node device through the REE, and the second response indicates whether the second node device agrees to The first node device becomes a leader node in the blockchain system.
在一种可能的实现方式中,所述TEE通过所述REE向所述第一节点设备发送第二响应 之后,所述方法还包括:In a possible implementation manner, after the TEE sends the second response to the first node device through the REE, the method further includes:
所述TEE通过所述REE接收来自所述第一节点设备的通知消息,所述通知消息指示所述第一节点设备成为所述区块链系统中的领导节点;The TEE receives a notification message from the first node device through the REE, and the notification message instructs the first node device to become a leader node in the blockchain system;
在所述通知消息通过了所述TEE的验证的情况下,所述TEE将存储的所述第一节点设备的节点状态修改为领导状态。If the notification message passes the verification of the TEE, the TEE modifies the stored node status of the first node device to a leader status.
在一种可能的实现方式中,所述方法还包括:In a possible implementation, the method further includes:
所述REE接收来自所述第一节点设备的第四请求,所述第四请求携带所述第一节点设备中日志序列的快照以及多个区块,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述日志序列中已提交的多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识,所述多个日志与所述多个区块对应;The REE receives a fourth request from the first node device, the fourth request carries a snapshot of the log sequence in the first node device and a plurality of blocks, and the snapshot includes a first identifier and a second identifier , wherein the first identifier is the identifier of the block corresponding to the start log among the multiple logs submitted in the log sequence, and the second identifier is the block corresponding to the end log among the multiple logs an identification of a block, the plurality of logs corresponding to the plurality of blocks;
所述REE缓存所述多个区块,向所述TEE发送所述快照;The REE caches the plurality of blocks, and sends the snapshot to the TEE;
所述TEE接收所述快照,在所述快照通过了所述TEE的验证的情况下,通知所述REE将所述多个区块提交至本地的所述区块链系统的区块链账本。The TEE receives the snapshot, and if the snapshot passes the verification of the TEE, notifies the REE to submit the multiple blocks to the local blockchain ledger of the blockchain system.
第三方面,提供了一种用于数据处理的区块链系统,所述区块链系统包括第一节点设备以及至少一个第二节点设备;In a third aspect, a blockchain system for data processing is provided, the blockchain system includes a first node device and at least one second node device;
所述第一节点设备,用于向所述区块链系统中的第二节点设备发送第一请求,所述第一请求携带区块的日志,所述日志中以所述区块的标识指代所述区块,所述第一请求指示所述第二节点设备处理所述日志;The first node device is configured to send a first request to a second node device in the blockchain system, the first request carries a log of a block, and the log is indicated by the identifier of the block On behalf of the block, the first request instructs the second node device to process the log;
每个第二节点设备,用于接收所述第一请求,若所述日志通过了所述第二节点设备验证的情况下,存储所述日志。Each second node device is configured to receive the first request, and store the log if the log is verified by the second node device.
在一种可能的实现方式中,所述第一节点设备包括可信执行环境TEE和富执行环境REE;In a possible implementation manner, the first node device includes a Trusted Execution Environment TEE and a Rich Execution Environment REE;
所述TEE,用于基于所述REE中的所述区块,生成所述日志,向所述REE发送所述日志;The TEE is configured to generate the log based on the block in the REE, and send the log to the REE;
所述REE,用于接收所述日志,向所述区块链系统中的第二节点设备发送所述第一请求。The REE is configured to receive the log, and send the first request to the second node device in the blockchain system.
在一种可能的实现方式中,每个第二节点设备包括TEE和REE;In a possible implementation manner, each second node device includes a TEE and a REE;
每个第二节点设备的REE,用于接收来所述第一请求,向所属第二节点设备的TEE发送所述第一请求携带的所述日志;The REE of each second node device is configured to receive the first request, and send the log carried in the first request to the TEE of the second node device to which it belongs;
每个第二节点设备的TEE,用于接收所述第一请求,在所述日志通过了所述TEE的验证的情况下,存储所述日志,通过所属第二节点设备的REE向所述第一节点设备发送第一响应,所述第一响应指示一个第二节点设备是否已经同意接收所述日志。The TEE of each second node device is configured to receive the first request, store the log when the log has passed the verification of the TEE, and send the log to the second node device through the REE of the second node device. A node device sends a first response, the first response indicating whether a second node device has agreed to receive the log.
在一种可能的实现方式中,所述第一节点设备包括TEE和REE;In a possible implementation manner, the first node device includes TEE and REE;
所述第一节点设备的TEE,用于通过所述第一节点设备的REE接收所述区块链系统中第二节点设备的所述第一响应,在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经存储所述日志的情况下,基于所述日志中所述区块的标识,通知所述第一节点设备的REE将所述区块提交至本地的所述区块链系统的区块链账本。The TEE of the first node device is used to receive the first response of the second node device in the blockchain system through the REE of the first node device, and half or a majority of them in the blockchain system If the first response of the second node device has passed the verification of the TEE, and each of the first responses passed the verification indicates that a second node device has stored the log, based on the area in the log block identification, and notify the REE of the first node device to submit the block to the local blockchain ledger of the blockchain system.
在一种可能的实现方式中,所述第一请求还携带所述区块;In a possible implementation manner, the first request also carries the block;
所述第一节点设备的TEE,还用于通过所属节点设备的REE向所述区块链系统中的第二节点设备发送第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述 区块链系统的区块链账本;The TEE of the first node device is also used to send a third request to the second node device in the blockchain system through the REE of the node device to which it belongs, and the third request instructs the second node device to send the Submit the block to the local block chain ledger of the block chain system;
每个第二节点设备的REE,还用于缓存所述第一请求携带的所述区块,接收所述第三请求,向所属第二节点设备的TEE发送所述第三请求;The REE of each second node device is also used to cache the block carried in the first request, receive the third request, and send the third request to the TEE of the second node device;
每个第二节点设备的TEE,还用于接收所述第三请求,在所述第三请求通过了所述TEE的验证的情况下,基于所述日志中所述区块的标识,通知所属第二节点设备的REE将所述区块提交至本地的所述区块链系统的区块链账本上。The TEE of each second node device is also used to receive the third request, and if the third request passes the verification of the TEE, based on the identifier of the block in the log, notify the owner The REE of the second node device submits the block to the local blockchain ledger of the blockchain system.
在一种可能的实现方式中,所述第一节点设备以及所述至少一个第二节点设备中的每个节点设备包括TEE以及REE;In a possible implementation manner, each node device in the first node device and the at least one second node device includes a TEE and a REE;
所述第一节点设备的TEE,用于所属节点设备的TEE向所述区块链系统中的第二节点设备发送第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;The TEE of the first node device is used for the TEE of the node device to which it belongs to send a second request to the second node device in the blockchain system, and the second request indicates that the first node device becomes the The leader nodes in the blockchain system vote;
每个第二节点设备的TEE,用于接收所述第二请求,在所述第二请求通过了所述TEE的验证的情况下,通过所属节点设备的REE向所述第一节点设备发送第二响应,每个第二响应指示一个第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点;The TEE of each second node device is configured to receive the second request, and when the second request passes the verification of the TEE, send the second request to the first node device through the REE of the associated node device. Two responses, each second response indicates whether a second node device agrees with the first node device to become the leader node in the blockchain system;
所述第一节点设备的TEE,还用于通过所属节点设备的REE接收所述区块链系统中第二节点设备对所述第二请求的第二响应,在所述区块链系统中半数或多数第二节点设备的第二响应通过了所述TEE的验证,且通过验证的每个所述第二响应指示一个第二节点设备赞同所述第一节点设备成为所述区块链系统中的领导节点的情况下,将所述第一节点设备的节点状态切换为领导状态。The TEE of the first node device is also used to receive the second response of the second node device in the blockchain system to the second request through the REE of the node device to which it belongs. In the blockchain system, half of the Or the second response of most of the second node devices has passed the verification of the TEE, and each of the second responses that pass the verification indicates that a second node device agrees that the first node device becomes a member of the block chain system. In the case of the leader node, switch the node state of the first node device to the leader state.
在一种可能的实现方式中,所述第一节点设备的TEE,还用于生成通知消息,通过所属节点设备的REE向所述区块链系统中的第二节点设备发送所述通知消息,所述通知消息指示所述第一节点设备为所述区块链系统中的领导节点;In a possible implementation manner, the TEE of the first node device is also used to generate a notification message, and send the notification message to the second node device in the blockchain system through the REE of the node device to which it belongs, The notification message indicates that the first node device is a leader node in the blockchain system;
每个第二节点设备的TEE,还用于通过所属节点设备的REE接收所述通知消息,在所述通知消息通过了所述TEE的验证的情况下,将存储的所述第一节点设备的节点状态修改为领导状态。The TEE of each second node device is also used to receive the notification message through the REE of the node device to which it belongs, and when the notification message passes the verification of the TEE, the stored first node device The node status is changed to leader status.
在一种可能的实现方式中,所述第一节点设备包括TEE以及REE;In a possible implementation manner, the first node device includes TEE and REE;
所述TEE,用于对日志序列中已提交的多个日志进行截断,得到所述日志序列的快照,向所述REE发送所述快照,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识;The TEE is configured to truncate multiple logs submitted in the log sequence, obtain a snapshot of the log sequence, and send the snapshot to the REE, the snapshot includes a first identifier and a second identifier, wherein, The first identification is the identification of the block corresponding to the start log in the plurality of logs, and the second identification is the identification of the block corresponding to the termination log in the plurality of logs;
所述REE,用于接收所述快照,基于所述快照中的所述第一标识和所述第二标识,从本地的所述区块链系统的区块链账本中获取所述多个日志所对应的多个区块,向所述区块链系统中的第二节点设备发送第四请求,所述快照包括当前时刻所述区块链账本中第一个区块的标识以及最后一个区块的标识,所述第四请求携带所述快照以及所述多个区块,所述第四请求指示所述第二节点设备将所述多个区块提交至本地的所述区块链账本。The REE is configured to receive the snapshot, and based on the first identifier and the second identifier in the snapshot, obtain the plurality of logs from the local blockchain ledger of the blockchain system For multiple corresponding blocks, send a fourth request to the second node device in the blockchain system, and the snapshot includes the identification of the first block in the blockchain account book at the current moment and the last block block identification, the fourth request carries the snapshot and the plurality of blocks, and the fourth request instructs the second node device to submit the plurality of blocks to the local blockchain ledger .
在一种可能的实现方式中,每个第二节点设备包括TEE以及REE;In a possible implementation manner, each second node device includes a TEE and a REE;
每个第二节点设备的REE,用于接收来自所述第一节点设备的所述第四请求,缓存所述多个区块,向所述TEE发送所述快照;The REE of each second node device is configured to receive the fourth request from the first node device, cache the plurality of blocks, and send the snapshot to the TEE;
每个第二节点设备的TEE,用于接收所述快照,在所述快照通过了所述TEE的验证的情 况下,通知所属第二节点设备的REE基于所述快照将所述多个区块提交至本地的所述区块链系统的区块链账本。The TEE of each second node device is used to receive the snapshot, and when the snapshot passes the verification of the TEE, notify the REE of the second node device to transfer the multiple blocks based on the snapshot Submit to the blockchain ledger of the local blockchain system.
第四方面,提供了一种数据处理装置,用于执行上述数据处理方法。具体地,该数据处理装置包括用于执行上述第一方面或上述第一方面的任一种可选方式提供的数据处理方法的功能模块。In a fourth aspect, a data processing device is provided, configured to execute the above data processing method. Specifically, the data processing apparatus includes a functional module configured to execute the data processing method provided in the above first aspect or any optional manner of the above first aspect.
第五方面,提供了一种数据处理装置,用于执行上述数据处理方法。具体地,该数据处理装置包括用于执行上述第二方面或上述第二方面的任一种可选方式提供的数据处理方法的功能模块。In a fifth aspect, a data processing device is provided, configured to execute the above data processing method. Specifically, the data processing apparatus includes a functional module for executing the data processing method provided in the second aspect above or in any optional manner of the second aspect above.
第六方面,提供一种计算机设备,该计算机设备包括可信执行环境TEE,该TEE包括处理器,所述处理器用于执行程序代码,使得计算机设备执行以实现如上述数据处理方法所执行的操作。According to a sixth aspect, there is provided a computer device, the computer device includes a trusted execution environment TEE, and the TEE includes a processor, the processor is used to execute program codes, so that the computer device executes to realize the operations performed by the above-mentioned data processing method .
第七方面,提供一种计算机可读存储介质,该存储介质中存储有至少一条程序代码,该程序代码由可信执行环境TEE中的处理器读取以使计算机设备执行如上述数据处理方法所执行的操作。In a seventh aspect, a computer-readable storage medium is provided, in which at least one piece of program code is stored, and the program code is read by a processor in the trusted execution environment TEE so that the computer device executes the above-mentioned data processing method. The action to perform.
第八方面,提供了一种计算机程序产品,该计算机程序产品包括程序代码,该程序代码存储在计算机可读存储介质中,计算机设备的可信执行环境TEE中的处理器从计算机可读存储介质读取该程序代码,处理器执行该程序代码,使得该计算机设备执行上述第一方面或者第一方面的各种可选实现方式中提供的方法,或者该计算机设备执行上述第二方面或者第二方面的各种可选实现方式中提供的方法。In an eighth aspect, a computer program product is provided, the computer program product includes program code, the program code is stored in a computer-readable storage medium, and the processor in the trusted execution environment TEE of the computer device reads the program code from the computer-readable storage medium The program code is read, and the processor executes the program code, so that the computer device executes the method provided in the above-mentioned first aspect or various optional implementation manners of the first aspect, or the computer device executes the above-mentioned second aspect or the second aspect. Methods provided in various alternative implementations of the aspect.
附图说明Description of drawings
图1是本申请实施例提供的一种区块链系统的示意图;Fig. 1 is a schematic diagram of a block chain system provided by the embodiment of the present application;
图2是本申请实施例提供的一种Raft共识算法中共识节点设备的角色转换示意图;FIG. 2 is a schematic diagram of role switching of consensus node devices in a Raft consensus algorithm provided by an embodiment of the present application;
图3是本申请实施例提供的一种基于TEE实现Raft共识算法的共识集群示意图;FIG. 3 is a schematic diagram of a consensus cluster that implements the Raft consensus algorithm based on TEE provided by the embodiment of the present application;
图4是本申请实施例提供的一种基于TEE实现Raft共识算法的共识节点设备的示意图;Fig. 4 is a schematic diagram of a consensus node device implementing the Raft consensus algorithm based on TEE provided by the embodiment of the present application;
图5是本申请实施例提供的一种领导节点选举方法的流程图;FIG. 5 is a flow chart of a method for electing a leader node provided in an embodiment of the present application;
图6是本申请实施例提供的一种领导节点选举流程的示意图;FIG. 6 is a schematic diagram of a leader node election process provided by an embodiment of the present application;
图7是本申请实施例提供的一种数据处理方法的流程图;FIG. 7 is a flow chart of a data processing method provided by an embodiment of the present application;
图8是本申请实施例提供的一种不同第三消息的数据量对比示意图;Fig. 8 is a schematic diagram of a data volume comparison of a different third message provided by the embodiment of the present application;
图9是本申请实施例提供的一种第一请求与相关技术中的日志复制请求的对比示意图;FIG. 9 is a schematic diagram of a comparison between a first request provided by an embodiment of the present application and a log copy request in the related art;
图10是本申请实施例提供的一种区块共识过程的示意图;Figure 10 is a schematic diagram of a block consensus process provided by the embodiment of the present application;
图11是本申请实施例提供的一种区块存储的示意图;Fig. 11 is a schematic diagram of a block storage provided by an embodiment of the present application;
图12是本申请实施例提供的一种共识集群中数据处理过程的示意图;FIG. 12 is a schematic diagram of a data processing process in a consensus cluster provided by an embodiment of the present application;
图13是本申请实施例提供的一种日志压缩方法的流程图;FIG. 13 is a flow chart of a log compression method provided by an embodiment of the present application;
图14是本申请实施例提供的一种快照对比的示意图的流程图;Fig. 14 is a flowchart of a schematic diagram of snapshot comparison provided by the embodiment of the present application;
图15是本申请实施例提供的一种数据处理装置的结构示意图;Fig. 15 is a schematic structural diagram of a data processing device provided by an embodiment of the present application;
图16是本申请实施例提供的一种数据处理装置的结构示意图;FIG. 16 is a schematic structural diagram of a data processing device provided by an embodiment of the present application;
图17是本申请实施例提供的一种计算机设备的结构示意图。Fig. 17 is a schematic structural diagram of a computer device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the purpose, technical solution and advantages of the present application clearer, the implementation manners of the present application will be further described in detail below in conjunction with the accompanying drawings.
图1是本申请实施例提供的一种区块链系统的示意图,参见图1,区块链系统100包括多个节点设备101,该多个节点设备101中的全部或部分节点设备为该区块链系统100中的共识节点设备,区块链系统100中的共识节点设备所组成的集群可以记为共识集群。其中,共识节点设备具有生成区块(Block),并在共识集群中广播区块的功能,以便共识集群中的各个共识节点设备基于共识协议,对该区块进行共识。若共识集群中多数共识节点设备对该区块共识通过,则共识集群中的各个共识节点设备将该区块存储至在本地的该区块链系统100的区块链(Blockchain)账本上,从而该共识集群中的各个共识节点设备存储的区块链账本均相同,达到共识集群维护同一区块链账本的目的。当然,该共识集群也可以按照维护一个区块链账本的方式,同时维护多个区块链账本。Fig. 1 is a schematic diagram of a block chain system provided by the embodiment of the present application. Referring to Fig. 1, the block chain system 100 includes a plurality of node devices 101, and all or part of the node devices in the plurality of node devices 101 are The consensus node devices in the block chain system 100, and the clusters formed by the consensus node devices in the block chain system 100 can be recorded as consensus clusters. Among them, the consensus node device has the function of generating a block (Block) and broadcasting the block in the consensus cluster, so that each consensus node device in the consensus cluster can agree on the block based on the consensus protocol. If most of the consensus node devices in the consensus cluster pass the consensus on the block, each consensus node device in the consensus cluster will store the block on the blockchain (Blockchain) ledger of the local blockchain system 100, thereby Each consensus node device in the consensus cluster stores the same blockchain ledger, achieving the purpose of the consensus cluster maintaining the same blockchain ledger. Of course, the consensus cluster can also maintain multiple blockchain ledgers at the same time in the same way as maintaining one blockchain ledger.
其中,共识协议包括CFT类共识协议,CFT类协议最早有Paxos算法。由于Paxos算法可理解性差,后续由Paxos算法衍生出许多其他CFT类协议。其中,比较有代表性的其他CFT类协议例如Raft共识算法,Raft共识算法对Paxos算法进行了简化设计和流程优化,使其更易理解和实现,更易在实际系统中应用。Among them, the consensus protocol includes the CFT consensus protocol, and the CFT protocol first has the Paxos algorithm. Due to the poor comprehensibility of the Paxos algorithm, many other CFT protocols were subsequently derived from the Paxos algorithm. Among them, other representative CFT protocols such as the Raft consensus algorithm, the Raft consensus algorithm simplifies the design and process optimization of the Paxos algorithm, making it easier to understand and implement, and easier to apply in actual systems.
在Raft共识算法中,共识集群中的共识节点设备可以具有三种角色,分别为领导者(leader)、候选者(candidate)、跟随者(follower),其中,共识节点设备的角色也可以理解为节点状态。这3种角色之间可以相互转换,在此结合图2所示的本申请实施例提供的一种Raft共识算法中共识节点设备的角色转换示意图,对这3种角色进行如下介绍:In the Raft consensus algorithm, the consensus node device in the consensus cluster can have three roles, namely leader, candidate (candidate), and follower (follower). Among them, the role of the consensus node device can also be understood as Node status. These three roles can be converted to each other. In combination with the schematic diagram of the role conversion of the consensus node device in a Raft consensus algorithm provided by the embodiment of the present application shown in FIG. 2, the three roles are introduced as follows:
领导者:在区块链系统中有一个共识节点设备作为领导者,用于生成区块以及区块的日志,在共识集群中广播区块以及日志,以便共识集群中的非领导节点能够接收区块以及日志。还用于与非领导节点之间保持心跳(heart beat),以向非领导节点通知自己是区块链系统中的领导者。其中,非领导节点为区块链系统中作为跟随者或者候选者的共识节点设备。为了便于描述,将区块链系统中作为领导者的共识节点设备记为领导节点。将区块链系统中作为候选者的共识节点设备记为候选节点。将区块链系统中作为跟随者的共识节点设备记为跟随节点,也即是候选节点和跟随节点均为非领导节点。Leader: In the blockchain system, there is a consensus node device as the leader, which is used to generate blocks and block logs, and broadcast blocks and logs in the consensus cluster so that non-leader nodes in the consensus cluster can receive block blocks and logs. It is also used to maintain a heartbeat with non-leader nodes to notify non-leader nodes that they are the leader in the blockchain system. Among them, the non-leader node is a consensus node device as a follower or candidate in the blockchain system. For ease of description, the consensus node device that is the leader in the blockchain system is recorded as the leader node. Record the consensus node device as a candidate in the blockchain system as a candidate node. The consensus node device as a follower in the blockchain system is recorded as a follower node, that is, both the candidate node and the follower node are non-leader nodes.
候选者:候选者是处于跟随者与领导者之间的中间状态,候选节点用于向共识集群中的各个非领导节点发送投票请求,以请求各个非领导节点为该候选节点成为领导节点进行投票。当候选节点竞选领导者成功(或者说本次选举成功)时,则该候选节点从跟候选者转换为领导者。Candidate: A candidate is an intermediate state between the follower and the leader. The candidate node is used to send a voting request to each non-leader node in the consensus cluster to request each non-leader node to vote for the candidate node to become the leader node . When the candidate node succeeds in running for the leader (or in other words, the election is successful), the candidate node is converted from a follower candidate to a leader.
跟随者:共识集群中的任一共识节点设备在启动时均为跟随者。跟随节点用于响应领导节点的接收领导节点发送的日志以及区块,并为候选节点成为领导者进行投票。Follower: Any consensus node device in the consensus cluster is a follower at startup. The follower node is used to respond to the leader node to receive the logs and blocks sent by the leader node, and to vote for the candidate node to become the leader.
在Raft共识算法中,副本数据是以日志的形式存在的,相关技术中的日志包括区块以及一些附加信息,比如日志的索引(Log index)、任期(Term)。共识集群中的领导节点可以生成日志,并在共识集群中广播日志,以便共识集群中的各个非领导节点都能够对该日志进行共识,共识集群通过对日志进行共识,实现对日志对应的区块进行共识。而本申请描述的方案中,对日志进行了改进以配合该方案的实现。具体的,本申请中提出的方案中的日志,是不包括区块的,只以一个标识指示与该日志对应的区块,也可以理解为,用区块的标识,在 日志中代替了区块本身,因此,下文中,也表述为,日志中,以区块的标识指代与日志对应的区块。In the Raft consensus algorithm, replica data exists in the form of logs. The logs in related technologies include blocks and some additional information, such as log index (Log index) and term (Term). The leader node in the consensus cluster can generate a log and broadcast the log in the consensus cluster, so that each non-leader node in the consensus cluster can agree on the log. The consensus cluster realizes the block corresponding to the log by consensus on the log. Make a consensus. However, in the solution described in this application, the log is improved to match the realization of the solution. Specifically, the log in the scheme proposed in this application does not include blocks, and only uses a logo to indicate the block corresponding to the log. It can also be understood that the block logo is used to replace the block in the log. The block itself, therefore, hereinafter, is also expressed as, in the log, the block identifier refers to the block corresponding to the log.
Raft共识算法的主要流程包括领导节点选举流程以及日志复制流程(即日志共识流程),下面结合图2对相关技术中领导节点选举流程中的选举机制以及日志复制流程中的日志复制机制进行如下介绍:The main process of the Raft consensus algorithm includes the leader node election process and the log replication process (that is, the log consensus process). The following describes the election mechanism in the leader node election process and the log replication mechanism in the log replication process in related technologies in conjunction with Figure 2. :
1、选举机制,以共识集群中的任一个共识节点设备为例,对该选举机制进行如下介绍:1. Election mechanism, taking any consensus node device in the consensus cluster as an example, the election mechanism is introduced as follows:
该共识节点设备在启动时为跟随者,此时该共识节点设备为跟随节点。跟随节点设置一个任期,该任期对应共识集群中的一次选举过程,例如任期为1对应共识集群中的第一次选举过程,任期为2对应共识集群中的第二次选举过程。跟随节点还设置一个开启选举自己成为领导者的选举时间,并开启倒计时。当该选举时间达到或超时,且共识集群中在预设时长内没有领导者时,跟随节点更新自己的任期(如任期加1),该任期对应共识集群中的一次选举过程,例如任期为1对应共识集群中的第一次选举过程,任期为2对应共识集群中的第二次选举过程。该共识节点设备从跟随者转换为候选者,此时该任一共识节点设备为候选节点,更新后的任期对应候选节点即将发起的选举过程(即本次选举过程)。The consensus node device is a follower at startup, and at this time the consensus node device is a follower node. Follow the node to set a term, which corresponds to an election process in the consensus cluster. For example, a term of 1 corresponds to the first election process in the consensus cluster, and a term of 2 corresponds to the second election process in the consensus cluster. The follower node also sets an election time to start electing itself to become the leader, and starts the countdown. When the election time reaches or times out, and there is no leader in the consensus cluster within the preset time period, the follower node updates its own term (such as term plus 1), which corresponds to an election process in the consensus cluster, for example, the term is 1 Corresponding to the first election process in the consensus cluster, the term of 2 corresponds to the second election process in the consensus cluster. The consensus node device is converted from a follower to a candidate. At this time, any consensus node device is a candidate node, and the updated term corresponds to the election process that the candidate node will initiate (ie, this election process).
候选节点通过向共识集群中除该候选节点以外的各个非领导节点发送投票请求,以发起选举,其中,该投票请求携带该候选节点的任期(即更新后的任期)。A candidate node initiates an election by sending a voting request to each non-leader node except the candidate node in the consensus cluster, wherein the voting request carries the term of the candidate node (ie, the updated term).
每个非领导节点接收到该投票请求后,根据该投票请求中该候选节点的任期,向该候选节点返回投票结果。例如若该候选节点的任期高于一个非领导节点的任期,且该非领导节点还未给其他候选节点投赞成票,则该非领导节点赞同该候选节点共识集群中的成为领导者,向该候选节点返回代表赞成票的投票结果。而若该候选节点的任期小于或等于该非领导节点的任期,或者该非领导节点已经给其他候选节点投赞成票,则该非领导节点反对该候选节点成为共识集群中的领导者,向为该候选领导节点返回代表投反对票的投票结果。After receiving the voting request, each non-leader node returns the voting result to the candidate node according to the term of office of the candidate node in the voting request. For example, if the tenure of the candidate node is higher than that of a non-leader node, and the non-leader node has not voted for other candidate nodes, then the non-leader node agrees to become the leader in the consensus cluster of the candidate node, and submits to the Candidate nodes return voting results representing yes votes. And if the tenure of the candidate node is less than or equal to the tenure of the non-leader node, or the non-leader node has voted for other candidate nodes, the non-leader node opposes the candidate node becoming the leader in the consensus cluster. The candidate leader node returns the voting result representing the negative vote.
当该候选节点接收到多个非领导节点的投票结果后,统计为该候选节点投赞成票的非领导节点数(也即是赞成票的个数)。若共识集群中多数的非领导节点(包括该候选节点)为该候选节点投赞成票,则该共识节点设备从候选者转换为共识集群中的领导者,此时该共识节点为领导节点,该领导节点向共识集群中的各个非领导节点发送心跳消息,以告知各个非领导节点自己为共识集群中的领导者以及领导者的任期,以便共识集群中的各个非领导节点将领导者的任期作为各自的任期。After the candidate node receives the voting results of multiple non-leader nodes, count the number of non-leader nodes (that is, the number of yes votes) that voted for the candidate node. If most of the non-leader nodes (including the candidate node) in the consensus cluster vote for the candidate node, the consensus node device will be converted from the candidate to the leader in the consensus cluster. At this time, the consensus node is the leader node. The leader node sends a heartbeat message to each non-leader node in the consensus cluster to inform each non-leader node that it is the leader in the consensus cluster and the term of the leader, so that each non-leader node in the consensus cluster takes the term of the leader as respective terms of office.
若共识集群中少数的非领导节点为该候选节点投赞成票,则说明该共识集群中的多数非领导节点已经为另一个候选节点投赞成票,则另一个候选节点可能已经成为领导者,则该候选节点本次选举失败(即落选)。在本次选举期间,若该候选节点接收到共识集群中领导节点发送的心跳消息,则说明已经有一个候选节点成为共识集群中的领导者,则该候选节点本次选举失败。一旦该候选节点选举失败,则该共识节点设备从候选者切换为跟随者。或者,若本次选举超时,共识集群中还未选举出领导者,则该共识节点设备从候选者切换为跟随者。If a small number of non-leader nodes in the consensus cluster vote for the candidate node, it means that the majority of the non-leader nodes in the consensus cluster have voted for another candidate node, and another candidate node may have become the leader, then The candidate node fails this election (that is, loses the election). During this election, if the candidate node receives the heartbeat message sent by the leader node in the consensus cluster, it means that a candidate node has become the leader in the consensus cluster, and the candidate node fails this election. Once the candidate node election fails, the consensus node device switches from a candidate to a follower. Or, if the election times out and a leader has not been elected in the consensus cluster, the consensus node device switches from a candidate to a follower.
2、日志复制机制:2. Log replication mechanism:
共识集群中的每个共识节点设备维护一个日志序列,该日志序列包括多个日志,多个日志按照日志中索引从小到大的顺序依次排列,组成日志序列。当共识集群中的领导节点生成一个新的区块后,领导节点基于该区块以及本地的日志序列中最后一个日志的索引,生成该区块的日志,该日志中索引比日志序列中当前时刻最后一个日志的索引大1。该领导节点将 该日志添加至本地的日志序列的最后,并向共识集群中的各个非领导节点发送日志复制请求,该日志复制请求携带该日志。Each consensus node device in the consensus cluster maintains a log sequence, which includes multiple logs, and the multiple logs are arranged in order according to the index in the log from small to large to form a log sequence. When the leader node in the consensus cluster generates a new block, the leader node generates the log of the block based on the block and the index of the last log in the local log sequence. The index in the log is higher than the current moment in the log sequence The index of the last log is 1 greater. The leader node adds the log to the end of the local log sequence, and sends a log copy request to each non-leader node in the consensus cluster, and the log copy request carries the log.
每个非领导节点接收到该日志复制请求后,根据该日志复制请求携带的日志的内容,决定是否同意接收该日志。若某个非领导节点同意接收该日志,则该非领导节点将该日志添加到该非领导节点的日志序列,并向领导节点返回该同意接收日志的响应。当共识集群中的多数非领导节点同意接收该日志后,该领导节点通过向共识集群中的各个非领导节点发送心跳消息,指示共识集群中的多数非领导节点已经同意接收该日志。当各个非领导节点接收到该心跳消息后,将该日志所携带的区块提交至各自的该区块链系统的区块链账本上,此时该共识集群对该日志(或者说区块)达成共识。After receiving the log copy request, each non-leader node decides whether to agree to receive the log according to the content of the log carried in the log copy request. If a non-leader node agrees to receive the log, the non-leader node adds the log to the log sequence of the non-leader node, and returns a response of agreeing to receive the log to the leader node. When most non-leader nodes in the consensus cluster agree to receive the log, the leader node indicates that most non-leader nodes in the consensus cluster have agreed to receive the log by sending a heartbeat message to each non-leader node in the consensus cluster. When each non-leadership node receives the heartbeat message, it submits the block carried by the log to the blockchain ledger of the respective blockchain system. Reach a consensus.
Raft共识算法作为CFT类共识算法的代表,各个区块链底层技术平台一般均能够支持Raft共识算法,例如区块链底层技术平台引入Raft共识算法的开源代码实现,或者稍作改动该开源代码实现以适应底层系统,此类实现均为Raft共识算法的纯软实现,可容忍共识集群出现节点故障。但是Raft共识算法的开源代码一般在节点设备的富执行环境(rich execution environment,REE)中运行,一旦共识集群中出现发生拜占庭错误的节点设备,发生拜占庭错误的节点设备可以对区块链系统发起任意攻击,可能导致共识集群无法正常工作。其中,出现的拜占庭错误包括但不限于通过篡改时间戳、篡改任期、篡改投票结果等手段当选领导节点,或者篡改区块链系统中传输的消息的内容,这种领导节点可能会恶意修改区块内容或者日志的索引,引发共识集群出现共识错误,导致共识集群无法正常工作。The Raft consensus algorithm is a representative of the CFT consensus algorithm. Each blockchain underlying technology platform can generally support the Raft consensus algorithm. For example, the blockchain underlying technology platform introduces the open source code implementation of the Raft consensus algorithm, or slightly changes the open source code implementation. To adapt to the underlying system, such implementations are pure soft implementations of the Raft consensus algorithm, which can tolerate node failures in the consensus cluster. However, the open source code of the Raft consensus algorithm generally runs in the rich execution environment (REE) of the node device. Once a node device with a Byzantine error occurs in the consensus cluster, the node device with a Byzantine error can initiate an attack on the blockchain system. Arbitrary attacks may cause the consensus cluster to fail to work properly. Among them, Byzantine errors include but are not limited to being elected as the leader node by tampering with timestamps, tenure, voting results, etc., or tampering with the content of messages transmitted in the blockchain system. This kind of leader node may maliciously modify the block. The index of the content or the log will cause a consensus error in the consensus cluster, resulting in the failure of the consensus cluster to work normally.
例如,若跟随节点恶意篡改时间戳,在实际的选举时间到来之前,提前发起选举,以便自己成为领导节点。再例如,在发起选举时,候选节点将自己的任期篡改的比较高,以便共识集群中的各个非领导节点为该候选节点投赞成票,进而促进该候选节点成为共识集群中的领导节点。再例如,当共识集群中只有少数非领导节点为某一候选节点投赞成票时,若该候选节点篡改赞成票的个数,例如增加赞成票的个数,使得自己成为共识集群中领导节点。再例如,领导节点篡改发送心跳消息的时间戳,若是将心跳消息的时间戳修改小,领导节点将会提前在共识集群中发送心跳消息,可能会导致拒绝服务(denial of service,Dos)攻击。若是将心跳消息的时间戳修改大,领导节点将长时间不在共识集群中发送心跳消息,即蓄意不发送心跳消息,导致跟随节点的选举时间超时,重新发起选举。For example, if the follower node maliciously tampers with the timestamp, before the actual election time comes, an election is initiated in advance so that it can become the leader node. For another example, when initiating an election, the candidate node tampers with its own tenure so that each non-leader node in the consensus cluster votes for the candidate node, thereby promoting the candidate node to become the leader node in the consensus cluster. For another example, when only a few non-leader nodes in the consensus cluster vote for a candidate node, if the candidate node tampers with the number of votes, such as increasing the number of votes, it becomes the leader node in the consensus cluster. For another example, the leader node tampers with the time stamp of sending the heartbeat message. If the time stamp of the heartbeat message is modified to be smaller, the leader node will send the heartbeat message in the consensus cluster in advance, which may lead to a denial of service (Dos) attack. If the time stamp of the heartbeat message is changed to a larger value, the leader node will not send heartbeat messages in the consensus cluster for a long time, that is, deliberately not sending heartbeat messages, causing the election time of the following nodes to time out and re-initiating the election.
为了便于表述,将出现拜占庭错误的节点设备记为拜占庭节点。并且为了避免共识集群中出现拜占庭错误(例如通过篡改任期当选为领导者,或者任意篡改日志),即为了避免共识集群中出现拜占庭节点,本申请实施例提出了一种节点设备在可信执行环境(trusted execution environment,TEE)中实现Raft共识算法的技术方案。例如将用于实现Raft共识算法的计算机程序(或者程序代码)存储在该TEE中,共识节点设备在TEE中运行用于实现Raft共识算法的计算机程序,从而使得共识节点设备实现Raft共识算法的算法流程。For the convenience of expression, the node device with Byzantine error is recorded as Byzantine node. And in order to avoid Byzantine errors in the consensus cluster (such as being elected as the leader by tampering with the term of office, or arbitrarily tampering with the log), that is, in order to avoid Byzantine nodes in the consensus cluster, the embodiment of this application proposes a node device in a trusted execution environment. (Trusted Execution Environment, TEE) is a technical solution for implementing the Raft consensus algorithm. For example, the computer program (or program code) used to implement the Raft consensus algorithm is stored in the TEE, and the consensus node device runs the computer program used to implement the Raft consensus algorithm in the TEE, so that the consensus node device implements the algorithm of the Raft consensus algorithm process.
其中,TEE是在计算设备的主处理器上划出了一个安全区域,可以保证加载到该TEE内部的代码和数据的安全性、机密性以及完整性。TEE提供的执行空间比常见的移动操作系统(如Linux、Android等)提供的空间具有更高级别的安全性。TEE的实现包括基于高级精简指令集处理器(advanced risc machines,ARM)的信任区(TrustZone)、英特尔(Intel)推出的指令集扩展(software guard extensions,SGX)等。Among them, the TEE defines a security area on the main processor of the computing device, which can guarantee the security, confidentiality and integrity of the codes and data loaded into the TEE. The execution space provided by TEE has a higher level of security than that provided by common mobile operating systems (such as Linux, Android, etc.). The implementation of TEE includes the trust zone (TrustZone) based on advanced risc machines (ARM), the instruction set extensions (software guard extensions, SGX) introduced by Intel (Intel), etc.
TEE受硬件机制的保护,提供了受保护的内存和执行环境的隔离,从而能够提供可靠的 安全隐私保证。TEE只能崩溃不会出现拜占庭错误,因此,共识节点设备在TEE中实现Raft共识算法,可以避免该节点设备出现拜占庭错误,进而避免区块链系统中出现拜占庭错误。TEE is protected by hardware mechanism, which provides the isolation of protected memory and execution environment, so as to provide reliable security and privacy guarantee. TEE can only crash without Byzantine errors. Therefore, the consensus node device implements the Raft consensus algorithm in TEE, which can avoid Byzantine errors in the node device, thereby avoiding Byzantine errors in the blockchain system.
在Raft共识算法中,各个共识节点设备通过日志复制进行共识,各个共识节点设备均存储有日志序列和区块链系统的区块链账本,该日志序列和区块链账本均需要占用一定的存储空间。尤其是在区块链系统长久运行后,区块链系统中的日志和区块链账本上的区块会越来越多。但是TEE是主处理器上的一块区域,其存储资源有限,TEE内部的存储空间可能无法承受越来越多的日志和区块。基于此,本申请提出对Raft共识算法的算法实现(如用于实现Raft共识算法的计算机程序)进行细粒度的模块拆分,将Raft共识算法的核心流程实现(如实现选举机制的计算机程序以及实现日志复制机制的计算机程序)置于TEE中保护,Raft共识算法的输入输出(inputoutput,IO)层在REE侧进行,既保证Raft共识算法的安全性,同时最小化依赖TEE,保证算法效率和性能。In the Raft consensus algorithm, each consensus node device performs consensus through log replication, and each consensus node device stores the log sequence and the blockchain ledger of the blockchain system. The log sequence and the blockchain ledger need to occupy a certain amount of storage. space. Especially after the blockchain system has been running for a long time, there will be more and more logs in the blockchain system and blocks on the blockchain ledger. However, the TEE is an area on the main processor, and its storage resources are limited. The storage space inside the TEE may not be able to withstand more and more logs and blocks. Based on this, this application proposes fine-grained module splitting of the algorithm implementation of the Raft consensus algorithm (such as the computer program used to realize the Raft consensus algorithm), and realizes the core process of the Raft consensus algorithm (such as the computer program for implementing the election mechanism and The computer program that implements the log replication mechanism) is placed in the TEE for protection, and the input and output (IO) layer of the Raft consensus algorithm is performed on the REE side, which not only ensures the security of the Raft consensus algorithm, but also minimizes the dependence on the TEE to ensure algorithm efficiency and performance.
例如图3所示的本申请实施例提供的一种基于TEE实现Raft共识算法的共识集群示意图,参见图3。图3所示的共识集群包括共识节点设备1-3,其中,共识节点设备1为领导节点,共识节点设备1和2为跟随节点。共识节点设备1-3中的每个共识节点设备均包括REE和TEE,REE用于实现消息的IO过程。例如共识节点设备的REE负责将来自本节点TEE的消息转发至其他的共识节点设备,或者将来自其他共识节点设备的消息转发至本节点的TEE,区块链系统的区块链账本(ledger)以及日志序列的快照(snapshot)等可以存储在REE中。TEE用于实现Raft共识算法的核心流程,例如共识(consensus)流程(也即是日志复制流程)、选举流程。For example, FIG. 3 shows a schematic diagram of a consensus cluster implementing the Raft consensus algorithm based on TEE provided by the embodiment of the present application, see FIG. 3 . The consensus cluster shown in FIG. 3 includes consensus node devices 1-3, wherein consensus node device 1 is a leader node, and consensus node devices 1 and 2 are follower nodes. Each consensus node device among consensus node devices 1-3 includes REE and TEE, and REE is used to realize the IO process of messages. For example, the REE of the consensus node device is responsible for forwarding messages from the TEE of this node to other consensus node devices, or forwarding messages from other consensus node devices to the TEE of this node, and the blockchain ledger of the blockchain system And a snapshot (snapshot) of the log sequence can be stored in the REE. TEE is used to implement the core process of the Raft consensus algorithm, such as the consensus process (that is, the log replication process) and the election process.
为了进一步说明TEE实现Raft共识算法的核心流程,REE实现消息的IO过程,参见图4所示的本申请实施例提供的一种基于TEE实现Raft共识算法的共识节点设备的示意图,图4所示的共识集群中的每个共识节点设备的执行环境包括TEE和REE。每个共识节点设备在TEE中实现Raft共识算法的核心逻辑,该核心逻辑包括合法验证逻辑、超时检测逻辑、日志(Log)序列维护逻辑、选举(election)逻辑、共识集群的配置(configuration)逻辑以及共识集群的状态维护逻辑。其中,合法验证逻辑用于验证其他共识节点设备传递的消息内容是否合法、验证其他共识节点设备的身份证书(certificate)(如数字签名)是否合法。超时检测逻辑采用计时器(timer)原理,检测最新的选举时间是否达到或超时,若最新的选举时间达到或超时,则发起选举。日志序列维护逻辑用于维护日志序列。共识集群的配置逻辑用于维护共识集群中每个共识节点设备的节点信息,例如每个共识节点设备的公钥、地址信息等。选举(election)逻辑用于实现开启选举过程或者为候选节点投票。共识集群的状态维护逻辑用于实时维护共识集群中每个共识节点设备的节点状态(或者说角色)。例如采用节点跟踪器(node tracker),实时维护区块链系统中每个共识节点设备的节点状态。In order to further illustrate the core process of the TEE implementing the Raft consensus algorithm and the IO process of the REE implementing the message, refer to the schematic diagram of a consensus node device based on the TEE implementing the Raft consensus algorithm provided by the embodiment of the application shown in Figure 4, as shown in Figure 4 The execution environment of each consensus node device in the consensus cluster includes TEE and REE. Each consensus node device implements the core logic of the Raft consensus algorithm in the TEE, which includes legal verification logic, timeout detection logic, log sequence maintenance logic, election logic, and consensus cluster configuration logic And the state maintenance logic of the consensus cluster. Among them, the legal verification logic is used to verify whether the content of the message transmitted by other consensus node devices is legal, and whether the identity certificate (such as a digital signature) of other consensus node devices is legal. The timeout detection logic uses the principle of a timer to detect whether the latest election time is reached or timed out, and if the latest election time is reached or timed out, an election is initiated. Log sequence maintenance logic is used to maintain log sequences. The configuration logic of the consensus cluster is used to maintain the node information of each consensus node device in the consensus cluster, such as the public key and address information of each consensus node device. Election logic is used to start the election process or vote for candidate nodes. The state maintenance logic of the consensus cluster is used to maintain the node state (or role) of each consensus node device in the consensus cluster in real time. For example, a node tracker is used to maintain the node status of each consensus node device in the blockchain system in real time.
每个共识节点设备在REE中实现Raft共识算法的IO层逻辑。例如REE中设置有提案(proposer)模块、存储(storage)模块、消息调度模块以及通信模块,其中,提案(proposer)模块用于生成区块。存储模块包括内存(memory)以及持久化(persistence)存储介质,内存用于存储提案模块生成的区块。持久化存储介质用于存储本地的区块链系统的区块链账本(ledger)、日志序列的快照(snapshot)以及预写日志(write-ahead logging)等,其中,区块链账本也即是区块链系统中所配置的区块链。通信模块也可以称为网络(network)模块,用于与其他共识节点设备进行通信,例如共识集群间的远程过程调用(remote procedure call, RPC)。消息调度模块用于完成共识节点设备内各个模块之间的消息调度。在一种可能的实现方式中,该消息调度模块可以遵循事件循环(Event Loop)机制,进行共识节点设备内部的消息调度。Each consensus node device implements the IO layer logic of the Raft consensus algorithm in REE. For example, the REE is provided with a proposer module, a storage module, a message scheduling module, and a communication module, wherein the proposer module is used to generate blocks. The storage module includes a memory and a persistence storage medium, and the memory is used to store blocks generated by the proposal module. The persistent storage medium is used to store the blockchain ledger of the local blockchain system, the snapshot of the log sequence (snapshot) and the write-ahead logging, among which the blockchain ledger is also The blockchain configured in the blockchain system. The communication module can also be called a network module, which is used to communicate with other consensus node devices, such as remote procedure calls (remote procedure call, RPC) between consensus clusters. The message scheduling module is used to complete the message scheduling among various modules in the consensus node device. In a possible implementation, the message scheduling module can follow the event loop (Event Loop) mechanism to perform message scheduling inside the consensus node device.
例如,在图4中客户端(client)向作为领导者的共识节点设备(即领导节点)发送(transmit,TX)第五请求,其中,该第五请求用于指示在至少两个区块链账户之间进行交易。领导节点中的提案模块基于该第五请求生成区块,通过消息调到模块,向存储模块中的内存发送该区块,向TEE发送该区块的标识。之后,TEE基于区块的标识,生成该区块的日志,将该日志存储在日志序列,并通过消息调度模块向提案模块发送该日志,提案模块从内存中获取该日志对应的区块,并通过消息调度模块以及通信模块,向共识集群中的非领导节点发送该日志以及该区块,并由非领导节点中的通信模块接收该日志以及该区块,向消息调度模块发送日志以及该区块,消息调度模块将该区块存储在存储模块,并向非领导节点的TEE发送日志,由TEE决定是否接受该日志。For example, in Fig. 4, the client (client) sends (transmit, TX) the fifth request to the consensus node device as the leader (that is, the leader node), wherein the fifth request is used to indicate that in at least two blockchains Transactions between accounts. The proposal module in the leader node generates a block based on the fifth request, transfers the block to the module through a message, sends the block to the memory in the storage module, and sends the identification of the block to the TEE. Afterwards, TEE generates a log of the block based on the identification of the block, stores the log in the log sequence, and sends the log to the proposal module through the message scheduling module, and the proposal module obtains the block corresponding to the log from the memory, and Send the log and the block to the non-leader node in the consensus cluster through the message scheduling module and the communication module, and the communication module in the non-leader node receives the log and the block, and sends the log and the block to the message scheduling module block, the message scheduling module stores the block in the storage module, and sends the log to the TEE of the non-leader node, and the TEE decides whether to accept the log.
为了进一步说明,区块链系统中共识节点设备基于TEE选举领导节点的过程,参见图5所示的本申请实施例提供的一种领导节点选举方法的流程图。For further explanation, the process of the consensus node device in the blockchain system electing the leader node based on the TEE, please refer to the flowchart of a leader node election method provided by the embodiment of the present application shown in FIG. 5 .
501、在启动时,第一节点设备的TEE初始化共识集群中各个共识节点设备的节点信息、第一节点设备的节点状态、第一节点设备的选举时间以及第一节点设备的初始任期。501. At startup, the TEE of the first node device initializes the node information of each consensus node device in the consensus cluster, the node status of the first node device, the election time of the first node device, and the initial tenure of the first node device.
其中,该第一节点设备为区块链系统中共识集群内的任一共识节点设备。每个共识节点设备的节点信息包括一个共识节点设备的节点标识、地址信息以及公钥。其中,每个共识节点设备的节点标识用于唯一指示一个共识节点设备,每个共识节点设备的地址信息可以是每个共识节点设备的网络协议(Internet protocol,IP)地址。Wherein, the first node device is any consensus node device in the consensus cluster in the blockchain system. The node information of each consensus node device includes a node identification, address information and public key of a consensus node device. Wherein, the node identifier of each consensus node device is used to uniquely indicate a consensus node device, and the address information of each consensus node device may be an Internet protocol (Internet protocol, IP) address of each consensus node device.
该共识集群中每个共识节点设备的节点状态包括跟随状态、候选状态或者领导状态,其中,跟随状态用于指示共识节点设备为跟随节点,候选状态用于指示共识节点设备为候选节点,领导状态用于指示共识节点设备为领导节点。在启动时,该第一节点设备的节点状态为跟随状态,该第一节点设备的选举时间为开启选举该第一节点设备成为区块链系统(或者说共识集群)中领导节点的时间。该第一节点设备的初始任期为该第一节点设备最初的任期,该初始任期可以为0或任一大于0的整数。The node state of each consensus node device in the consensus cluster includes follower state, candidate state or leader state, wherein the follower state is used to indicate that the consensus node device is a follower node, the candidate state is used to indicate that the consensus node device is a candidate node, and the leader state It is used to indicate that the consensus node device is the leader node. At startup, the node state of the first node device is a follower state, and the election time of the first node device is the time when the election of the first node device becomes the leader node in the blockchain system (or consensus cluster). The initial term of the first node device is the initial term of the first node device, and the initial term may be 0 or any integer greater than 0.
在一种可能的实现方式中,由该第一节点设备中的REE触发TEE执行本步骤501。例如下述步骤5011-5013所示的过程。In a possible implementation manner, the REE in the first node device triggers the TEE to execute step 501 . For example, the process shown in the following steps 5011-5013.
步骤5011、当节点启动时,该第一节点设备中的REE生成第六请求,该第六请求指示TEE初始化共识集群中各个共识节点设备的节点信息、第一节点设备的节点状态、第一节点设备的选举时间以及第一节点设备的初始任期。Step 5011, when the node starts, the REE in the first node device generates a sixth request, and the sixth request instructs the TEE to initialize the node information of each consensus node device in the consensus cluster, the node status of the first node device, the first node The election time of the device and the initial term of the first node device.
其中,该第六请求携带共识集群中各个共识节点设备的节点信息。Wherein, the sixth request carries node information of each consensus node device in the consensus cluster.
在一种可能的实现方式中,该第一节点设备的REE中存储有该区块链系统中的区块链账本,REE从该区块链账本中获取共识集群中各个共识节点设备的节点信息。例如从该区块链账本中的创世区块,获取该共识集群配置信息,其中,该创世区块为该区块链账本上的第一个区块。In a possible implementation, the REE of the first node device stores the blockchain ledger in the blockchain system, and the REE obtains the node information of each consensus node device in the consensus cluster from the blockchain ledger . For example, the configuration information of the consensus cluster is obtained from the genesis block in the ledger of the blockchain, wherein the genesis block is the first block in the ledger of the blockchain.
当获取到共识集群中各个共识节点设备的节点信息后,该REE基于该共识集群中各个共识节点设备的节点信息,生成该第六请求。After obtaining the node information of each consensus node device in the consensus cluster, the REE generates the sixth request based on the node information of each consensus node device in the consensus cluster.
步骤5012、该第一节点设备的REE向该第一节点设备的TEE发送第六请求。Step 5012, the REE of the first node device sends a sixth request to the TEE of the first node device.
在一种可能的实现方式中,第一节点设备REE调用该REE与该TEE之间的初始化配置接口,向初始化配置接口发送第六请求。其中,该初始化配置接口可以位于该REE中的消息调度模块,消息调度模块向该初始化配置接口发送第六请求,以便TEE从初始化配置接口接收该第六请求。In a possible implementation manner, the first node device REE invokes an initialization configuration interface between the REE and the TEE, and sends a sixth request to the initialization configuration interface. Wherein, the initialization configuration interface may be located in the message scheduling module of the REE, and the message scheduling module sends a sixth request to the initialization configuration interface, so that the TEE receives the sixth request from the initialization configuration interface.
步骤5013、该第一节点设备的TEE接收该第六请求,并基于该第六请求,初始化共识集群中各个共识节点设备的节点信息、第一节点设备的节点状态、第一节点设备的选举时间以及第一节点设备的初始任期。Step 5013, the TEE of the first node device receives the sixth request, and based on the sixth request, initializes the node information of each consensus node device in the consensus cluster, the node status of the first node device, and the election time of the first node device and the initial tenure of the first node device.
在一种可能的实现方式中,该第一节点设备的TEE从该初始化配置接口接收该第六请求。In a possible implementation manner, the TEE of the first node device receives the sixth request from the initialization configuration interface.
当接收到该第六请求后,该第一节点设备的TEE从该第六请求中,解析出该共识集群中各个共识节点设备的节点信息,并基于该第六请求的指示,存储共识集群中各个共识节点设备的节点信息,完成节点信息配置。After receiving the sixth request, the TEE of the first node device parses out the node information of each consensus node device in the consensus cluster from the sixth request, and stores the information in the consensus cluster based on the instruction of the sixth request. Node information of each consensus node device, complete node information configuration.
该第一节点设备的TEE基于该第六请求的指示,初始化该第一节点设备的节点状态,例如第一节点设备的TEE的将该第一节点设备的节点状态存储为跟随状态。The TEE of the first node device initializes the node state of the first node device based on the indication of the sixth request, for example, the TEE of the first node device stores the node state of the first node device as a follow state.
在一种可能的实现方式中,该第一节点设备的TEE从该共识集群中各个共识节点设备的节点信息中,获取共识集群中各个共识节点设备的节点标识。该第一节点设备的TEE基于共识节点设备的节点标识,创建状态表。其中,该状态表用于记录共识集群中各个共识节点设备的节点状态与各个共识节点设备的节点标识的对应关系。例如该第一节点设备可以将该第一节点设备的节点标识与跟随状态的标识关联存储在该状态表中,以指示该第一节点设备的节点状态为跟随状态。需要说明的是,初始时,该第一节点设备并不知晓共识集群中其他共识节点设备的节点状态,则该第一节点设备可以在该状态表中将其他共识节点设备的节点状态记录为跟随状态。In a possible implementation manner, the TEE of the first node device obtains the node identifier of each consensus node device in the consensus cluster from the node information of each consensus node device in the consensus cluster. The TEE of the first node device creates a state table based on the node identifier of the consensus node device. Wherein, the state table is used to record the corresponding relationship between the node status of each consensus node device in the consensus cluster and the node identifier of each consensus node device. For example, the first node device may associate and store the node identifier of the first node device and the identifier of the following state in the state table, so as to indicate that the node state of the first node device is the following state. It should be noted that initially, the first node device does not know the node status of other consensus node devices in the consensus cluster, so the first node device can record the node status of other consensus node devices in the status table as following state.
该第一节点设备的TEE基于该第六请求的指示,根据第一预设规则,生成该第一节点设备的选举时间,并记录该选举时间。其中,该第一预设规则可以是随机生成规则,也可以其他的预设规则。在此,本申请实施例对该第一预设规则不做限定。Based on the indication of the sixth request, the TEE of the first node device generates the election time of the first node device according to the first preset rule, and records the election time. Wherein, the first preset rule may be a random generation rule, or other preset rules. Here, the embodiment of the present application does not limit the first preset rule.
该第一节点设备的TEE基于该第六请求的指示,生成并记录该第一节点设备的初始任期,例如将0作为该第一节点设备的初始任期。Based on the indication of the sixth request, the TEE of the first node device generates and records the initial term of the first node device, for example, takes 0 as the initial term of the first node device.
在一种可能的实现方式中,该第一节点设备的TEE向该第一节点设备的REE发送该第一节点设备的选举时间,该第一节点设备的REE接收并存储该选举时间。In a possible implementation manner, the TEE of the first node device sends the election time of the first node device to the REE of the first node device, and the REE of the first node device receives and stores the election time.
需要说明的是,该区块链系统中的每个共识节点设备在启动时均能够通过本步骤501初始化该共识集群中各个共识节点设备的节点信息、各自的节点状态、各自的选举时间以及各自的初始任期。且每个共识节点设备在启动时执行一次本步骤501即可,无须重复执行。It should be noted that each consensus node device in the blockchain system can initialize the node information, respective node status, respective election time and respective initial term of office. And each consensus node device only needs to execute this step 501 once when it is started, and there is no need to execute it repeatedly.
502、第一节点设备的TEE生成第二请求,该第二请求指示对该第一节点设备成为该区块链系统中的领导节点进行投票。502. The TEE of the first node device generates a second request, and the second request indicates to vote for the first node device to become the leader node in the blockchain system.
其中,该第二请求包括该第一节点设备的第一任期,其中,该第一任期为该第一节点设备发起的本次选举过程所对应的任期。Wherein, the second request includes the first term of the first node device, wherein the first term is the term corresponding to the current election process initiated by the first node device.
在一种可能的实现方式中,若在预设时长内未接收到来自共识集群中领导节点的通知消息,则说明此时该共识集群中不存在领导节点,其中,该通知消息指示区块链系统中的一个节点设备为区块链系统中的领导节点。In a possible implementation, if the notification message from the leader node in the consensus cluster is not received within the preset time period, it means that there is no leader node in the consensus cluster at this time, wherein the notification message indicates that the blockchain A node device in the system is the leader node in the blockchain system.
由于同一个时刻共识集群中允许存在一个领导节点,因此,若在预设时长内未接收到来 自共识集群中领导节点的通知消息,且该第一节点设备的TEE中记录的该第一节点设备的选举时间已达到或已超时,则该第一节点设备的TEE生成该第二请求。其中,该选举时间已到达是指:当前时刻为TEE中记录的选举时间,该选举时间已超时是指当前时刻晚于该TEE中记录的选举时间。Since one leader node is allowed to exist in the consensus cluster at the same time, if the notification message from the leader node in the consensus cluster is not received within the preset time period, and the first node device recorded in the TEE of the first node device The election time has reached or expired, then the TEE of the first node device generates the second request. Wherein, the election time has arrived means that the current time is the election time recorded in the TEE, and the election time has expired means that the current time is later than the election time recorded in the TEE.
在TEE是不能调用REE,且REE能够调用TEE的情况下(例如在基于ARM的TrustZone技术中是REE调用TEE,TEE不能调用REE),该第一节点设备的TEE中生成第二请求的动作,是由REE来触发的,例如下述步骤5021-5024所述的过程。In the case that the TEE cannot call the REE, and the REE can call the TEE (for example, in the ARM-based TrustZone technology, the REE calls the TEE, and the TEE cannot call the REE), the TEE of the first node device generates the action of the second request, It is triggered by REE, for example, the process described in steps 5021-5024 below.
步骤5021、若第一节点设备的REE中记录的该第一节点设备的选举时间已达到或已超时,该第一节点设备的REE生成第一消息,该第一消息用于提示TEE开启该第一节点设备的选举过程。Step 5021. If the election time of the first node device recorded in the REE of the first node device has reached or expired, the REE of the first node device generates a first message, and the first message is used to prompt the TEE to start the first node device. The election process of a node device.
其中,该第一节点设备的选举过程是指选举第一节点设备成为区块链系统中的领导节点的过程。Wherein, the election process of the first node device refers to the process of electing the first node device to become the leading node in the blockchain system.
在一种可能的实现方式中,当接收到第一节点设备TEE所发送的第一节点设备的选举时间后,该第一节点设备的REE记录第一节点设备的该选举时间,并开启倒计时。若该选举时间已到达或已超时,且预设时长内没有接收到来自共识集群中领导节点的通知消息,则该第一节点设备的REE生成该第一消息。In a possible implementation manner, after receiving the election time of the first node device sent by the first node device TEE, the REE of the first node device records the election time of the first node device and starts a countdown. If the election time has arrived or has timed out, and no notification message is received from the leader node in the consensus cluster within the preset time period, the REE of the first node device generates the first message.
步骤5022、该第一节点设备的REE向第一节点设备的TEE发送第一消息。Step 5022, the REE of the first node device sends a first message to the TEE of the first node device.
例如,该第一节点设备的REE中的提案模块生成第一消息,并通过消息调度模块向该第一节点设备的TEE发送该第一消息。For example, the proposal module in the REE of the first node device generates the first message, and sends the first message to the TEE of the first node device through the message scheduling module.
步骤5023、该第一节点设备的TEE接收该第一消息,并对该第一消息进行验证。Step 5023, the TEE of the first node device receives the first message, and verifies the first message.
例如,该第一节点设备的TEE从消息调度模块接收该第一消息。For example, the TEE of the first node device receives the first message from the message scheduling module.
当接收到该第一消息后,该第一节点设备的TEE基于记录该第一节点设备的选举时间,对该第一消息进行验证。例如,若该第一节点设备的TEE所记录的选举时间已达到或已超时,则该第一节点设备的TEE对该第一消息验证通过。After receiving the first message, the TEE of the first node device verifies the first message based on recording the election time of the first node device. For example, if the election time recorded by the TEE of the first node device has reached or expired, the TEE of the first node device passes the verification of the first message.
若该第一节点设备的TEE记录的选举时间没有达到,则说明第一节点设备篡改了REE中该第一节点设备的选举时间,出现拜占庭错误。因此,若该第一节点设备的TEE记录的选举时间没有达到,则该第一节点设备的TEE对该第一消息验证不通过。若该第一节点设备的TEE对该第一消息验证不通过,则不再执行后续的步骤。If the election time recorded in the TEE of the first node device has not been reached, it means that the first node device has tampered with the election time of the first node device in the REE, and a Byzantine error occurs. Therefore, if the election time recorded by the TEE of the first node device has not arrived, the TEE of the first node device fails to verify the first message. If the TEE of the first node device fails to verify the first message, the subsequent steps are not performed.
步骤5024、在该第一消息通过了该第一节点设备的TEE的验证的情况下,该第一节点设备的TEE生成该第二请求。Step 5024, if the first message is verified by the TEE of the first node device, the TEE of the first node device generates the second request.
在该第一消息通过了该第一节点设备的TEE的验证的情况下,该第一节点设备的TEE将记录的该第一节点设备的任期增加第一预设数值,得到第一节点设备的该第一任期。该第一预设数值为相邻任期之间的差值,该第一预设数值可以是1或其他数值。该第一预设数值可以根据实际应用场景进行设置,在此,本申请实施例对该第一预设数值不做限定。In the case that the first message has passed the verification of the TEE of the first node device, the TEE of the first node device will increase the recorded term of the first node device by a first preset value to obtain the The first term. The first preset value is the difference between adjacent tenures, and the first preset value may be 1 or other values. The first preset value may be set according to an actual application scenario. Here, the embodiment of the present application does not limit the first preset value.
该第一节点设备的TEE将记录的该第一节点设备的任期更新为该第一任期,并基于该第一任期,生成该第二请求,其中,该第二请求携带该第一任期。The TEE of the first node device updates the recorded term of the first node device to the first term, and generates the second request based on the first term, where the second request carries the first term.
在另一种可能的实现方式,为了避免该第二请求在离开该第一节点设备的TEE后,第二请求携带的内容被篡改,该第一节点设备的TEE基于该第一节点设备的私钥,对该第二请求进行签名,得到该第二请求的数字签名。In another possible implementation, in order to prevent the content carried in the second request from being tampered with after the second request leaves the TEE of the first node device, the TEE of the first node device is based on the private key to sign the second request to obtain the digital signature of the second request.
对于步骤5021-5024所示的过程,即使该第一节点设备的REE出现拜占庭错误,例如篡改REE中的计时器,使得计时器记录的时间提前达到选举时间,触发REE向TEE发送第一消息。但是,由于第一节点设备的TEE还进一步验证记录的选举时间是否已达到或已超时,若第一消息没有通过第一节点设备的TEE的验证,第一节点设备的TEE不会生成该第二请求,从而避免该第一节点设备在共识集群中提前发起选举。For the process shown in steps 5021-5024, even if the REE of the first node device has a Byzantine error, such as tampering with the timer in the REE, so that the time recorded by the timer reaches the election time in advance, the REE is triggered to send the first message to the TEE. However, since the TEE of the first node device further verifies whether the recorded election time has reached or expired, if the first message does not pass the verification of the TEE of the first node device, the TEE of the first node device will not generate the second message. request, thereby preventing the first node device from initiating an election in advance in the consensus cluster.
需要说明的是,当该第一节点设备的TEE生成该第二请求后,第一节点设备的TEE要发起选举,则该第一节点设备的TEE将记录的该第一节点设备的节点状态由跟随状态更新为候选状态,例如,该第一节点设备的TEE将状态表中该第一节点设备所对应的节点状态的标识更新为候选状态的标识。It should be noted that, after the TEE of the first node device generates the second request, and the TEE of the first node device wants to initiate an election, the TEE of the first node device will record the node state of the first node device by Following the update of the state to the candidate state, for example, the TEE of the first node device updates the identifier of the node state corresponding to the first node device in the state table to the identifier of the candidate state.
503、该第一节点设备的TEE通过第一节点设备REE,向该区块链系统中的第二节点设备发送该第二请求。503. The TEE of the first node device sends the second request to the second node device in the blockchain system through the first node device REE.
其中,区块链系统中的第二节点设备为共识集群中除该第一节点设备以外的各个共识节点设备,区块链系统中的第二节点设备可以有至少一个。Wherein, the second node device in the blockchain system is each consensus node device in the consensus cluster except the first node device, and there may be at least one second node device in the blockchain system.
在一种可能的实现方式中,本步骤503由下述步骤5031-5032来执行。In a possible implementation manner, this step 503 is performed by the following steps 5031-5032.
步骤5031、该第一节点设备的TEE向该第一节点设备的REE发送该第二请求。Step 5031, the TEE of the first node device sends the second request to the REE of the first node device.
在一种可能的实现方式中,该第二节点设备的TEE向该第一节点设备的REE发送该第二请求以及该第二请求的数字签名。例如,该第一节点设备的TEE向该第一节点设备的REE中的消息调度模块发送该第二请求以及该第二请求的数字签名。In a possible implementation manner, the TEE of the second node device sends the second request and the digital signature of the second request to the REE of the first node device. For example, the TEE of the first node device sends the second request and the digital signature of the second request to the message scheduling module in the REE of the first node device.
步骤5032、该第一节点设备的REE接收该第二请求,并向该区块链系统中的第二节点设备发送该第二请求。Step 5032, the REE of the first node device receives the second request, and sends the second request to the second node device in the blockchain system.
在一种可能的实现方式中,该第二节点设备的REE接收该第二请求以及该第二请求的数字签名。例如,该第一节点设备的REE中的消息调度模块接收该第二请求以及该第二请求的数字签名,该消息调度模块向通信模块发送该第二请求以及该第二请求的数字签名,并由通信模块向该区块链系统中的第二节点设备发送该第二请求以及该第二请求的数字签名。In a possible implementation manner, the REE of the second node device receives the second request and the digital signature of the second request. For example, the message scheduling module in the REE of the first node device receives the second request and the digital signature of the second request, the message scheduling module sends the second request and the digital signature of the second request to the communication module, and The second request and the digital signature of the second request are sent by the communication module to the second node device in the blockchain system.
504、第二节点设备的TEE通过该第二节点设备的REE,接收该第二请求。504. The TEE of the second node device receives the second request through the REE of the second node device.
其中,步骤504-506中的第二节点设备为该区块链系统中的任一个第二节点设备,也即是区块链系统中的每个第二节点设备均执行步骤504-506所示的过程。Wherein, the second node device in steps 504-506 is any second node device in the blockchain system, that is, each second node device in the blockchain system executes steps 504-506 the process of.
在一种可能的实现方式中,本步骤504由下述步骤5041-5043来实现。In a possible implementation manner, this step 504 is implemented by the following steps 5041-5043.
步骤5041、该第二节点设备的REE接收该第二请求。Step 5041, the REE of the second node device receives the second request.
在一种可能的实现方式中,该第二节点设备的REE接收该第二请求以及该第二请求的数字签名。例如,该第二节点设备的REE中的通信模块接收第二请求以及该第二请求的数字签名,该通信模块向该REE中的消息调度模块发送该第二请求以及该第二请求的数字签名。In a possible implementation manner, the REE of the second node device receives the second request and the digital signature of the second request. For example, the communication module in the REE of the second node device receives the second request and the digital signature of the second request, and the communication module sends the second request and the digital signature of the second request to the message scheduling module in the REE .
步骤5042、该第二节点设备的REE向该第二节点设备的TEE发送该第二请求。Step 5042, the REE of the second node device sends the second request to the TEE of the second node device.
在一种可能的实现方式中,该第二节点设备的REE向该第二节点设备的TEE,发送该第二请求以及该第二请求的数字签名。例如,该第二节点设备的REE中的该消息调度模块向该第二节点设备的TEE发送接收到的该第二请求以及该第二请求的数字签名。In a possible implementation manner, the REE of the second node device sends the second request and the digital signature of the second request to the TEE of the second node device. For example, the message scheduling module in the REE of the second node device sends the received second request and the digital signature of the second request to the TEE of the second node device.
步骤5043、该第二节点设备的TEE接收该第二请求。Step 5043, the TEE of the second node device receives the second request.
在一种可能的实现方式中,该第二节点设备的TEE接收该第二请求以及该第二请求的数字签名。例如,该第二节点设备的TEE从该第二节点设备的REE中的消息调度模块接收该 第二请求以及该第二请求的数字签名。In a possible implementation manner, the TEE of the second node device receives the second request and the digital signature of the second request. For example, the TEE of the second node device receives the second request and the digital signature of the second request from the message scheduling module in the REE of the second node device.
505、该第二节点设备的TEE对该第二请求进行验证。505. The TEE of the second node device verifies the second request.
在一种可能的实现方式中,该第二节点设备的TEE从存储的该第一节点设备的节点信息中查询内该第一节点设备的公钥。该第二节点设备的TEE基于该第一节点设备的公钥,对该第二请求进行验证。例如,该第二节点设备的TEE基于该第一节点设备的公钥,对该第二请求的数字签名进行验签,若验签成功,则该第二节点设备的TEE对该第二请求验证通过。若验签失败,说明该第二请求的内容已经被篡改,该第二节点设备的TEE对该第二请求验证不通过。In a possible implementation manner, the TEE of the second node device queries the public key of the first node device from stored node information of the first node device. The TEE of the second node device verifies the second request based on the public key of the first node device. For example, the TEE of the second node device verifies the digital signature of the second request based on the public key of the first node device, and if the verification is successful, the TEE of the second node device verifies the second request pass. If the signature verification fails, it means that the content of the second request has been tampered with, and the TEE of the second node device fails to verify the second request.
506、在该第二请求通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE通过该第二节点设备的REE,向该第一节点设备发送第二响应,该第二响应指示该第二节点设备是否赞同该第一节点设备成为该区块链系统中的领导节点。506. When the second request passes the verification of the TEE of the second node device, the TEE of the second node device sends a second response to the first node device through the REE of the second node device, and the The second response indicates whether the second node device agrees with the first node device to become the leader node in the blockchain system.
其中,该第二响应携带第一投票标识或第二投票标识,该第一投票标识指示该第二节点设备赞同该第一节点设备成为该区块链系统中的领导节点,该第一投票标识也即是一个赞成票。该第二投票标识指示该第二节点设备不赞同该第一节点设备成为该区块链系统中的领导节点,该第二投票标识也即是一个反对票。Wherein, the second response carries a first voting ID or a second voting ID, the first voting ID indicates that the second node device agrees that the first node device becomes the leader node in the blockchain system, and the first voting ID That is a yes vote. The second voting identifier indicates that the second node device does not agree with the first node device becoming the leading node in the blockchain system, and the second voting identifier is also a negative vote.
共识集群中的每个共识节点设备在选举领导节点时,有一次投赞成票的权力。且在每一次选举时,每个共识节点设备为比自己任期高的候选节点投赞成票,或者为自己投赞成票。Each consensus node device in the consensus cluster has the right to vote once when electing a leader node. And in each election, each consensus node device votes for a candidate node whose tenure is higher than its own, or votes for itself.
在一种可能的实现方式中,在该第二请求通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE从该第二请求中,解析出该第一节点设备的第一任期。该第二节点设备的TEE基于记录该第二节点设备的任期以及该第一任期,生成该第二响应。In a possible implementation, when the second request passes the verification of the TEE of the second node device, the TEE of the second node device parses out the first node device from the second request of the first term. The TEE of the second node device generates the second response based on recording the term of the second node device and the first term.
例如,若该第一任期大于该第二节点设备的任期,且该第二节点设备没有给除该第一节点设备以外的候选节点投过赞成票,则该第二节点设备的TEE生成携带第一投票标识的第二响应,否则,该第二节点设备的TEE生成携带第二投票标识的第二响应。For example, if the first term is greater than the term of the second node device, and the second node device has not voted for candidate nodes other than the first node device, then the TEE generated by the second node device carries the A second response with a voting ID; otherwise, the TEE of the second node device generates a second response carrying the second voting ID.
进一步地,为了避免该第二响应在离开该第二节点设备的TEE后,该第二响应的内容被篡改,该第二节点设备的TEE基于该第二节点设备的私钥,对该第二响应进行签名,得到该第二响应的数字签名。Further, in order to prevent the content of the second response from being tampered with after the second response leaves the TEE of the second node device, the TEE of the second node device is based on the private key of the second node device, and the second The response is signed to obtain a digital signature of the second response.
在一种可能的实现方式中,该第二节点设备的TEE通过该第二节点设备的REE,向该第一节点设备发送该第二响应,或者发送该第二响应以及该第二响应的数字签名,例如下述步骤5061-5062所示的过程。In a possible implementation manner, the TEE of the second node device sends the second response to the first node device through the REE of the second node device, or sends the second response and the number of the second response Signature, such as the process shown in the following steps 5061-5062.
步骤5061、该第二节点设备的TEE向该第二节点设备的REE发送该第二响应。Step 5061, the TEE of the second node device sends the second response to the REE of the second node device.
在一种可能的实现方式中,该第二节点设备的TEE向REE发送该第二响应以及该第二响应的数字签名。例如,该第二节点设备的TEE向该第二节点设备的REE中的息调度模块发送该第二响应以及该第二响应的数字签名。In a possible implementation manner, the TEE of the second node device sends the second response and the digital signature of the second response to the REE. For example, the TEE of the second node device sends the second response and the digital signature of the second response to the message scheduling module in the REE of the second node device.
步骤5062、该第二节点设备的REE接收该第二响应,并向该第一节点设备发送该第二响应。Step 5062, the REE of the second node device receives the second response, and sends the second response to the first node device.
在一种可能的实现方式中,该第二节点设备的REE接收该第二响应以及该第二响应的数字签名,向该第一节点设备发送该第二响应以及该第二响应的数字签名。例如,若该第二节点设备的REE中的消息调度模块接收该第二响应以及该第二响应的数字签名,向该REE中的通信模块发送该第二响应以及该第二响应的数字签名,并由该通信模块向该第一节点设备 发送该第二响应以及该第二响应的数字签名。In a possible implementation manner, the REE of the second node device receives the second response and the digital signature of the second response, and sends the second response and the digital signature of the second response to the first node device. For example, if the message scheduling module in the REE of the second node device receives the second response and the digital signature of the second response, and sends the second response and the digital signature of the second response to the communication module in the REE, And the communication module sends the second response and the digital signature of the second response to the first node device.
需要说明的是,在该第二请求通过了该第二节点设备的TEE的验证的情况下,说明该第一节点设备处于候选状态,则该第二节点设备的TEE将记录的该第一节点设备的节点状态从跟随状态更新为候选状态。It should be noted that, if the second request passes the verification of the TEE of the second node device, it means that the first node device is in the candidate state, then the TEE of the second node device will record the first node The node state of the device is updated from follow state to candidate state.
507、该第一节点设备的TEE通过第一节点设备的REE,接收多个第二响应。507. The TEE of the first node device receives multiple second responses through the REE of the first node device.
其中,该多个第二响应中的每个第二响应分别来自共识集群中的一个第二节点设备。Wherein, each of the multiple second responses is from a second node device in the consensus cluster.
在一种可能的实现方式中,该第一节点设备的TEE通过第一节点设备的REE,接收该多个响应中每个第二响应以及每个第二响应的数字签名。本步骤507所示的过程与上述步骤504中该第二节点设备的TEE通过第二节点设备的REE接收该第二请求的过程同理,在此,本申请实施例对本步骤507不再赘述。In a possible implementation manner, the TEE of the first node device receives each second response and the digital signature of each second response in the multiple responses through the REE of the first node device. The process shown in this step 507 is the same as the process in which the TEE of the second node device receives the second request through the REE of the second node device in the above step 504, and this embodiment of the present application does not repeat this step 507 here.
508、该第一节点设备的TEE对接收到的每个第二响应进行验证。508. The TEE of the first node device verifies each received second response.
以该第一节点设备的TEE对一个第二节点设备的第二响应进行验证为例,对本步骤508进行如下介绍:Taking the TEE of the first node device to verify the second response of a second node device as an example, this step 508 is introduced as follows:
该第一节点设备的TEE从存储的该第二节点设备的节点信息中,查询该第二节点设备的公钥,并基于该第二节点设备的公钥,对该第二响应进行验证。The TEE of the first node device queries the public key of the second node device from the stored node information of the second node device, and verifies the second response based on the public key of the second node device.
例如该第一节点设备TEE基于该第二节点设备的公钥,对该第二节点设备的第二响应的数字签名进行验签。若验签成功,则该第一节点设备的TEE对该第二响应验证通过。若验签失败,则说明该第二响应的内容已经被篡改,则该第一节点设备TEE对该第二响应验证不通过。For example, the first node device TEE verifies the digital signature of the second response of the second node device based on the public key of the second node device. If the signature verification is successful, the TEE of the first node device passes the verification of the second response. If the signature verification fails, it means that the content of the second response has been tampered with, and the first node device TEE fails to verify the second response.
509、在该区块链系统中半数或多数第二节点设备的第二响应通过了该TEE的验证,且通过验证的每个第二响应指示一个第二节点设备赞同该第一节点设备成为该区块链系统中的领导节点的情况下,该第一节点设备的TEE将该第一节点设备的节点状态切换为领导状态。509. In the blockchain system, half or most of the second responses of the second node devices pass the verification of the TEE, and each second response that passes the verification indicates that a second node device agrees that the first node device becomes the TEE. In the case of the leader node in the blockchain system, the TEE of the first node device switches the node status of the first node device to the leader status.
在一种可能的实现方式中,在该区块链系统中半数或多数第二节点设备的第二响应通过了该TEE的验证的情况下,该第一节点设备的TEE对该第二节点设备的第二响应进行解析,得到该第二响应携带的投票标识。In a possible implementation, when half or most of the second response of the second node device in the blockchain system passes the verification of the TEE, the TEE of the first node device will The second response is parsed to obtain the voting identifier carried in the second response.
该第一节点设备的TEE统计验证通过的第二响应中第一投票标识的总个数,其中,该总个数也即是共识集群中对该第一节点设备成为领导节点投赞成票的第二节点设备的总个数。该第一节点设备的TEE判断该总个数是否大于第一阈值,其中,该第一阈值为共识集群一半第二节点设备的个数。由于第一节点设备赞成该第一节点设备成为区块链系统中的领导节点,也是该第一节点设备为该第一节点设备投赞成票。若统计的总个数大于或等于第一阈值,再考虑到第一节点设赞成该第一节点设备成为领导节点,则说明共识集群中多数的共识节点设备赞同该第一节点设备成为区块链系统中的领导节点,则该第一节点设备的TEE将该第一节点设备的节点状态由候选状态切换为领导状态。The TEE statistical verification of the first node device is the total number of the first voting identifier in the second response, where the total number is the number of votes for the first node device to become the leader node in the consensus cluster. The total number of two-node devices. The TEE of the first node device judges whether the total number is greater than a first threshold, where the first threshold is half the number of second node devices in the consensus cluster. Because the first node device agrees that the first node device becomes the leader node in the blockchain system, it is also the first node device that votes for the first node device. If the total number of statistics is greater than or equal to the first threshold, and considering that the first node agrees that the first node device becomes the leader node, it means that most of the consensus node devices in the consensus cluster agree that the first node device becomes the blockchain The leader node in the system, the TEE of the first node device switches the node status of the first node device from the candidate status to the leader status.
例如,该第一节点设备的TEE将状态表内记录的该第一节点设备的跟随状态的标识更新为领导状态的标识,此时,该第一节点设备为该区块链系统中的领导节点。For example, the TEE of the first node device updates the identification of the following state of the first node device recorded in the state table to the identification of the leader state, and at this time, the first node device is the leader node in the blockchain system .
510、该第一节点设备的TEE生成通知消息,该通知消息指示该第一节点设备为该区块链系统中的领导节点。510. The TEE of the first node device generates a notification message, and the notification message indicates that the first node device is a leader node in the blockchain system.
其中,该通知消息为心跳消息或者是除心跳消息以外的其他类型的消息。该通知消息包括该第一节点设备的第一任期。Wherein, the notification message is a heartbeat message or other types of messages except the heartbeat message. The notification message includes the first term of the first node device.
在一种可能的实现方式中,该第一节点设备的TEE基于该第一任期生成该通知消息。In a possible implementation manner, the TEE of the first node device generates the notification message based on the first term.
在一种可能的实现方式中,该第一节点设备的TEE生成通知消息的动作,是由第一节点设备的REE来触发的,例如下述步骤5101-5103所示的过程。In a possible implementation manner, the action of the TEE of the first node device to generate the notification message is triggered by the REE of the first node device, for example, the process shown in the following steps 5101-5103.
步骤5101、若该第一节点设备的REE中的记录的目标时长已达到或已超时,该第一节点设备的REE生成第二消息,该第二消息用于提示该TEE向区块链系统中的第二节点设备发送通知消息。Step 5101: If the target duration of the record in the REE of the first node device has been reached or has timed out, the REE of the first node device generates a second message, which is used to prompt the TEE to send data to the blockchain system The second node device sends a notification message.
其中,该目标时长为领导节点在共识集群中周期性发送通知消息的时长,也即是每经过一个目标时长领导节点在共识集群中发送一次通知消息,以告知共识集群中的各个共识节点设备领导节点的存在。Among them, the target duration is the duration for the leader node to periodically send notification messages in the consensus cluster, that is, the leader node sends a notification message in the consensus cluster every time a target duration passes to inform each consensus node device leader in the consensus cluster the presence of nodes.
当该第一节点设备成为区块链系统中的领导节点后,该第一节点设备的TEE通知第一节点的REE该第一节点设备已经成为区块链系统中的领导节点。当该第一节点设备的REE接收到TEE的通知后,开启倒计时,若目标时长已达到或已超时,该第一节点设备的REE向该第一节点设备的TEE发送该第二消息。When the first node device becomes the leader node in the blockchain system, the TEE of the first node device notifies the REE of the first node that the first node device has become the leader node in the blockchain system. After receiving the notification from the TEE, the REE of the first node device starts the countdown, and if the target duration has been reached or expired, the REE of the first node device sends the second message to the TEE of the first node device.
步骤5102、该第一节点设备的TEE接收该第二消息,并对该第二消息进行验证。Step 5102, the TEE of the first node device receives the second message, and verifies the second message.
当该第一节点设备的TEE接收到该第二消息后,若该第一节点设备的TEE中记录的目标时长已经达到或超时,则说明第一节点设备的REE没有篡改目标时长,则该第一节点设备的TEE对该第二消息验证通过。若该第一节点设备的TEE中记录的目标时长还未达到,则说明该第一节点设备的REE篡改了目标时长,提前发送了第二消息,则该第一节点设备的TEE对该第二消息验证不通过。After the TEE of the first node device receives the second message, if the target duration recorded in the TEE of the first node device has reached or expired, it means that the REE of the first node device has not tampered with the target duration, then the second The TEE of a node device passes the verification of the second message. If the target duration recorded in the TEE of the first node device has not been reached, it means that the REE of the first node device has tampered with the target duration and sent the second message in advance, then the TEE of the first node device will Message verification failed.
步骤5103、在该第二消息通过了该第一节点设备的TEE验证的情况下,该第一节点设备的TEE生成该通知消息。Step 5103, if the second message is verified by the TEE of the first node device, the TEE of the first node device generates the notification message.
例如,在该第二消息通过了该第一节点设备的TEE验证的情况下,该第一节点设备的TEE基于该第一任期,生成通知消息。For example, if the second message passes the TEE verification of the first node device, the TEE of the first node device generates a notification message based on the first term.
在另一种可能的实现方式,为了避免该通知消息在离开该第一节点设备的TEE后,通知消息的内容被篡改,该第一节点设备的TEE基于该第一节点设备的私钥,对该通知消息进行签名,得到该通知消息的数字签名。In another possible implementation manner, in order to prevent the content of the notification message from being tampered with after the notification message leaves the TEE of the first node device, the TEE of the first node device is based on the private key of the first node device. The notification message is signed to obtain the digital signature of the notification message.
511、该第一节点设备的TEE通过第一节点设备的REE,向该区块链系统中的第二节点设备发送该通知消息。511. The TEE of the first node device sends the notification message to the second node device in the blockchain system through the REE of the first node device.
在一种可能实现方式中,该第一节点设备的TEE通过第一节点设备的REE,向该区块链系统中的第二节点设备,发送该通知消息以及该通知消息的数字签名。In a possible implementation manner, the TEE of the first node device sends the notification message and the digital signature of the notification message to the second node device in the blockchain system through the REE of the first node device.
其中,本步骤511所示的过程与上述步骤503中该第一节点设备的TEE通过第一节点设备REE,向该区块链系统中的第二节点设备发送该第二请求的过程同理,在此,本申请实施例对本步骤511不再赘述。Wherein, the process shown in this step 511 is the same as the process in which the TEE of the first node device sends the second request to the second node device in the blockchain system through the first node device REE in the above step 503, Here, step 511 is not described in detail in this embodiment of the present application.
512、第二节点设备的TEE通过该第二节点设备的REE,接收该通知消息。512. The TEE of the second node device receives the notification message through the REE of the second node device.
在一种可能实现方式中,第二节点设备的TEE通过该第二节点设备的REE,接收该通知消息以及该通知消息的数字签名。In a possible implementation manner, the TEE of the second node device receives the notification message and the digital signature of the notification message through the REE of the second node device.
其中,步骤512-514中的第二节点设备为该区块链系统中的任一个第二节点设备,也即是区块链系统中的每个第二节点设备均执行步骤512-514所示的过程。Wherein, the second node device in steps 512-514 is any second node device in the block chain system, that is, each second node device in the block chain system executes steps 512-514 the process of.
本步骤512所示的过程与上述步骤504中该第二节点设备的TEE通过该第二节点设备的 REE,接收该第二请求的过程同理,在此,本申请实施例对本步骤512不再赘述。The process shown in this step 512 is the same as the process of receiving the second request through the TEE of the second node device in the above step 504 through the REE of the second node device. repeat.
513、该第二节点设备的TEE对该通知消息进行验证。513. The TEE of the second node device verifies the notification message.
在一种可能的实现方式中,该第二节点设备的TEE基于该第一节点设备的公钥,对该通知消息进行验证。例如,该第二节点设备的TEE基于该第一节点设备的公钥,对该通知消息的数字签名进行验签。若验签成功,则该第二节点设备的TEE对该通知消息验证通过。若验签失败,说明该通知消息的内容已经被篡改,该第二节点设备的TEE对该通知消息验证不通过。In a possible implementation manner, the TEE of the second node device verifies the notification message based on the public key of the first node device. For example, the TEE of the second node device verifies the digital signature of the notification message based on the public key of the first node device. If the signature verification is successful, the TEE of the second node device passes the verification of the notification message. If the signature verification fails, it means that the content of the notification message has been tampered with, and the TEE of the second node device fails to verify the notification message.
514、在该通知消息通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE将存储的该第一节点设备的节点状态修改为领导状态。514. If the notification message passes the verification of the TEE of the second node device, the TEE of the second node device modifies the stored node status of the first node device to the leader status.
例如,该第二节点设备的TEE将状态表内该第一节点设备对应的跟随状态的标识修改为领导状态的标识,此时对于该第二节点设备而言,该区块链系统中的领导节点为第一节点设备。该第二节点设备的TEE还可以将状态表中除该第一节点设备以外的各个共识节点设备的节点状态的标识更新为跟随状态的标识,以指示共识集群中除该第一节点设备以外的各个共识节点设备均为跟随节点。For example, the TEE of the second node device modifies the identification of the following state corresponding to the first node device in the state table to the identification of the leader state. At this time, for the second node device, the leader in the blockchain system The node is a first node device. The TEE of the second node device can also update the node status identification of each consensus node device in the state table except the first node device to the identification of the following state, to indicate that in the consensus cluster other than the first node device Each consensus node device is a follower node.
在一种可能的实现方式中,在该通知消息通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE从该通知消息中,解析出该第一节点设备的第一任期。该第二节点设备的TEE将记录的该第二节点设备的任期更新为该第一任期,从而在该第一节点设备成为该区块链系统中的领导节点后,该区块链系统中的共识节点设备将领导节点的任期作为各自最新的任期。In a possible implementation manner, when the notification message passes the verification of the TEE of the second node device, the TEE of the second node device parses out the one term. The TEE of the second node device updates the recorded term of the second node device to the first term, so that after the first node device becomes the leader node in the blockchain system, the Consensus node devices take the term of the leader node as their latest term.
本申请实施例提供的方法,通过区块链系统中节点设备的TEE生成第二请求,并向区块链系统中的其他节点设备发送第二请求,以发起选举。由于TEE不会出现拜占庭错误,因此在TEE在生成第二请求时不会出现拜占庭错误,从而能够避免参加节点设备恶意发起选举,减少了区块链系统中出现的拜占庭错误。并且,节点设备的REE在触发TEE发起选举之后,TEE还会对选举时间是否真正到达进行验证,从而可以避免因REE中的选举时间被恶意篡改,提前发起选举的情况发生。并且,第一节点设备的TEE将消息(如第二请求、第二响应或者通知消息)以及消息的数字签名一起发送给第二节点设备,并由第二节点设备对基于该消息的数字签名,对该消息进行验证,从而避免消息离开第一节点设备的TEE后,消息的内容被篡改。In the method provided by the embodiment of the present application, the TEE of the node device in the blockchain system generates a second request, and sends the second request to other node devices in the blockchain system to initiate an election. Since the TEE does not have a Byzantine error, there will be no Byzantine error when the TEE generates the second request, thereby avoiding the malicious initiation of elections by participating node devices and reducing the Byzantine error in the blockchain system. In addition, after the REE of the node device triggers the TEE to initiate an election, the TEE will also verify whether the election time has actually arrived, so as to avoid the situation that the election time in the REE is maliciously tampered with and the election is initiated in advance. And, the TEE of the first node device sends the message (such as the second request, the second response or the notification message) and the digital signature of the message to the second node device together, and the digital signature based on the message is sent by the second node device, The message is verified, so as to prevent the content of the message from being tampered with after the message leaves the TEE of the first node device.
为了进一步说明图5的过程,参见图6所示的本申请实施例提供的一种领导节点选举流程的示意图。区块链系统中的每个共识节点设备在启动时,每个共识节点设备的REE调用初始化接口,触发每个共识节点设备的TEE进行初始化共识(initialize consensus,initconsensus)配置(例如上述步骤5011-5013所示的过程),每个该共识节点设备的TEE还会向所属共识节点设备的REE发送选举时间,以便REE开启倒计时。当区块链系统中第一个跟随节点(即初始时选举时间最近的跟随节点)的选举时间到达时,该跟随节点的REE调用超时接口,提示该跟随节点的TEE发起选举。该跟随节点的TEE进一步地验证该选举时间是否真实的到达或超时,以保证超时机制的正确性。当该选举时间确实是真实到达或超时,则该跟随节点变成候选节点。该候选节点的TEE增加候选节点的任期,并根据增加后的任期,生成第二请求。该候选节点的TEE通过输出(output)接口,向该候选节点的REE发送该第二请求。该候选节点的REE接收并向共识集群中除该候选节点以外的非领导节点发送该第二请求。非领 导节点的REE接收该第二请求,并通过调用输入(input)接口,向非领导节点的TEE发送该第二请求。非领导节点的TEE根据自己的任期,确定是否投票给该候选节点,非领导节点的TEE通过输出接口向该非领导节点的REE发送第二响应。该非领导节点的REE接收并向该候选节点发送该第二响应。该候选节点的REE接收该非领导节点设备发送的第二响应,并通过输入接口向该候选节点的TEE发送接收到的第二响应。该候选节点的TEE基于接收到各个第二响应,统计为共识集群中为该候选节点投赞成票的非领导节点的个数,若共识集群中多数的非领导节点投赞成票,则该候选节点成为区块链系统中的领导节点。该领导节点的REE校验心跳时长(如目标时长)是否到达,若到达则提示领导节点的TEE生成心跳信息(如通知消息)。领导节点的TEE收到REE的提示后先验证心跳时长是否真正到达,若真正到达,则领导节点的TEE生成心跳信息,并通过输出接口向领导节点的REE发送心跳消息。领导节点的REE接收并向共识集群中的非领导节点发送该心跳消息。非领导节点的REE接收到心跳消息后,通过调用输入接口,向非领导节点的TEE发送将该心跳消息,当非领导节点的TEE收到该心跳消息后,表明区块链系统中已经产生领导节点,则非领导节点成为跟随节点,非领导节点的TEE记录领导节点的信息。To further illustrate the process in FIG. 5 , refer to FIG. 6 , which is a schematic diagram of a leader node election process provided by an embodiment of the present application. When each consensus node device in the blockchain system is started, the REE of each consensus node device calls the initialization interface, triggering the TEE of each consensus node device to initialize consensus (initialize consensus, initconsensus) configuration (such as the above steps 5011- 5013), the TEE of each consensus node device will also send the election time to the REE of the consensus node device, so that the REE starts the countdown. When the election time of the first follower node in the blockchain system (that is, the follower node with the closest initial election time) arrives, the REE of the follower node invokes the timeout interface to prompt the TEE of the follower node to initiate an election. The TEE of the following node further verifies whether the election time has actually arrived or expired, so as to ensure the correctness of the timeout mechanism. When the election time is actually reached or timed out, the follower node becomes a candidate node. The TEE of the candidate node increases the term of the candidate node, and generates a second request according to the increased term. The TEE of the candidate node sends the second request to the REE of the candidate node through an output (output) interface. The REE of the candidate node receives and sends the second request to non-leader nodes in the consensus cluster except the candidate node. The REE of the non-leader node receives the second request, and sends the second request to the TEE of the non-leader node by calling an input (input) interface. The TEE of the non-leader node determines whether to vote for the candidate node according to its term of office, and the TEE of the non-leader node sends a second response to the REE of the non-leader node through the output interface. The REE of the non-leader node receives and sends the second response to the candidate node. The REE of the candidate node receives the second response sent by the non-leader node device, and sends the received second response to the TEE of the candidate node through an input interface. The TEE of the candidate node is counted as the number of non-leader nodes that voted for the candidate node in the consensus cluster based on receiving each second response. If the majority of non-leader nodes in the consensus cluster voted for the candidate node, the candidate node Become a leader node in the blockchain system. The REE of the leader node checks whether the heartbeat duration (such as the target duration) has arrived, and if it arrives, it prompts the TEE of the leader node to generate heartbeat information (such as a notification message). After receiving the prompt from REE, the TEE of the leader node first verifies whether the heartbeat duration has really arrived. If it does arrive, the TEE of the leader node generates a heartbeat message and sends a heartbeat message to the REE of the leader node through the output interface. The REE of the leader node receives and sends this heartbeat message to the non-leader nodes in the consensus cluster. After the REE of the non-leadership node receives the heartbeat message, it sends the heartbeat message to the TEE of the non-leadership node by calling the input interface. When the TEE of the non-leadership node receives the heartbeat message, it indicates that a leader has been generated in the blockchain system. node, the non-leader node becomes a follower node, and the TEE of the non-leader node records the information of the leader node.
共识集群中的领导节点用于生成区块,共识集群中的各个共识节点设备用于共识区块,为了进一步说明区块共识的过程,参见图7所示的本申请实施例提供的一种数据处理方法的流程图。The leader node in the consensus cluster is used to generate blocks, and each consensus node device in the consensus cluster is used for consensus blocks. In order to further illustrate the process of block consensus, refer to a data provided by the embodiment of this application shown in Figure 7 Flowchart of the processing method.
701、若第一节点设备为区块链系统中的领导节点,该第一节点设备的REE获取终端的第五请求。701. If the first node device is the leader node in the blockchain system, the REE of the first node device acquires the fifth request of the terminal.
其中,该第五请求指示在至少两个区块链账户之间进行交易。该终端为第一节点设备以外的用户设备,或者为该第一节点设备。Wherein, the fifth request indicates to perform transactions between at least two blockchain accounts. The terminal is user equipment other than the first node device, or the first node device.
该终端内安装有客户端,用户向该客户端下达对至少两个区块链账户之间进行交易的交易指令,当接收到该交易指令后,该客户端基于该交易指令,生成该第五请求。若第一节点设备为该终端,则该第一节点设备从该客户端获取该第五请求。A client is installed in the terminal, and the user issues a transaction instruction to the client to conduct transactions between at least two blockchain accounts. After receiving the transaction instruction, the client generates the fifth transaction instruction based on the transaction instruction. ask. If the first node device is the terminal, the first node device obtains the fifth request from the client.
若该第一节点设备为第一节点设备以外的用户设备,该终端从客户端获取该第五请求,并向该第一节点设备发送该第五请求,相应地,该第一节点设备的REE接收该第五请求。或者,该终端向区块链系统中的任一个第二节点设备发送该第五请求,当该第二节点设备的REE接收到该终端的第五请求后,向该第二节点设备的TEE发送该第五请求。该第二节点设备的TEE通过该第二节点设备的REE,向该第一节点设备发送该第五请求,相应地,该第一节点设备的REE从该第二节点设备接收该第五请求。If the first node device is a user device other than the first node device, the terminal obtains the fifth request from the client and sends the fifth request to the first node device, correspondingly, the REE of the first node device The fifth request is received. Or, the terminal sends the fifth request to any second node device in the blockchain system, and when the REE of the second node device receives the fifth request of the terminal, it sends the fifth request to the TEE of the second node device The fifth request. The TEE of the second node device sends the fifth request to the first node device through the REE of the second node device, and correspondingly, the REE of the first node device receives the fifth request from the second node device.
702、该第一节点设备的REE基于该第五请求,生成区块,并缓存该区块。702. The REE of the first node device generates a block based on the fifth request, and caches the block.
其中,该区块为该第一节点设备生成的任一区块,该区块包括至少一个交易事件,每个交易事件指示已经完成至少两个区块链账户之间的交易。Wherein, the block is any block generated by the first node device, and the block includes at least one transaction event, and each transaction event indicates that a transaction between at least two blockchain accounts has been completed.
在一种可能的实现方式中,该第一节点设备的REE基于该第五请求的指示,在至少两个区块链账户之间进行交易,得到该第五请求对应的交易事件。该第一节点设备的REE将该交易事件打包成区块体,或者将该交易事件以及事件池中的至少一个交易事件打包成区块体,其中,该事件池包括多个待打包的交易事件。该第一节点设备的REE基于该区块体中的各个交易事件,在该区块体上添加区块头,得到该区块。其中,该区块头包括该区块的哈希值以及该区块的区块号,该区块的哈希值基于该区块体中各个交易事件的哈希值得到,该区块的 块号比本地的该区块链系统的区块链账本上最后一个区块的区块号大1。其中,区块链账本上任一区块的区块号指示该任一区块在区块链账本上的位置,任一区块的区块号也可以称为该任一区块的块高。In a possible implementation manner, the REE of the first node device conducts transactions between at least two blockchain accounts based on the indication of the fifth request, and obtains a transaction event corresponding to the fifth request. The REE of the first node device packages the transaction event into a block body, or packages the transaction event and at least one transaction event in the event pool into a block body, wherein the event pool includes multiple transaction events to be packaged . The REE of the first node device adds a block header to the block body based on each transaction event in the block body to obtain the block. Wherein, the block header includes the hash value of the block and the block number of the block, the hash value of the block is obtained based on the hash value of each transaction event in the block body, and the block number of the block It is 1 larger than the block number of the last block on the blockchain ledger of the local blockchain system. Wherein, the block number of any block on the blockchain ledger indicates the position of any block on the blockchain ledger, and the block number of any block may also be referred to as the block height of any block.
在一种可能的实现方式中,当该区块生成后,该第一节点设备的REE将该区块缓存在内存中。In a possible implementation manner, after the block is generated, the REE of the first node device caches the block in memory.
在一种可能的实现方式中,本步骤702所示的过程由该第一节点设备的REE中的提案模块来执行。In a possible implementation manner, the process shown in step 702 is executed by the proposal module in the REE of the first node device.
703、该第一节点设备的REE向该第一节点设备的TEE发送该区块的标识。703. The REE of the first node device sends the identifier of the block to the TEE of the first node device.
其中,该区块的标识的用于指代该区块。在一种可能的实现方式中,该区块的标识包括该区块的哈希值以及该区块的区块号中的至少一个。Wherein, the identifier of the block is used to refer to the block. In a possible implementation manner, the identifier of the block includes at least one of a hash value of the block and a block number of the block.
在一种可能的实现方式中,该第一节点设备的REE生成第三消息,该第三消息指示共识集群对该区块进行共识。其中,该第三消息携带该区块的标识。该第一节点设备的REE向第一节点设备的TEE发送该第三消息。In a possible implementation manner, the REE of the first node device generates a third message, and the third message instructs the consensus cluster to perform consensus on the block. Wherein, the third message carries the identifier of the block. The REE of the first node device sends the third message to the TEE of the first node device.
在一种可能的实现方式中,本步骤703由该第一节点设备的REE中的提案模块来执行,例如提案模块基于该区块中该区块的标识,生成第三消息,向该第一节点设备的REE中的消息调度模块发送该第三消息,该消息调度模块向该第一节点设备的TEE发送该第三消息。In a possible implementation, step 703 is performed by the proposal module in the REE of the first node device. For example, the proposal module generates a third message based on the identifier of the block in the block, and sends the first The message scheduling module in the REE of the node device sends the third message, and the message scheduling module sends the third message to the TEE of the first node device.
704、该第一节点设备的TEE接收该区块的标识,并基于该区块的标识,生成该区块的日志,该日志中以该区块的标识指代该区块。704. The TEE of the first node device receives the identification of the block, and generates a log of the block based on the identification of the block, where the block is referred to by the identification of the block in the log.
其中,该日志包括该区块的标识,但不包括该区块,并以区块的标识指代该区块,但该日志不包括该区块。例如,所述区块的标识包括所述区块的哈希值和所述区块的区块号中的至少一个,当然,该日志的标识也可以是除区块的哈希值或者区块号以外的其他表示方式,在此本申请对该日志的标识不做限定。Wherein, the log includes the identifier of the block, but does not include the block, and refers to the block with the identifier of the block, but the log does not include the block. For example, the identification of the block includes at least one of the hash value of the block and the block number of the block. Of course, the identification of the log can also be the hash value of the block or the block number There are other representation methods other than the number, and this application does not limit the logo of the log.
由于本申请中的日志以区块的标识指代该区块,因此,本申请中的日志不包括该区块。而相关技术中的日志没有采用区块的标识来指代日志,而是直接将区块添加在日志中,也即是相关技术中的日志包括区块。或者也可以理解为,本申请将相关技术中日志内的区块用成区块的标识来替代。而区块的标识相对于整个区块来而言数据量会更小,因此,与相关技术中的日志相比,本申请中的日志的数据量更小。Since the log in the present application refers to the block with the identifier of the block, the log in the present application does not include the block. However, the log in the related art does not use the identifier of the block to refer to the log, but directly adds the block to the log, that is, the log in the related art includes the block. Or it can also be understood that the present application replaces the blocks in the log in the related art with block identifiers. Compared with the whole block, the identification of the block will have a smaller data volume. Therefore, compared with the log in the related art, the data volume of the log in the present application is smaller.
在一种可能的实现方式中,该日志还包括该日志的索引以及该第一节点设备的任期中的至少一个。In a possible implementation manner, the log further includes at least one of an index of the log and a tenure of the first node device.
在一种可能的实现方式中,该第一节点设备的TEE接收该第三消息,该第一节点设备的TEE从该第三消息中解析出该区块的标识,并基于该区块的标识,生成该日志。In a possible implementation, the TEE of the first node device receives the third message, and the TEE of the first node device parses out the identity of the block from the third message, and based on the identity of the block , to generate the log.
例如,该第一节点设备的TEE中存储有该第一节点设备的日志序列,该第一节点设备的TEE基于该日志序列中最后一个日志的索引,生成目标索引,该第一节点设备的TEE基于目标索引以及该区块的标识,生成该日志。该第一节点设备的TEE在该日志序列中添加该日志。For example, the log sequence of the first node device is stored in the TEE of the first node device, and the TEE of the first node device generates a target index based on the index of the last log in the log sequence, and the TEE of the first node device The log is generated based on the target index and the identity of the block. The TEE of the first node device adds the log in the log sequence.
其中,该目标索引为该日志的索引,该目标索引比该日志序列中该最后一个日志的索引大第二预设数值。该第二预设数值为日志序列中相邻两个日志的索引之间差值,该第二预设数值可以是1或其他数值,该第二预设数值可以根据实际应用场景进行设置,在此,本申请实施例对该第二预设数值不做限定。Wherein, the target index is the index of the log, and the target index is greater than the index of the last log in the log sequence by a second preset value. The second preset value is the difference between the indexes of two adjacent logs in the log sequence. The second preset value can be 1 or other values. The second preset value can be set according to the actual application scenario. Therefore, the embodiment of the present application does not limit the second preset value.
在一种可能的实现方式中,该第一节点设备的TEE将该日志的状态记录为未提交状态, 以指示该日志对应的区块还未提交至本地的该区块链系统的区块链账本。In a possible implementation, the TEE of the first node device records the state of the log as an uncommitted state, to indicate that the block corresponding to the log has not been submitted to the local block chain of the block chain system ledger.
需要说明的是,上述步骤703-704为第一节点设备的TEE基于第一节点设备的REE中的区块,生成该区块的日志的一种方式。It should be noted that the above steps 703-704 are a way for the TEE of the first node device to generate a log of the block based on the block in the REE of the first node device.
在另一种可能的实现方式中,第一节点设备的TEE基于第一节点设备的REE中的区块,生成该区块的日志包括:该第一节点设备的REE向该第一节点设备的TEE发送第三消息,该三消息包括该区块。该第一节点设备的TEE从该第三消息携带的区块中,获取该区块的标识,并基于该区块的标识,生成该区块的日志。当该日志生成后,该第一节点设备的TEE丢弃该区块。In another possible implementation manner, the TEE of the first node device is based on a block in the REE of the first node device, and generating the log of the block includes: sending the REE of the first node device to the block of the first node device The TEE sends a third message, which includes the block. The TEE of the first node device obtains the identifier of the block from the block carried in the third message, and generates a log of the block based on the identifier of the block. After the log is generated, the TEE of the first node device discards the block.
相对于包括区块的第三消息,包括区块的标识的第三消息的数据量要少得多,例如图8所示的本申请实施例提供的一种不同第三消息的数据量对比示意图,图8中包括区块的第三消息的数据量可以达到2M,而包括区块的标识的第三消息的数据量有200字节(bytes)。因此,REE向TEE发送区块的标识,能够降低TEE与REE间交互的数据量。Compared with the third message including the block, the data amount of the third message including the identification of the block is much smaller, for example, the data amount comparison diagram of a different third message provided by the embodiment of the present application shown in FIG. 8 , the data volume of the third message including the block in FIG. 8 can reach 2M, and the data volume of the third message including the identification of the block is 200 bytes (bytes). Therefore, the REE sends the block identifier to the TEE, which can reduce the amount of data exchanged between the TEE and the REE.
705、该第一节点设备的TEE向该第一节点设备的REE发送该日志。705. The TEE of the first node device sends the log to the REE of the first node device.
在一种可能的实现方式中,该第一节点设备的TEE基于该日志,生成第一目标消息,该第一目标消息携带该日志,该第一目标消息指示区块链系统中的第二节点设备处理该日志以及该日志对应的区块,该第一节点设备的TEE向该第一节点设备的REE发送该第一目标消息。In a possible implementation, the TEE of the first node device generates a first target message based on the log, the first target message carries the log, and the first target message indicates that the second node in the blockchain system The device processes the log and the block corresponding to the log, and the TEE of the first node device sends the first target message to the REE of the first node device.
在另一种可能的实现方式中,为了避免该第一目标消息在离开该第一节点设备的TEE后,该第一目标消息的内容被篡改,该第一节点设备的TEE基于该第一节点设备的私钥,对该第一目标消息进行签名,得到该第一目标消息的数字签名。相应地,该第一节点设备的TEE向该第一节点设备的REE发送该第一目标消息以及该第一目标消息的数字签名。In another possible implementation manner, in order to prevent the content of the first target message from being tampered with after the first target message leaves the TEE of the first node device, the TEE of the first node device is based on the The private key of the device signs the first target message to obtain the digital signature of the first target message. Correspondingly, the TEE of the first node device sends the first target message and the digital signature of the first target message to the REE of the first node device.
706、该第一节点设备的REE接收该日志,向该区块链系统中的第二节点设备发送第一请求,该第一请求携带该日志,该第一请求指示该第二节点设备处理该日志。706. The REE of the first node device receives the log, sends a first request to the second node device in the blockchain system, the first request carries the log, and the first request instructs the second node device to process the log. log.
在一种可能的实现方式中,该第一节点设备的REE接收第一目标消息,基于该第一目标消息携带的该日志,在内存中查询该日志中区块的标识所指代的区块。该第一节点设备的REE基于查询到的区块以及该第一目标消息,生成该第一请求,此时该第一请求携带该区块以及该第一目标消息,此时,该第一请求指示对区块以及该区块的日志进行处理。In a possible implementation manner, the REE of the first node device receives the first target message, and based on the log carried by the first target message, queries the block indicated by the block identifier in the log in the memory . The REE of the first node device generates the first request based on the queried block and the first target message. At this time, the first request carries the block and the first target message. At this time, the first request Indicates processing of the block and the log for that block.
若该第一节点设备的REE还接收到该第一目标消息的数字签名,则该第一节点设备的REE基于查询到的区块、该第一目标消息以及该第一目标消息的数字签名,生成该第一请求,此时该第一请求携带该区块、该第一目标消息以及该第一目标消息的数字签名,此时,该第一请求指示对区块以及该区块的日志进行处理。If the REE of the first node device also receives the digital signature of the first target message, then the REE of the first node device is based on the queried block, the first target message, and the digital signature of the first target message, generating the first request, at this time, the first request carries the block, the first target message, and the digital signature of the first target message, and at this time, the first request indicates that the log of the block and the block should be deal with.
当该第一节点设备的REE生成该第一请求后,向该区块链系统中的第二节点设备发送第一请求。After the REE of the first node device generates the first request, it sends the first request to the second node device in the blockchain system.
为了进一步体现该第一请求与日志复制请求的不同之处,参见图9所示的本申请实施例提供的一种第一请求与相关技术中的日志复制请求的对比示意图。如图9所示,日志复制请求携带区块的日志,且日志复制请求中的日志包括日志的索引以及区块,该日志复制请求中的日志为相关技术中的日志。而第一请求携带的是区块和区块的日志,且第一请求中的日志包括区块的标识以及日志的索引,而不包括区块。In order to further reflect the difference between the first request and the log copy request, see FIG. 9 , which is a schematic diagram showing a comparison between a first request provided by an embodiment of the present application and a log copy request in the related art. As shown in FIG. 9 , the log copy request carries the log of the block, and the log in the log copy request includes the index of the log and the block, and the log in the log copy request is a log in the related art. However, what the first request carries is a block and a log of the block, and the log in the first request includes the identification of the block and the index of the log, but does not include the block.
707、第二节点设备的REE接收该第一请求。707. The REE of the second node device receives the first request.
其中,步骤707-712中的第二节点设备为该区块链系统中的任一个第二节点设备,也即是区块链系统中的每个第二节点设备均执行步骤707-712所示的过程。Wherein, the second node device in steps 707-712 is any second node device in the blockchain system, that is, each second node device in the blockchain system executes steps 707-712 the process of.
708、该第二节点设备的REE缓存该第一请求中的该区块。708. The REE of the second node device caches the block in the first request.
例如,该第二节点设备的REE将该第一请求携带的该区块转移至内存中。For example, the REE of the second node device transfers the block carried in the first request to memory.
709、该第二节点设备的REE向该第二节点设备的TEE发送该日志。709. The REE of the second node device sends the log to the TEE of the second node device.
例如,该第二节点设备的REE向该第二节点设备的TEE发送转移区块后的第一请求,此时,该第一请求不再携带该区块。For example, the REE of the second node device sends a first request after transferring the block to the TEE of the second node device, and at this time, the first request no longer carries the block.
710、该第二节点设备的TEE接收该日志,并对该日志进行验证。710. The TEE of the second node device receives the log and verifies the log.
在一种可能的实现方式中,该第二节点设备的TEE接收该第二节点设备的REE发送的第一请求,从该第一请求中解析出第一目标消息,或者解析出该第一目标消息以及该第一目标消息的数字签名。In a possible implementation, the TEE of the second node device receives the first request sent by the REE of the second node device, and parses out the first target message from the first request, or parses out the first target message and the digital signature of the first target message.
该第二节点设备的TEE对该日志进行验证方式包括下述方式1或2中的任一方式。A manner in which the TEE of the second node device verifies the log includes any of the following manners 1 or 2.
方式1、该第二节点设备的TEE中存储有该第二节点设备的日志序列,该第二节点设备的TEE基于该日志序列中最后一个日志的索引,对该日志进行验证。Mode 1. The log sequence of the second node device is stored in the TEE of the second node device, and the TEE of the second node device verifies the log based on the index of the last log in the log sequence.
例如,该第二节点设备的TEE从该目标消息中获取该日志,将该日志的索引与该日志序列中最后一个日志的索引进行比较,若该日志的索引比该日志序列中该最后一个日志的索引大第二预设数值,则该第二节点设备的TEE对该日志验证通过,否则对该日志验证不通过。For example, the TEE of the second node device obtains the log from the target message, compares the index of the log with the index of the last log in the log sequence, and if the index of the log is higher than the index of the last log in the log sequence If the index of is greater than the second preset value, then the TEE of the second node device passes the verification of the log, otherwise the verification of the log fails.
方式2、该第二节点设备的TEE基于该日志序列中最后一个日志的索引以及该第一节点设备的对公钥,对该日志进行验证。 Mode 2. The TEE of the second node device verifies the log based on the index of the last log in the log sequence and the pair public key of the first node device.
若从该第一请求中解析出该第一目标消息以及该第一目标消息的数字签名,该第二节点设备的TEE基于该第一节点设备的公钥,对该第一目标消息进行验签。若验签成功,则该第二节点设备的TEE对该第一目标消息验证通过。若验签失败,说明该第一目标消息的内容已经被篡改,则该第二节点设备的TEE对该第一目标消息验证不通过。If the first target message and the digital signature of the first target message are parsed from the first request, the TEE of the second node device verifies the signature of the first target message based on the public key of the first node device . If the signature verification is successful, the TEE of the second node device passes the verification of the first target message. If the signature verification fails, it means that the content of the first target message has been tampered with, and the TEE of the second node device fails to verify the first target message.
在该第二节点设备的TEE对该第一目标消息验证通过的情况下,该第二节点设备的TEE从该目标消息中获取该日志,若该日志的索引比该日志序列中该最后一个日志的索引大第二预设数值,则该第二节点设备的TEE对该日志验证通过,否则对该日志验证不通过。或者,若该日志的索引比该日志序列中该最后一个日志的索引大第二预设数值,且该日志携带的第一节点设备的任期与该第二节点设备TEE记录区块链系统中领导节点的任期相同,则该第二节点设备的TEE对该日志验证通过,否则对该日志验证不通过。In the case that the TEE of the second node device passes the verification of the first target message, the TEE of the second node device obtains the log from the target message, if the index of the log is greater than the last log in the log sequence If the index of is greater than the second preset value, then the TEE of the second node device passes the verification of the log, otherwise the verification of the log fails. Or, if the index of the log is greater than the index of the last log in the log sequence by a second preset value, and the tenure of the first node device carried by the log is the same as that of the second node device TEE record leader in the blockchain system If the tenure of the nodes is the same, the TEE of the second node device passes the verification of the log; otherwise, the verification of the log fails.
711、在该日志通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE存储该日志。711. If the log passes the verification of the TEE of the second node device, the TEE of the second node device stores the log.
若该第二节点设备的TEE对该日志验证通过,则第二节点设备的TEE在该第二节点设备的日志序列中添加该日志,此时,该日志为该日志序列中的最后一个日志。If the TEE of the second node device passes the verification of the log, the TEE of the second node device adds the log to the log sequence of the second node device, and at this time, the log is the last log in the log sequence.
在一种可能的实现方式中,在该日志通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE将该日志的状态记录为未提交状态,以指示该日志对应的区块还未提交至本地的该区块链系统的区块链账本。In a possible implementation, when the log has passed the verification of the TEE of the second node device, the TEE of the second node device records the status of the log as uncommitted to indicate that the log corresponds to The blocks of have not yet been submitted to the blockchain ledger of the local blockchain system.
在该日志没有通过该第二节点设备的TEE的验证的情况下,则该第二节点设备不执行本步骤711。If the log does not pass the verification of the TEE of the second node device, the second node device does not perform step 711 .
712、该第二节点设备的TEE通过该第二节点设备的REE,向该第一节点设备发送第一 响应,该第一响应指示一个第二节点设备已经同意接收该日志。712. The TEE of the second node device sends a first response to the first node device through the REE of the second node device, where the first response indicates that a second node device has agreed to receive the log.
其中,该第一响应包括第一目标标识或第二目标标识,该第一目标标识指示第二节点设备已经同意接收该日志,该第二目标标识指示该第二节点设备不同意接收该日志。Wherein, the first response includes a first target identifier or a second target identifier, the first target identifier indicates that the second node device has agreed to receive the log, and the second target identifier indicates that the second node device does not agree to receive the log.
在一种可能的实现方式中,在该日志通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE生成包括第一目标标识的第一响应,此时第一响应指示第二节点设备已经同意接收该日志。在该日志没有通过该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE生成包括第二目标标识的第一响应,此时第一响应指示该第二节点设备不同意接收该日志。In a possible implementation, when the log passes the verification of the TEE of the second node device, the TEE of the second node device generates a first response including the first target identifier, and the first response Indicates that the second node device has agreed to receive the log. In the case that the log does not pass the verification of the TEE of the second node device, the TEE of the second node device generates a first response including the second target identifier, and at this time, the first response indicates that the second node device does not agree to receive the log.
进一步地,为了避免该第一响应的内容被篡改,该第二节点设备的TEE基于该第二节点设备的私钥,对该第一响应进行签名,得到该第一响应的数字签名。相应地,该第二节点设备的TEE通过该第二节点设备的REE,向该第一节点设备发送第一响应以及该第一响应的数字签名。Further, in order to prevent the content of the first response from being tampered with, the TEE of the second node device signs the first response based on the private key of the second node device to obtain a digital signature of the first response. Correspondingly, the TEE of the second node device sends the first response and the digital signature of the first response to the first node device through the REE of the second node device.
该第二节点设备的TEE通过第二节点设备的REE,向该第一节点设备发送第一响应的过程与步骤506中该第二节点设备的TEE通过该第二节点设备的REE,向该第一节点设备发送第二响应的过程同理,在此,本申请实施例对该第二节点设备的TEE通过第二节点设备的REE,向该第一节点设备发送第一响应的过程不再赘述。The process that the TEE of the second node device sends the first response to the first node device through the REE of the second node device is the same as that in step 506, the TEE of the second node device sends the first response to the first node device through the REE of the second node device The process of sending the second response by a node device is the same. Here, the embodiment of the present application uses the TEE of the second node device to send the first response to the first node device through the REE of the second node device. .
713、该第一节点设备的TEE通过第一节点设备的REE接收多个第一响应。713. The TEE of the first node device receives multiple first responses through the REE of the first node device.
其中,该多个第一响应中的每个第一响应分别来自共识集群中的一个第二节点设备。在一种可能的实现方式中,该第一节点设备的TEE通过第一节点设备的REE,接收多个第一响应以及每个第一响应的数字签名。Wherein, each of the multiple first responses is from a second node device in the consensus cluster. In a possible implementation manner, the TEE of the first node device receives multiple first responses and a digital signature of each first response through the REE of the first node device.
该第一节点设备的TEE通过第一节点设备的REE接收多个第一响应的过程与步骤507中该第一节点设备的TEE通过第一节点设备的REE接收多个第二响应的过程同理,在此,本申请实施例对本步骤713不再赘述。The process for the TEE of the first node device to receive multiple first responses through the REE of the first node device is the same as the process for the TEE of the first node device to receive multiple second responses through the REE of the first node device in step 507 Here, step 713 is not described in detail in this embodiment of the present application.
714、该第一节点设备的TEE对接收到的每个第一响应进行验证。714. The TEE of the first node device verifies each received first response.
以该第一节点设备的TEE对一个第二节点设备的第一响应进行验证为例,对本步骤714进行如下介绍:Taking the TEE of the first node device verifying the first response of a second node device as an example, this step 714 is introduced as follows:
该第一节点设备的TEE基于该第二节点设备的公钥,对该第二节点设备的第一响应的数字签名进行验签。若验签成功,则该第一节点设备的TEE对该第一响应验证通过。若验签失败,则说明该第一响应的内容已经被篡改,则该第一节点设备的TEE对该第一响应验证不通过。The TEE of the first node device verifies the digital signature of the first response of the second node device based on the public key of the second node device. If the signature verification is successful, the TEE of the first node device passes the verification of the first response. If the signature verification fails, it means that the content of the first response has been tampered with, and the TEE of the first node device fails to verify the first response.
715、在该区块链系统中半数或多数第二节点设备的第一响应通过了第一节点设备的TEE的验证,且通过验证的每个第一响应指示一个第二节点设备已经同意接收该日志的情况下,该第一节点设备的TEE基于该日志中该区块的标识,通知该REE将该区块提交至本地的该区块链系统的区块链账本。715. In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE of the first node device, and each first response that has passed the verification indicates that a second node device has agreed to receive the TEE In the case of a log, the TEE of the first node device notifies the REE to submit the block to the local blockchain ledger of the blockchain system based on the identification of the block in the log.
其中,第一节点设备的本地的该区块链系统的区块账本存储在该第一节点设备的REE。Wherein, the block ledger of the local blockchain system of the first node device is stored in the REE of the first node device.
在一种可能的实现方式中,在该区块链系统中半数或多数第二节点设备的第一响应通过了第一节点设备的TEE的验证的情况下,该第一节点设备的TEE对该第二节点设备的第一响应进行解析,得到该第一响应携带的目标标识(如第一目标标识或第二目标标识)。该第一节节点设备的TEE统计验证通过的第一响应中第一目标标识的总个数,其中,该总个数也即 是共识集群中同意接收该日志的第二节点设备的个数。该第一节点设备TEE判断该总个数是否大于第一阈值。由于第一节点设备的TEE已经将该日志添加至第一节点设备的日志序列,则该第一节点设备已经同意接收日志。则若该总个数大于或等于第一阈值,再考虑到第一节点设备已经同意接收日志,则说明共识集群中多数的共识节点设备已经同意接收日志,也即是该共识集群对该日志共识通过,也即是共识集群对该日志对应的区块共识通过。则该第一节点设备的TEE基于该日志中该区块的标识,通知该REE将该区块提交至本地的该区块链系统的区块链账本。In a possible implementation, when half or most of the first responses of the second node devices in the blockchain system pass the verification of the TEE of the first node device, the TEE of the first node device The first response of the second node device is parsed to obtain the target identifier (such as the first target identifier or the second target identifier) carried in the first response. The total number of first target identifiers in the first response whose TEE statistical verification of the node device in the first section passes, wherein, the total number is also the number of second node devices in the consensus cluster that agree to receive the log. The first node device TEE judges whether the total number is greater than a first threshold. Since the TEE of the first node device has added the log to the log sequence of the first node device, the first node device has agreed to receive the log. Then if the total number is greater than or equal to the first threshold, and considering that the first node device has agreed to receive the log, it means that most of the consensus node devices in the consensus cluster have agreed to receive the log, that is, the consensus cluster has agreed to receive the log. Passed, that is, the consensus cluster passed the consensus of the block corresponding to the log. Then, based on the identification of the block in the log, the TEE of the first node device notifies the REE to submit the block to the local blockchain ledger of the blockchain system.
例如,该第一节点设备的TEE基于该日志中区块的标识,生成第四消息,该第四消息携带该区块的标识,该第四消息指示该第一节点设备的REE将该区块提交至本地的该区块链系统的区块链账本。该第一节点设备的TEE向该第一节点设备的REE发送该第四消息。之后该第一节点设备的REE接收该第四消息,并基于第四消息携带的该区块的标识,查询内存中缓存的该区块,并将查询到的区块存储在持久化存储介质中该区块链系统的区块链账本上。For example, the TEE of the first node device generates a fourth message based on the identifier of the block in the log, the fourth message carries the identifier of the block, and the fourth message instructs the REE of the first node device to take the block The blockchain ledger submitted to the local blockchain system. The TEE of the first node device sends the fourth message to the REE of the first node device. Afterwards, the REE of the first node device receives the fourth message, and based on the identification of the block carried in the fourth message, queries the block cached in the memory, and stores the queried block in the persistent storage medium On the blockchain ledger of the blockchain system.
之后,该第一节点设备的TEE将记录的该日志的状态更新为提交状态,以指示该日志对应的区块已经提交至该区块链系统的区块链上账本。Afterwards, the TEE of the first node device updates the recorded state of the log to the submitted state, to indicate that the block corresponding to the log has been submitted to the ledger on the block chain of the block chain system.
该第一节点设备的TEEH还可以通过该第一节点设备的REE,向终端返回交易成功消息,该交易成功消息用于指示该第五请求已经完成。The TEEH of the first node device may also return a transaction success message to the terminal through the REE of the first node device, where the transaction success message is used to indicate that the fifth request has been completed.
716、该第一节点设备的TEE通过该第一节点设备的REE,向该区块链系统中的第二节点设备发送第三请求,该第三请求指示该第二节点设备将该区块提交至本地的该区块链系统的区块链账本。716. The TEE of the first node device sends a third request to the second node device in the blockchain system through the REE of the first node device, and the third request instructs the second node device to submit the block To the blockchain ledger of the local blockchain system.
其中,该第三请求可以是心跳消息也可以是除心跳消息之外的其他类型的消息。Wherein, the third request may be a heartbeat message or other types of messages except the heartbeat message.
在一种可能的实现方式中,该第一节点设备的TEE基于该日志的索引,生成该第三请求,该第三请求携带该日志的索引。可选地,该第三请求还携带该第一节点设备的第一任期。In a possible implementation manner, the TEE of the first node device generates the third request based on the index of the log, where the third request carries the index of the log. Optionally, the third request also carries the first term of the first node device.
在另一种可能的实现方式中,为了避免该第三请求在离开该第一节点设备的TEE后,该第三请求的内容被篡改,该第一节点设备的TEE基于该第一节点设备私钥,对该第三请求进行签名,得到该第三请求的数字签名。相应地,该第一节点设备的TEE通过该第一节点设备的REE,向该区块链系统中的第二节点设备发送第三请求以及该第三请求的数字签名。In another possible implementation, in order to prevent the content of the third request from being tampered with after the third request leaves the TEE of the first node device, the TEE of the first node device is based on the first node device's private key to sign the third request to obtain the digital signature of the third request. Correspondingly, the TEE of the first node device sends the third request and the digital signature of the third request to the second node device in the blockchain system through the REE of the first node device.
其中,该第一节点设备的TEE通过该第一节点设备的REE,向该区块链系统中的第二节点设备发送第三请求的过程与上述步骤503中该第一节点设备的TEE通过第一节点设备REE,向该区块链系统中的第二节点设备发送该第二请求的过程同理,在此,本申请实施例对该第一节点设备的TEE通过该第一节点设备的REE,向该区块链系统中的第二节点设备发送第三请求的过程,不再赘述。Wherein, the TEE of the first node device sends the third request to the second node device in the blockchain system through the REE of the first node device, which is the same as the process of sending the third request to the second node device in the block chain system through the TEE of the first node device in step 503 above. A node device REE, the process of sending the second request to the second node device in the blockchain system is the same. Here, in this embodiment of the application, the TEE of the first node device is passed through the REE , the process of sending the third request to the second node device in the blockchain system will not be repeated here.
717、区块链系统中的第二节点设备的TEE通过该第二节点设备的REE,接收该第三请求。717. The TEE of the second node device in the blockchain system receives the third request through the REE of the second node device.
其中,步骤717-719中的第二节点设备为该区块链系统中的任一个第二节点设备,也即是区块链系统中的每个第二节点设备均执行步骤717-719所示的过程。Wherein, the second node device in steps 717-719 is any second node device in the blockchain system, that is, each second node device in the blockchain system executes steps 717-719 the process of.
在一种可能的实现方式中,区块链系统中的第二节点设备的TEE通过该第二节点设备的REE,接收该第三请求以及该第三请求的数字签名。In a possible implementation manner, the TEE of the second node device in the blockchain system receives the third request and the digital signature of the third request through the REE of the second node device.
本步骤717所述的过程与上述步骤504中第二节点设备的TEE通过该第二节点设备的REE,接收该第二请求的过程同理,在此,本申请实施例对本步骤717不再赘述。The process described in this step 717 is the same as the process of receiving the second request through the TEE of the second node device in the above step 504 through the REE of the second node device. Here, this embodiment of the present application will not repeat this step 717. .
718、该第二节点设备的TEE对该第三请求进行验证。718. The TEE of the second node device verifies the third request.
在一种可能的实现方式中,该第二节点设备的TEE基于该第一节点设备的公钥,对该第三请求的数字签名进行验签。若验签成功,则该第二节点设备的TEE对该第三请求验证通过。若验签失败,说明该第三请求的内容已经被篡改,该第二节点设备的TEE对该第三请求验证不通过。In a possible implementation manner, the TEE of the second node device verifies the digital signature of the third request based on the public key of the first node device. If the signature verification is successful, the TEE of the second node device passes the verification of the third request. If the signature verification fails, it means that the content of the third request has been tampered with, and the TEE of the second node device fails to verify the third request.
719、在该第三请求通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE基于该日志中的区块的标识,通知该第二节点设备的REE将该区块提交至本地的该区块链系统的区块链账本。719. In the case that the third request passes the verification of the TEE of the second node device, the TEE of the second node device notifies the REE of the second node device based on the identification of the block in the log The block is submitted to the blockchain ledger of the local blockchain system.
其中,该第二节点设备的TEE基于该日志中的区块的标识,通知该第二节点设备的REE将该区块提交至本地的该区块链系统的区块链账本的过程与步骤715中该第一节点设备的TEE基于该日志中该区块的标识,通知该第一节点设备的REE将该区块提交至本地的该区块链系统的区块链账本的过程同理,在此,本申请实施例对本步骤719不再赘述。Wherein, the TEE of the second node device notifies the REE of the second node device to submit the block to the blockchain ledger of the local blockchain system based on the identification of the block in the log and step 715 Based on the identification of the block in the log, the TEE of the first node device notifies the REE of the first node device to submit the block to the blockchain account book of the local blockchain system. Here, step 719 is not described in detail in this embodiment of the present application.
在一种可能的实现方式中,在该第三请求通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE从该第三请求中解析出该日志的索引。该第二节点设备的TEE基于该日志的索引,将记录的该日志的状态更新为提交状态,以指示该日志对应的区块已经提交至在该区块链系统中的区块链上账本。In a possible implementation manner, when the third request passes the verification of the TEE of the second node device, the TEE of the second node device parses out the index of the log from the third request. Based on the index of the log, the TEE of the second node device updates the recorded state of the log to the submitted state, to indicate that the block corresponding to the log has been submitted to the ledger on the block chain in the block chain system.
需要说明的是,图7所示的过程是以第一请求携带区块以及区块的日志为例进行说明,而在另一种可能的实现方式中,第一节点设备的TEE在发起共识集群中的共识节点设备对该日志进行共识时,可以先不发送该区块,待对日志共识完成后,再发送该区块。例如,第一请求不携带区块,而第三请求携带区块,对于这种情况,当区块链系统中的第二节点设备的REE接收到该第三请求后,先将该第三请求中的区块转移到内存中缓存,然后第二节点设备的TEE发送将三请求。从而当共识集群中少数共识节点设备同意接收该日志的情况下,第一节点设备的TEE无须向区块链系统中的第二节点设备发送第三请求,从而避免第一节点设备将共识失败的区块发送给区块链系统中的第二节点设备。It should be noted that the process shown in Figure 7 is illustrated by taking the first request to carry the block and the log of the block as an example. In another possible implementation, the TEE of the first node device initiates the consensus cluster When the consensus node device in the log agrees on the log, it can not send the block first, and then send the block after the consensus on the log is completed. For example, the first request does not carry a block, but the third request carries a block. In this case, when the REE of the second node device in the blockchain system receives the third request, it first sends the third request The blocks in the block are transferred to the in-memory cache, and then the TEE of the second node device sends three requests. Therefore, when a small number of consensus node devices in the consensus cluster agree to receive the log, the TEE of the first node device does not need to send a third request to the second node device in the blockchain system, thereby preventing the first node device from failing the consensus. The block is sent to the second node device in the blockchain system.
本申请实施例提供的方法,通过区块链系统中节点设备的TEE生成日志,节点设备的REE向区块链系统中的其他节点设备发送该TEE所生成的日志,以便其他节点设备对该日志进行共识。由于TEE受硬件的保护,不会作恶,因此,能够实现使用TEE保护共识流程目的,能够防止区块链系统中出现拜占庭错误。并且,日志中以区块的标识来指代区块,日志无须携带区块,从而降低了日志的数据量,相应地,降低了日志序列所占用的存储空间。并且,第一请求还携带日志的数字签名,从而避免该日志被篡改,避免日志共识出错。另外,第一节点设备将第一响应以及第一响应的数字签名发送给区块链系统中的第二节点设备,且第二节点设备的TEE基于该第一响应的数字签名,对第一响应进行验证,从而避免第一响应的内容被篡改,避免日志共识出错。In the method provided by the embodiment of this application, the log is generated by the TEE of the node device in the blockchain system, and the REE of the node device sends the log generated by the TEE to other node devices in the blockchain system, so that other node devices can compare the log Make a consensus. Since TEE is protected by hardware and will not do evil, it can achieve the purpose of using TEE to protect the consensus process and prevent Byzantine errors in the blockchain system. Moreover, the block is referred to by the block identifier in the log, and the log does not need to carry the block, thereby reducing the data volume of the log, and correspondingly reducing the storage space occupied by the log sequence. In addition, the first request also carries the digital signature of the log, so as to prevent the log from being tampered with and to avoid errors in the log consensus. In addition, the first node device sends the first response and the digital signature of the first response to the second node device in the blockchain system, and the TEE of the second node device is based on the digital signature of the first response to the first response Verification is performed to prevent the content of the first response from being tampered with and to avoid log consensus errors.
为了进一步说明图7所示的过程,参见图10所示的本申请实施例提供的一种区块共识过程的示意图。领导节点的REE的提案模块交易请求(如第五请求),生成区块,向领导节点的TEE发送区块的标识,以向领导节点的TEE发起共识提案。领导节点的TEE基于区块的标识,生成区块的日志。领导节点的TEE将日志添加至日志序列,生成第一请求,并通过输出接口领导节点的REE发送该第一请求,领导节点的REE向共识集群中的各个非领导节点发送接收到的第一请求。每个非领导节点的REE向各自的TEE发送接收到的第一请求。每 个非领导节点的TEE对第一请求携带的日志进行验证,若该日志通过验证,则将该日志添加在本地的日志序列,若验证不通过,则不接收该日志。每个非领导节点的TEE生成日志添加结果(如第一响应),并通过输出接口向各自的REE发送日志添加结果,每个非领导节点的REE向领导节点返回日志添加结果。领导节点的REE通过调用输入接口,向领导节点的TEE发送接收到的每个日志添加结果。当若半数以上的共识节点添加了该日志,领导节点的TEE通过输出接口通知该日志的共识结果(如若半数以上的共识节点添加了该日志),此时交易成功。之后,领导节点的REE在校验到心跳时长(如目标时长)已经到达或超时,则触发领导节点的TEE发起心跳信息(如第三请求)。之后,领导节点的TEE先验证心跳时长是否真正到达或超时,若真正到达或超时,则领导节点的TEE生成心跳信息,此时该心跳消息携带当前提交的日志的索引,领导节点的TEE通过输出接口向领导节点的REE发送心跳消息。该领导节点的REE将该心跳消息发送给共识集群中各个非领导节点。每个非领导节点的REE通过调用输入接口,向各自的TEE发送接收到的心跳消息。当各个非领导节点的TEE收到该心跳消息后,根据该心跳消息携带的索引,提交该日志。In order to further illustrate the process shown in FIG. 7 , refer to the schematic diagram of a block consensus process provided by the embodiment of the present application shown in FIG. 10 . The proposal module transaction request (such as the fifth request) of the REE of the leader node generates a block, and sends the identification of the block to the TEE of the leader node to initiate a consensus proposal to the TEE of the leader node. The TEE of the leader node generates a log of the block based on the identification of the block. The TEE of the leader node adds the log to the log sequence, generates the first request, and sends the first request through the output interface REE of the leader node, and the REE of the leader node sends the received first request to each non-leader node in the consensus cluster . The REE of each non-leader node sends the received first request to the respective TEE. The TEE of each non-leadership node verifies the log carried by the first request. If the log passes the verification, the log is added to the local log sequence, and if the verification fails, the log is not received. The TEE of each non-leader node generates a log addition result (such as the first response), and sends the log addition result to the respective REE through the output interface, and each non-leader node REE returns the log addition result to the leader node. The REE of the leader node sends each log addition result received to the TEE of the leader node by calling the input interface. When more than half of the consensus nodes have added the log, the TEE of the leader node will notify the consensus result of the log through the output interface (if more than half of the consensus nodes have added the log), the transaction is successful. Afterwards, the REE of the leader node will trigger the TEE of the leader node to initiate a heartbeat message (such as the third request) after verifying that the heartbeat duration (such as the target duration) has reached or expired. Afterwards, the TEE of the leader node first verifies whether the heartbeat duration has actually arrived or timed out. If it has actually arrived or timed out, the TEE of the leader node will generate a heartbeat message. At this time, the heartbeat message carries the index of the currently submitted log, and the TEE of the leader node passes the output The interface sends a heartbeat message to the REE of the leader node. The REE of the leader node sends the heartbeat message to each non-leader node in the consensus cluster. REEs of each non-leader node send received heartbeat messages to their respective TEEs by calling the input interface. After the TEE of each non-leader node receives the heartbeat message, it submits the log according to the index carried in the heartbeat message.
为了进一步说明图7所示的过程,参见图11所示的本申请实施例提供的一种区块存储的示意图。领导节点的REE打包交易,生成区块,并缓存区块。领导节点的REE向领导节点的TEE发送该区块的标识,以指示TEE对该区块的标识进行共识。领导节点的TEE基于该区块的标识生成日志,并对该日志进行签名。领导节点的TEE将该日志以及该日志的数字签名(sign)返回领导节点的REE。领导节点的REE从缓存的区块中,获取该日志所对应的区块,并向跟随节点同步该区块以及该日志。例如领导节点的REE向各个跟随节点发送该日志、该日志的数字签名以及该区块。每个跟随节点的REE缓存该区块,并向各自的TEE发送日志以及日志的数字签名。每个跟随节点的TEE基于该日志的数字签名,对该日志进行验证,若验证通过,每个跟随节点的TEE接收该日志,否则不接收该日志。每个跟随节点的TEE向各自的REE发送日志接收结果(如目标标识)以及日志接收结果的数字签名。每个跟随节点的REE向领导节点发送各自的日志接收结果(如第一响应)以及日志接收结果的数字签名。领导节点的REE向领导节点的TEE发送接收到的每个日志接收结果以及每个日志接收结果的数字签名。领导节点的REE基于每个日志接收结果的数字签名,对每个日志接收结果进行验证。若共识集群中至少半数共识节点设备的日志接收结果通过验证,且这半数共识节点设备均同意接收该日志,则该领导节点的TEE提交日志。例如,领导节点的TEE通知领导节点的REE将该日志对应的区块落盘,此时该交易成功。之后,领导节点的TEE生成心跳消息(如第三请求),并对心跳消息进行签名,领导节点的TEE向领导节点的REE发送心跳消息以及心跳消息的数字签名。领导节点的REE接收并向共识集群中的各个跟随节点发送该心跳消息。每个跟随节点的REE接收该心跳消息以及该心跳消息的数字签名,并向各自的TEE发送该心跳消息以及该心跳消息的数字签名。每个跟随节点的TEE基于心跳消息的数字签名,对心跳消息进行验证,若心跳消息通过验证,每个跟随节点的TEE基于该心跳消息携带的该日志的索引提交该日志。例如每个跟随节点的TEE通知各自的REE将该日志对应的区块落盘。To further illustrate the process shown in FIG. 7 , refer to FIG. 11 , which is a schematic diagram of a block storage provided by an embodiment of the present application. The REE of the leader node packs transactions, generates blocks, and caches blocks. The REE of the leader node sends the identity of the block to the TEE of the leader node to instruct the TEE to agree on the identity of the block. The TEE of the leader node generates a log based on the identity of the block and signs the log. The leader node's TEE returns the log and the log's digital signature (sign) to the leader node's REE. The REE of the leader node obtains the block corresponding to the log from the cached block, and synchronizes the block and the log to the follower node. For example, the REE of the leader node sends the log, the digital signature of the log, and the block to each follower node. Each REE following the node caches the block and sends the log and the digital signature of the log to the respective TEE. The TEE of each following node verifies the log based on the digital signature of the log. If the verification is passed, the TEE of each following node receives the log, otherwise it does not receive the log. Each TEE that follows a node sends the log reception result (such as the target ID) and the digital signature of the log reception result to its respective REE. Each REE following the node sends its own log receiving result (such as the first response) and the digital signature of the log receiving result to the leader node. The REE of the leader node sends each received log reception result and the digital signature of each log reception result to the TEE of the leader node. The REE of the leader node verifies each log receiving result based on the digital signature of each log receiving result. If the log reception results of at least half of the consensus node devices in the consensus cluster pass the verification, and these half of the consensus node devices agree to receive the log, then the TEE of the leader node submits the log. For example, the TEE of the leader node notifies the REE of the leader node to place the block corresponding to the log, and the transaction is successful at this time. Afterwards, the TEE of the leader node generates a heartbeat message (such as the third request), and signs the heartbeat message, and the TEE of the leader node sends the heartbeat message and the digital signature of the heartbeat message to the REE of the leader node. The REE of the leader node receives and sends the heartbeat message to each follower node in the consensus cluster. Each REE following the node receives the heartbeat message and the digital signature of the heartbeat message, and sends the heartbeat message and the digital signature of the heartbeat message to its respective TEE. The TEE of each following node verifies the heartbeat message based on the digital signature of the heartbeat message. If the heartbeat message passes the verification, the TEE of each following node submits the log based on the index of the log carried in the heartbeat message. For example, each TEE that follows a node notifies its respective REE to place the block corresponding to the log on disk.
为了进一步说明图5和图7所示的过程,参见图12所示的本申请实施例提供的一种共识集群中数据处理过程的示意图。以共识集群包括跟随节点1-3为例,对图12进行如下介绍:In order to further illustrate the process shown in FIG. 5 and FIG. 7 , refer to the schematic diagram of the data processing process in a consensus cluster provided by the embodiment of the present application shown in FIG. 12 . Taking the consensus cluster including follower nodes 1-3 as an example, the introduction to Figure 12 is as follows:
跟随节点3的TEE验证时间戳,若确定选举时间达到或超时,则进行超时选主。例如, 跟随节点3切换为候选节点,候选节点3的TEE分别向跟随节点1和2发送携带数字签名的投票请求(如第二请求)。跟随节点1和2的TEE分别基于投票请求携带的数字签名,对投票请求进行验证。在投票请求通过验证的情况下,跟随节点1和2的TEE分别对候选节点3进行投票,并分别向候选节点3返回各自的投票结果(如第二响应)以及投票结果的数字签名。候选节点3的TEE处理投票结果,成为共识集群中的领导节点。例如,候选节点3的TEE分别基于各个投票结果的数字签名,对各个投票结果进行验证。若这2个投票结果中至少有一个投票结果通过验证,且该至少一个投票结果为赞成票,则该候选节点3切换为领导节点。之后,领导节点3的TEE验证时间戳,若心跳时长到达或超时,则领导节点3的TEE分别向跟随节点1和2发送携带数字签名的心跳消息(如通知消息)。跟随节点1和2的TEE分别基于心跳消息中的数字签名,对心跳消息进行验证。在心跳消息通过验证的情况下,跟随节点1和2的TEE接受候选节点3成为共识集群中的领导节点。之后,客户端向领导节点3发送交易请求(如第五请求),领导节点3的REE打包交易,生成区块。领导节点3的TEE基于该区块的标识生成日志,并开始共识日志。例如,领导节点3的TEE通过REE分别向跟随节点1和2发送日志、日志的数字签名以及区块。跟随节点1和2的REE分别缓存区块。跟随节点1和2的TEE分别基于日志的数字签名,对日志进行验证。在日志通过验证的情况下,跟随节点1和2的TEE分别接收日志,如将日志添加在日志序列。跟随节点1和2分别向领导节点3返回各自的日志接收结果(如第一响应)以及日志接收结果的数字签名。领导节点3的TEE基于每个日志接收结果的数字签名,对每个日志接收结果进行验证。若跟随节点1和2的至少一个日志接收结果通过验证,且至少一个日志接收结果指代已经接收日志,则该领导节点3的TEE提交日志,将该日志对应的区块落盘,此时交易成功,并通知客户交易处理结果。之后,领导节点3的TEE进行时间戳校验,若心跳时长到达或超时,则领导节点3的TEE分别向跟随节点1和2发送心跳消息(如第三请求)以及心跳消息的数字签名。跟随节点1和2的TEE分别基于心跳消息的数字签名,对心跳消息进行验证。在该心跳消息通过验证的情况下,跟随节点1和2的TEE分别基于该心跳消息携带的该日志的索引,提交日志,例如,跟随节点1和2的TEE分别通知各自的REE将该日志对应的区块落盘。Following the TEE verification timestamp of node 3, if it is determined that the election time has reached or timed out, the master election will be timed out. For example, following node 3 is switched to be a candidate node, and the TEE of candidate node 3 sends voting requests (such as the second request) carrying digital signatures to following nodes 1 and 2 respectively. The TEEs following nodes 1 and 2 verify the voting requests based on the digital signatures carried in the voting requests. When the voting request is verified, the TEEs following nodes 1 and 2 vote for candidate node 3 respectively, and return respective voting results (such as the second response) and digital signatures of the voting results to candidate node 3 respectively. The TEE of candidate node 3 processes the voting results and becomes the leader node in the consensus cluster. For example, the TEE of the candidate node 3 verifies each voting result based on the digital signature of each voting result. If at least one of the two voting results passes the verification, and the at least one voting result is an affirmative vote, then the candidate node 3 is switched to be the leader node. Afterwards, the TEE of the leader node 3 verifies the time stamp. If the heartbeat duration is reached or times out, the TEE of the leader node 3 sends a heartbeat message (such as a notification message) carrying a digital signature to the follower nodes 1 and 2 respectively. The TEEs following nodes 1 and 2 verify the heartbeat message based on the digital signature in the heartbeat message respectively. In the case that the heartbeat message is verified, the TEE following nodes 1 and 2 accepts candidate node 3 to become the leader node in the consensus cluster. After that, the client sends a transaction request (such as the fifth request) to the leader node 3, and the REE of the leader node 3 packages the transaction to generate a block. The TEE of the leader node 3 generates a log based on the identification of the block, and starts a consensus log. For example, the TEE of the leader node 3 sends the log, the digital signature of the log, and the block to the follower nodes 1 and 2 respectively through the REE. REEs following nodes 1 and 2 cache blocks separately. The TEEs following nodes 1 and 2 verify the log based on the digital signature of the log respectively. In the case that the log is verified, the TEEs following nodes 1 and 2 receive the log respectively, such as adding the log to the log sequence. Follower nodes 1 and 2 respectively return their respective log receiving results (such as the first response) and digital signatures of the log receiving results to the leader node 3 . The TEE of the leader node 3 verifies each log receiving result based on the digital signature of each log receiving result. If at least one log reception result of following nodes 1 and 2 passes the verification, and at least one log reception result indicates that the log has been received, then the TEE of the leader node 3 submits the log, and puts the block corresponding to the log to the disk. At this time, the transaction Success, and notify the client of the transaction processing result. Afterwards, the TEE of the leader node 3 performs timestamp verification. If the heartbeat duration is reached or times out, the TEE of the leader node 3 sends a heartbeat message (such as the third request) and a digital signature of the heartbeat message to follower nodes 1 and 2 respectively. The TEEs following nodes 1 and 2 verify the heartbeat message based on the digital signature of the heartbeat message respectively. When the heartbeat message passes the verification, the TEEs following nodes 1 and 2 submit the log based on the index of the log carried in the heartbeat message, for example, the TEEs following nodes 1 and 2 notify their respective REEs to correspond to the log of blocks placed on the disk.
随着共识集群服务时长的增加,共识节点设备的日志序列中的日志越来越多,为了降低该日志序列所占用的存储空间,共识节点设备的TEE可以通过快照的方式,对日志序列进行压缩,为了进一步说明该过程,参见图13所示的本申请实施例提供的一种日志压缩方法的流程图。As the service duration of the consensus cluster increases, more and more logs are included in the log sequence of the consensus node device. In order to reduce the storage space occupied by the log sequence, the TEE of the consensus node device can compress the log sequence through a snapshot , to further illustrate this process, refer to the flowchart of a log compression method provided by the embodiment of the present application shown in FIG. 13 .
1301、第一节点设备的TEE对日志序列中已提交的多个日志进行截断,得到该日志序列的快照。1301. The TEE of the first node device truncates multiple submitted logs in the log sequence to obtain a snapshot of the log sequence.
此时,第一节点设备为共识集群中的领导节点。该日志序列为第一节点设备的日志序列,该日志序列存储在第一节点设备的TEE中。已提交的日志是指该日志对应的区块已经提交至本地的该区块链系统的区块链账本,或者说该日志对应的区块已经落盘。该快照包括第一标识以及第二标识,该第一标识为该多个日志中起始日志所对应的区块的标识,该第二标识为该多个日志中终止日志所对应的区块的标识。其中,该多个日志中的起始日志为该多个日志中的第一个日志,该多个日志中的终止日志为该多个日志中的最后一个日志。At this time, the first node device is the leader node in the consensus cluster. The log sequence is the log sequence of the first node device, and the log sequence is stored in the TEE of the first node device. The submitted log means that the block corresponding to the log has been submitted to the blockchain ledger of the local blockchain system, or the block corresponding to the log has been placed on the disk. The snapshot includes a first identifier and a second identifier, the first identifier is the identifier of the block corresponding to the start log in the multiple logs, and the second identifier is the block corresponding to the end log in the multiple logs logo. Wherein, the start log of the multiple logs is the first log of the multiple logs, and the end log of the multiple logs is the last log of the multiple logs.
在一种可能的实现方式中,在该日志序列中日志的个数大于或者等于个数阈值,则该第一节点设备的TEE查询该日志序列中各个日志的状态,并将该日志序列中处于提交状态的多 个日志,确定为已提交的多个日志。其中,该个数阈值可以根据实际的实施场景进行设置,在此本申请实施例对该个数阈值不做限定。In a possible implementation, if the number of logs in the log sequence is greater than or equal to the number threshold, the TEE of the first node device queries the status of each log in the log sequence, and sets the status of each log in the log sequence to Multiple logs of commit status, multiple logs determined to be committed. Wherein, the number threshold may be set according to an actual implementation scenario, and this embodiment of the present application does not limit the number threshold.
当确定出日志序列中已提交的多个日志后,该第一节点设备的TEE基于该多个日志中起始日志的第一标识以及该多个日志中终止日志的第二标识,生成该快照,并删除该日志序列中的多个快照。其中,快照包括该第一标识和第二标识。After determining the submitted multiple logs in the log sequence, the TEE of the first node device generates the snapshot based on the first identifier of the start log in the multiple logs and the second identifier of the terminated log in the multiple logs , and delete multiple snapshots in that log sequence. Wherein, the snapshot includes the first identifier and the second identifier.
1302、该第一节点设备的TEE向该第一节点设备的REE发送该快照。1302. The TEE of the first node device sends the snapshot to the REE of the first node device.
在一种可能的实现方式中,该第一节点设备的TEE基于该快照,生成第二目标消息,该第二目标消息携带该快照,该第二目标消息指示区块链系统中的第二节点设备基于该快照将该多个日志对应的多个区块提交至本地的区块链账本。该第一节点设备的TEE向该第一节点设备的REE发送该第二目标消息。In a possible implementation, the TEE of the first node device generates a second target message based on the snapshot, the second target message carries the snapshot, and the second target message indicates that the second node in the blockchain system The device submits multiple blocks corresponding to the multiple logs to the local blockchain ledger based on the snapshot. The TEE of the first node device sends the second target message to the REE of the first node device.
在一种可能的实现方式中,为了避免该第二目标消息在离开该第一节点设备的TEE后,该第二目标消息的内容被篡改,该第一节点设备的TEE基于该第一节点设备的私钥,对该第二目标消息进行签名,得到该第二目标消息的数字签名。相应地,该第一节点设备的TEE向该第一节点设备的REE发送该第二目标消息以及该第二目标消息的数字签名。In a possible implementation manner, in order to prevent the content of the second target message from being tampered with after the second target message leaves the TEE of the first node device, the TEE of the first node device is based on the private key to sign the second target message to obtain the digital signature of the second target message. Correspondingly, the TEE of the first node device sends the second target message and the digital signature of the second target message to the REE of the first node device.
需要说明的是,该第二目标消息为心跳消息或者除心跳消息以外的其他类型的消息。若该第二目标消息为心跳消息,则该第一节点设备的TEE验证该目标时长是否到达,若该目标时长到达,该第一节点设备的TEE生成该第二目标消息。It should be noted that the second target message is a heartbeat message or other types of messages other than the heartbeat message. If the second target message is a heartbeat message, the TEE of the first node device verifies whether the target duration is reached, and if the target duration is reached, the TEE of the first node device generates the second target message.
1303、该第一节点设备的REE接收该快照,基于该快照中的该第一标识和该第二标识,从本地的该区块链系统的区块链账本中获取该多个日志所对应的多个区块。1303. The REE of the first node device receives the snapshot, and based on the first identifier and the second identifier in the snapshot, obtains the corresponding logs from the blockchain ledger of the local blockchain system. multiple blocks.
在一种可能的实现方式中,该第一节点设备的REE接收该第二目标消息,从该第二目标消息中解析出该快照,并在本地的该区块链系统的区块链账本上,查询该快照中的第一标识所指示的第一区块以及快照中的该第二标识所指示的第二区块。该第一节点设备的REE从该区块链账本上获取该第一区块、该第二区块以及该第一区块与该第二区块之间的各个区块。其中,其中该第一区块、该第二区块以及该第一区块与该第二区块之间的各个区块也即是该多个日志所对应的多个区块。该第一区块为该多个区块中的第一个区块,该第二区块为该多个区块中的最后一个区块。In a possible implementation, the REE of the first node device receives the second target message, parses the snapshot from the second target message, and stores the snapshot on the blockchain account book of the local blockchain system , query the first block indicated by the first identifier in the snapshot and the second block indicated by the second identifier in the snapshot. The REE of the first node device obtains the first block, the second block, and each block between the first block and the second block from the blockchain ledger. Wherein, the first block, the second block, and each block between the first block and the second block are the multiple blocks corresponding to the multiple logs. The first block is the first block among the multiple blocks, and the second block is the last block among the multiple blocks.
1304、该第一节点设备的REE向该区块链系统中的第二节点设备发送第四请求,该第四请求携带该快照以及该多个区块,该第四请求指示区块链系统中的第二节点设备基于该快照将该多个日志对应的多个区块提交至本地的区块链账本。1304. The REE of the first node device sends a fourth request to the second node device in the blockchain system, the fourth request carries the snapshot and the multiple blocks, and the fourth request indicates that in the blockchain system The second node device submits multiple blocks corresponding to the multiple logs to the local blockchain ledger based on the snapshot.
在一种可能的实现方式中,当获取到该多个区块后,该第一节点设备的REE基于该第二目标消息以及该多个区块,生成该第四请求,此时,该第四请求携带该第二目标消息以及该多个区块。In a possible implementation manner, after obtaining the multiple blocks, the REE of the first node device generates the fourth request based on the second target message and the multiple blocks. At this time, the first The fourth request carries the second target message and the plurality of blocks.
在一种可能的实现方式中,若接收到该第二目标消息的数字签名,该第一节点设备的REE基于该第二目标消息、该第二目标消息的数字签名以及该多个区块,生成该第四请求,此时,该第四请求携带该第二目标消息、该第二目标消息的数字签名以及该多个区块。In a possible implementation, if the digital signature of the second target message is received, the REE of the first node device is based on the second target message, the digital signature of the second target message, and the plurality of blocks, The fourth request is generated. At this time, the fourth request carries the second target message, the digital signature of the second target message, and the multiple blocks.
当生成该第四请求后,该第一节点设备的REE向该区块链系统中的第二节点设备发送该第四请求。After generating the fourth request, the REE of the first node device sends the fourth request to the second node device in the blockchain system.
1305、第二节点设备的REE接收该第四请求。1305. The REE of the second node device receives the fourth request.
其中,步骤1305-1309中的第二节点设备为该区块链系统中的任一个第二节点设备,也 即是区块链系统中的每个第二节点设备均执行步骤1305-1309所示的过程。Wherein, the second node device in steps 1305-1309 is any second node device in the blockchain system, that is, each second node device in the blockchain system executes steps 1305-1309 the process of.
1306、该第二节点设备的REE缓存该多个区块。1306. The REE of the second node device caches the multiple blocks.
例如,该第二节点设备的REE将该第四请求携带的该多个区块转移至内存中。For example, the REE of the second node device transfers the multiple blocks carried in the fourth request to memory.
1307、该第二节点设备的REE向该第二节点设备的TEE发送该快照。1307. The REE of the second node device sends the snapshot to the TEE of the second node device.
例如,该第二节点设备的REE向该第二节点设备的TEE发送转移区块后的第四请求,此时,该第四请求不再携带该多个区块。For example, the REE of the second node device sends a fourth request after transferring blocks to the TEE of the second node device, and at this time, the fourth request no longer carries the plurality of blocks.
在一种可能的实现方式中,快照不包括区块的标识,而是包括区块中各个交易事件的状态数据,每个交易事件的状态数据指示每个交易事件涉及的数据的最新状态。但是,每个交易事件的状态数据所占用的字节数多,因此,这种快照的数据量比较大。而本申请实施例中的快照包括的是区块的标识的,若区块的标识为区块号,第一标识和第二标识也即是两个整数值,因此,本申请实施例中的快照数量少,相应地,快照传输速率高。In a possible implementation manner, the snapshot does not include the identification of the block, but includes the state data of each transaction event in the block, and the state data of each transaction event indicates the latest state of the data involved in each transaction event. However, the state data of each transaction event occupies a large number of bytes, so the data volume of this snapshot is relatively large. However, the snapshot in the embodiment of the present application includes the identifier of the block. If the identifier of the block is the block number, the first identifier and the second identifier are two integer values. Therefore, the snapshot in the embodiment of the present application The number of snapshots is small, and accordingly, the snapshot transfer rate is high.
例如图14所示的本申请实施例提供的一种快照对比的示意图。参见图14中左图所示的相关技术,日志序列1包括日志1-6,该日志1-6分别包括区块1-6,其中,日志1-4为已提交日志,日志5-6还未提交,区块1-4已经提交至区块链系统的区块链账本。领导节点对日志序列1中的日志1-4进行截断,生成日志序列1的快照1,该快照1包括区块1-4中各个交易事件的状态数据。For example, FIG. 14 is a schematic diagram of snapshot comparison provided by the embodiment of the present application. Referring to the related technology shown in the left figure in FIG. 14, the log sequence 1 includes logs 1-6, and the logs 1-6 include blocks 1-6 respectively, wherein, logs 1-4 are submitted logs, and logs 5-6 are still Not submitted, blocks 1-4 have been submitted to the blockchain ledger of the blockchain system. The leader node truncates the logs 1-4 in the log sequence 1 to generate a snapshot 1 of the log sequence 1, which includes the state data of each transaction event in the blocks 1-4.
图14的右图为本申请实施例的一个示意图。在图14的右图中,日志序列2存储在领导节点的TEE中。日志序列2包括日志1-6,其中,日志1-4为已提交日志,日志5-6还未提交,区块1-4已经提交至区块链系统的区块链账本。领导节点以区块哈希值作为区块的标识,在日志中指代区块。例如,区块序列2中的日志1-6分别包括哈希值1-6,以分别指代区块1-6。领导节点的TEE对日志序列2中的日志1-4进行截断,生成日志序列2的快照2,该快照2包括区块1-4中的起始区块的区块号1和终止区块的区块号4。可见,快照2的内容比快照1的内容少,则快照2的数据量要小于快照1的数据量。并且,领导节点的TEE向领导节点的REE发送快照2,领导节点的REE在本地的区块链账本,获取快照2对应的区块1-4,并向共识集群中的非领导节点发送快照2和区块1-4。The right figure of FIG. 14 is a schematic diagram of the embodiment of the present application. In the right diagram of Figure 14, log sequence 2 is stored in the TEE of the leader node. Log sequence 2 includes logs 1-6, wherein logs 1-4 are submitted logs, logs 5-6 have not yet been submitted, and blocks 1-4 have been submitted to the blockchain ledger of the blockchain system. The leader node uses the block hash value as the identification of the block, and refers to the block in the log. For example, logs 1-6 in block sequence 2 include hash values 1-6, respectively, to refer to blocks 1-6, respectively. The TEE of the leader node truncates the logs 1-4 in the log sequence 2 to generate a snapshot 2 of the log sequence 2, which includes the block number 1 of the start block and the block number of the end block in blocks 1-4. Block number 4. It can be seen that the content of the snapshot 2 is less than that of the snapshot 1, and the data volume of the snapshot 2 is smaller than the data volume of the snapshot 1. And, the TEE of the leader node sends the snapshot 2 to the REE of the leader node, and the REE of the leader node obtains the blocks 1-4 corresponding to the snapshot 2 in the local blockchain ledger, and sends the snapshot 2 to the non-leader nodes in the consensus cluster and blocks 1-4.
1308、该第二节点设备的TEE接收该快照,并对该快照进行验证。1308. The TEE of the second node device receives the snapshot, and verifies the snapshot.
在一种可能的实现方式中,该第二节点设备的TEE接收该第二节点设备的REE发送的第四请求,从该第四请求中解析出第二目标消息以及第二目标消息的数字签名。In a possible implementation, the TEE of the second node device receives a fourth request sent by the REE of the second node device, and parses out the second target message and the digital signature of the second target message from the fourth request .
该第二节点设备的TEE基于该第一节点设备的公钥,对该第二目标消息的数字签名进行验签。由于该第二目标消息携带快照。若验签成功,则该第二节点设备的TEE对该快照验证通过。若验签失败,说明该第第二目标消息的内容已经被篡改,该第二节点设备的TEE对该快照验证不通过。The TEE of the second node device verifies the digital signature of the second target message based on the public key of the first node device. Because the second target message carries a snapshot. If the signature verification is successful, the TEE of the second node device passes the verification of the snapshot. If the signature verification fails, it means that the content of the second target message has been tampered with, and the TEE of the second node device fails to pass the verification of the snapshot.
1309、在该快照通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE通知该第二节点设备的REE将该多个区块提交至本地的该区块链系统的区块链账本。1309. If the snapshot passes the verification of the TEE of the second node device, the TEE of the second node device notifies the REE of the second node device to submit the multiple blocks to the local blockchain system blockchain ledger.
在该快照通过了该第二节点设备的TEE的验证的情况下,该第二节点设备的TEE从该第二目标消息中解析出快照,并从该快照中,获取第一标识以及第二标识。该第二节点设备的TEE在该第二节点设备的日志序列中,查询该日志序列中该第一标识对应的第一日志以及该第二标识对应的第二日志,该第二节点设备删除该日志序列中的第一日志、第二日志以及该第一日志以及该第二日志之间的各个日志。其中,第一日志、第二日志以及该第一日志以 及该第二日志之间的各个日志也即是该第一节点设备截断的多个日志,该第一日志为该多个日志中的起始日志,该第二日志为该多个日志的终止日志。If the snapshot passes the verification of the TEE of the second node device, the TEE of the second node device parses the snapshot from the second target message, and obtains the first identifier and the second identifier from the snapshot . In the log sequence of the second node device, the TEE of the second node device queries the first log corresponding to the first identifier and the second log corresponding to the second identifier in the log sequence, and the second node device deletes the The first log, the second log, and each log between the first log and the second log in the log sequence. Wherein, the first log, the second log, and each log between the first log and the second log are multiple logs truncated by the first node device, and the first log is the starting point of the multiple logs. The start log, the second log is the termination log of the plurality of logs.
在一种可能的实现方式中,该第二节点设备的TEE通过向该第二节点设备的REE发送请求,来通知该第二节点设备的REE将该多个区块提交至本地的该区块链系统的区块链账本。In a possible implementation, the TEE of the second node device notifies the REE of the second node device to submit the multiple blocks to the local block by sending a request to the REE of the second node device The blockchain ledger of the chain system.
例如,该第二节点设备的TEE向该第二节点设备的REE发送第七请求,该第七请求携带该快照,该第七请求指示该第二节点设备的REE该快照对应的多个区块提交至本地的该区块链系统的区块链账本。当该第二节点设备的REE接收到该第七请求后,基于该第七请求携带的快照,从缓存的区块中查询该快照对应的多个区块,并将查询到的多个区块提交至本地的该区块链系统的区块链账本。该第二节点设备的REE还可以将该快照存储在持久性存储介质中。For example, the TEE of the second node device sends a seventh request to the REE of the second node device, the seventh request carries the snapshot, and the seventh request indicates that the REE of the second node device corresponds to a plurality of blocks The blockchain ledger submitted to the local blockchain system. When the REE of the second node device receives the seventh request, based on the snapshot carried by the seventh request, it queries the cached blocks for the multiple blocks corresponding to the snapshot, and sends the queried multiple blocks The blockchain ledger submitted to the local blockchain system. The REE of the second node device may also store the snapshot in a persistent storage medium.
本申请实施例提供的方法,通过节点设备的TEE生成快照,且快照携带已提交的多个区块中起始区块的标识以及终止区块的标识,降低了快照的数据量,并且由于TEE受硬件的保护,不会作恶,因此,能够实现使用TEE保护快照同步目的,能够防止区块链系统中出现拜占庭错误。并且,由于第四请求携带第二目标消息以及第二目标消息的数字签名,从而避免第二目标消息的内容被篡改,减了区块链系统中出现的拜占庭错误。In the method provided by the embodiment of the present application, a snapshot is generated through the TEE of the node device, and the snapshot carries the identification of the starting block and the identification of the ending block in the submitted multiple blocks, which reduces the data volume of the snapshot, and because the TEE It is protected by hardware and will not do evil. Therefore, it can achieve the purpose of using TEE to protect snapshot synchronization and prevent Byzantine errors in the blockchain system. Moreover, since the fourth request carries the second target message and the digital signature of the second target message, the content of the second target message is prevented from being tampered with, reducing the occurrence of Byzantine errors in the blockchain system.
以上介绍了本申请实施例的方法,以下介绍本申请实施例的装置。应理解,以下介绍的装置具有上述方法中任一节点设备的任意功能。The method of the embodiment of the present application is described above, and the device of the embodiment of the present application is introduced below. It should be understood that the apparatus described below has any function of any node device in the above methods.
图15本申请实施例提供了一种数据处理装置的结构示意图,参见图15,所述装置1500被配置为区块链系统中的第一节点设备,所述第一节点设备包括可信执行环境TEE和富执行环境REE,所述TEE包括处理单元1501,所述REE包括通信单元1502;Figure 15 The embodiment of this application provides a schematic structural diagram of a data processing device, see Figure 15, the device 1500 is configured as a first node device in a blockchain system, and the first node device includes a trusted execution environment TEE and Rich Execution Environment REE, the TEE includes a processing unit 1501, and the REE includes a communication unit 1502;
所述处理单元1501,用于基于所述REE中的区块,生成所述区块的日志,向所述REE发送所述日志,所述日志中以所述区块的标识指代所述区块;The processing unit 1501 is configured to generate a log of the block based on the block in the REE, and send the log to the REE, and the block identifier in the log refers to the area piece;
所述通信单元1502,用于接收所述日志,向所述区块链系统中的第二节点设备发送第一请求,所述第一请求携带所述日志,所述第一请求指示所述第二节点设备处理所述日志。The communication unit 1502 is configured to receive the log, and send a first request to the second node device in the blockchain system, the first request carries the log, and the first request indicates that the second The two-node device processes the logs.
可选地,所述第一请求还携带所述区块,所述第一请求指示所述第二节点设备处理所述日志以及所述区块;所述处理单元1501还用于:Optionally, the first request also carries the block, and the first request instructs the second node device to process the log and the block; the processing unit 1501 is further configured to:
通过所述REE接收多个第一响应,每个第一响应指示一个第二节点设备是否已经同意接收所述日志;receiving a plurality of first responses through the REE, each first response indicating whether a second node device has agreed to receive the log;
在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , based on the identification of the block in the log, notify the REE to submit the block to the local blockchain ledger of the blockchain system.
可选地,所述处理单元1501还用于:Optionally, the processing unit 1501 is further configured to:
通过所述REE向所述区块链系统中的第二节点设备发送第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;sending a second request to a second node device in the blockchain system through the REE, the second request indicating to vote for the first node device to become the leader node in the blockchain system;
通过所述REE接收多个第二响应,每个第二响应指示一个第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点;receiving a plurality of second responses through the REE, each second response indicating whether a second node device agrees with the first node device to become the leader node in the blockchain system;
在所述区块链系统中半数或多数第二节点设备的第二响应通过了所述TEE的验证,且通过验证的每个所述第二响应指示一个第二节点设备赞同所述第一节点设备成为所述区块链系 统中的领导节点的情况下,将所述第一节点设备的节点状态切换为领导状态。In the blockchain system, half or most of the second responses of the second node devices have passed the verification of the TEE, and each of the verified second responses indicates that a second node device agrees with the first node When the device becomes the leader node in the blockchain system, the node status of the first node device is switched to the leader status.
可选地,所述处理单元1501还用于:Optionally, the processing unit 1501 is further configured to:
生成通知消息,所述通知消息指示所述第一节点设备为所述区块链系统中的领导节点;generating a notification message, the notification message indicating that the first node device is the leader node in the blockchain system;
通过所述REE向所述区块链系统中的第二节点设备发送所述通知消息。Sending the notification message to the second node device in the blockchain system through the REE.
可选地,所述处理单元1501还用于:Optionally, the processing unit 1501 is further configured to:
在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,通过所述REE向所述区块链系统中的第二节点设备发送第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , send a third request to the second node device in the blockchain system through the REE, and the third request instructs the second node device to submit the block to the local zone The blockchain ledger of the blockchain system.
可选地,所述处理单元1501,还用于对日志序列中已提交的多个日志进行截断,得到所述日志序列的快照,向所述REE发送所述快照,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识;Optionally, the processing unit 1501 is further configured to truncate multiple logs submitted in the log sequence to obtain a snapshot of the log sequence, and send the snapshot to the REE, the snapshot including the first identifier And the second identification, wherein the first identification is the identification of the block corresponding to the start log in the plurality of logs, and the second identification is the identification of the block corresponding to the termination log in the plurality of logs logo;
所述通信单元1502,还用于接收所述快照,基于所述快照中的所述第一标识和所述第二标识,从本地的所述区块链系统的区块链账本中获取所述多个日志所对应的多个区块,向所述区块链系统中的第二节点设备发送第四请求,所述第四请求携带所述快照以及所述多个区块,所述第四请求指示所述第二节点设备基于所述快照将所述多个区块提交至本地的所述区块链账本。The communication unit 1502 is further configured to receive the snapshot, and based on the first identifier and the second identifier in the snapshot, obtain the local blockchain ledger of the blockchain system. Multiple blocks corresponding to multiple logs, sending a fourth request to the second node device in the blockchain system, the fourth request carrying the snapshot and the multiple blocks, the fourth The request instructs the second node device to submit the multiple blocks to the local blockchain ledger based on the snapshot.
应理解,装置1500对应于上述方法实施例中的第一节点设备,装置1500中的各模块和上述其他操作和/或功能分别为了实现方法实施例中第一节点设备所实施的各种步骤和方法,具体细节可参见上述方法实施例,为了简洁,在此不再赘述。It should be understood that the apparatus 1500 corresponds to the first node device in the above method embodiment, and each module in the apparatus 1500 and other operations and/or functions mentioned above are respectively to realize various steps and functions implemented by the first node device in the method embodiment. For the method, specific details may refer to the foregoing method embodiments, and for the sake of brevity, details are not repeated here.
应理解,装置1500在确定处理数据时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置1500的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的装置1500与上述方法实施例属于同一构思,其具体实现过程详见上述方法实施例,这里不再赘述。It should be understood that when the device 1500 determines the data to be processed, it only uses the division of the above-mentioned functional modules as an example for illustration. Different functional modules to complete all or part of the functions described above. In addition, the device 1500 provided in the above embodiment is based on the same idea as the above method embodiment, and its specific implementation process is detailed in the above method embodiment, and will not be repeated here.
图16本申请实施例提供了一种数据处理装置的结构示意图,参见图16,所述装置1600被配置为区块链系统中的第二节点设备,所述第二节点设备包括可信执行环境TEE和富执行环境REE;所述TEE包括处理单元1601,所述REE包括通信单元1602;Figure 16 The embodiment of this application provides a schematic structural diagram of a data processing device, see Figure 16, the device 1600 is configured as a second node device in the blockchain system, and the second node device includes a trusted execution environment TEE and Rich Execution Environment REE; the TEE includes a processing unit 1601, and the REE includes a communication unit 1602;
所述通信单元1602,用于接收来自所述区块链系统中第一节点设备的第一请求,所述第一请求携带区块的日志,向所述TEE发送所述日志,所述日志中以所述区块的标识指代所述区块,所述第一请求指示所述第二节点设备处理所述日志;The communication unit 1602 is configured to receive a first request from a first node device in the blockchain system, the first request carries a block log, and send the log to the TEE, and the log includes referring to the block with the identifier of the block, and the first request instructs the second node device to process the log;
所述处理单元1601,用于在所述日志通过了所述TEE的验证的情况下,所述TEE存储所述日志,通过所述REE向所述第一节点设备发送第一响应,所述第一响应指示所述第二节点设备已经同意接收所述日志。The processing unit 1601 is configured to store the log in the TEE when the log has passed the verification of the TEE, and send a first response to the first node device through the REE, and the second A response indicates that the second node device has agreed to receive the log.
可选地,所述第一请求还携带所述区块;Optionally, the first request also carries the block;
所述通信单元1602,还用于缓存所述区块;The communication unit 1602 is also configured to cache the block;
所述处理单元1601,还用于通过所述REE接收来自所述第一节点设备的第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本;The processing unit 1601 is further configured to receive a third request from the first node device through the REE, and the third request instructs the second node device to submit the block to the local zone The blockchain ledger of the blockchain system;
所述处理单元1601,还用于在所述第三请求通过了所述TEE的验证的情况下,基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本上。The processing unit 1601 is further configured to notify the REE to submit the block to the local on the blockchain ledger of the blockchain system.
可选地,所述处理单元1601还用于:Optionally, the processing unit 1601 is further configured to:
通过所述REE接收来自所述第一节点设备的第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;receiving a second request from the first node device through the REE, the second request indicating to vote for the first node device to become the leader node in the blockchain system;
在所述第二请求通过了所述TEE的验证的情况下,通过所述REE向所述第一节点设备发送第二响应,所述第二响应指示所述第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点。If the second request passes the verification of the TEE, send a second response to the first node device through the REE, and the second response indicates whether the second node device agrees with the first node device A node device becomes the leader node in the blockchain system.
可选地,所述处理单元1601还用于:Optionally, the processing unit 1601 is further configured to:
通过所述REE接收来自所述第一节点设备的通知消息,所述通知消息指示所述第一节点设备成为所述区块链系统中的领导节点;receiving a notification message from the first node device through the REE, the notification message instructing the first node device to become a leader node in the blockchain system;
在所述通知消息通过了所述TEE的验证的情况下,将存储的所述第一节点设备的节点状态修改为领导状态。If the notification message passes the verification of the TEE, modify the stored node status of the first node device to be the leader status.
可选地,所述通信单元1602,还用于接收来自所述第一节点设备的第四请求,所述第四请求携带所述第一节点设备中日志序列的快照以及多个区块,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述日志序列中已提交的多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识,所述多个日志与所述多个区块对应;Optionally, the communication unit 1602 is further configured to receive a fourth request from the first node device, the fourth request carrying a snapshot of the log sequence in the first node device and a plurality of blocks, the The snapshot includes a first identifier and a second identifier, wherein the first identifier is the identifier of the block corresponding to the start log among the multiple logs submitted in the log sequence, and the second identifier is the an identifier of a block corresponding to a termination log in a plurality of logs, the plurality of logs corresponding to the plurality of blocks;
所述通信单元1602,还用于缓存所述多个区块,向所述TEE发送所述快照;The communication unit 1602 is further configured to cache the multiple blocks, and send the snapshot to the TEE;
所述处理单元1601,还用于接收所述快照,在所述快照通过了所述TEE的验证的情况下,通知所述REE将所述多个区块提交至本地的所述区块链系统的区块链账本。The processing unit 1601 is further configured to receive the snapshot, and when the snapshot passes the verification of the TEE, notify the REE to submit the multiple blocks to the local blockchain system blockchain ledger.
应理解,装置1600对应于上述方法实施例中的第二节点设备,装置1600中的各模块和上述其他操作和/或功能分别为了实现方法实施例中第二节点设备所实施的各种步骤和方法,具体细节可参见上述方法实施例,为了简洁,在此不再赘述。It should be understood that the apparatus 1600 corresponds to the second node device in the above method embodiment, and each module in the apparatus 1600 and the above-mentioned other operations and/or functions are to realize various steps and functions implemented by the second node device in the method embodiment respectively. For the method, specific details may refer to the foregoing method embodiments, and for the sake of brevity, details are not repeated here.
应理解,装置1600在确定处理数据时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置1600的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的装置1600与上述方法实施例属于同一构思,其具体实现过程详见上述方法实施例,这里不再赘述。It should be understood that when the device 1600 determines the data to be processed, it only uses the division of the above-mentioned functional modules as an example for illustration. Different functional modules to complete all or part of the functions described above. In addition, the device 1600 provided in the above embodiment is based on the same idea as the above method embodiment, and its specific implementation process is detailed in the above method embodiment, and will not be repeated here.
图17是本申请实施例提供的一种计算机设备的结构示意图,该计算机设备1700包括一个或多个处理器1701以及一个或多个存储器1702。一个或多个处理器1701以及一个或多个存储器1702位于该计算机设备1700的TEE中。该一个或多个存储器1702与一个或多个处理器1701耦合,一个或多个存储器1702用于存储至少一条程序代码,该程序代码包括计算机指令,当一个或多个处理器1701执行计算机指令时,使得计算机设备1700执行上述相关方法步骤实现上述实施例中的数据处理方法。计算机设备1700可以为本申请实施例提供的任一节点设备。当然,该计算机设备1700还可以具有有线或无线网络接口、键盘以及输入输出接口等部件,以便进行输入输出,该计算机设备17200还可以包括其他用于实现设备功能的部件,在此不再赘述。FIG. 17 is a schematic structural diagram of a computer device provided by an embodiment of the present application. The computer device 1700 includes one or more processors 1701 and one or more memories 1702 . One or more processors 1701 and one or more memories 1702 are located in the TEE of the computer device 1700 . The one or more memories 1702 are coupled with the one or more processors 1701, and the one or more memories 1702 are used to store at least one piece of program code, which includes computer instructions, and when the one or more processors 1701 execute the computer instructions , so that the computer device 1700 executes the above related method steps to implement the data processing method in the above embodiment. The computer device 1700 may be any node device provided in this embodiment of the present application. Of course, the computer device 1700 may also have components such as wired or wireless network interfaces, keyboards, and input/output interfaces for input and output. The computer device 17200 may also include other components for implementing device functions, which will not be repeated here.
在示例性实施例中,还提供了一种计算机可读存储介质,例如包括程序代码的存储器,上述程序代码可由计算机设备的TEE中的处理器执行以完成上述实施例中的数据处理方法。例如,该计算机可读存储介质是非临时计算机可读存储介质,如只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、只读光盘(compact disc read-only memory,CD-ROM)、磁带、软盘和光数据存储设备等。In an exemplary embodiment, there is also provided a computer-readable storage medium, such as a memory including program codes, which can be executed by a processor in a TEE of a computer device to implement the data processing method in the above-mentioned embodiments. For example, the computer readable storage medium is a non-transitory computer readable storage medium, such as read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), read-only optical disc (compact disc read-only memory, CD-ROM), tapes, floppy disks and optical data storage devices, etc.
本申请实施例还提供了一种计算机程序产品,该计算机程序产品包括计算机指令,该计算机指令存储在计算机可读存储介质中,计算机设备的TEE的处理器从计算机可读存储介质读取该计算机指令,处理器执行该计算机指令,使得计算机设备执行上述数据处理方法。The embodiment of the present application also provides a computer program product, the computer program product includes computer instructions, the computer instructions are stored in a computer-readable storage medium, and the processor of the TEE of the computer device reads the computer program from the computer-readable storage medium. instruction, the processor executes the computer instruction, so that the computer device executes the above data processing method.
另外,本申请的实施例还提供一种装置,这个装置具体可以是芯片,组件或模块,该装置可包括相连的处理器和存储器;其中,存储器用于存储计算机执行指令,当装置运行时,处理器可执行存储器存储的计算机执行指令,以使芯片执行上述各方法实施例中数据处理方法。In addition, an embodiment of the present application also provides a device, which may specifically be a chip, a component or a module, and the device may include a connected processor and a memory; wherein the memory is used to store computer-executable instructions, and when the device is running, The processor can execute the computer-executable instructions stored in the memory, so that the chip executes the data processing methods in the above method embodiments.
其中,本实施例提供的装置、设备、计算机可读存储介质、计算机程序产品或芯片均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。Wherein, the device, equipment, computer-readable storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding method provided above, therefore, the beneficial effects it can achieve can refer to the above-mentioned provided The beneficial effects of the corresponding method will not be repeated here.
通过以上实施方式的描述,所属领域的技术人员可以了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,与上述实施例提供的数据处理方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。Through the description of the above embodiments, those skilled in the art can understand that for the convenience and brevity of the description, only the division of the above functional modules is used as an example for illustration. In practical applications, the above functions can be assigned by different Completion of functional modules means that the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the data processing method embodiments provided in the above embodiments belong to the same idea, and the specific implementation process thereof is detailed in the method embodiments, and will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be Incorporation or may be integrated into another device, or some features may be omitted, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The unit described as a separate component may or may not be physically separated, and the component displayed as a unit may be one physical unit or multiple physical units, that is, it may be located in one place, or may be distributed to multiple different places . Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium Among them, several instructions are included to make a device (which may be a single-chip microcomputer, a chip, etc.) or a processor (processor) execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media capable of storing program codes such as U disk, mobile hard disk, ROM, RAM, magnetic disk or optical disk.
在本申请的描述中,除非另有说明,“/”表示“或”的意思,例如,A/B可以表示A或B。 本文中的“和/或”仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。此外,“至少一个”是指一个或多个,“多个”是指两个或两个以上。“第一”、“第二”等字样并不对数量和执行次序进行限定,并且“第一”、“第二”等字样也并不限定一定不同。In the description of the present application, unless otherwise specified, "/" means "or", for example, A/B may mean A or B. The "and/or" in this article is just an association relationship describing associated objects, which means that there can be three relationships, for example, A and/or B, which can mean: A exists alone, A and B exist at the same time, and B exists alone These three situations. In addition, "at least one" means one or more, and "plurality" means two or more. Words such as "first" and "second" do not limit the number and order of execution, and words such as "first" and "second" do not necessarily limit the difference.
本申请中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其他实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。In this application, words such as "exemplary" or "for example" are used to mean an example, illustration or illustration. Any embodiment or design described herein as "exemplary" or "for example" is not to be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete manner.
上述所有可选技术方案,可以采用任意结合形成本公开的可选实施例,在此不再一一赘述。All the above optional technical solutions may be combined in any way to form optional embodiments of the present disclosure, which will not be repeated here.
以上所述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above are only optional embodiments of the application, and are not intended to limit the application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the application shall be included in the protection of the application. within range.

Claims (34)

  1. 一种数据处理方法,其特征在于,所述方法由区块链系统中的第一节点设备执行,所述第一节点设备包括可信执行环境TEE和富执行环境REE;所述方法包括:A data processing method, characterized in that the method is executed by a first node device in a block chain system, and the first node device includes a trusted execution environment TEE and a rich execution environment REE; the method includes:
    所述TEE基于所述REE中的区块,生成所述区块的日志,所述日志中以所述区块的标识指代所述区块;The TEE generates a log of the block based on the block in the REE, and the block is referred to by the block identifier in the log;
    所述TEE向所述REE发送所述日志;the TEE sends the log to the REE;
    所述REE接收所述日志,向所述区块链系统中的第二节点设备发送第一请求,所述第一请求携带所述日志,所述第一请求指示所述第二节点设备处理所述日志。The REE receives the log, sends a first request to the second node device in the blockchain system, the first request carries the log, and the first request instructs the second node device to process the log.
  2. 根据权利要求1所述的方法,其特征在于,所述第一请求还携带所述区块,所述第一请求指示所述第二节点设备处理所述日志以及所述区块;所述向所述区块链系统中的第二节点设备发送第一请求之后,所述方法还包括:The method according to claim 1, wherein the first request also carries the block, and the first request instructs the second node device to process the log and the block; After the second node device in the blockchain system sends the first request, the method further includes:
    所述TEE通过所述REE接收多个第一响应,每个第一响应指示一个第二节点设备是否已经同意接收所述日志;The TEE receives a plurality of first responses through the REE, each first response indicating whether a second node device has agreed to receive the log;
    在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,所述TEE基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , the TEE notifies the REE to submit the block to the local blockchain ledger of the blockchain system based on the identification of the block in the log.
  3. 根据权利要求1或2所述的方法,其特征在于,所述TEE基于所述REE中的区块,生成日志之前,所述方法还包括:The method according to claim 1 or 2, wherein the TEE is based on blocks in the REE, and before generating a log, the method further comprises:
    所述TEE通过所述REE向所述区块链系统中的第二节点设备发送第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;The TEE sends a second request to the second node device in the blockchain system through the REE, and the second request indicates that the first node device becomes the leader node in the blockchain system. vote;
    所述TEE通过所述REE接收多个第二响应,每个第二响应指示一个第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点;The TEE receives a plurality of second responses through the REE, and each second response indicates whether a second node device agrees with the first node device to become the leader node in the blockchain system;
    在所述区块链系统中半数或多数第二节点设备的第二响应通过了所述TEE的验证,且通过验证的每个所述第二响应指示一个第二节点设备赞同所述第一节点设备成为所述区块链系统中的领导节点的情况下,所述TEE将所述第一节点设备的节点状态切换为领导状态。In the blockchain system, half or most of the second responses of the second node devices have passed the verification of the TEE, and each of the verified second responses indicates that a second node device agrees with the first node When the device becomes the leader node in the blockchain system, the TEE switches the node status of the first node device to the leader status.
  4. 根据权利要求3所述的方法,其特征在于,所述TEE将所述第一节点设备的节点状态切换为领导状态之后,所述方法还包括:The method according to claim 3, wherein after the TEE switches the node state of the first node device to the leader state, the method further comprises:
    所述TEE生成通知消息,所述通知消息指示所述第一节点设备为所述区块链系统中的领导节点;The TEE generates a notification message, and the notification message indicates that the first node device is a leader node in the blockchain system;
    所述TEE通过所述REE向所述区块链系统中的第二节点设备发送所述通知消息。The TEE sends the notification message to the second node device in the blockchain system through the REE.
  5. 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method according to claim 2, further comprising:
    在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通 过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,所述TEE通过所述REE向所述区块链系统中的第二节点设备发送第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , the TEE sends a third request to the second node device in the blockchain system through the REE, and the third request instructs the second node device to submit the block to the local The blockchain ledger of the blockchain system.
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 1-5, wherein the method further comprises:
    所述TEE对日志序列中已提交的多个日志进行截断,得到所述日志序列的快照,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识;The TEE truncates multiple logs submitted in the log sequence to obtain a snapshot of the log sequence, and the snapshot includes a first identifier and a second identifier, wherein the first identifier is the An identifier of the block corresponding to the start log, the second identifier being the identifier of the block corresponding to the termination log in the plurality of logs;
    所述TEE向所述REE发送所述快照;the TEE sends the snapshot to the REE;
    所述REE接收所述快照,基于所述快照中的所述第一标识和所述第二标识,从本地的所述区块链系统的区块链账本中获取所述多个日志所对应的多个区块,向所述区块链系统中的第二节点设备发送第四请求,所述第四请求携带所述快照以及所述多个区块,所述第四请求指示所述第二节点设备基于所述快照将所述多个区块提交至本地的所述区块链账本。The REE receives the snapshot, and based on the first identifier and the second identifier in the snapshot, obtains the corresponding logs from the local blockchain ledger of the blockchain system. A plurality of blocks, sending a fourth request to the second node device in the blockchain system, the fourth request carries the snapshot and the plurality of blocks, the fourth request indicates that the second The node device submits the multiple blocks to the local blockchain ledger based on the snapshot.
  7. 一种数据处理方法,其特征在于,所述方法由区块链系统中的第二节点设备执行,所述第二节点设备包括可信执行环境TEE和富执行环境REE;所述方法包括:A data processing method, characterized in that the method is executed by a second node device in a blockchain system, the second node device includes a trusted execution environment TEE and a rich execution environment REE; the method includes:
    所述REE接收来自所述区块链系统中第一节点设备的第一请求,所述第一请求携带区块的日志,所述日志中以所述区块的标识指代所述区块,所述第一请求指示所述第二节点设备处理所述日志;The REE receives a first request from a first node device in the blockchain system, the first request carries a log of a block, and the block is referred to by the identifier of the block in the log, The first request instructs the second node device to process the log;
    所述REE向所述TEE发送所述日志;the REE sends the log to the TEE;
    在所述日志通过了所述TEE的验证的情况下,所述TEE存储所述日志,通过所述REE向所述第一节点设备发送第一响应,所述第一响应指示所述第二节点设备已经同意接收所述日志。If the log has passed the verification of the TEE, the TEE stores the log, and sends a first response to the first node device through the REE, and the first response indicates that the second node The device has agreed to receive said logs.
  8. 根据权利要求7所述的方法,其特征在于,所述第一请求还携带所述区块,所述REE接收来自所述区块链系统中第一节点设备的第一请求之后,所述方法还包括:The method according to claim 7, wherein the first request also carries the block, and after the REE receives the first request from the first node device in the blockchain system, the method Also includes:
    所述REE缓存所述区块;the REE caches the block;
    所述通过所述REE向所述第一节点设备发送第一响应之后,所述方法还包括:After sending the first response to the first node device through the REE, the method further includes:
    所述TEE通过所述REE接收来自所述第一节点设备的第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本;The TEE receives a third request from the first node device through the REE, and the third request instructs the second node device to submit the block to the block of the local block chain system Chain ledger;
    在所述第三请求通过了所述TEE的验证的情况下,所述TEE基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本上。In the case that the third request passes the verification of the TEE, the TEE notifies the REE to submit the block to the local blockchain based on the identification of the block in the log on the blockchain ledger of the system.
  9. 根据权利要求7或8所述的方法,其特征在于,所述REE接收来自所述区块链系统中第一节点设备的第一请求之前,所述方法还包括:The method according to claim 7 or 8, wherein before the REE receives the first request from the first node device in the blockchain system, the method further comprises:
    所述TEE通过所述REE接收来自所述第一节点设备的第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;The TEE receives a second request from the first node device through the REE, and the second request indicates to vote for the first node device to become the leader node in the blockchain system;
    在所述第二请求通过了所述TEE的验证的情况下,所述TEE通过所述REE向所述第一节点设备发送第二响应,所述第二响应指示所述第二节点设备是否赞同所述第一节点设备成 为所述区块链系统中的领导节点。If the second request is verified by the TEE, the TEE sends a second response to the first node device through the REE, and the second response indicates whether the second node device agrees to The first node device becomes a leader node in the blockchain system.
  10. 根据权利要求9所述的方法,其特征在于,所述TEE通过所述REE向所述第一节点设备发送第二响应之后,所述方法还包括:The method according to claim 9, wherein after the TEE sends a second response to the first node device through the REE, the method further comprises:
    所述TEE通过所述REE接收来自所述第一节点设备的通知消息,所述通知消息指示所述第一节点设备成为所述区块链系统中的领导节点;The TEE receives a notification message from the first node device through the REE, and the notification message instructs the first node device to become a leader node in the blockchain system;
    在所述通知消息通过了所述TEE的验证的情况下,所述TEE将存储的所述第一节点设备的节点状态修改为领导状态。If the notification message passes the verification of the TEE, the TEE modifies the stored node status of the first node device to a leader status.
  11. 根据权利要求7-10中任一项所述的方法,其特征在于,所述方法还包括:The method according to any one of claims 7-10, further comprising:
    所述REE接收来自所述第一节点设备的第四请求,所述第四请求携带所述第一节点设备中日志序列的快照以及多个区块,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述日志序列中已提交的多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识,所述多个日志与所述多个区块对应;The REE receives a fourth request from the first node device, the fourth request carries a snapshot of the log sequence in the first node device and a plurality of blocks, and the snapshot includes a first identifier and a second identifier , wherein the first identifier is the identifier of the block corresponding to the start log among the multiple logs submitted in the log sequence, and the second identifier is the block corresponding to the end log among the multiple logs an identification of a block, the plurality of logs corresponding to the plurality of blocks;
    所述REE缓存所述多个区块,向所述TEE发送所述快照;The REE caches the plurality of blocks, and sends the snapshot to the TEE;
    所述TEE接收所述快照,在所述快照通过了所述TEE的验证的情况下,通知所述REE将所述多个区块提交至本地的所述区块链系统的区块链账本。The TEE receives the snapshot, and if the snapshot passes the verification of the TEE, notifies the REE to submit the multiple blocks to the local blockchain ledger of the blockchain system.
  12. 一种用于数据处理的区块链系统,其特征在于,所述区块链系统包括第一节点设备以及至少一个第二节点设备;A blockchain system for data processing, characterized in that the blockchain system includes a first node device and at least one second node device;
    所述第一节点设备,用于向所述区块链系统中的第二节点设备发送第一请求,所述第一请求携带区块的日志,所述日志中以所述区块的标识指代所述区块,所述第一请求指示所述第二节点设备处理所述日志;The first node device is configured to send a first request to a second node device in the blockchain system, the first request carries a log of a block, and the log is indicated by the identifier of the block On behalf of the block, the first request instructs the second node device to process the log;
    每个第二节点设备,用于接收所述第一请求,若所述日志通过了所述第二节点设备验证的情况下,存储所述日志。Each second node device is configured to receive the first request, and store the log if the log is verified by the second node device.
  13. 根据权利要求12所述的系统,其特征在于,所述第一节点设备包括可信执行环境TEE和富执行环境REE;The system according to claim 12, wherein the first node device includes a Trusted Execution Environment (TEE) and a Rich Execution Environment (REE);
    所述TEE,用于基于所述REE中的所述区块,生成所述日志,向所述REE发送所述日志;The TEE is configured to generate the log based on the block in the REE, and send the log to the REE;
    所述REE,用于接收所述日志,向所述区块链系统中的第二节点设备发送所述第一请求。The REE is configured to receive the log, and send the first request to the second node device in the blockchain system.
  14. 根据权利要求12或13所述的系统,其特征在于,每个第二节点设备包括TEE和REE;The system according to claim 12 or 13, wherein each second node device includes a TEE and a REE;
    每个第二节点设备的REE,用于接收来所述第一请求,向所属第二节点设备的TEE发送所述第一请求携带的所述日志;The REE of each second node device is configured to receive the first request, and send the log carried in the first request to the TEE of the second node device to which it belongs;
    每个第二节点设备的TEE,用于接收所述第一请求,在所述日志通过了所述TEE的验证的情况下,存储所述日志,通过所属第二节点设备的REE向所述第一节点设备发送第一响应,所述第一响应指示一个第二节点设备是否已经同意接收所述日志。The TEE of each second node device is configured to receive the first request, store the log when the log has passed the verification of the TEE, and send the log to the second node device through the REE of the second node device. A node device sends a first response, the first response indicating whether a second node device has agreed to receive the log.
  15. 根据权利要求14所述的系统,其特征在于,所述第一节点设备包括TEE和REE;The system according to claim 14, wherein the first node device comprises a TEE and a REE;
    所述第一节点设备的TEE,用于通过所述第一节点设备的REE接收所述区块链系统中第二节点设备的所述第一响应,在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经存储所述日志的情况下,基于所述日志中所述区块的标识,通知所述第一节点设备的REE将所述区块提交至本地的所述区块链系统的区块链账本。The TEE of the first node device is used to receive the first response of the second node device in the blockchain system through the REE of the first node device, and half or a majority of them in the blockchain system If the first response of the second node device has passed the verification of the TEE, and each of the first responses passed the verification indicates that a second node device has stored the log, based on the area in the log block identification, and notify the REE of the first node device to submit the block to the local blockchain ledger of the blockchain system.
  16. 根据权利要求15所述的系统,其特征在于,所述第一请求还携带所述区块;The system according to claim 15, wherein the first request also carries the block;
    所述第一节点设备的TEE,还用于通过所属节点设备的REE向所述区块链系统中的第二节点设备发送第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本;The TEE of the first node device is also used to send a third request to the second node device in the blockchain system through the REE of the node device to which it belongs, and the third request instructs the second node device to send the Submit the block to the local block chain ledger of the block chain system;
    每个第二节点设备的REE,还用于缓存所述第一请求携带的所述区块,接收所述第三请求,向所属第二节点设备的TEE发送所述第三请求;The REE of each second node device is also used to cache the block carried in the first request, receive the third request, and send the third request to the TEE of the second node device;
    每个第二节点设备的TEE,还用于接收所述第三请求,在所述第三请求通过了所述TEE的验证的情况下,基于所述日志中所述区块的标识,通知所属第二节点设备的REE将所述区块提交至本地的所述区块链系统的区块链账本上。The TEE of each second node device is also used to receive the third request, and if the third request passes the verification of the TEE, based on the identifier of the block in the log, notify the owner The REE of the second node device submits the block to the local blockchain ledger of the blockchain system.
  17. 根据权利要求12-16中任一项所述的系统,其特征在于,所述第一节点设备以及所述至少一个第二节点设备中的每个节点设备包括TEE以及REE;The system according to any one of claims 12-16, wherein each node device in the first node device and the at least one second node device includes a TEE and a REE;
    所述第一节点设备的TEE,用于所属节点设备的TEE向所述区块链系统中的第二节点设备发送第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;The TEE of the first node device is used for the TEE of the node device to which it belongs to send a second request to the second node device in the blockchain system, and the second request indicates that the first node device becomes the The leader nodes in the blockchain system vote;
    每个第二节点设备的TEE,用于接收所述第二请求,在所述第二请求通过了所述TEE的验证的情况下,通过所属节点设备的REE向所述第一节点设备发送第二响应,每个第二响应指示一个第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点;The TEE of each second node device is configured to receive the second request, and when the second request passes the verification of the TEE, send the second request to the first node device through the REE of the associated node device. Two responses, each second response indicates whether a second node device agrees with the first node device to become the leader node in the blockchain system;
    所述第一节点设备的TEE,还用于通过所属节点设备的REE接收所述区块链系统中第二节点设备对所述第二请求的第二响应,在所述区块链系统中半数或多数第二节点设备的第二响应通过了所述TEE的验证,且通过验证的每个所述第二响应指示一个第二节点设备赞同所述第一节点设备成为所述区块链系统中的领导节点的情况下,将所述第一节点设备的节点状态切换为领导状态。The TEE of the first node device is also used to receive the second response of the second node device in the blockchain system to the second request through the REE of the node device to which it belongs. In the blockchain system, half of the Or the second response of most of the second node devices has passed the verification of the TEE, and each of the second responses that pass the verification indicates that a second node device agrees that the first node device becomes a member of the block chain system. In the case of the leader node, switch the node state of the first node device to the leader state.
  18. 根据权利要求17所述的系统,其特征在于,The system of claim 17, wherein
    所述第一节点设备的TEE,还用于生成通知消息,通过所属节点设备的REE向所述区块链系统中的第二节点设备发送所述通知消息,所述通知消息指示所述第一节点设备为所述区块链系统中的领导节点;The TEE of the first node device is also used to generate a notification message, and send the notification message to the second node device in the blockchain system through the REE of the node device to which it belongs, and the notification message indicates that the first The node device is the leader node in the blockchain system;
    每个第二节点设备的TEE,还用于通过所属节点设备的REE接收所述通知消息,在所述通知消息通过了所述TEE的验证的情况下,将存储的所述第一节点设备的节点状态修改为领导状态。The TEE of each second node device is also used to receive the notification message through the REE of the node device to which it belongs, and when the notification message passes the verification of the TEE, the stored first node device The node status is changed to leader status.
  19. 根据权利要求12-17中任一项所述的系统,其特征在于,所述第一节点设备包括TEE以及REE;The system according to any one of claims 12-17, wherein the first node device includes TEE and REE;
    所述TEE,用于对日志序列中已提交的多个日志进行截断,得到所述日志序列的快照,向所述REE发送所述快照,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识;The TEE is configured to truncate multiple logs submitted in the log sequence, obtain a snapshot of the log sequence, and send the snapshot to the REE, the snapshot includes a first identifier and a second identifier, wherein, The first identification is the identification of the block corresponding to the start log in the plurality of logs, and the second identification is the identification of the block corresponding to the termination log in the plurality of logs;
    所述REE,用于接收所述快照,基于所述快照中的所述第一标识和所述第二标识,从本地的所述区块链系统的区块链账本中获取所述多个日志所对应的多个区块,向所述区块链系统中的第二节点设备发送第四请求,所述快照包括当前时刻所述区块链账本中第一个区块的标识以及最后一个区块的标识,所述第四请求携带所述快照以及所述多个区块,所述第四请求指示所述第二节点设备将所述多个区块提交至本地的所述区块链账本。The REE is configured to receive the snapshot, and based on the first identifier and the second identifier in the snapshot, obtain the plurality of logs from the local blockchain ledger of the blockchain system For multiple corresponding blocks, send a fourth request to the second node device in the blockchain system, and the snapshot includes the identification of the first block in the blockchain account book at the current moment and the last block block identification, the fourth request carries the snapshot and the plurality of blocks, and the fourth request instructs the second node device to submit the plurality of blocks to the local blockchain ledger .
  20. 根据权利要求19所述的系统,其特征在于,每个第二节点设备包括TEE以及REE;The system according to claim 19, wherein each second node device includes a TEE and a REE;
    每个第二节点设备的REE,用于接收来自所述第一节点设备的所述第四请求,缓存所述多个区块,向所述TEE发送所述快照;The REE of each second node device is configured to receive the fourth request from the first node device, cache the plurality of blocks, and send the snapshot to the TEE;
    每个第二节点设备的TEE,用于接收所述快照,在所述快照通过了所述TEE的验证的情况下,通知所属第二节点设备的REE基于所述快照将所述多个区块提交至本地的所述区块链系统的区块链账本。The TEE of each second node device is used to receive the snapshot, and when the snapshot passes the verification of the TEE, notify the REE of the second node device to transfer the multiple blocks based on the snapshot Submit to the blockchain ledger of the local blockchain system.
  21. 一种数据处理装置,其特征在于,所述装置被配置为区块链系统中的第一节点设备,所述第一节点设备包括可信执行环境TEE和富执行环境REE,所述TEE包括处理单元,所述REE包括通信单元;A data processing device, characterized in that the device is configured as a first node device in a blockchain system, the first node device includes a Trusted Execution Environment TEE and a Rich Execution Environment REE, and the TEE includes processing a unit, the REE comprising a communication unit;
    所述处理单元,用于基于所述REE中的区块,生成所述区块的日志,向所述REE发送所述日志,所述日志中以所述区块的标识指代所述区块;The processing unit is configured to generate a log of the block based on the block in the REE, and send the log to the REE, where the block is referred to by the identifier of the block in the log ;
    所述通信单元,用于接收所述日志,向所述区块链系统中的第二节点设备发送第一请求,所述第一请求携带所述日志,所述第一请求指示所述第二节点设备处理所述日志。The communication unit is configured to receive the log, and send a first request to the second node device in the blockchain system, the first request carries the log, and the first request indicates that the second The node device processes the log.
  22. 根据权利要求21所述的装置,其特征在于,所述第一请求还携带所述区块,所述第一请求指示所述第二节点设备处理所述日志以及所述区块;所述处理单元还用于:The apparatus according to claim 21, wherein the first request also carries the block, and the first request instructs the second node device to process the log and the block; the processing Units are also used for:
    通过所述REE接收多个第一响应,每个第一响应指示一个第二节点设备是否已经同意接收所述日志;receiving a plurality of first responses through the REE, each first response indicating whether a second node device has agreed to receive the log;
    在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , based on the identification of the block in the log, notify the REE to submit the block to the local blockchain ledger of the blockchain system.
  23. 根据权利要求21或22所述的装置,其特征在于,所述处理单元还用于:The device according to claim 21 or 22, wherein the processing unit is further used for:
    通过所述REE向所述区块链系统中的第二节点设备发送第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;sending a second request to a second node device in the blockchain system through the REE, the second request indicating to vote for the first node device to become the leader node in the blockchain system;
    通过所述REE接收多个第二响应,每个第二响应指示一个第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点;receiving a plurality of second responses through the REE, each second response indicating whether a second node device agrees with the first node device to become the leader node in the blockchain system;
    在所述区块链系统中半数或多数第二节点设备的第二响应通过了所述TEE的验证,且通过验证的每个所述第二响应指示一个第二节点设备赞同所述第一节点设备成为所述区块链系统中的领导节点的情况下,将所述第一节点设备的节点状态切换为领导状态。In the blockchain system, half or most of the second responses of the second node devices have passed the verification of the TEE, and each of the verified second responses indicates that a second node device agrees with the first node When the device becomes the leader node in the blockchain system, the node status of the first node device is switched to the leader status.
  24. 根据权利要求23所述的装置,其特征在于,所述处理单元还用于:The device according to claim 23, wherein the processing unit is further used for:
    生成通知消息,所述通知消息指示所述第一节点设备为所述区块链系统中的领导节点;generating a notification message, the notification message indicating that the first node device is the leader node in the blockchain system;
    通过所述REE向所述区块链系统中的第二节点设备发送所述通知消息。Sending the notification message to the second node device in the blockchain system through the REE.
  25. 根据权利要求22所述的装置,其特征在于,所述处理单元还用于:The device according to claim 22, wherein the processing unit is further used for:
    在所述区块链系统中半数或多数第二节点设备的第一响应通过了所述TEE的验证,且通过验证的每个所述第一响应指示一个第二节点设备已经同意接收所述日志的情况下,通过所述REE向所述区块链系统中的第二节点设备发送第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本。In the blockchain system, half or most of the first responses of the second node devices have passed the verification of the TEE, and each of the verified first responses indicates that a second node device has agreed to receive the log In the case of , send a third request to the second node device in the blockchain system through the REE, and the third request instructs the second node device to submit the block to the local zone The blockchain ledger of the blockchain system.
  26. 根据权利要求21-25任一项所述的装置,其特征在于,The device according to any one of claims 21-25, characterized in that,
    所述处理单元,还用于对日志序列中已提交的多个日志进行截断,得到所述日志序列的快照,向所述REE发送所述快照,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识;The processing unit is further configured to truncate a plurality of submitted logs in the log sequence to obtain a snapshot of the log sequence, and send the snapshot to the REE, the snapshot includes a first identifier and a second identifier, Wherein, the first identification is the identification of the block corresponding to the start log in the plurality of logs, and the second identification is the identification of the block corresponding to the termination log in the plurality of logs;
    所述通信单元,还用于接收所述快照,基于所述快照中的所述第一标识和所述第二标识,从本地的所述区块链系统的区块链账本中获取所述多个日志所对应的多个区块,向所述区块链系统中的第二节点设备发送第四请求,所述第四请求携带所述快照以及所述多个区块,所述第四请求指示所述第二节点设备基于所述快照将所述多个区块提交至本地的所述区块链账本。The communication unit is further configured to receive the snapshot, and based on the first identifier and the second identifier in the snapshot, obtain the multiple from the local blockchain ledger of the blockchain system. a plurality of blocks corresponding to a log, and send a fourth request to the second node device in the blockchain system, the fourth request carries the snapshot and the plurality of blocks, and the fourth request carries the snapshot and the plurality of blocks, the fourth request Instructing the second node device to submit the multiple blocks to the local blockchain ledger based on the snapshot.
  27. 一种数据处理装置,其特征在于,所述装置被配置为区块链系统中的第二节点设备,所述第二节点设备包括可信执行环境TEE和富执行环境REE;所述TEE包括处理单元,所述REE包括通信单元;A data processing device, characterized in that the device is configured as a second node device in a blockchain system, and the second node device includes a Trusted Execution Environment TEE and a Rich Execution Environment REE; the TEE includes processing a unit, the REE comprising a communication unit;
    所述通信单元,用于接收来自所述区块链系统中第一节点设备的第一请求,所述第一请求携带区块的日志,向所述TEE发送所述日志,所述日志中以所述区块的标识指代所述区块,所述第一请求指示所述第二节点设备处理所述日志;The communication unit is configured to receive a first request from a first node device in the blockchain system, the first request carries a log of a block, and send the log to the TEE, and the log is in the form of The identifier of the block refers to the block, and the first request instructs the second node device to process the log;
    所述处理单元,用于在所述日志通过了所述TEE的验证的情况下,所述TEE存储所述日志,通过所述REE向所述第一节点设备发送第一响应,所述第一响应指示所述第二节点设备已经同意接收所述日志。The processing unit is configured to store the log in the TEE when the log has passed the verification of the TEE, and send a first response to the first node device through the REE, and the first The response indicates that the second node device has agreed to receive the log.
  28. 根据权利要求27所述的装置,其特征在于,所述第一请求还携带所述区块;The device according to claim 27, wherein the first request also carries the block;
    所述通信单元,还用于缓存所述区块;The communication unit is also used to cache the blocks;
    所述处理单元,还用于通过所述REE接收来自所述第一节点设备的第三请求,所述第三请求指示所述第二节点设备将所述区块提交至本地的所述区块链系统的区块链账本;The processing unit is further configured to receive a third request from the first node device through the REE, and the third request instructs the second node device to submit the block to the local block The blockchain ledger of the chain system;
    所述处理单元,还用于在所述第三请求通过了所述TEE的验证的情况下,基于所述日志中所述区块的标识,通知所述REE将所述区块提交至本地的所述区块链系统的区块链账本上。The processing unit is further configured to notify the REE to submit the block to a local On the blockchain ledger of the blockchain system.
  29. 根据权利要求27或28所述的装置,其特征在于,所述处理单元还用于:The device according to claim 27 or 28, wherein the processing unit is further used for:
    通过所述REE接收来自所述第一节点设备的第二请求,所述第二请求指示对所述第一节点设备成为所述区块链系统中的领导节点进行投票;receiving a second request from the first node device through the REE, the second request indicating to vote for the first node device to become the leader node in the blockchain system;
    在所述第二请求通过了所述TEE的验证的情况下,通过所述REE向所述第一节点设备发送第二响应,所述第二响应指示所述第二节点设备是否赞同所述第一节点设备成为所述区块链系统中的领导节点。If the second request passes the verification of the TEE, send a second response to the first node device through the REE, and the second response indicates whether the second node device agrees with the first node device A node device becomes the leader node in the blockchain system.
  30. 根据权利要求29所述的装置,其特征在于,所述处理单元还用于:The device according to claim 29, wherein the processing unit is further used for:
    通过所述REE接收来自所述第一节点设备的通知消息,所述通知消息指示所述第一节点设备成为所述区块链系统中的领导节点;receiving a notification message from the first node device through the REE, the notification message instructing the first node device to become a leader node in the blockchain system;
    在所述通知消息通过了所述TEE的验证的情况下,将存储的所述第一节点设备的节点状态修改为领导状态。If the notification message passes the verification of the TEE, modify the stored node status of the first node device to be the leader status.
  31. 根据权利要求27-30中任一项所述的装置,其特征在于,Apparatus according to any one of claims 27-30, characterized in that,
    所述通信单元,还用于接收来自所述第一节点设备的第四请求,所述第四请求携带所述第一节点设备中日志序列的快照以及多个区块,所述快照包括第一标识以及第二标识,其中,所述第一标识为所述日志序列中已提交的多个日志中起始日志所对应的区块的标识,所述第二标识为所述多个日志中终止日志所对应的区块的标识,所述多个日志与所述多个区块对应;The communication unit is further configured to receive a fourth request from the first node device, the fourth request carries a snapshot of the log sequence in the first node device and a plurality of blocks, and the snapshot includes the first An identifier and a second identifier, wherein the first identifier is the identifier of the block corresponding to the start log in the multiple logs that have been submitted in the log sequence, and the second identifier is the termination log of the multiple logs an identifier of a block corresponding to the log, and the multiple logs correspond to the multiple blocks;
    所述通信单元,还用于缓存所述多个区块,向所述TEE发送所述快照;The communication unit is further configured to cache the plurality of blocks, and send the snapshot to the TEE;
    所述处理单元,还用于接收所述快照,在所述快照通过了所述TEE的验证的情况下,通知所述REE将所述多个区块提交至本地的所述区块链系统的区块链账本。The processing unit is further configured to receive the snapshot, and when the snapshot passes the verification of the TEE, notify the REE to submit the plurality of blocks to the local blockchain system Blockchain ledger.
  32. 一种计算机设备,其特征在于,所述计算机设备包括可信执行环境TEE,所述TEE包括处理器,所述处理器用于执行程序代码,使得所述计算机设备执行如权利要求1至权利要求11中任一项所述的方法。A computer device, characterized in that the computer device includes a Trusted Execution Environment (TEE), the TEE includes a processor, and the processor is used to execute program codes, so that the computer device performs the tasks of claim 1 to claim 11. any one of the methods described.
  33. 一种计算机可读存储介质,其特征在于,所述存储介质中存储有至少一条程序代码,所述至少一条程序代码由可信执行环境TEE中的处理器读取以使计算机设备执行如权利要求1至权利要求11中任一项所述的方法。A computer-readable storage medium, characterized in that at least one program code is stored in the storage medium, and the at least one program code is read by a processor in a trusted execution environment (TEE) to enable a computer device to execute 1 to the method described in any one of claims 11.
  34. 一种计算机程序产品,其特征在于,所述计算机程序产品包括至少一条程序代码,所述至少一条程序代码由可信执行环境TEE中的处理器读取以使计算机设备执行如权利要求1至权利要求11中任一项所述的方法。A computer program product, characterized in that the computer program product includes at least one piece of program code, and the at least one piece of program code is read by a processor in the Trusted Execution Environment (TEE) to enable the computer device to execute the The method according to any one of claim 11.
PCT/CN2022/108710 2021-08-26 2022-07-28 Data processing method, system and apparatus, computer device, and storage medium WO2023024821A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110989279.0A CN115719272A (en) 2021-08-26 2021-08-26 Data processing method, system, device, computer equipment and storage medium
CN202110989279.0 2021-08-26

Publications (1)

Publication Number Publication Date
WO2023024821A1 true WO2023024821A1 (en) 2023-03-02

Family

ID=85253617

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/108710 WO2023024821A1 (en) 2021-08-26 2022-07-28 Data processing method, system and apparatus, computer device, and storage medium

Country Status (2)

Country Link
CN (1) CN115719272A (en)
WO (1) WO2023024821A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109583898A (en) * 2018-12-07 2019-04-05 四川长虹电器股份有限公司 The intelligent terminal and method paid based on TEE and block chain
US20200259646A1 (en) * 2019-02-13 2020-08-13 TEEware Co., Ltd. System and method for storing and managing keys for signing transactions using key of cluster managed in trusted execution environment
CN112347184A (en) * 2019-08-07 2021-02-09 华为技术有限公司 Bifurcation processing method and block link point
CN113010894A (en) * 2020-06-12 2021-06-22 腾讯科技(深圳)有限公司 Data processing method and device and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109583898A (en) * 2018-12-07 2019-04-05 四川长虹电器股份有限公司 The intelligent terminal and method paid based on TEE and block chain
US20200259646A1 (en) * 2019-02-13 2020-08-13 TEEware Co., Ltd. System and method for storing and managing keys for signing transactions using key of cluster managed in trusted execution environment
CN112347184A (en) * 2019-08-07 2021-02-09 华为技术有限公司 Bifurcation processing method and block link point
CN113010894A (en) * 2020-06-12 2021-06-22 腾讯科技(深圳)有限公司 Data processing method and device and computer readable storage medium

Also Published As

Publication number Publication date
CN115719272A (en) 2023-02-28

Similar Documents

Publication Publication Date Title
US10833919B2 (en) Node device operation method, work status switching apparatus, node device, and medium
US11966916B2 (en) Resource transfer method and apparatus, storage medium, and computer device
KR102562558B1 (en) Block processing methods, node and system
WO2020258831A1 (en) Method and device for master node handover processing in blockchain system
Castro et al. Proactive Recovery in a {Byzantine-Fault-Tolerant} System
US6421688B1 (en) Method and apparatus for database fault tolerance with instant transaction replication using off-the-shelf database servers and low bandwidth networks
Dobre et al. PoWerStore: Proofs of writing for efficient and robust storage
CN113141414B (en) Grouped multi-chain asynchronous consensus method for block chain nodes in CNFS protocol
JP5594828B2 (en) Data distributed storage device and method, program, and recording medium
JP4309354B2 (en) Write operation control in storage network
CN114048517B (en) Dual channel consensus system and method for blockchains, computer readable storage medium
US7454521B2 (en) Byzantine fault quantifying clock synchronization
CN110602108B (en) Data communication method, device, equipment and storage medium based on block chain network
WO2018192534A1 (en) Node device running method, working state switching device, node device, and medium
WO2012145963A1 (en) Data management system and method
CN109388481A (en) A kind of transmission method of transaction information, device, calculates equipment and medium at system
Chai et al. Byzantine fault tolerance for services with commutative operations
CN104731892B (en) A kind of mimicry tamper resistant method of centralized File Serving System
WO2023024821A1 (en) Data processing method, system and apparatus, computer device, and storage medium
CN112019599A (en) Method and device for synchronizing processing messages during block chain consensus processing
Ren et al. Distributed consensus and fault tolerance mechanisms
LUČIĆ Byzantine fault tolerant raft algorithm with round robin leader election
CN116846888A (en) Consensus processing method, device, equipment and storage medium of block chain network
Rodrigues Robust services in dynamic systems
CN115048337B (en) Byzantine fault-tolerant consensus method based on TEE and related equipment

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22860167

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE