[Paper Review] On-Chain Decentralized Learning and Cost-Effective Inference for DeFi Attack Mitigation
YODA enables efficient, secure off-chain execution of Computationally Intensive Contracts (CICs) on permissionless blockchains like Ethereum by using adaptive, multi-round consensus via the MIRACLE algorithm and incentive-compatible mechanisms like RICE. It achieves up to 450× higher gas usage per transaction than Ethereum's limit, with strong security guarantees under a Byzantine, Altruistic, Rational (BAR) threat model and near-optimal efficiency when Byzantine node fractions are low.
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 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. We demonstrate that on-chain ML governed by PoIm detects previously unseen attacks with over 97% attack detection accuracy and 82.0% F1. A single inference, such as one made via an external call, typically incurs zero cost. Fully on-chain inference consumes 57,603 gas (≈ $0.18) for linear models, 143,647 gas (≈ $0.49) for CNN(F2, K1), and 506,397 gas (≈ $1.77) for CNN(F8, K4) on L1 (e.g., Ethereum). Our results show that practical and continually evolving DeFi defenses can be embedded directly in protocol logic without trusted guardians, and our solution achieves highly cost-effective protection while filling a critical gap between vulnerability scanners and real-time transaction screening.
Motivation & Objective
- To address the limitation of permissionless blockchains like Ethereum in executing CICs due to high gas costs and the Verifier’s Dilemma.
- To design a system that ensures correct CIC execution under a realistic threat model including both Byzantine and rational (selfish) nodes.
- To enable off-chain execution of CICs without on-chain verification or partial execution, ensuring scalability and fairness.
- To provide economic and technical incentives that make honest behavior an approximate Nash equilibrium for rational nodes.
- To minimize computational and transactional overhead while maintaining high probability of correct result determination.
Proposed method
- YODA uses Sortition to select small, random Execution Sets (ES) for off-chain CIC computation, reducing on-chain load.
- The MultI-Round Adaptive Consensus using Likelihood Estimation (MIRACLE) algorithm determines the correct CIC result by iteratively evaluating solution digest likelihoods based on counts and estimated Byzantine fraction f.
- MIRACLE adapts the number of rounds based on the actual fraction f of Byzantine nodes, minimizing expected computation when f is low.
- The Randomness Inserted Contract Execution (RICE) protocol introduces randomness to prevent free-riding and ensures timely, fair rewards for correct ES participants.
- Economic incentives and technical mechanisms enforce that honest behavior is an approximate Nash equilibrium for rational nodes.
- A modular architecture allows independent replacement of components like ES selection, RICE, and MIRACLE for future extensibility.
Experimental results
Research questions
- RQ1Can off-chain CIC execution be made secure and efficient in permissionless blockchains under a combined Byzantine and rational (selfish) threat model?
- RQ2How can consensus on a single correct CIC result be achieved with minimal on-chain overhead and high probability, even when execution sets are small and potentially compromised?
- RQ3What mechanisms can ensure that rational (selfish) nodes do not free-ride on others’ computation and instead submit correct results?
- RQ4How can the system adaptively reduce resource usage when the actual fraction of Byzantine nodes is lower than the worst-case assumption?
- RQ5Can the system achieve near-optimal expected number of execution rounds when the Byzantine fraction is at its maximum, under adversarial behavior?
Key findings
- YODA enables execution of individual CICs with gas usage up to 450 times the maximum allowed by Ethereum’s current EVM, demonstrating significant scalability improvement.
- The MIRACLE algorithm guarantees correct CIC result with probability at least 1−β, and adapts to lower Byzantine fractions by reducing the expected number of rounds.
- When the actual Byzantine fraction f is less than the assumed worst-case fmax, MIRACLE achieves substantial efficiency gains, reducing the number of required execution rounds.
- RICE introduces minimal overhead: absolute overhead remains under 0.2 seconds even at 100 million gas usage, and relative time difference is negligible.
- The system ensures that honest behavior is an approximate Nash equilibrium for rational nodes, preventing free-riding through economic and technical incentives.
- The prototype implementation on Ethereum shows that YODA can handle CICs with orders of magnitude higher gas per unit time and total gas requirements than native Ethereum supports.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.