github.com/tenywen/fabric@v1.0.0-beta.0.20170620030522-a5b1ed380643/docs/source/blockchain.rst (about) 1 Introduction 2 ============ 3 Hyperledger Fabric is a platform for distributed ledger solutions underpinned 4 by a modular architecture delivering high degrees of confidentiality, 5 resiliency, flexibility and scalability. It is designed to support pluggable 6 implementations of different components and accommodate the complexity and 7 intricacies that exist across the economic ecosystem. 8 9 Fabric delivers a uniquely elastic and extensible architecture, distinguishing 10 it from alternative blockchain solutions. Planning for the future of enterprise 11 blockchain requires building on top of a fully vetted, open-source architecture; 12 Hyperledger Fabric is your starting point. 13 14 We recommended first-time users begin by going through the rest of the 15 introduction below in order to gain familiarity with how blockchains work 16 and with the specific features and components of Fabric. 17 18 Once comfortable -- or if you're already familiar with blockchain and 19 Hyperledger Fabric -- go to :doc:`getting_started` and from there explore the 20 demos, technical specifications, APIs, etc. 21 22 What is a Blockchain? 23 --------------------- 24 **A Distributed Ledger** 25 26 At the heart of a blockchain network is a distributed ledger that records all 27 the transactions that take place on the network. 28 29 A blockchain ledger is often described as **decentralized** because it is replicated 30 across many network participants, each of whom **collaborate** in its maintenance. 31 We’ll see that decentralization and collaboration are powerful attributes that 32 mirror the way businesses exchange goods and services in the real world. 33 34 .. image:: images/basic_network.png 35 36 In addition to being decentralized and collaborative, the information recorded 37 to a blockchain is append-only, using cryptographic techniques that guarantee 38 that once a transaction has been added 39 to the ledger it cannot be modified. This property of immutability makes it 40 simple to determine the provenance of information because participants can be 41 sure information has not been changed after the fact. It’s why blockchains 42 are sometimes described as **systems of proof**. 43 44 45 **Smart Contracts** 46 47 To support the consistent update of information – and to enable a whole host of 48 ledger functions (transacting, querying, etc) – a blockchain network uses **smart 49 contracts** to provide controlled access to the ledger. 50 51 .. image:: images/Smart_Contract.png 52 53 Smart contracts are not only a key mechanism for encapsulating information 54 and keeping it simple across the network, they can also be written to allow 55 participants to execute certain aspects of transactions automatically. 56 57 A smart contract can, for example, be written to stipulate the cost of shipping 58 an item that changes depending on when it arrives. With the terms agreed to 59 by both parties and written to the ledger, the appropriate funds change hands 60 automatically when the item is received. 61 62 **Consensus** 63 64 The process of keeping the ledger transactions synchronized across the network – 65 to ensure that ledgers only update when transactions are approved by the appropriate 66 participants, and that when ledgers do update, they update with the 67 same transactions in the same order – is called **consensus**. 68 69 .. image:: images/consensus.png 70 71 We’ll learn a lot more about ledgers, smart contracts and consensus later. For 72 now, it’s enough to think of a blockchain as a shared, replicated transaction 73 system which is updated via smart contracts and kept consistently 74 synchronized through a collaborative process called consensus. 75 76 Why is a Blockchain useful? 77 --------------------------- 78 79 **Today’s Systems of Record** 80 81 The transactional networks of today are little more than slightly updated 82 versions of networks that have existed since business records have been kept. 83 The members of a **Business Network** transact with each other, but they maintain 84 separate records of their transactions. And the things they’re transacting – 85 whether it’s Flemish tapestries in the 16th century or the securities of today 86 – must have their provenance established each time they’re sold to ensure that 87 the business selling an item possesses a chain of title verifying their 88 ownership of it. 89 90 What you’re left with is a business network that looks like this: 91 92 93 .. image:: images/current_network.png 94 95 Modern technology has taken this process from stone tablets and paper folders 96 to hard drives and cloud platforms, but the underlying structure is the same. 97 Unified systems for managing the identity of network participants do not exist, 98 establishing provenance is so laborious it takes days to clear securities 99 transactions (the world volume of which is numbered in the many trillions of 100 dollars), contracts must be signed and executed manually, and every database in 101 the system contains unique information and therefore represents a single point 102 of failure. 103 104 It’s impossible with today’s fractured approach to information and 105 process sharing to build a system of record that spans a business network, even 106 though the needs of visibility and trust are clear. 107 108 109 **The Blockchain Difference** 110 111 What if instead of the rat’s nest of inefficiencies represented by the “modern” 112 system of transactions, business networks had standard methods for establishing 113 identity on the network, executing transactions, and storing data? What 114 if establishing the provenance of an asset could be determined by looking 115 through a list of transactions that, once written, cannot be changed, and can 116 therefore be trusted? 117 118 That business network would look more like this: 119 120 .. image:: images/future_net.png 121 122 This is a blockchain network. Every participant in it has their own replicated 123 copy of the ledger. In addition to ledger information being shared, the processes 124 which update the ledger are also shared. Unlike today’s systems, where a 125 participant’s **private** programs are used to update their **private** ledgers, 126 a blockchain system has **shared** programs to update **shared** ledgers. 127 128 With the ability to coordinate their business network through a shared ledger, 129 blockchain networks can reduce the time, cost, and risk associated with private information and 130 processing while improving trust and visibility. 131 132 You now know what blockchain is and why it’s useful. There are a lot of other 133 details that are important, but they all relate to these fundamental ideas of 134 the sharing of information and processes. 135 136 137 What is Hyperledger Fabric? 138 --------------------------- 139 140 The Linux Foundation founded Hyperledger in 2015 to advance 141 cross-industry blockchain technologies. Rather than declaring a single 142 blockchain standard, it encourages a collaborative approach to developing 143 blockchain technologies via a community process, with intellectual property 144 rights that encourage open development and the adoption of key standards over 145 time. 146 147 Hyperledger Fabric is a one of the blockchain projects within Hyperledger. 148 Like other blockchain technologies, it has a ledger, uses smart contracts, 149 and is a system by which participants manage their transactions. 150 151 Where Hyperledger Fabric breaks from some other blockchain systems is that 152 it is **private** and **permissioned**. Rather than the “proof of work” some 153 blockchain networks use to verify identity (allowing anyone who meets those 154 criteria to join the network), the members of a Fabric network enroll through 155 a **membership services provider**. 156 157 Fabric also offers several pluggable options. Ledger data can be stored in 158 multiple formats, consensus mechanisms can be switched in and out, 159 and different membership service providers are supported. 160 161 Fabric also offers the ability to create **channels**, allowing a group of 162 participants to create a separate ledger of transactions. This is an especially 163 important option for networks where some participants might be competitors and not 164 want every transaction they make - a special price they're offering to some participants 165 and not others, for example - known to every participant. If two 166 participants form a channel, then those participants – and no others – have copies 167 of the ledger for that channel. 168 169 The following diagram outlines the four building blocks of Hyperledger Fabric: 170 171 .. image:: images/Requirements.png 172 173 **Shared Ledger** 174 175 Hyperledger Fabric has a ledger subsystem comprising two components: the **world 176 state** and the **transaction log**. Each participant has a copy of the ledger to 177 every Fabric network they belong to. 178 179 .. image:: images/what.png 180 181 The world state component describes the state of the ledger at a given point 182 in time. It’s the database of the ledger. The transaction log component records 183 all transactions which have resulted in the current value of the world state. 184 It’s the update history for the world state. The ledger, then, is a combination 185 of the world state database and the transaction log history. 186 187 The ledger has a replaceable data store for the world state. By default, this 188 is a LevelDB key-value store database. The transaction log does not need to be 189 pluggable. It simply records the before and after values of the ledger database 190 being used by the blockchain network. 191 192 **Smart Contracts** 193 194 Hyperledger Fabric smart contracts are written in **chaincode** and are invoked 195 by an application external to the blockchain when that 196 application needs to interact with the ledger. In most cases chaincode only 197 interacts with the database component of the ledger, the world state (querying 198 it, for example), and not the transaction log. 199 200 .. image:: images/sContracts.png 201 202 You can write chaincode in several programming languages. Currently supported 203 languages include GOLANG and Java with others coming soon. 204 205 **Privacy** 206 207 Depending on the needs of a network, participants in a Business-to-Business 208 (B2B) network might be extremely sensitive about how much information they share. 209 For other networks, privacy will not be a top concern. 210 211 .. image:: images/Lock.png 212 213 Hyperledger Fabric supports networks where privacy (using channels) is a key 214 operational requirement as well as networks that are comparatively open. 215 216 **Consensus** 217 218 Transactions must be written to the ledger in the order in which they occur, 219 even though they might be between different sets of participants within the 220 network. For this to happen, the order of transactions must be established 221 and a method for rejecting bad transactions that have been inserted into the 222 ledger in error (or maliciously) must be put into place. 223 224 .. image:: images/handshake.png 225 226 227 This is a thoroughly researched area of computer science, and there are many 228 ways to achieve it, each with different trade-offs. For example, PBFT (Practical 229 Byzantine Fault Tolerance) can provide a mechanism for file replicas to 230 communicate with each other to keep each copy consistent, even in the event 231 of corruption. Alternatively, in Bitcoin, ordering happens through a process 232 called mining where competing computers race to solve a cryptographic puzzle 233 which defines the order that all processes subsequently build upon. 234 235 Hyperledger Fabric has been designed to allow network starters to choose a 236 consensus mechanism that best represents the relationships that exist between 237 participants. As with privacy, there is a spectrum of needs; from networks 238 that are highly structured in their relationships to those that are more 239 peer-to-peer. 240 241 We’ll learn more about the Hyperledger Fabric consensus mechanisms, which 242 currently include SOLO, Kafka, and will soon extend to SBFT (Simplified 243 Byzantine Fault Tolerance), in another document. 244 245 246 Where can I learn more? 247 ----------------------- 248 249 :doc:`getting_started` 250 251 Where you learn how to set up a sample network on your local machine. You’ll be 252 introduced to most of the key components within a blockchain network, learn 253 more about how they interact with each other, and then you’ll actually get the 254 code and run some simple query and update transactions. 255 256 :doc:`fabric_model` 257 258 A deeper look at the components and concepts brought up in this introduction as 259 well as a few others and describes how they work together in a sample 260 transaction flow. 261 262 :doc:`marbles` 263 264 Where you can learn how to write a sample smart contract in GOLANG and invoke 265 it from an application written in JavaScript. You’ll become comfortable with 266 the key APIs used by both smart contract developers and application developers 267 and ready to write your own application using the Hyperledger Fabric API 268 reference information. 269 270 Designing a Business Network (coming soon) 271 272 Takes you through how to design a business network using a standard process. 273 You’ll start by defining the business network and identify the participants 274 and the goods and services that move between them. You’ll think about the key 275 lifecycles and how they are impacted by the activities of the key participants. 276 By the time you’re through, you’ll be ready to start working with key 277 stakeholders in your company to design a business network that uses Hyperledger 278 Fabric. 279 280 :doc:`planning_guide` 281 282 Deals with the practical concerns of setting up and managing a production 283 Hyperledger Fabric blockchain. You’ll understand the key factors to consider 284 when planning a blockchain solution, such as compute, storage and network 285 requirements. You’ll also understand the key non-functional requirements, 286 including maintainability, performance, availability and disaster recovery. 287 288 .. Licensed under Creative Commons Attribution 4.0 International License 289 https://creativecommons.org/licenses/by/4.0/