arXiv:2510.16024cs.CRcs.AI2025-10被引 1

首个完全链上学习框架,用智能合约实时防御DeFi攻击

On-Chain Decentralized Learning and Cost-Effective Inference for DeFi Attack Mitigation

  • 链上训练+链下计算,通过验证机制确保模型持续优化
  • 在以太坊气体限制内实现逻辑回归等模型的精确推理
  • 专为抵御私密中继和恶意合约攻击设计,适合DeFi安全团队

每年数十亿美元因DeFi平台中的业务逻辑或会计漏洞被交易利用而损失。现有防御手段聚焦静态代码分析、公共内存池筛查、攻击者合约检测或可信链下监控,均无法防范通过私有中继提交或同区块内执行的恶意合约。本文提出首个完全去中心化、全程链上的学习框架:(i)在Layer-2执行高耗气计算以降低成本;(ii)将经验证的模型更新传播至Layer-1;(iii)在智能合约内实现气体受限、低延迟的推理。新颖的Proof-of-Improvement(PoIm)协议管理训练过程,验证每个微更新为自验证交易。更新仅在至少一项核心指标(如准确率、F1-score、精度或召回率)提升且不降低其他指标时被接受,对抗性提案则通过可适应的测试集受到经济惩罚。我们开发了量化与循环展开技术,使逻辑回归、SVM、MLP、CNN及门控RNN(支持形式化验证的决策树推理)可在以太坊区块气体上限内运行,且比特完全一致,已通过Z3形式证明。我们整理了298个真实世界漏洞(2020–2025),涵盖八个EVM链上的402笔攻击交易,合计造成37.4亿美元损失。

原文摘要 · Abstract (English)

Billions of dollars are lost every year in DeFi platforms by transactions exploiting business logic or accounting vulnerabilities. Existing defenses focus on static code analysis, public mempool screening, attacker contract detection, or trusted off-chain monitors, none of which prevents exploits submitted through private relays or malicious contracts that execute within the same block. We present the first decentralized, fully on-chain learning framework that: (i) performs gas-prohibitive computation on Layer-2 to reduce cost, (ii) propagates verified model updates to Layer-1, and (iii) enables gas-bounded, low-latency inference inside smart contracts. A novel Proof-of-Improvement (PoIm) protocol governs the training process and verifies each decentralized micro update as a self-verifying training transaction. Updates are accepted by \textit{PoIm} only if they demonstrably improve at least one core metric (e.g., accuracy, F1-score, precision, or recall) on a public benchmark without degrading any of the other core metrics, while adversarial proposals get financially penalized through an adaptable test set for evolving threats. We develop quantization and loop-unrolling techniques that enable inference for logistic regression, SVM, MLPs, CNNs, and gated RNNs (with support for formally verified decision tree inference) within the Ethereum block gas limit, while remaining bit-exact to their off-chain counterparts, formally proven in Z3. We curate 298 unique real-world exploits (2020 - 2025) with 402 exploit transactions across eight EVM chains, collectively responsible for \$3.74 B in losses.

DeFi安全链上学习智能合约模型推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。