TL;DR
This paper introduces TimeFabric, a novel system for providing trusted, synchronized time to permissioned blockchains. It addresses the challenge of time-dependent smart contracts by enabling peers to reach consensus on time without relying on external oracles, and it introduces a caching mechanism for efficient access to recent transaction histories.
What Problem Does This Paper Address?
Blockchains, particularly permissioned ones like Hyperledger Fabric, are increasingly used for applications requiring more than just transaction ordering and validity. Many financial and marketplace applications need to incorporate time-based logic, such as verifying deadlines, expiry dates, or analyzing activity within a specific time window. Existing blockchain systems struggle with this because:
- Decentralized Time Discrepancies: Different nodes in a distributed network can have slightly different local clocks. This can lead to inconsistent interpretations of time-dependent conditions, causing transactions to be validated differently by different peers.
- Reliance on External Oracles: A common solution is to use external, trusted time oracles. However, this reintroduces a single point of failure and contradicts the decentralized nature of blockchains.
- Inefficient History Retrieval: Accessing historical transaction data to reconstruct an account's state over a time window is computationally expensive, requiring traversal of the entire ledger.
TimeFabric aims to solve these issues by providing a built-in, trusted time reference and an efficient way to query historical data within permissioned blockchain environments.
Methods
TimeFabric introduces two main innovations:
- Trusted Time Consensus: Instead of external oracles, TimeFabric establishes a trusted time reference by assigning a timestamp to each block. This is achieved through a modified validation process:
- Transaction Timestamp Validation: Peers validate that incoming transaction timestamps are within a small, configurable window (δ) of the current trusted time.
- Block Timestamp Assignment: Peers determine the block timestamp based on the validated transaction timestamps within that block. They can use the maximum or median timestamp, with a mechanism to ensure monotonically increasing time even during periods of low transaction activity (using a "heartbeat" mechanism with a dummy client).
- Block Time as Trusted Reference: The timestamp of the latest committed block becomes the network's trusted "current time" for smart contract execution and validation.
- Data Layer Support for Time-Based Transactions: To efficiently query historical data, TimeFabric extends the account-based data model with a cache:
- Cache Database: Each validating peer maintains a cache database that stores key-value pairs, where the key is a concatenation of the original key and the block timestamp of the transaction that updated it.
- Sliding Window Queries: New methods,
GetTimenow()andGetHistoryRangeForKey(key, start, end), are provided to smart contracts.GetStateWindow(key, window_length)is a wrapper that uses these to retrieve a history of values for a given key within a specified time window, leveraging the cache for speed. - Cache Management: The cache is partitioned by time, and older partitions are periodically dropped to manage storage, similar to calendar queues.
These modifications are integrated into Hyperledger Fabric's existing Execute-Order-Validate (EOV) pipeline, primarily affecting the validation step.
Datasets
Not discussed in the paper. The experiments were conducted on a local cluster of six servers.
Key Insights and Ideas
- Decentralized Time is Achievable: The paper demonstrates that a trusted, synchronized time reference can be established within a permissioned blockchain without external dependencies, by leveraging the collective validation of peers.
- Block Timestamp as the Source of Truth: Using the block timestamp as the canonical "current time" simplifies consensus and ensures consistency across all peers.
- Cache for Performance: The introduction of a time-partitioned cache significantly speeds up queries for recent transaction histories, a critical bottleneck for time-dependent smart contracts.
- Minimal Disruption to Fabric: TimeFabric's design integrates smoothly into Hyperledger Fabric's modular architecture, requiring only minor modifications to the validation and commit stages, preserving the ability to swap out consensus algorithms.
- Heartbeat for Time Progression: The "heartbeat" mechanism is an elegant solution to ensure that the trusted time progresses even when the network is idle, preventing time from becoming stale.
Key Results
- Commiter Overhead: TimeFabric introduces a minimal overhead of approximately 3% to the block validation and commit process compared to standard Fabric 1.4.
- Block Time Latency: The latency between an endorser's local clock and the block time was measured. For a block size of 100, the mean latency was under 200 milliseconds. This latency increases with block size but is generally acceptable.
- GetTimenow() Performance: The overhead of calling
GetTimenow()within a smart contract was found to be statistically insignificant. - GetStateWindow() Performance: TimeFabric's
GetStateWindow()method demonstrated a significant performance improvement over Fabric'sGetHistoryForKey(). For a window of 200 historical values, TimeFabric was nearly twice as fast. The performance ofGetStateWindow()increased only slightly with window length, unlike Fabric's method which degraded considerably.
Limitations and Future Work
- Heartbeat Configuration: The paper notes that the frequency of heartbeat transactions (set to every two seconds in their implementation) needs careful consideration to balance time progression with network load.
- δ Parameter Tuning: The parameter δ, which defines the acceptable window for transaction timestamps, needs to be chosen appropriately to avoid rejecting legitimate transactions while preventing manipulation.
- Future Work: The authors plan to explore new applications that can leverage TimeFabric's capabilities, particularly in areas like finance, retail, supply chains, and online auctions. They also aim to investigate how to further optimize the cache management and explore its use in other time-related smart contract functionalities.
Summary updated