How anansi-research/federatedlearningblockchain works
Main Components
• Blockchain & Smart Contracts:
• Files: The “contracts” directory (including tests) and brownie-config.yaml indicate the use of smart contracts (using Eth-Brownie) for handling the blockchain operations.
• Purpose: These contracts are used to store hashes (as pointers) of model weights uploaded to IPFS for secure and verifiable aggregation.
• Federated Learning Simulation Components:
• Files: The “scripts” directory contains multiple scripts—classHospital.py, collaborator.py, manager.py, deploy_FL.py, setup.py, etc.—indicating different roles like hospital peer simulation, model weight aggregation, and system setup.
• Roles:
∙ Hospital Peer (or Node): Handles local training on MRI images and prepares the model weights.
∙ Collaborator: Simulates sequential training across different hospital models (noting the README clarifies sequential execution due to GPU concurrency concerns).
∙ Manager: Likely orchestrates the federated learning rounds, aggregates weights, and interacts with the blockchain components.
• IPFS Integration Component:
• While not a directory in the repository, the README details that model weights are stored on IPFS, with only the hash stored on the blockchain.
• This should be represented as an external service that interacts with the blockchain contracts.
• Supporting Components:
• External Tools/Services: Ganache for a local Ethereum network simulation, and additional dependencies (TensorFlow, OpenCV, Pandas, scikit-learn) which are part of the learning model training pipelines.
• Data/Control Flow:
• Each hospital peer trains a local model. Once local training is complete, the model weights are stored on IPFS.
• The IPFS hash is then recorded on the blockchain using a smart contract – illustrating the secure and decentralized storage of model weight references.
• The Manager (or Aggregator) reads these hashes from the blockchain, retrieves the corresponding weights from IPFS, and performs the aggregation (applying ensemble techniques in the weight space as described in the README).
• The flow is iterative: the updated aggregated model can be redistributed to hospital nodes for further rounds.
• Interaction Direction:
Important Architectural Patterns and Design Principles
• Distributed Federation:
• Separation of concerns—each hospital peer handles its own data and model training.
• The blockchain provides a trusted intermediary that ensures integrity through decentralized smart contract operations.
• Separation Between Core Layers:
• The simulation distinctly separates the training (machine learning computations) from the blockchain-based aggregation and verification.
• Security and Privacy:
• That no raw data is exchanged between participants; only model weights’ hashes are committed on-chain ensuring privacy.
Relevant Technologies and Frameworks
• Blockchain-related:
• Ethereum smart contracts (via Brownie), Ganache for network simulation.
• Federated Learning and ML:
• TensorFlow (model training), OpenCV (image processing), etc.
• External Storage/Networking:
• IPFS for decentralised storage.
• Python and Supporting Libraries:
• Scripts use Python along with libraries like Pandas and scikit-learn for data management and analysis.