Introducing Hyperledger Besu: The youngest member of the Hyperledger family

Tram Ho

1. Introduction

Hyperledger Besu is an Ethereum client (open source) written in Java. It can run well on the Ethereum MainNet and test networks like Rinkeby, Rospten and Görli.

So what is the specific Ethereum Client?

The Ethereum Client is the software that implements the protocols of the Ethereum network or the software that runs the EVM virtual machine. If you want to participate directly in the Ethereum network without using a third party such as Infura, or use Metamask … then you must download the Ethereum Client to install on your computer.

Currently, there are many versions of Ethereum Client written in many different languages.

  1. Main release by Ethereum
  2. Published by 3rd party

A basic Ethereum Client has the following features:

  • Transaction processing, smart contract with EVM environment
  • Data storage of networks (blocks)
  • Connect P2P to other nodes in the network to synchronize data or broadcast events to the network.
  • Provide APIs for developers to interact with the blockchain network

2. Architecture

Besu’s architecture is divided into 4 main parts: Storage , Ethereum Core , Networking and User-facing APIs

  1. Storage : Besu uses RocksDB to store key-value data. Data stored in storage divided into 2 parts.
    • Blockchain : Save a sequence of blocks (including header and body block).
    • World State : Save StateTree (mapping address account with state of account (eg balance)).
  2. Ethereum Core :
    • EVM: Compile and process smart contracts as well as transactions.
    • Consensus Algorithms: Support 3 algorithms: Proof of Work (Ethash) , Clique and IBFT 2.0 .
  3. Networking
  • Discovery: Protocol based on UDP to find peers on the network
  • RLPx: TCP-based protocol that interacts with other peers. Depending on the consensus algorithm, the node will use ETH Sub-protocol or IBF Sub-protocol .
  1. User-facing APIs
  • The application side can use HTTP JSON-RPC , WebSocket JSON-RPC or GrapgQL to interact with the blockchain network. When developing dapp with Besu we can use familiar tools like Truffle , Remix or web3 .

3. Privacy

In addition to being able to work normally on the Ethereum mainet and testnet like other versions of Ethereum Client. Hyperledger Besu also allows users to create a private network (private network) and conduct private transactions on that network.

Orion

We will first explore Orion, an important concept for handling private transactions in Besu.

Orion is an open source software for managing private transactions (private transaction managers) written in Java.

Orion ‘s function:

  • Create and maintain public key pairs (private / public keypairs)
  • Storing details about privacy group (we will learn what is privacy group later)
  • Connect to other Orio nodes in the network
  • Provide API to connect with the Ethereum Client as well as Orion nodes.

Privacy Group

The Privacy Group is a collection of nodes identified by a unique id.

The besu node in this case stores the public world state of the publics network and the private state for each privacy group. Data in private state will be accessed from external components.

Private Transactions

Private transactions are transactions that take place in Privacy Groups , the data and status of private transactions will be stored in some private state of Besu node as described above.

Features of private transactions

  • Private transactions are only successful when the nodes participating in the transactions are online (verbatim: All private transaction participants must be online for a private transaction to be successfully distributed )
  • Private transactions can only be deploy contracts or call functions in contracts. ETH transfers cannot be private transactions.
  • To make private transactions, each Besu node needs a corresponding Orion node.

In addition to some schools similar to public transactions, private transactions have the following additional schools:

  • privateFrom : The Orion public key of the sender
  • privateFor : – The Orion public keys of the recipient
  • privacyGroupId
  • restriction : One of 2 restricted or unrestricted values
    • restricted : Only nodes participating in the transaction receive a payload
    • unrestricted : All nodes in the network receive a payload of private transactions, but only nodes that are part of the transaction can read it.

The process of handling a private transaction

The process of handling a private transaction includes:

  • Precompiled Contract : Smart contract is compiled into EVM bytecode and stored at the Ethereum node for further processing.
  • Privacy Marker Transaction : A public Ethereum transaction with payload accompanied by a enclave key. The Enclave key is a pointer, it points to the private transaction at the Orion node. The to field in the Privacy Marker Transaction is the address of the contract compiled above.

The Privacy Marker Transaction is signed with a random key or a key specified via the command-line

Note : Private transactions are still public on the Ethereum network and close into normal blocks like other public transactions. The only difference is that when in the Privacy group , the nodes will use the private state instead of the public state of the Ethereum network.

  1. Private transactions are submitted using eea_sendRawTransaction
  2. Private transactions are forwarded to the Private Transaction Handler in the Besu node via JSON-RPC.
  3. Private Transaction Handler sends private transactions to the Orion node corresponding to the current Besu node.
  4. The Orion node sends private transactions directly to the recipient’s Orion node (point-to-point) or the Orion nodes in the privacy group (subject to the restriction field in private transactions). Orion nodes receive and store private transactions in key-value form.
  5. The Orion node returns transactions hash to the Private Transaction Handler .
  6. Private Transaction Handler creates a Privacy Marker Transaction . The Private Transaction Handler will broadcast the Privacy Marker Transaction throughout the public network via P2P protocol.
  7. Miner will close the Privacy Marker Transaction to the block and broadcast it over the network
  8. With the storage nodes contract with the same address with the address in the contract Privacy Privacy Marker Marker Transaction Transaction will retain and further processing. The remaining nodes will ignore the Privacy Marker Transaction .
  9. Contract queries the Orion node for information and private transaction and privacy group ID using transaction hashes.
  10. Contract converts the private transaction into Private Transaction Processor
  11. Private Transaction Processor executes transactions. The Private Transaction Processor can read and write to the private world state and can only be read from the public world state .

References

https://www.hyperledger.org/blog/2019/08/29/announcing-hyperledger-besu https://besu.hyperledger.org/en/stable/

Share the news now

Source : Viblo