Source-linked AI summary

Werracle: Sub-Cent Intra-Block AI Reflex Oracles and Flash-Loan Circuit Breakers for EVM Smart Contracts

Volkan Dağlı, Zerrin Dağlı, Dağhan Dağlı

arXiv:2609.30719v1cs.CRcs.AIcs.DC

TL;DR

DeFi exploits can occur within a single transaction, while on-chain model storage is costly and ZK-ML has substantial proving latency and verification overhead. Werracle uses procedural Mandelbrot escape dynamics in an EVM-native oracle. It reports reduced latency and gas relative to ZK-ML, and deterministic parity across its verification test vectors.

  • Problem

    DeFi exploits can unfold within a single transaction, while ZK-ML proof generation takes 10 to 300 seconds and verification consumes 250,000 to 500,000 gas.

    Source: §1 · pp. 1–2
  • Method

    Werracle is an EVM-native procedural decision oracle using Mandelbrot escape dynamics instead of external neural weights, off-chain provers, and persistent storage arrays.

    Source: §1 · p. 2, §2 · p. 2
  • Results

    1,000× latency reduction and 18× gas reduction relative to state-of-the-art ZK-ML; all 1,000 test vectors passed with 100.0% deterministic parity.

    Source: §6 · p. 3, §7 · p. 3
  • Takeaways & Limitations

    The Uniswap v4 hook adjusts swap fees from 0.05% in calm orderflow up to 0.50% under volatile or flash-loan attack conditions within the swap transaction.

    Source: §5 · p. 3

Abstract

from arXiv · show

Contemporary on-chain artificial intelligence (AI) encounters an intractable Von Neumann memory and latency wall. Storing static floating-point neural weight matrices inside Ethereum Virtual Machine (EVM) storage costs millions of gas, rendering direct on-chain inference impossible. While Zero-Knowledge Machine Learning (ZK-ML) offloads matrix tensor multiplications to off-chain provers, it introduces fatal constraints: 10 to 300 seconds of SNARK proving latency and 250,000 to 500,000 gas per proof verification. Because decentralized finance (DeFi) exploits - such as uncollateralized flash-loan attacks, predatory sandwich MEV, and toxic loss-versus-rebalancing (LVR) flow - occur atomically inside a single block, ZK-ML oracles cannot react in time. Here, we present Werracle, a production-grade, zero-storage on-chain AI decision oracle fitting inside a single 32-byte EVM storage slot (bytes32). Leveraging foundational procedural Mandelbrot escape dynamics (z_{n+1} = z_n^2 + c) established by Dagli et al. (arXiv:2609.25498), Werracle derives continuous non-linear decision hyperplanes from a 24-byte coordinate triplet Theta = (c_x, c_y, zoom). Implemented in pure Solidity bytecode using fixed-point Q16.16 arithmetic (WerrMath.sol), Werracle evaluates a 16-point Pareto micro-grid in only 21,438 gas (under 0.0005 USD on Layer-2 rollups like Base and Arbitrum) with sub-millisecond execution latency. We demonstrate real-world DeFi efficacy via WerracleFeeHook.sol, a Uniswap v4 dynamic swap fee governor that measures orderbook turbulence on-the-fly and atomically adjusts liquidity provider fees between 0.05% and 0.50%. The protocol is formally verified against a 1,000-test cryptographically sealed deterministic verification suite (100.0% pass rate) with telemetry permanently disabled, operating live on a dedicated EVM devnet sandbox (Chain ID 4242).

1 Introduction

DeFi exploits can unfold within one atomic transaction, yet direct on-chain machine learning is constrained by EVM storage costs and ZK-ML latency and verification overhead. Werracle is introduced as an EVM-native procedural oracle that avoids external neural weights, off-chain provers, and persistent storage arrays.

