How Many Fake Transactions Is One Real One Worth? Synthetic Traces for Cold-Start Smart-Contract Invariants

Some of the most effective smart-contract defenses are simple runtime checks built from expert templates. A template might say "only human-owned accounts may call this function" or "this value must stay within a range". A tool fills in the specifics from the contract's past transactions, then blocks any transaction that breaks the check. These checks work well when they have history to learn from: Demystifying Invariant Effectiveness for Securing Smart Contracts (Trace2Inv) reports blocking 20 of 27 real DeFi hacks with a 0.28% false-positive rate. The same paper names its central weakness, historical dependency. A contract attacked soon after deployment has no benign history, so the ranges cannot be learned. The obvious fix is to generate synthetic transactions before deployment. Nobody knows whether that works, or how much synthetic data it takes.

We propose to measure this directly. The approach borrows the exchange rate and substitutability measurements that On the Equivalency, Substitutability, and Flexibility of Synthetic Data developed for video tracking, where roughly 30 synthetic frames matched one real frame and 60–80% of real data could be replaced. We apply them to the step where a security template's parameters are filled in. The core claim is that synthetic traces can stand in for real ones for some template families and not for others. For each family, the exchange rate depends on how much economic and multi-actor behavior the generator simulates, not on how many transactions it produces. If this holds, it tells practitioners which invariants they can safely deploy on day zero. It also tells generator designers which behaviors to simulate.

Core Claim and What Is New

The closest existing work is Strengthening Solidity Invariant Generation: From Post- to Pre-Deployment (InvSol). InvSol translates Solidity into Java, generates synthetic tests with the EvoSuite search-based test generator, and applies Daikon-style invariant templates. It treats synthetic tests as a heuristic substitute. It never compares them against real on-chain histories, and it reports that it misses Time Lock, Oracle Slippage and Money Flow invariants.

Our proposal differs in three ways. It evaluates rather than assumes: the unit of analysis is a curve of defense quality against the amount of real versus synthetic data. It runs on real contract execution rather than a Java translation, which removes the translation-fidelity confound InvSol acknowledges. And it varies the generator's behavioral knobs, in the way the M3Act study varied crowd complexity rather than photorealism. This lets us locate the cause of InvSol's economic-invariant failures instead of just observing them.

For a template family $T$ and contract $c$, define $\mathrm{FP}_T(D)$ as the false-positive rate on held-out real benign transactions, and $B_T(D)$ as the number of known hacks blocked, when the template's bounds are learned from dataset $D$. The exchange rate at real-history size $n$ is

$$ e_T(n) = \frac{1}{n}\,\min\{\, m : \mathrm{FP}_T(S_m) \le \mathrm{FP}_T(R_n) \ \text{and}\ B_T(S_m) \ge B_T(R_n) \,\}. $$

Here $R_n$ is the first $n$ real transactions and $S_m$ is $m$ synthetic ones. If no $m$ within budget satisfies both conditions, $e_T(n)=\infty$: the family is not substitutable.

Our hypothesis has two parts. For access-control-style families, $e_T$ is finite and small even for simple generators. For bound-style families on value and oracle quantities, $e_T$ is infinite under naive fuzzing and becomes finite only when the generator simulates multi-step economic interactions.

Research Program

We will build a pre-deployment trace generator that runs on a local fork of Ethereum mainnet at the contract's deployment block. Real neighboring contracts (tokens, oracles, pools) are therefore present, and transactions execute exactly as they would on chain.

The generator's knobs are the main object of study. The simplest setting draws random calls to the contract's public functions, the way a fuzzer would. The next adds a population of simulated users with distinct roles and realistic value distributions. The third adds multi-step economic scripts: deposit-then-borrow, swap sequences, and liquidity entry and exit. The richest setting also moves the prices of the external oracles and pools the contract depends on.

Each trace set is fed into Trace2Inv's template instantiation unchanged, including its taint analysis and bound deduction. Any change in outcome can then be attributed to the data alone.

The analysis has three parts. The first sweeps $n$ and $m$ per template family on the Trace2Inv exploit contracts to produce the exchange-rate curves. The second measures substitutability. We fix a total budget, replace a fraction $f$ of real transactions with synthetic ones, and find the largest $f$ at which false positives and blocked hacks are no worse than using all-real data. We also test whether "synthetic pretraining plus a little real data" beats small real histories alone, which is the M3Act finding translated to this setting. The third is a gap diagnosis. For template families that fail to transfer, we compare the learned bounds from real and synthetic data dimension by dimension. The method is borrowed from Is this Model for Real? Simulating Data to Reveal the Proximity of a Model to Reality, which compares where parameter estimates settle on real versus simulated student data. This tells us which unsimulated behavior drives the failure.

