GRuB: Gas-Efficient Blockchain Storage via Workload-Adaptive Data Replication

Kai Li, Yuzhe Richard Tang, Qi Zhang, Cheng Xu, Jianliang XuarXiv 2019

Introduction

Smart contracts are isolated by design, necessitating "data feeds" (e.g., price updates for stablecoins or block headers for cross-chain swaps) to interact with external environments. However, managing these feeds presents a significant financial challenge. Storing data directly on-chain is prohibitively expensive due to Ethereum "Gas" fees, while keeping it entirely off-chain requires a costly transaction every time a contract needs to "fetch" a value.

The core issue is that real-world workloads are rarely static. A price feed might be updated frequently but read rarely (write-intensive), or it might experience a surge of reads during market volatility (read-intensive). Existing solutions typically employ static placement—either always on-chain or always off-chain—which inevitably leads to excessive costs when workload patterns shift. GRuB (Gas-efficient Replication under Blockchain) addresses this by treating blockchain and cloud storage as a tiered memory hierarchy, dynamically moving data to optimize for cost.

System Architecture

GRuB introduces a hybrid storage framework that balances the security of the blockchain with the cost-efficiency of off-chain storage.

The GRuB hybrid storage architecture, featuring a Storage Manager smart contract and an off-chain Cloud Storage Provider.

The architecture consists of several key components:

  1. Hybrid Storage Layer: Data is primarily stored on an untrusted off-chain Cloud Storage Provider (SP). A "Storage Manager" smart contract on-chain acts as a dynamic cache.
  2. Data Owner (DO): The DO monitors workload patterns and makes replication decisions off-chain to minimize Gas consumption.
  3. Security via Authenticated Data Structures (ADS): To ensure data integrity from the untrusted SP, GRuB utilizes Merkle trees. When data is fetched from the cloud, it is accompanied by a cryptographic proof that the Storage Manager verifies against a root hash stored on-chain.

Workload-Adaptive Replication

The heart of GRuB is its ability to adapt to changing read/write ratios for individual data records. If a record is read frequently, it is "replicated" to the blockchain's permanent storage, making subsequent reads significantly cheaper. Conversely, if a record is mostly updated without being read, the on-chain replica is evicted to avoid high update costs.

Cost analysis showing the crossover point between on-chain and off-chain storage based on the read-to-write ratio.

The system identifies a clear "break-even" point. On Ethereum, if a piece of data is read more than approximately 1.5 times for every update, storing it on-chain becomes more economical than repeatedly fetching it from the cloud. GRuB employs two primary online algorithms to manage this:

  • Memoryless Algorithm: A counter-based approach that triggers replication after a fixed number of consecutive reads.
  • Memorizing Algorithm: A more sophisticated approach that uses historical windows to handle "spiky" or temporal workloads more effectively.

The authors prove these algorithms are "2-competitive," meaning their cost is guaranteed to be no more than twice that of an "optimal offline" algorithm with perfect future knowledge.

Evaluation and Results

The researchers evaluated GRuB using real-world traces from the MakerDAO ethPriceOracle, synthetic YCSB benchmarks, and a custom BtcRelay benchmark for cross-chain feeds.

Key findings include:

  • Significant Gas Savings: In mixed YCSB workloads, GRuB reduced Gas costs by 10% to 74% compared to static baselines.
  • Real-world Robustness: Against the MakerDAO price feed trace, GRuB consistently maintained the lowest cost per operation, effectively navigating market demand fluctuations.
  • Scalability: The benefits of adaptive replication scale with data record size, as the relative cost of on-chain updates becomes more dominant.

Limitations and Future Work

While GRuB offers substantial improvements, it currently assumes a trusted Data Owner (DO). While the Cloud SP is untrusted and verified via ADS, a malicious DO could theoretically provide incorrect updates. Future work may explore decentralized decision-making or machine learning models to further refine workload prediction and push the competitive ratio closer to the theoretical optimum. Additionally, tuning the "Memorizing" algorithm's time-window parameter is crucial to avoid "thrashing" (rapid replication and eviction).

Summary updated

Abstract

Feeding external data to a blockchain, a.k.a. data feed, is an essential task to enable blockchain interoperability and support emerging cross-domain applications, notably stablecoins. Given the data-intensive feeds in real life (e.g., high-frequency price updates) and the high cost in using blockchain, namely Gas, it is imperative to reduce the Gas cost of data feeds. Motivated by the constant-changing workloads in finance and other applications, this work focuses on designing a dynamic, workload-aware approach for cost effectiveness in Gas. This design space is understudied in the existing blockchain research which has so far focused on static data placement. This work presents GRuB, a cost-effective data feed that dynamically replicates data between the blockchain and an off-chain cloud storage. GRuB's data replication is workload-adaptive by monitoring the current workload and making online decisions w.r.t. data replication. A series of online algorithms are proposed that achieve the bounded worst-case cost in blockchain's Gas. GRuB runs the decision-making components on the untrusted cloud off-chain for lower Gas costs, and employs a security protocol to authenticate the data transferred between the blockchain and cloud. The overall GRuB system can autonomously achieve low Gas costs with changing workloads. We built a GRuB prototype functional with Ethereum and Google LevelDB, and supported real applications in stablecoins. Under real workloads collected from the Ethereum contract-call history and mixed workloads of YCSB, we systematically evaluate GRuB's cost which shows a saving of Gas by 10% ~ 74%, with comparison to the baselines of static data-placement.
BibTeX
@misc{li2019grub,
  author = {Kai Li and Yuzhe Richard Tang and Qi Zhang and Cheng Xu and Jianliang Xu},
  title = {{GRuB: Gas-Efficient Blockchain Storage via Workload-Adaptive Data Replication}},
  year = {2019},
  eprint = {1911.04078},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1911.04078},
}
Figure