1 Introduction

  • Flash-loan attacks can manipulate liquidity and extract value within a single Ethereum transaction, motivating sub-millisecond, intra-block defenses.The attacks described involve borrowing without upfront capital and repaying within the same transaction.Source: §1 · p. 1
  • A 100,000-weight FP32 perceptron requires 400 KB, costing over 2.5 billion gas to store through EVM SSTORE opcodes.The passage estimates this at more than $100,000 on Ethereum Mainnet.Source: §1 · p. 1
  • SNARK proof generation for neural inference takes 10 to 300 seconds, too slow for the described intra-block exploit response.The passage says the victim protocol may suffer total reserve depletion before proof submission.Source: §1 · pp. 1–2
  • On-chain ZK-ML proof verification consumes 250,000 to 500,000 gas, making continuous invocation economically prohibitive for everyday decentralized exchanges.The passage estimates verification at approximately $10 to $25.Source: §1 · p. 2
  • Werracle is an EVM-native procedural decision oracle that eliminates external neural weights, off-chain provers, and persistent storage arrays.The introduction also identifies reliance on off-chain prover farms as a centralized point-of-failure risk [4, 5].Source: §1 · p. 2

2 Procedural Decision Synthesis

Werracle replaces dense matrix tensors with Mandelbrot escape dynamics to create a nonlinear decision boundary from a compact coordinate triplet. Transaction features perturb the coordinates, and boundary-cusp sensitivity provides the decision behavior without persistent parameter arrays.

2 Procedural Decision Synthesis

  • Werracle replaces dense matrix tensors with Mandelbrot-set escape dynamics, building on the WERR architecture [6] and the Mandelbrot set [8].The passage identifies these dynamics as the basis for procedural decision synthesis.Source: §2 · p. 2
  • A complex classification boundary is parameterized by an invariant 24-byte coordinate triplet.The triplet is Θ = (cx, cy, zoom).Source: §2 · p. 2
  • Normalized transaction features map to an affine coordinate perturbation, and boundary-cusp points exhibit deterministic sensitivity without persistent parameter arrays.The contract evaluates local escape velocity after applying the perturbation.Source: §2 · p. 2

3 EVM Opcode and Storage Packing

Werracle packs model and control parameters into one 32-byte EVM storage word. The packing supports inexpensive warm reads and avoids dynamic memory arrays.

3 EVM Opcode and Storage Packing

  • The entire model is compressed into one 32-byte EVM storage word, with fields for coordinates, zoom, threshold, nonce, and security/domain flags.The listing assigns 64 bits each to cx, cy, and zoom; 16 bits each to threshold and nonce; and 32 bits to flags.Source: §3 · p. 2
  • After the initial warm access, subsequent model-parameter reads cost exactly 100 gas.This is the passage's stated warm SLOAD optimization.Source: §3 · p. 2
  • The oracle avoids dynamic memory arrays, thereby avoiding quadratic EVM memory-expansion penalties.The passage names this benefit as zero memory expansion.Source: §3 · p. 2

4 Fixed-Point Bytecode Arithmetic

Werracle uses fixed-point Q16.16 arithmetic because the EVM natively supports integer arithmetic. Its decision confidence comes from a 16-point Pareto micro-grid, with a threshold test for escape behavior.

4 Fixed-Point Bytecode Arithmetic

  • Q16.16 represents 1.0 as 65,536, adapting Werracle's arithmetic to the EVM's native integer operations.The fixed-point implementation is provided by WerrMath.sol.Source: §4 · p. 2
  • Fixed-point multiplication widens to a 128-bit intermediate and then applies an arithmetic right shift.The displayed multiplication formula shifts the product right by 16 bits.Source: §4 · p. 2
  • A 16-point (4 × 4) Pareto micro-grid estimates decision confidence from the proportion of non-escaping points, while y > 4.0 is tested against 262,144.The threshold is expressed using the integer constant corresponding to 4.0.Source: §4 · p. 2

5 DeFi Integration: Uniswap v4 Dynamic Fee Hook

WerracleFeeHook applies Werracle’s on-chain decision engine to Uniswap v4 swaps, evaluating pool turbulence in the beforeSwap callback. It adjusts fees between 0.05% and 0.50% and is reported to reduce gas and latency relative to ZK-ML.

