You have 3 free guides left 😟
Unlock your guides
You have 3 free guides left 😟
Unlock your guides

Hyperledger Fabric's architecture is built on a network of peers, orderers, and clients. These components work together to maintain the , process transactions, and ensure network consistency. The system's unique approach to consensus and smart contracts sets it apart from other blockchain platforms.

Chaincode, Fabric's version of smart contracts, is central to the platform's functionality. Written in languages like Go or Java, chaincode encapsulates business logic and data, allowing for deterministic execution across the network. Developers can create, deploy, and interact with chaincode using Fabric's SDK and tools.

Hyperledger Fabric Architecture

Components of Hyperledger Fabric architecture

Top images from around the web for Components of Hyperledger Fabric architecture
Top images from around the web for Components of Hyperledger Fabric architecture
  • Peers maintain the state and a copy of the , endorse transactions and participate in the consensus process
    • Endorsing peers simulate and endorse transactions (validate, sign, and return to client)
    • Committing peers validate endorsement signatures, update state and ledger (apply transactions to the local ledger)
  • Orderers establish the total order of transactions, create blocks of transactions and distribute them to peers maintaining consistency across the network
    • Ordering service (, ) collects endorsed transactions, orders them, and creates blocks
    • Deliver blocks to committing peers for validation and commitment
  • Clients are applications that interact with the Fabric network by submitting transaction proposals to peers for endorsement and sending endorsed transactions to the for inclusion in a block
    • SDK (Node.js, Java, Go) provides APIs to connect, chaincode, and ledger
    • CLI tools (, fabric-ca-client) to manage and interact with the network

Transaction flow and consensus mechanism

  • Transaction flow involves client submitting a proposal to endorsing peers, collecting endorsements, and sending to the orderer for inclusion in a block, which is then distributed to all peers for validation and state/ledger update
    1. sends a signed transaction proposal to endorsing peers
    2. Endorsing peers simulate the transaction, sign the result (endorsement), and return to the client
    3. Client collects endorsements and sends the transaction to the ordering service
    4. Ordering service orders transactions, creates blocks, and delivers to all peers
    5. Peers validate transactions, update state and ledger, and notify the client
  • Consensus mechanism in Fabric is permissioned and pluggable, with Raft as the default crash fault-tolerant (CFT) algorithm, while other Byzantine fault-tolerant (BFT) algorithms can be used
    • specifies the set of peers required to endorse a transaction
    • Ordering service establishes consensus on the order of transactions
    • Validation and commitment of transactions happen independently at each peer

Chaincode (Smart Contracts)

Role of smart contracts in Fabric

  • Chaincode are self-executing contracts with the terms of the agreement directly written into code, encapsulating the business logic and data of a blockchain application
    • Defined in programming languages (Go, Java, Node.js)
    • Invoked by transactions to read and modify the state of the ledger
    • Deterministic execution ensures consistent results across peers
  • Chaincode execution involves installation on peers, instantiation on a , and invocation through transactions
    1. Chaincode installed on endorsing peers and instantiated on a channel
    2. Client application sends a transaction proposal invoking chaincode functions
    3. Endorsing peers simulate the transaction, sign the result, and return to the client
    4. Client sends endorsed transaction to the ordering service for inclusion in a block
    5. Committing peers validate endorsement signatures and update state and ledger

Development of chaincode applications

  • provides APIs for interacting with a Fabric network, supporting multiple programming languages (Node.js, Java, Go, Python) to create, deploy, and invoke chaincode
    • Gateway abstracts the network topology and provides a simple API for client applications
    • Wallet stores and manages user identities and credentials for authentication
    • Contract class provides methods to invoke and query chaincode functions
  • Developing chaincode involves defining the data model and business logic, implementing the required chaincode interface (Init and Invoke functions), and using the Fabric SDK to package and install the chaincode on peers
    • Define assets, participants, and transactions in the chaincode (Car, Owner, TransferOwnership)
    • Implement Init function to initialize the chaincode state and Invoke function to process transactions
    • Use Fabric SDK to package the chaincode into a deployable artifact (.tar.gz)
    • Install the chaincode package on the required endorsing peers
  • Deploying chaincode involves instantiating it on a channel using the Fabric SDK, specifying the endorsement policy and other configuration options, and invoking chaincode functions to interact with the deployed chaincode
    • Instantiate the chaincode on a channel, specifying the endorsement policy (majority of org1 and org2)
    • Invoke chaincode functions (createCar, transferOwnership) using the Fabric SDK
    • Query the chaincode state (queryCar, queryAllCars) using the Fabric SDK
© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.

© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.
Glossary
Glossary