CN116975151A - Block chain event processing method and device - Google Patents

Block chain event processing method and device Download PDF

Info

Publication number
CN116975151A
CN116975151A CN202310903818.3A CN202310903818A CN116975151A CN 116975151 A CN116975151 A CN 116975151A CN 202310903818 A CN202310903818 A CN 202310903818A CN 116975151 A CN116975151 A CN 116975151A
Authority
CN
China
Prior art keywords
contract
event
processed
block
processing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310903818.3A
Other languages
Chinese (zh)
Inventor
张亚宁
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Rivtower Technology Co Ltd
Original Assignee
Hangzhou Rivtower Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Rivtower Technology Co Ltd filed Critical Hangzhou Rivtower Technology Co Ltd
Priority to CN202310903818.3A priority Critical patent/CN116975151A/en
Publication of CN116975151A publication Critical patent/CN116975151A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/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
    • 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/25Integrating or interfacing systems involving database management systems

Landscapes

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

Abstract

The embodiment of the specification discloses a blockchain event processing method and device, and corresponding electronic equipment and computer readable storage medium, wherein the method comprises the following steps: obtaining a block to be processed with a specified block height in an out-of-chain database and a transaction receipt of the block to be processed; and processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt. The application can effectively expand the application scene outside the chain and improve the capability of the application outside the chain for processing the data of the block chain for analyzing and processing the events generated by the block to be processed and the transaction receipt thereof in an intelligent contract mode.

Description

