Securing Smart Contract On The Fly

Ao Li, Jemin Andrew Choi, Fan LongarXiv 2019

Abstract

Solythesis is a source-to-source compiler designed to bring runtime validation to Ethereum smart contracts with minimal performance impact. By leveraging the inherent "slack" in blockchain consensus protocols, Solythesis enforces high-level safety invariants, effectively nullifying exploits like integer overflows while maintaining an average CPU overhead of just 0.12%.

Introduction

Smart contracts manage billions in digital assets but are notoriously difficult to secure. Once deployed, their immutability makes patching bugs nearly impossible. Current security methodologies generally fall into two categories: static analysis, which often suffers from high false-positive rates, and formal verification, which is mathematically robust but requires significant manual effort and expertise.

Solythesis proposes a middle ground: runtime validation. While runtime checks typically slow down traditional software, the authors observed that Ethereum's performance is primarily limited by network consensus and disk-heavy storage operations rather than CPU speed. Solythesis utilizes this idle CPU time to run sophisticated security checks without delaying the blockchain's transaction processing.

Methodology

Solythesis operates as a source-to-source Solidity compiler. Developers provide a contract along with a set of invariants—logical rules that must always remain true (e.g., "the sum of all user balances must equal the total supply").

To ensure efficiency, Solythesis implements several core technical innovations:

  • Delta Updates and Checks: Rather than re-calculating complex global rules from scratch, Solythesis instruments code to update running totals incrementally ($O(1)$ complexity).
  • State Variable Caching: Accessing the blockchain's Merkle Patricia Tree storage is expensive. Solythesis identifies frequently accessed variables and caches them in the EVM's faster stack or memory.
  • Invariant Specification Language: A custom language allows developers to express high-level properties using quantifiers (e.g., "For All") and aggregations (e.g., "Sum").

Performance and Throughput Analysis

The evaluation of Solythesis across 23 benchmark contracts (including ERC20, ERC721, and ERC1202) reveals that the tool's overhead is negligible in standard environments. The primary insight is the "Consensus Slack": because Proof-of-Work consensus is a massive bottleneck, the execution engine can perform significantly more work without the user noticing a delay.

Throughput (TPS) comparison across different contract types and consensus scenarios.

As shown in the throughput data, even in a "No Consensus" scenario—which simulates a future high-speed blockchain—Solythesis only reduced transaction throughput by approximately 24%. In the current "Native" Ethereum environment, the impact is virtually imperceptible.

Execution Overhead Breakdown

To understand why Solythesis is so efficient, the authors analyzed the breakdown of execution time. The data confirms that the Merkle Patricia Tree (Storage) remains the secondary bottleneck after consensus.

Breakdown of execution time, highlighting the dominance of storage costs over verification overhead.

In the breakdown above, the "Verifier" (the code added by Solythesis) accounts for a relatively small portion of the total execution time compared to storage operations. By minimizing state accesses through caching and incremental updates, Solythesis ensures that security does not come at the cost of performance.

Security Effectiveness and Limitations

Solythesis successfully prevented real-world exploits during testing, such as the infamous integer overflow in the BEC token. By automatically rejecting transactions that violated the "total supply" invariant, the tool provided a robust safety net.

However, limitations remain. While the time overhead is low, the gas cost (transaction fees) increases because the instrumented contract performs more EVM operations. Additionally, the system still relies on humans to write correct invariants; a flawed invariant results in flawed protection. Future work may involve integrating these optimizations directly into the EVM via hard forks to further reduce costs and improve expressiveness.

Summary updated

BibTeX
@misc{li2019securing,
  author = {Ao Li and Jemin Andrew Choi and Fan Long},
  title = {{Securing Smart Contract On The Fly}},
  year = {2019},
  eprint = {1911.12555},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.12555},
}
Figure