HPB’s optimization of the on-chain transaction process
Summary
There are various blockchain systems on the market, such as the public blockchains Ethereum and Bitcoin,or alliance blockchains like IBM’s Hyperledger. Their transaction structure is different, and they use different Curve signature algorithms. There are also various kinds of consensus: Proof of Work (PoW), Proof of Stake (PoS), and the RAFT Consensus Algorithm.
There are big differences between these blockchain systems, but they are similar in terms of transaction processing procedures. Therefore, this article will introduce in detail the various steps of a transaction from construction to packaging, the entire life cycle of the transaction, including the aspects optimized by HPB.
The Blockchain Transaction Process
We can refer to the following flow chart to explain the transaction process. First, transaction construction and signature require the client to construct a transaction based on the transaction function, such as ‘transfer’ or calling the contract, including basic information such as the sender and receiver’s transfer amount. Because the transaction involves the security of personal assets, in order to prevent the transaction from being tampered with and forged by malicious attackers, the wallet uses the private key to sign the transaction. Then the client sends the transaction to the node’s transaction pool through the network protocol. The transaction pool will first verify its correctness and legitimacy. Wrong transactions will be kicked out by the node, and normal transactions will remain in the pool, waiting for the consensus module to reach a new round of consensus. When the consensus module reaches an agreement, it will get these pending transactions from the transaction pool, package them into a block, and hand it over to the processing execution module. The processing execution module executes the logic that the user wants according to the content of the transaction. After the execution is completed, the results, transactions, and blocks are written to the storage module for subsequent transaction execution and query. When the process ends, the transaction completes its mission and is permanently stored on-chain.
1.1 Transaction construction and signing
The content of the transaction may be different due to the blockchain system, but the main components of the transaction include the sender, receiver, transfer amount, contract script, and signature.
When the client constructs the transaction according to the requirements, it uses the wallet to find the private key of the sender of the transaction to sign the transaction ‘Hash’, and put signature in the transaction, so that the node transaction pool can verify and check after receiving it, that the content of the transaction has not been tampered with during the transaction.
1.2 Broadcasting the Transaction
The client sends the constructed and signed transaction to a certain blockchain network node through a network protocol (RPC or HTTPS). This node will broadcast the transaction to the entire network through the P2P protocol, which also includes the block producer. The block producer packs this transaction.
1.3 Transaction Pool Processing
When the node’s transaction pool receives the transaction broadcasted by the client or P2P, it will first verify the correctness and legitimacy of the transaction. After the basic verification is passed, the transaction enters the cache of the transaction pool, and the consensus will package the block and get the correct transaction from the transaction pool.
1.4 Consensus packaging block
Take PoW consensus as an example. The consensus module will first assemble the block header. This block header contains the hash value of the previous block, timestamp, Hash of Merkel tree, proof of work (PoW difficulty value), and miner user address and other information. The body of the block is the correct transaction obtained from the transaction pool to form a complete block, which is handed over to the execution module to execute the transaction.
1.5 Executing the Transaction
The execution module of the blockchain system will modify the account status according to the type and content of the transaction. For blockchain systems that support smart contracts, the execution module will have a virtual machine. For example, Ethereum uses Turing’s complete virtual machine EVM. Bitcoin has only a stack-based scripting system, so it smart contract function has more limitations than Ethereum’s.
Because the blockchain system has many nodes distributed to execute transactions, when the execution module gets all the transactions in a block, they are executed in the sort order, and the results of each node’s execution are the same, and everyone has the same ledger.
1.6 Data on-chain
When the block is executed, the execution result, transaction and block will be written to the database. When the next block is generated, it will contain the Hash value of the previous block, thus forming a chain. The longer the chain, the lower the possibility of the transaction being overturned, and it will be permanently stored on chain.
Innovation and Optimization by HPB
Transaction verification takes up most of the time in block packaging and block verification. According to tests, the speed of Ethereum’s software verification algorithm is about 4000 times per second, plus the repetitive work of front-end transaction pool and block synchronization. The effective verification transaction speed is only 2000 times per second, which would be completely unsatisfactory for blockchain projects not using a PoW consensus algorithm.
In this regard, HPB first proposed the use of FPGA hardware to implement transaction verification algorithms. Relying on FPGA’s large number operations and concurrency advantages, as well as matching drivers, the verification speed was increased to 20,000 times per second.
2.1 Hardware Signature
In traditional blockchain projects, the processing of transaction and block signatures and verification are all based on the software level, which has disadvantages such as low processing performance and long delay time.
In response to the above problems, HPB innovatively designed the BOE (Blockchain Offload Engine) technology. It is a heterogeneous processing system, including BOE hardware, BOE firmware, and matching system software. It achieves high performance and high concurrent computing by combining the CPU’s serial capability and the parallel processing capability of the FPGA/ASIC chip.
About HPB
High Performance Blockchain (HPB) is a revolutionary permissionless blockchain architecture that combines HPB’s customized hardware Blockchain Offload Engine (BOE), with high-performance blockchain software, enabling unrivaled scalability.
| Website | Twitter | Telegram | Reddit | Youtube | Github |