Smart Consistency - solving block and mempool inconsistency

Lava Vision and How it Works
Kagemni Karimu
Jan 26, 2024

Introduction

This article is a condensed version of our long-form research publications. You can see a more in depth version of this article on our research forum here: https://community.lavanet.xyz/t/rsch-1005-smart-consistency/34

Blockchain technology, characterized by distributed storage systems, confronts the inherent challenges of the CAP theorem, which posits a trade-off between consistency, availability, and partition tolerance in such systems. This article delves into how the Lava protocol addresses these challenges through its Smart Consistency mechanism, moving beyond traditional stickiness approaches to ensure both mempool and block consistency.

The CAP Theorem and Stickiness

In blockchain, the CAP theorem's implications are particularly critical. The theorem suggests that in the event of a network partition, a system must choose between dropping requests (compromising availability) or presenting stale data (compromising consistency). Traditional web3 solutions often rely on stickiness—where a data consumer repeatedly interacts with the same node—to maintain consistency. However, this approach sacrifices partition tolerance and comes with its own set of drawbacks, including limited scalability and uneven resource utilization.

CAP Theorem Explained

Smart Consistency: An Overview

Lava protocol's Smart Consistency offers an alternative strategy. It employs accountability measures, message parsing, and metadata analysis on a relay-by-relay basis, enabling predictions on which providers are likely to deliver the most appropriate response. This allows for a more inclusive range of providers without the drawbacks of stickiness.

Block Inconsistency and Mempool Inconsistency

The Lava protocol addresses two primary types of inconsistency:

1. Block Inconsistency: This occurs when nodes have different states in the blockchain, often due to network delays, forks, or malicious activities. It results in inconsistent or unavailable responses.

Block Inconsistency

2. Mempool Inconsistency: This refers to discrepancies in the local state of nodes (i.e., their memory pools), impacting nonce order and potentially leading to transaction collisions or invalid transactions.

Untitled (40)

Addressing Block Inconsistency

To mitigate block inconsistency, the Lava protocol employs a three-step process:

  • Consumer Mechanism (Provider Optimization): Consumers use a Provider Optimizer to determine the optimal provider based on various factors, including the last seen block, requested block, and provider data. This calculation helps select a provider likely to offer the freshest block.
  • Provider Mechanism (Handle Consistency Function): Providers evaluate their ability to return necessary data before responding. They assess whether their latest block is sufficient to meet the consumer's needs and decide between providing a response or waiting to sync to the required block height.
  • Consumer Mechanism (Finalization Verification): Consumers verify the finalization proof in provider responses to ensure data accuracy and prevent misrepresentation.
Equation 2
Incomplete Inverse Upper Gamma Function used by Providers to predict blockchain state / block advancement rate

Addressing Mempool Inconsistency

Mempool inconsistency is tackled through request propagation. Changes in a provider's local state are propagated to all providers in a consumer's pairing list for a given epoch. This ensures all providers accessed by a consumer share the same mempool information, thereby maintaining consistency.

Advantages of Smart Consistency

Smart Consistency offers several benefits over traditional stickiness:

  • Diverse Provider Inclusion: It allows for a broader range of providers, enhancing network efficiency and reducing centralization risks.
  • Improved Data Freshness: By optimizing provider selection and verifying data accuracy, Smart Consistency ensures more up-to-date and reliable responses.
  • Scalability and Resource Utilization: Unlike stickiness, Smart Consistency promotes more balanced resource distribution across the network, aiding scalability.