Block chain event processing method and device
Technical Field
The present disclosure relates to the field of blockchain technologies, and in particular, to a blockchain event processing method and apparatus, and corresponding electronic device and computer readable storage medium.
Background
The chain structure formed by combining the data blocks in a sequential connection mode has the characteristics of data non-tamper property and decentralization, so that the recorded information is more real and reliable, and the problem of mutual trust can be solved. The intelligent contract is used as an Ethernet block chain service logic implementation carrier, and an event mechanism of the intelligent contract is used for triggering and calling event parameters to be stored in a transaction log so as to be convenient for contract address association, and when the occurrence of an event is monitored, the next operation is executed through an event callback function.
Therefore, in the out-of-chain synchronization scenario of the blockchain data, how to enable intelligence to implement business logic processing in the out-of-chain application and to implement blockchain event processing is a technical problem to be solved.
Disclosure of Invention
An objective of the embodiments of the present disclosure is to provide a method and an apparatus for processing a blockchain event, and corresponding electronic devices and storage media.
In order to solve the above technical problems, the embodiments of the present specification are implemented as follows:
in a first aspect, a blockchain event processing method is provided, including:
obtaining a block to be processed with a specified block height in an out-of-chain database and a transaction receipt of the block to be processed;
and processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
Further, abi files of the smart contract are saved to the out-of-chain database prior to creating and deploying the smart contract to the blockchain.
Further, the obtaining the block to be processed with the specified block height in the out-of-chain database and the transaction receipt of the block to be processed includes:
obtaining the processed block height recorded in the out-of-chain data;
obtaining a block to be processed with the specified block height according to the processed block height;
and when all the transaction receipts of the blocks to be processed are stored in the out-of-chain database, obtaining the transaction receipts of the blocks to be processed.
Further, the smart contract event type includes a contract creation event; and/or, when the intelligent contract event type included in the transaction receipt is a contract creation event, processing the intelligent contract event, including saving a contract name, a contract version, and a contract address to the off-chain database.
Further, the smart contract event type includes other events of the contract; and/or, when the smart contract event type included in the transaction receipt is a contract other event, a process for processing the smart contract event includes:
obtaining a contract version and a contract name from the off-link database according to the contract address corresponding to the event in the transaction return license;
obtaining abi files of the intelligent contracts from the off-link database according to the contract names and the contract versions;
and analyzing the event according to the abi file of the intelligent contract.
Further, when the smart contract event type included in the transaction receipt is other contract events, the process of processing the smart contract event further includes: and processing the parsed event according to the business processing logic of the intelligent contract, and updating the out-of-chain database.
Further, processing the events in the transaction return of the block to be processed according to the transaction hash sequence in the block to be processed; and/or the off-chain database includes a contract table, a abi file table, and a business table.
In a second aspect, a blockchain event processing device is provided, including:
the first module can obtain a block to be processed with a specified block height in the out-of-chain database and a transaction receipt of the block to be processed;
and the second module is capable of processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
In a third aspect, an electronic device is provided, comprising: a processor; and
a memory arranged to store computer executable instructions which, when executed, cause the processor to perform the method of the first aspect.
In a fourth aspect, a computer readable storage medium is presented, the computer readable storage medium storing one or more programs, which when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of the first aspect.
The specification can achieve at least the following technical effects:
the application firstly obtains a block to be processed with a designated block height in an out-of-chain database and a transaction receipt of the block to be processed in a blockchain, and processes the intelligent contract event according to the intelligent contract event type contained in the transaction receipt. The application can effectively expand the application scene outside the chain and improve the capability of the application outside the chain for processing the data of the block chain for analyzing and processing the events generated by the block to be processed and the transaction receipt thereof in an intelligent contract mode.
Drawings
In order to more clearly illustrate the embodiments of the present description or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some of the embodiments described in the present description, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart of a blockchain event processing method according to an embodiment of the present disclosure.
FIG. 2 is a second flowchart of a block chain event processing method according to an embodiment of the present disclosure.
FIG. 3 is a third flowchart illustrating a block chain event processing method according to an embodiment of the present disclosure.
FIG. 4 is a flowchart illustrating a block chain event processing method according to an embodiment of the present disclosure.
Fig. 5 is a schematic diagram of a blockchain event processing device according to an embodiment of the present disclosure.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only some embodiments of the present specification, not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
A blockchain event processing scheme referred to in this specification is detailed below by way of specific examples.
The application aims to provide a scheme for processing a blockchain event, which aims to solve the technical problem of how to enable intelligent to realize business logic processing in an out-of-chain application in an out-of-chain synchronization scene of blockchain data so as to realize out-of-chain synchronization of blockchain transaction data. Taking the ethernet as an example, the event is a convenient interface provided by the log infrastructure of the ethernet virtual machine, when an intelligent contract containing one or more events is called, the calling event parameters are triggered to be stored in a transaction log, the log is associated with an intelligent contract address and recorded in a blockchain, and when the event is monitored, the next operation is executed through an event callback function. When developing intelligent contracts, blockchain users write intelligent contract states which need to be synchronized outside the chain in the intelligent contract logic in the form of events. Meanwhile, in the construction function of the intelligent contract, an intelligent contract creation success message is recorded in the form of an event, wherein the event of the intelligent contract creation success comprises a contract address, a contract name and a version. After the user has developed the contract, the contract is compiled to produce a related abi file, and the contract name, contract version and abi file are recorded in the off-chain database. Therefore, the technical scheme of the application is as follows: and creating and deploying an intelligent contract for processing the out-of-chain synchronous event of the blockchain data in the blockchain, and processing the intelligent contract event by acquiring a to-be-processed block with a specified block height in an out-of-chain database and a transaction receipt of the to-be-processed block and combining the intelligent contract event type contained in the transaction receipt.
Example 1
FIG. 1 is a flowchart illustrating a block chain event processing method according to an embodiment of the present application. The method comprises the following steps:
s101: and obtaining a block to be processed with a specified block height in the out-of-chain database, and a transaction receipt of the block to be processed.
S102: and processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
In some embodiments, it may be desirable to save abi files of the smart contracts to the off-chain database before the smart contracts are created and deployed.
In some embodiments, the off-chain database includes a contract table, a abi file table, and a business table.
In some embodiments, the obtaining the pending block with the specified block height in the out-of-chain database and the transaction receipt of the pending block, as shown in fig. 2, includes:
s211: the processed block height recorded in the out-of-chain data is obtained.
S212: and obtaining the block to be processed with the specified block height according to the processed block height.
S213: and when the out-of-chain database stores all the transaction receipts of the blocks to be processed, obtaining the transaction receipts of the blocks to be processed.
In some embodiments, the smart contract event types include a contract creation event; and/or, when the intelligent contract event type included in the transaction receipt is a contract creation event, processing the intelligent contract event, including saving a contract name, a contract version and a contract address to the off-link database.
In some embodiments, the smart contract event types described above include other events of the contract.
In some embodiments, when the smart contract event type included in the transaction receipt is a contract other event, a process for processing the smart contract event, as shown in fig. 3, includes:
s311: and obtaining a contract version and a contract name from the off-link database according to the contract address corresponding to the event in the transaction receipt.
S312: and obtaining abi files of the intelligent contracts from the off-link database according to the contract names and the contract versions.
S313: the event is parsed according to the abi file of the smart contract.
Specifically, a typical abi, application binary interface, is an interface between two program modules, typically between an operating system and a user program. Taking the ethernet virtual machine as an example, the abi file is a core component of the workshop network, and the intelligent contract is a code segment stored in the workshop blockchain and executed on the EVM. Intelligent contracts written in high-level languages such as Solidity or Vyper need to be compiled into EVM executable bytecodes, which exist on blockchains and are associated with addresses when the intelligent contracts are deployed, and for ethernet virtual machines, the intelligent contracts are the series of bytecodes. To access a function defined in a high-level language, a user needs to convert names and parameters into byte representations for the bytecode to use. To interpret the bytes sent in the response, the user needs to convert back the return value tuples defined in the high-level language. abi defines a method and structure for interfacing with binary contracts that can instruct a caller of a function to encode required information, such as function signatures and variable declarations, in a format that can be understood by the ethernet virtual machine, to call the function in bytecode. In blockchain applications, the smart contract abi file is represented in JSON format.
In some embodiments, when the smart contract event type included in the transaction receipt is a contract other event, a process for processing the smart contract event, as shown in fig. 4, further includes:
s314: and processing the analyzed event according to the business processing logic of the intelligent contract, and updating the off-chain database.
In some embodiments, the events in the transaction return of the block to be processed are processed according to the transaction hash order in the block to be processed.
The application firstly obtains a block to be processed with a designated block height in an out-of-chain database and a transaction receipt of the block to be processed in a blockchain, and processes the intelligent contract event according to the intelligent contract event type contained in the transaction receipt. The application can effectively expand the application scene outside the chain and improve the capability of the application outside the chain for processing the data of the block chain for analyzing and processing the events generated by the block to be processed and the transaction receipt thereof in an intelligent contract mode.
Example two
Fig. 5 is a schematic structural diagram of a blockchain event processing device 500 according to an embodiment of the present disclosure. Referring to fig. 5, a blockchain event processing device 500 in one embodiment includes:
a first module 501 capable of obtaining a block to be processed of a specified block height in an out-of-chain database and a transaction receipt of the block to be processed;
the second module 502 is capable of processing the smart contract event according to the smart contract event type included in the transaction receipt.
It should be understood that, in the embodiment of the present disclosure, the blockchain event processing device 500 may also perform the methods performed by the blockchain event processing device (or apparatus) in fig. 1 to 4, and implement the functions of the blockchain event processing device (or apparatus) in the examples shown in fig. 1 to 4, which are not described herein.
Example III
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present specification. Referring to fig. 6, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified into address buses, data buses, control buses, and the like. For ease of illustration, only one bi-directional arrow is shown in FIG. 6, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs, and forms a shared resource access control device on a logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
obtaining a block to be processed with a specified block height in an out-of-chain database and a transaction receipt of the block to be processed;
and processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
The blockchain event processing method disclosed in the embodiments shown in fig. 1 to 4 of the present specification may be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic blocks disclosed in the embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present specification may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
Of course, in addition to the software implementation, the electronic device of the embodiments of the present disclosure does not exclude other implementations, such as a logic device or a combination of software and hardware, that is, the execution subject of the following processing flow is not limited to each logic unit, but may also be hardware or a logic device.
Example IV
The present description also proposes a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the blockchain event processing method of the embodiments shown in fig. 1-4, and in particular to perform the method of:
obtaining a block to be processed with a specified block height in an out-of-chain database and a transaction receipt of the block to be processed;
and processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
In summary, the foregoing description is only a preferred embodiment of the present application and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the protection scope of the present specification.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.

