How hyperledger-caliper/caliper works
Main Components
• CLI Interface: Represented by packages/caliper-cli, this is the entry point for users. It is responsible for loading benchmark configurations and initiating tests.
• Core Engine: Found in packages/caliper-core, this forms the heart of the system. It manages the overall benchmark lifecycle, such as worker orchestration, configuration management, message handling, reporting, and interactions with the connectors.
• Connectors/Adapters: There are dedicated packages for each supported blockchain:
• packages/caliper-ethereum (for Ethereum)
• packages/caliper-fabric (for Hyperledger Fabric)
• (And potentially other connectors like for Hyperledger Besu through Ethereum adapters)
These connector components implement specific interfaces (e.g., connector-interface.js) that allow seamless communication with varying underlying blockchain technologies.
• Worker Modules & Rate Controllers: Located within caliper-core and caliper-core/worker, these modules handle the actual transaction submission, including various rate control implementations (such as fixedRate, linearRate, etc.) which simulate network load.
• Test Orchestrators, Monitors, & Reporting: The caliper-core package includes orchestrators (worker, round, monitor orchestrators), monitor modules for collecting metrics, and report generation modules (with chart builders and HTML templates).
• Supplementary Tools: Include modules like packages/caliper-publish (for Docker and npm publishing), packages/generator-caliper (for generating configuration templates), and various integration tests (under packages/caliper-tests-integration) used to validate functionality against real blockchain networks.
• A bidirectional communication between the Core Engine and the Worker Modules, mediated by message handlers and rate controllers.
• Core Engine interfacing with various Connectors, which abstract the underlying blockchain network protocols.
• Reporting/monitoring subsystem as receiving inputs from the Worker and Core Engine; then flowing these outputs into report generators (including chart builders).
• If desired, add connections from the integration testing and publishing tools to the respective components they target (for continuous integration and deployment).
Architectural Patterns and Design Principles
• Modular and Pluggable Structure: Emphasize the layered modular design where components like connectors, worker modules, and rate controllers can be independently maintained or extended.
• Separation of Concerns: The project cleanly separates the user interface (CLI), core benchmarking logic, blockchain-specific interactions, testing integrations, and deployment scripts.
• Communication via Messaging: Point out that there is an abstraction for messaging (using different messengers like MQTT or process-based) which decouples components.
• Extensible Plugin Architecture: Note how new blockchain solutions or workload generators can be added as new packages or generators.
Relevant Technologies and Libraries
• Node.js is the primary runtime (with many .js files visible).
• Use of YAML and JSON for configuration files.
• Docker is used for publishing and running the environment (as seen in Dockerfiles and compose files).
• Testing frameworks and possibly linting/build tools are indicated by ESLint configurations and GitHub workflow scripts.
• Documentation is provided via the docs directory (including mkdocs for generating static documentation sites).