The Data Tier: The Database (State Machine) of TApps

Two State Categories: An Eventually Consistent CRDT Database and a Strongly Consistent State Machine

According to the needs of their specific business logic, the many TApp applications running on the TEA network actually have two state categories:

  • A strong-consistency state machine based on Proof of Time.
  • An eventually consistent CRDT database built on OrbitDB that can be used ad hoc by TApps.

Strong Consistency State Machine

Type A, B, & C CML on the TEA network
  • It is not necessary for all nodes to periodically reach a consensus on the latest block. But in order to ensure that most replications can be synchronized to a consistent state, the TEA Project’s state machine requires a short waiting queue due to network latency. For example, an earlier timestamped transaction may arrive to a node after other later transactions due to issues with network traffic. But eventually all nodes will have the same transaction order.
  • When more than 50% of nodes can no longer adjust the order transactions in the queue, these transactions becomes immutable and are then sent to the state machine for processing. This is called the conveyor belt algorithm and ensures that the state machine will eventually reach strong consistency. A similar consensus model that also uses physical time for sharding and is able to achieve large-capacity processing is Google Spanner.

The Eventually Consistent CRDT Database

For apps that can tolerate short-term inconsistency but still eventually achieve consistency, the ideal is the CRDT algorithm. CRDT (conflcit-free replication data type) allows conflict-free mergers between different replications and ultimately achieves network-wide consistency. In fact, the business logic of most apps can tolerate short-term inconsistencies to achieve both decentralization and efficiency, which is why we can use an OrbitDB database to track these short-term changes. A typical example of a traditional cloud app that deals with this issue gracefully is Google Docs.

  • CRDT is fast as it has no time delay and doesn’t wait for others. Allowances are made for new transaction reports which are added non-destructively. This is in contrast to the TEA Project’s strong consistency state machine which must wait a minimum amount of time for confirmation.
  • CRDT storage cost is cheap, relying on IPFS for decentralized hard drive storage instead of the more expensive RAM storage.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store