Claims (10)

1. A method of blockchain event processing, comprising:
obtaining a block to be processed with a specified block height in an out-of-chain database and a transaction receipt of the block to be processed;
and processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
2. The method of claim 1, wherein abi files of the smart contract are saved to the out-of-chain database prior to creating and deploying the smart contract to the blockchain.
3. The method of claim 2, wherein obtaining the blocks to be processed and transaction receipt of the blocks to be processed for a specified block height in the out-of-chain database comprises:
obtaining the processed block height recorded in the out-of-chain data;
obtaining a block to be processed with the specified block height according to the processed block height;
and when all the transaction receipts of the blocks to be processed are stored in the out-of-chain database, obtaining the transaction receipts of the blocks to be processed.
4. The method of claim 3, wherein the smart contract event type includes a contract creation event; and/or, when the intelligent contract event type included in the transaction receipt is a contract creation event, processing the intelligent contract event, including saving a contract name, a contract version, and a contract address to the off-chain database.
5. The method of claim 3, wherein the smart contract event type includes contract other events; and/or, when the smart contract event type included in the transaction receipt is a contract other event, a process for processing the smart contract event includes:
obtaining a contract version and a contract name from the off-link database according to the contract address corresponding to the event in the transaction return license;
obtaining abi files of the intelligent contracts from the off-link database according to the contract names and the contract versions;
and analyzing the event according to the abi file of the intelligent contract.
6. The method of claim 5, wherein when the transaction receipt contains a smart contract event type that is a contract other event, the process of processing the smart contract event further comprises: and processing the parsed event according to the business processing logic of the intelligent contract, and updating the out-of-chain database.
7. The method of claim 1, wherein the events in the transaction return for the block to be processed are processed in a transaction hash order in the block to be processed; and/or the off-chain database includes a contract table, a abi file table, and a business table.
8. A blockchain event processing device, comprising:
the first module can obtain a block to be processed with a specified block height in the out-of-chain database and a transaction receipt of the block to be processed;
and the second module is capable of processing the intelligent contract event according to the intelligent contract event type contained in the transaction receipt.
9. An electronic device, comprising:
a processor; and
a memory arranged to store computer executable instructions which, when executed, cause the processor to perform the method of any of claims 1 to 7.
10. A computer readable storage medium storing one or more programs, which when executed by an electronic device comprising a plurality of application programs, cause the electronic device to perform the method of any of claims 1-7.
CN202310903818.3A 2023-07-20 2023-07-20 Block chain event processing method and device Pending CN116975151A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310903818.3A CN116975151A (en) 2023-07-20 2023-07-20 Block chain event processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310903818.3A CN116975151A (en) 2023-07-20 2023-07-20 Block chain event processing method and device

