Fabric development (1) first meet Fabric

Fabric introduction

Hyperledger Fabric is a modular architecture distributed ledger platform that provides high confidentiality, flexibility, flexibility and scalability. It is designed to support the pluggable implementation of different components and can accommodate highly complex applications that exist in the ecosystem.

Unlike other blockchain solutions, Hyperledger Fabric provides a unique scalable architecture. It is also an open source architecture established on this basis to meet the needs of enterprise-level blockchains that need to be audited in the future. Hyperledger Fabric will be your starting point.

We recommend first-time users to read the following introduction to familiarize themselves with the working method of the blockchain and the specific functions and components of Hyperledger Fabric.

Once you feel good — or you are already familiar with blockchain and Hyperledger Fabric, then skip to the Getting Started chapter, where you will explore more examples, technical specifications, APIs, etc.

What is blockchain?

A Distributed Ledger

The core of the blockchain network is a distributed ledger that is used to record all transactions that occur on the network. The blockchain ledger is usually described as decentralized because it is replicated among many network participants, and each participant is cooperating to maintain it. We will see that decentralization and collaboration are powerful attributes that reflect the way companies exchange products and services in the real world.
Insert picture description here
In addition to decentralization and collaboration, the information recorded in the blockchain can only be added, and the use of encryption technology can ensure that once a transaction is added to the ledger, it cannot be modified. This inability to tamper with makes it easy to determine the source of the information, because participants can be sure that the information has not been changed afterwards. This is why blockchain is sometimes described as a proof system.

Smart Contracts

In order to support the consistent update of information-enabling a whole set of functions (transactions, queries, etc.) that act on the ledger-the blockchain network uses smart contracts to provide access control to the ledger.

Insert picture description here

Smart contracts are not only simply encapsulated information that is synchronized across the entire network, they can also be written to allow participants to perform some transactions automatically. For example, you can write a smart contract that determines the transmission cost based on when the item arrives. Once the two parties agree to the terms and write them in the ledger, when the goods arrive, the corresponding funds will be automatically transferred.

Consensus

The process of keeping the ledger transactions synchronized through the network — ensuring that the ledger is updated only when the transaction is approved by the corresponding participant, and when the ledger is updated, they update the ledger with the same sequential blocks — this process is called consensus.
Insert picture description here

We will learn more about ledgers, smart contracts and consensus later. For the time being, it is sufficient to treat the blockchain as a shared, replicated trading system that is updated through smart contracts and kept in sync through a collaborative process called consensus.

Why is blockchain useful?

Existing record system

Today's trading network is simply a simple update of old business record keeping. Members of a business network trade with each other, but they each maintain a set of transaction records—whether it is a Flemish tapestry in the 16th century or securities today—and each time it is sold, its provenance must be established to ensure that the seller sells the product. Have a series of property rights.

It looks like this business network:
Insert picture description here

