Smart Contracts Deep-dive
This page gives detailed explanation of FL Alliance's smart contracts.

Core Contracts
FlockTaskManager.sol
FlockTaskManager.solRole: Factory and lifecycle controller for all FlockTask instances.
Task Creation: Deploys new
FlockTaskcontracts, passing in initial parameters like_totalNumberOfRounds,_minStakeThreshold,_initialRewardPoolSize, etc.Task Management: Maintains a list (via
EnumerableSet) of active or unfinishedFlockTaskaddresses.Finish Task: The owner can mark a task as
finishedif necessary (finishTask(...)), removing it from the active set.
FlockTask.sol
FlockTask.solRole: This contract implements a decentralized and scalable model for round-based federated learning (“FL tasks”).
Staking & Roles: Participants stake tokens to become eligible to join rounds, where they are randomly assigned roles (proposers, voters).
Proposal & Voting Rounds: Each round, selected proposers submit model updates, and voters commit/reveal votes that determine the most popular model via stake-weighted voting.
Rewards & Slashing: Well-behaved participants (correct contributions/votes) receive rewards; dishonest behaviors can be “slashed,” losing a percentage of their stake.
Libraries
LibABDKMathQuad.sol
LibABDKMathQuad.solRole: Quadruple-precision (128-bit) math operations.
Implements IEEE 754–style floating-point arithmetic for
bytes16values.Provides precision far beyond typical fixed-point or 256-bit integer math.
Useful for advanced computations like logarithms, exponentials, or rational approximations.
LibFlockTask.sol
LibFlockTask.solRole: Provides specialized numeric and utility functions for federated-learning tasks. Key Functions include:
mulDiv(uint256 x, uint256 y, uint256 z)Combines multiplication and division with quadruple precision by leveraging
LibABDKMathQuad.
rand()Generates a pseudo-random number by hashing block and transaction properties.
Last updated
Was this helpful?