The motivation from the wider repair literature is the synthetic-versus-real gap. SoK: Towards Effective Automated Vulnerability Repair documents GPT-4 reaching a 96.6% repair success rate on the synthetic DSARD benchmark but falling below 50% on real benchmarks. Examining Zero-Shot Vulnerability Repair with Large Language Models finds a similar collapse from synthetic scenarios to ExtractFix. Both measure the gap after the fact. We quantify it per defense component and predict it in advance.

Challenging Bug Prediction and Repair Models with Synthetic Bugs acts as a constraint on the design. It shows that the kind of synthetic data matters more than its volume: naive mutants make repair look easier than it is. That finding is why our generator is organized around behavioral knobs rather than raw sample count.

Baselines

The naive reference point is deploying the templates with no learned bounds. Only the parts that need no data are kept, and numeric ranges are set to permissive defaults. Hacks blocked and false positives for this configuration set the floor that any data source must beat.

The strongest existing method, and our ceiling, is Trace2Inv trained on full real history under its own 70/30 split. On the 42-contract set it reports 20 of 27 hacks blocked, a 0.28% false-positive rate, and under 0.68% gas overhead, using the combined template reported as EOA ∧ (OB ∨ DFU) (Demystifying Invariant Effectiveness for Securing Smart Contracts). We will rerun it on the same contracts and splits rather than rely only on the quoted figures.

The realistic competitor at cold start is Trace2Inv on the first $n$ real transactions, for $n$ ranging from a handful to a few hundred. This is what a deployer could actually do after a short delay. Beating it means achieving false positives at or below its level and hacks blocked at or above it, using zero real transactions or fewer real ones.

The existing synthetic alternative is InvSol, run on the same contracts. For it we found no single hacks-blocked figure on the 42-contract set on Lacuna. The paper states qualitatively that InvSol protects better against access-control exploits than Trace2Inv. It reports loop-invariant precision of 93–100% and recall of 77–83% on contracts with scarce history.

All data sources receive the same template library, the same bound-deduction code, and equal wall-clock budgets for generating or collecting traces. False positives are always measured on the same held-out real transactions.

The key ablation removes the generator's economic and oracle-price knobs while keeping total transaction count fixed. This isolates behavioral complexity from volume.

Why not just…?

Why not just wait for a small amount of real history? This is the most serious threat. If Trace2Inv trained on the first 50 real transactions already matches full history, synthetic traces add little. The $n$-sweep answers this directly. If short real windows suffice for every template family, we will report that and recast the contribution as a measurement of how long the "cold-start window" actually lasts. Several exploits in the Trace2Inv set occurred early in their contracts' lives, and those cases are the ones that decide the question.

Why not just use InvSol's EvoSuite tests? InvSol reports missing Time Lock, Oracle Slippage and Money Flow invariants. Its Java translation also cannot faithfully represent delegate calls and cross-contract reentrancy. We include it as a baseline. If it matches our richest generator's exchange rate on every template family, then behavioral simulation is unnecessary and our hypothesis is false.

Why not just deploy only the templates that need no bounds? Access-control templates, such as restricting callers to human-owned accounts, may need little data, and they may account for much of the 20/27. The naive baseline measures exactly how many hacks such templates block alone. If that number is close to 20, the case for synthetic bound-learning shrinks to the remaining cases, and we will say so.

Why not just borrow real history from sibling contracts with the same code? Forks and redeployments of the same protocol often share code. Their histories are real data, just not from this contract, so this option is a genuine competitor. We add it as a baseline wherever a sibling exists. We will report whether synthetic traces beat it, match it, or are only useful for contracts with no sibling.

Proposed Experiments and Decisive Checks

The main benchmark is the 42 exploited contracts and 27 hacks from Trace2Inv, which supplies real benign histories and real attacks. A secondary check uses the 37 recently deployed, low-history contracts from InvSol's Ethereum ETL subset. There we measure false positives only on whatever real traffic later arrived. The 143 SmartBugs contracts serve as a sanity check that generated traces exercise the vulnerable functions.

Metrics are:

  • hacks blocked out of 27;
  • false-positive rate on held-out real benign transactions;
  • gas overhead;
  • $e_T(n)$ and the substitutable fraction $f$ for each template family.

One outcome would confirm the proposal. At zero real transactions, the richest generator reaches at least the hacks-blocked count of a modest real window, with false positives within a small factor of 0.28%. Its advantage over the fuzzing-level generator is concentrated in value- and oracle-bound families, and the knob ablation removes it.

Another outcome would refute it. If exchange rates are infinite for bound families at every generator setting, synthetic traces cannot replace history for economic invariants. That is a useful negative result, because it would imply pre-deployment tools like InvSol are limited in principle, not by engineering.

A final check tests whether the method generalizes. We fit exchange rates on half the contracts, then predict which template families will transfer on the other half before running them.