5 DeFi Integration: Uniswap v4 Dynamic Fee Hook

  • The Uniswap v4 hook intercepts swaps through beforeSwap and evaluates instantaneous pool turbulence associated with toxic Loss-Versus-Rebalancing.The passage describes informed traders front-running price changes as the setting in which passive liquidity providers suffer LVR.Source: §5 · p. 2
  • Incoming volume, tick velocity, and address metrics are normalized into coordinate shifts for the on-chain engine.The engine uses a single 32-byte storage word and fixed-point Q16.16 Mandelbrot escape dynamics across a 16-point micro-grid.Source: Figure 1 · p. 3
  • Werracle reports an 18× gas reduction and over 1,000× latency reduction compared with ZK-ML proving architectures.The architecture evaluates a 16-point Pareto micro-grid in 21,438 gas with sub-millisecond latency.Source: §5 · p. 3, Figure 1 · p. 3
  • During calm orderflow, fees drop to 0.05%; under volatile or flash-loan attack conditions, they scale up to 0.50%.The stated purpose is to capture retail routing volume in calm conditions and neutralize predatory margins while shielding liquidity providers atomically during swaps.Source: §5 · p. 3

6 Comparative Empirical Evaluation

The evaluation compares Werracle with traditional centralized oracles and ZK-ML proving architectures. Werracle is reported to reduce latency and gas relative to state-of-the-art ZK-ML provers, enabling intra-block circuit breaking.

6 Comparative Empirical Evaluation

  • The reported comparison is against traditional centralized oracles and contemporary ZK-ML proving architectures.Table 2 and Figure 2 are identified as the benchmark presentation.Source: §6 · p. 3
  • Werracle reports a 1,000× latency reduction and an 18× gas reduction relative to state-of-the-art ZK-ML provers.The passage states that this enables intra-block circuit breaking.Source: §6 · p. 3
  • The paper describes intra-block circuit breaking as enabled by the reported reductions relative to ZK-ML provers.It characterizes this as occurring for the first time in EVM history.Source: §6 · p. 3

7 Cryptographically Sealed Verification

Werracle was tested with a 1,000-test deterministic verification battery spanning arithmetic, exploit, classification, and fee-regime cases. All vectors passed with 100.0% deterministic parity, and the results and artifacts are described as cryptographically sealed.

7 Cryptographically Sealed Verification

  • The 1,000-Test Master Verification Battery comprises four 250-test groups covering fixed-point invariance, flash-loan exploit reverts, AML/OFAC traps, and Uniswap v4 fee regimes.The fee-regime tests check scaling boundaries without out-of-gas errors.Source: §7 · p. 3
  • All 1,000 test vectors passed with 100.0% deterministic parity.The results, gas snapshots, and bytecode receipts are sealed under a SHA-256 digest in SEAL MANIFEST.json.Source: §7 · p. 3
  • Results, gas snapshots, and bytecode receipts are sealed under a SHA-256 digest in SEAL MANIFEST.json.The passage reports that all test vectors passed with 100.0% deterministic parity.Source: §7 · p. 3

8 Privacy by Design: Zero Telemetry

Werracle presents operational privacy as a design property, contrasting its operation with Web3 RPC gateways that collect user IP addresses and transaction telemetry. Its diagnostics and external listeners are disabled, and evaluations run inside the EVM sandbox.

8 Privacy by Design: Zero Telemetry

  • Werracle contrasts its claimed operational privacy with Web3 RPC gateways that harvest user IP addresses and transaction telemetry.The paper characterizes its own approach as enforcing absolute operational privacy.Source: §8 · p. 3
  • Diagnostic logging and external listeners are permanently disabled, and decision evaluations execute exclusively inside the EVM sandbox.The passage states TELEMETRY ENABLED = False and describes this as ensuring computational sovereignty for institutional participants.Source: §8 · p. 4

9 Conclusion and Code Availability

Werracle presents procedural Mandelbrot dynamics as a way for smart contracts to make sub-millisecond, sub-cent decisions within a single storage slot. The conclusion also lists public code, documentation, replication resources, and a live EVM node.

9 Conclusion and Code Availability

  • Werracle replaces multi-gigabyte weight tensors with procedural Mandelbrot dynamics for sub-millisecond, sub-cent decisions in a single storage slot.The conclusion describes this as a foundational paradigm shift for on-chain machine intelligence.Source: §9 · p. 4
  • The authors list a GitHub repository, interactive documentation, and a Zenodo replication package as publicly available resources.The replication package is identified by DOI 10.5281/zenodo.22942598.Source: §9 · p. 4
  • A live EVM node is listed with Chain ID 4242.Source: §9 · p. 4
  • The underlying zero-storage procedural fractal synthesis is identified as protected under Turkish Patent Application TR 2026/016285.Source: §9 · p. 4
Loading 2609.30719v1…