How hyperledger/fabric works
Core Components
• Orderer Service: Represented by the “orderer” directory and its subdirectories (including consensus mechanisms like Raft, SmartBFT, etc.). The orderer provides the ordering service which collects endorsed transactions and forms blocks.
• Peer Nodes: Found in directories such as “peer”, “core/peer” and “gossip”. Peers are responsible for executing chaincode (smart contracts), endorsing transactions, maintaining the ledger, and committing blocks.
• Chaincode (Smart Contracts): The lifecycle, build, and deployment logic are contained in the “core/chaincode”, “ccaas_builder” and “integration/chaincode” directories. These components handle the packaging, endorsement, and runtime container management of chaincode.
• Membership Service Provider (MSP): The “msp” directory and related files deal with identity management, certificate validation, and revocation that secure communication between entities.
• Gossip and Communication: The “gossip” directories (and related submodules under “gossip/comm”, “gossip/gossip”, etc.) implement peer-to-peer message dissemination, including block and state sharing.
• Configuration & Channel Management: Components in “common/channelconfig”, “core/config” and parts of “common/configtx” support channel creation, configuration updates, and policy enforcement.
• Auxiliary Tools and Integration: Directories like “discovery”, “integration”, “docs”, “scripts”, and “vagrant” support tools and tests which help illustrate real-world deployment and network interaction.
Relationships and Data Flow
• External Clients/APIs interact with the network via SDKs that trigger chaincode invocations.
• The client submits a transaction proposal to one or several endorser peers.
• Endorser peers simulate the transaction by invoking the chaincode and return endorsements.
• The client collects endorsements and submits a transaction to the ordering service.
• The ordering service (implemented using one of several consensus protocols) orders transactions and forms blocks.
• The generated blocks are distributed to all peers via the gossip network, where peers validate and commit the blocks to their ledger.
• Identity and access management (via MSP) cross-cuts these interactions to ensure proper authentication and authorization.
Architectural Patterns and Modularity
• Modular "plug-and-play" design: Different consensus mechanisms, chaincode runtimes, and cryptography modules can be interchanged.
• Clear separation of concerns: Orderers manage transaction ordering, peers handle transaction execution/validation/commitment, and MSP modules secure communications.
• Decentralized and scalable communications via the gossip protocol: Peers disseminate updates and ledger information in a decentralized way.
• Configuration management and dynamic channel updates: Configurations are handled separately from the transaction processing path to allow instantiation of multiple channels.
Technologies, Frameworks, or Libraries
• Written in Go, as evidenced by the “go.mod” files.
• Utilizes container-based chaincode execution (with directories like “ccaas_builder”, “core/container”).
• Uses common libraries for cryptography, network communication, and gRPC (as shown in “gossip/comm”, “internal/pkg/comm”).
Final Practical Steps
• Validate that every component seen in the file tree has a representation or is clearly part of a higher-level block.
• Directional flows that denote data and transaction propagation are accurate.