DTG-BlockFL: Dynamic Trust Graph-Driven Secure Federated Learning with Blockchain-Based Traceability
A structured research codebase for secure federated learning under poisoning and backdoor attacks, centered on the DTG-BlockFL pipeline: anomaly-aware update modeling, dynamic trust graph construction, temporal trust evolution, trust-weighted aggregation, and append-only audit logging.
This repository is designed as a single, coherent experimental framework for running end-to-end studies across multiple datasets, attack families, baselines, ablations, and auditability analyses.
Federated learning protects raw data locality, but it remains vulnerable to malicious client updates such as label flipping, model poisoning, model replacement, and stealth backdoor injection. DTG-BlockFL addresses this challenge by combining four tightly coupled components: (1) compact behavioral feature extraction from client updates, (2) malicious-probability estimation and anomaly scoring, (3) dynamic trust graph construction with temporal trust memory, and (4) survivor-aware trust-weighted aggregation with append-only audit metadata logging. The framework is organized to support reproducible experimentation on MNIST, Fashion-MNIST, CIFAR-10, CIFAR-100, and FEMNIST, with both single-run and manifest-based batch execution workflows.
- update feature extraction from client reports
- anomaly scoring and malicious-probability estimation
- top-k trust graph construction and graph-consistency scoring
- temporal trust update with rolling history
- survivor-aware trust-weighted aggregation
- append-only audit logging for replay and accountability analysis
- label flip
- Gaussian poisoning
- model replacement
- distributed backdoor
- stealth backdoor
- slow-drift poisoning
- FedAvg
- Median / Trimmed Mean / Krum / RFA
- FLTrust-style aggregation
- FLDetector-style filtering
- CONTRA-style consistency weighting
- FLEST-style history-aware trust baseline
- AlignIns-style alignment aggregation
- MARS-style malignity-aware screening
- D-Byz-SGDM-style robust server momentum
- YAML-based single-run configuration
- dotted-key runtime override support
- manifest-based batch launching
- result summarization and grouped statistics
- figure generation utilities
- Windows CPU / GPU launcher scripts
run.py # main experiment entrypoint
configs/ # single-run experiment configurations
manifests/ # batch experiment plans
scripts/ # setup, diagnosis, launch, summary, plotting
src/
attacks/ # attack implementations
audit/ # append-only audit logging
common/ # utilities, metrics, hashing, logging
data/ # dataset loading and federated partitioning
defenses/ # DTG and baseline defenses
eval/ # evaluation utilities
fl/ # federated server/client/training flow
models/ # model definitions and model factory
outputs/ # metrics, logs, registry, figures, tensorboard
Organized launcher and docs entrypoints:
WIN_MENU.bat— root Windows launcher entrylaunchers/windows/— categorized Windows batch launchersdocs/README.md— documentation index
Detailed Chinese guides:
README_CN.mddocs/01_project/PROJECT_OVERVIEW_CN.mddocs/01_project/CODEBASE_GUIDE_CN.mddocs/02_experiments/EXPERIMENT_PORTFOLIO_CN.mddocs/03_windows/WINDOWS_FRIENDLY_GUIDE_CN.md
This repository includes a paper-asset layer used both to organize the completed submission experiment campaign and to package a lightweight source release.
Added in v13:
- paper manifest generation (
scripts/build_paper_manifests.py) - paper coverage audit (
scripts/check_paper_coverage.py) - paper artifact collection (
scripts/collect_paper_artifacts.py) - stricter paper-table export (
scripts/export_paper_tables.py) - baseline fidelity policy (
docs/05_policy/baseline_fidelity_policy.md) - paper-packaging Chinese guides (
docs/05_policy/READINESS_GAP_CN.md,docs/02_experiments/EXECUTION_ROADMAP_CN.md)
Current package scope:
- The manuscript is intended to use the completed full experiment archive.
- This lightweight zip may keep only smoke / example outputs in
outputs/andpaper_artifacts/outputs/to keep the package size manageable. - Before archival release, copy or regenerate the final
run_summary,grouped_summary,paper_tables, figures, and coverage JSON in the predefined directories. - Treat the bundled example outputs as path-validation artifacts only, not as the evidence source for the paper tables.
Important scope note:
DTG-BlockFLis implemented directly in this repository.- The audit component is a lightweight pseudo-chain metadata logging prototype for accountability studies.
- Several advanced comparison methods in
src/defenses/advanced.pyare compact baseline-style reproductions, not official upstream code releases.
For a paper submission or archival release, always generate manuscript tables from actual run outputs via the manifest / summary / export pipeline.
This repository now includes a standard open-source project layout for public hosting and long-term maintenance:
LICENSE— repository licenseCONTRIBUTING.md— contribution workflow and coding expectationsCODE_OF_CONDUCT.md— community participation guidelinesSECURITY.md— vulnerability disclosure policyROADMAP.md— near-term development prioritiesdocs/— curated documentation index and topic guides.github/ISSUE_TEMPLATE/— issue templates for bugs and feature requests
conda create -n dtgblockfl_cpu python=3.10 -y
conda activate dtgblockfl_cpu
pip install -r requirements-cpu-pytorch.txt
pip install -r requirements.txtconda create -n dtgblockfl_gpu python=3.10 -y
conda activate dtgblockfl_gpu
pip install -r requirements-cu118-pytorch.txt
pip install -r requirements.txtThe repository includes click-to-run Windows launchers under launchers/windows/ and a root entry file WIN_MENU.bat.
entry points for:
- CPU environment creation
- CUDA environment creation
- GPU availability check
- doctor / project validation
- smoke runs
- quick MNIST runs
- baseline / attack / CIFAR trend experiments
- result summarization and figure generation
Recommended first-run order:
WIN_MENU.bat- In the menu, choose Environment and doctor → create CPU env / run CPU doctor
- Then choose Quick tests → smoke test CPU / MNIST quick CPU
- Then choose Trend experiments for baseline / attack trend runs
bash scripts/setup_env.sh
python scripts/doctor.py
python scripts/validate_project.py
python run.py --config configs/smoke_femnist_dtg.yamlpython scripts/prepare_data.pyPlace LEAF-style FEMNIST JSON files under:
data/raw/femnist/train/data/raw/femnist/test/
Then build the processed cache:
python scripts/prepare_femnist.pypython run.py --config configs/smoke_mnist_fedavg.yaml
python run.py --config configs/smoke_mnist_labelflip.yaml
python run.py --config configs/smoke_femnist_dtg.yamlpython run.py --config configs/mnist_labelflip.yaml
python run.py --config configs/femnist_labelflip.yaml
python run.py --config configs/cifar10_backdoor.yaml
python run.py --config configs/cifar10_stealth_backdoor.yamlpython scripts/launch_experiments.py --manifest manifests/trend_baselines_quick.yaml --max_workers 1
python scripts/launch_experiments.py --manifest manifests/trend_attacks_quick.yaml --max_workers 1
python scripts/launch_experiments.py --manifest manifests/trend_cifar_quick.yaml --max_workers 1Purpose:
- verify data loading
- verify federated training
- verify DTG pipeline execution
- verify audit logging and metric export
Representative files:
configs/smoke_femnist_dtg.yamlconfigs/smoke_mnist_fedavg.yamlconfigs/smoke_mnist_labelflip.yaml
Purpose:
- compare DTG-BlockFL against classical robust aggregation and trust-aware baselines
Representative files:
manifests/trend_baselines_quick.yamlmanifests/paper_baselines_mnist.yaml
Purpose:
- evaluate DTG across different attack families under a unified workflow
Representative files:
manifests/trend_attacks_quick.yamlconfigs/cifar10_model_replacement.yamlconfigs/cifar10_slow_drift.yaml
Purpose:
- evaluate DTG against stronger backdoor-oriented methods on CIFAR-style settings
Representative files:
manifests/trend_cifar_quick.yamlmanifests/paper_backdoor_subset.yamlconfigs/cifar10_stealth_backdoor.yamlconfigs/cifar100_backdoor.yaml
Purpose:
- measure the contribution of anomaly detection, graph structure, trust memory, and filtering/weighting strategies
Representative files:
configs/dtg_ablation.yamlmanifests/dtg_ablation.yamlmanifests/paper_ablation_full.yaml
A detailed Chinese experiment map is provided in docs/02_experiments/EXPERIMENT_PORTFOLIO_CN.md.
After running experiments, the main outputs are organized as:
outputs/metrics/— run-level JSONL metric logsoutputs/logs/— detailed logs and audit tracesoutputs/registry/— batch execution registryoutputs/figures/— generated plotsoutputs/tensorboard/— TensorBoard logs
python scripts/summarize_results.py
python scripts/summarize_registry.pypython scripts/plot_metrics.py --input outputs/metrics/<run>.jsonl --outdir outputs/figures/<run>
python scripts/plot_compare.py --inputs outputs/metrics/run_a.jsonl outputs/metrics/run_b.jsonl --outdir outputs/figures/compareThis repository emphasizes a self-contained and unified experimental workflow. For certain external baselines and advanced attack variants, the implementations are provided as compact in-repository reference variants so that all methods can be launched, logged, summarized, and compared within one codebase. The emphasis of this repository is engineering coherence, experiment portability, and consistent evaluation workflow.
If you use this repository in academic work, please cite the associated DTG-BlockFL study. A citation template is included in CITATION.cff.
@misc{dtgblockfl_framework,
title={DTG-BlockFL: Dynamic Trust Graph-Driven Secure Federated Learning with Blockchain-Based Traceability},
author={Anonymous},
year={2026},
note={Research codebase and experimental framework}
}For project-level understanding and code navigation, see:
docs/01_project/PROJECT_OVERVIEW_CN.mddocs/01_project/CODEBASE_GUIDE_CN.mddocs/02_experiments/EXPERIMENT_PORTFOLIO_CN.mddocs/03_windows/WINDOWS_FRIENDLY_GUIDE_CN.md
For a more repository-style documentation experience, start with docs/README.md.
The repository now includes additional publication and hosting assets:
docs/04_release/RELEASE_ASSETS_GUIDE.md— what to include in a public releasedocs/04_release/REPOSITORY_PROFILE_SUGGESTIONS.md— suggested description, topics, badges, and social preview messagingreleases/RELEASE_TEMPLATE_v12.md— release note templateassets/— placeholder directory for social preview, architecture overview, and branding materialsdocs/release_readiness.md— release-readiness documentation
Recommended repository description:
Dynamic trust graph-driven secure federated learning with poisoning/backdoor defenses, trust-aware aggregation, and append-only auditability.
Recommended repository topics:
federated-learning, secure-federated-learning, byzantine-robustness, backdoor-defense, poisoning-defense, trust-graph, anomaly-detection, blockchain-audit, pytorch, reproducibility
Use the files under releases/ as templates when publishing source archives or preparing a formal project release page.