Modern technology has transitioned from the era of slate and paper folders to hard disk drives and cloud platforms, but the underlying architecture is the same. A unified system for managing the identities of network participants does not exist. It is very laborious to establish the origin. It takes several days to clear securities transactions (the world's magnitude is trillions of dollars). Contracts must be manually signed and executed. Both databases contain unique information, which means that a single point of failure occurs.

The need for visibility and trust systems in transactions is clear, but today’s information and process sharing methods are still impossible to establish a system of record across business networks.

The difference of blockchain

What if, compared to the current low-efficiency transaction system, a standard system is provided to establish an identity network, automatic transaction execution, and data synchronization storage? What if the asset source mechanism is established by looking at the transaction list and not allowing changes once written? Is it true that a trust system can be formed?
Insert picture description here

The figure above depicts a blockchain network where each participant has his own copy of the ledger. In addition to sharing ledger information, the process of ledger update is also shared. Unlike today's system, today's system is a private program used to update private ledgers, while the blockchain system uses a shared program to update shared ledgers.

With the ability to coordinate business networks through shared ledgers, blockchain networks can reduce the time, cost and risk of processing private information, while increasing mutual trust and information transparency.

You now know what blockchain is and why it is useful. There are many other important details of the blockchain, but they are inseparable from the basic idea of ​​information and process sharing mentioned above.

What is Hyperledger Fabric?

The Linux Foundation founded Hyperledger in 2015 to advance cross-industry blockchain technology. Compared with declaring a blockchain standard, it encourages the development of blockchain technology through community collaboration processes, encourages open source to develop intellectual property rights and finally adopts a set of standards.

Hyperledger Fabric is one of the blockchain projects in Hyperledger. Like other blockchain technologies, it has a ledger, uses smart contracts, and the system is where participants manage their transactions.

Hyperledger Fabric stands out from some other blockchain systems in that it is private and permissioned. Compared with an open permission system that allows unknown identities to participate in the network (requires proof of work and other protocols to verify transactions and protect the network). The members of the Hyperledger Fabric network guarantee the privacy of the system by registering a trusted member service provider (Membership Service Provider, referred to as MSP).

Hyperledger Fabric also provides multiple hot-pluggable options. Ledger data can be stored in multiple formats, the consensus mechanism can switch on and off at any time, and supports multiple MSPs.

Hyperledger Fabric also provides the ability to create channels, allowing a group of participants to create a separate transaction ledger. This is a particularly important option for potential competitors among network participants—for example, the special prices they offer to certain participants—each participant knows. If two participants are on the same channel, then those participants (and no one else) have a copy of the ledger for that channel.

Shared Ledger

Hyperledger Fabric's ledger system has two components: world state and transaction log. Each participant assigns a copy of the ledger to each Hyperledger Fabric network to which it belongs. Each network participant in Hyperledger Fabric has a copy of the ledger.

The world state component describes the state of the ledger at a specific point in time. This is the database equivalent to the ledger. The transaction log component records all transactions that constitute the world state; from this, the ledger is a combination of the world state database and transaction log history.

The ledger has replaceable data storage for the state of the world. By default, this is a LevelDB key-value store database. The transaction log does not need to be pluggable. It only records the before and after values ​​of the ledger database used in the blockchain network.

Smart Contracts

Hyperledger Fabric's smart contracts are implemented using chaincode and are called by external applications on the blockchain to interact with the ledger. In most cases, the chaincode only interacts with the database components (world state) of the ledger (such as queries), not the transaction log.

Chaincode can be implemented in several programming languages. The currently supported chaincode language is Go, and Java and other languages ​​will be supported in the future.

Privacy (Privacy)

Depending on the needs of the network, business-to-business (B2B) network participants may be very sensitive to how much information they share. For other blockchain networks, privacy will not be the primary issue.

Encountering other blockchain networks, privacy (using the channel method) is a very critical requirement for Hyperledger Fabric.

Consensus

Transactions must be written in the ledger in the order in which they occur, and this is true for different participants in the network. To do this, a transaction sequence must be established, and a method must be implemented to reject bad transactions that are inserted into the ledger by mistake (or maliciously).

This is an old-fashioned field of computer science. There are many ways to implement consensus algorithms, and each method has different pros and cons. For example, PBFT (Practical Byzantine Fault Tolerance) can provide a mechanism for file copies to communicate with each other to maintain the consistency of each copy, even in the event of damage. Or, in Bitcoin, consensus is achieved by calculating the encryption problem (also known as mining), and whoever calculates the block first counts.

Hyperledger Fabric is designed to allow network initiators to choose the consensus mechanism that best represents the relationship between participants. As with privacy, there are a range of needs; from networks with highly structured relationships to more peer-to-peer networks.

We will learn more about Hyperledger Fabric consensus mechanisms, which currently include SOLO, Kafka, and in another document, we will soon learn about SBFT (Simplified Byzantine Fault Tolerance).

What exactly is Fabric (please describe it in human terms)?

Okay, if you talk about Fabric, you need to know the history of blockchain development. We should all have heard that Satoshi Nakamoto invented Bitcoin, which brought blockchain technology into the public eye. So far, just 12 years, but blockchain technology has experienced several important leap periods. The first time was the encrypted digital currency Bitcoin, the second time was the Turing complete language smart contract Ethereum, and the third time was the consortium chain Fabric implemented based on a truly universal language for access. In short, it is becoming more and more advanced, more powerful, and more universal. Knowing this is enough, and we will start slowly after the details.

Guess you like

Origin blog.csdn.net/aiwaston/article/details/108775516