Publications (1)

Publication Number Publication Date
CN116975151A true CN116975151A (en) 2023-10-31

Family

ID=88474402

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310903818.3A Pending CN116975151A (en) 2023-07-20 2023-07-20 Block chain event processing method and device

Country Status (1)

Country Link
CN (1) CN116975151A (en)

Similar Documents

Publication Publication Date Title
CN107609437B (en) Target graphic code identification method and device
CN110704037B (en) Rule engine implementation method and device
CN108599973B (en) Log association method, device and equipment
CN107479868B (en) Interface loading method, device and equipment
CN107578338B (en) Service publishing method, device and equipment
CN111651467B (en) Block chain node interface issuing and calling method and device
CN111639278A (en) Webpage loading method and device
CN110851207B (en) State transition management method and device, electronic equipment and storage medium
CN107678741B (en) List view implementation method and device, readable storage medium and equipment
CN108647102B (en) Service request processing method and device of heterogeneous system and electronic equipment
CN112181378B (en) Method and device for realizing business process
CN111949297B (en) Block chain intelligent contract upgrading method and device and electronic equipment
CN110941443B (en) Method and device for modifying file name in SDK (software development kit) and electronic equipment
CN111523887A (en) Authority control method and device of intelligent contract read-only method and electronic equipment
CN111078435A (en) Service processing method and device and electronic equipment
CN116975151A (en) Block chain event processing method and device
CN110750271B (en) Service aggregation, method and device for executing aggregated service and electronic equipment
CN113254163B (en) Processing method and device of block chain data
CN110688430B (en) Method and device for obtaining data bypass and electronic equipment
CN109656805B (en) Method and device for generating code link for business analysis and business server
CN112306710A (en) Service processing system, interface calling method and device
CN110704134A (en) Method and device for performing function expansion on block chain
CN111506577B (en) Data operation method and device based on multiple state organization modes on block chain
CN116700841B (en) Method and device for calling native API (application program interface)
CN108829732B (en) Data processing method and device

Legal Events

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