- December 28, 2018
- Posted by: iygmg
- Category: Computational DAG, Programming Model, Smart Contract
The Computational DAG (directed acyclic graph) directly mimics the programming model, using several innovations to create an unforgeable, persistent, and verifiable history of Contract execution. The DAG consists of Contracts, Actions, States, Inputs, Outputs, Signatures, and Coins.
Object Keys and Object Hashes
Object keys and object hashes form a unique linking structure in the DAG. Each object has a unique key. Some of the keys are hashes of other keys which create a forward linking (hash chain) structure in the DAG. Hashes of object content are used to point backward to existing objects in the DAG. This gives the Computational DAG several important properties:
- Consensus protocols can be simplified, due to the linking structure of the DAG.
- Keys can detect certain types of attacks, such as double spend and replay attacks.
- If you have access to any object in the Computational DAG, you can easily get to any other object in the DAG. This makes contracts and contract operations easy to verify, including tracing back to the origin of any Coin.
When a Template is instantiated as a Contract, it is given a unique key. Each Action that is executed on the Contract is given a key that is the hash of either the Contract key, or the last Action key executed on the Contract. This creates a forward linking structure in the DAG. Each new Action has a hash of either the previous Action or a hash of the Contract instance, forming a backward chain.
A consumed Output is called an Input, which is signed by the Ledger of the owner of the Output, and sent to an Action. The key of the Input is the hash of the Output key. The existence of an Input for an Output means that the Output was consumed and is no longer available.
Inputs, Outputs, and States contain a hash of the Action that either consumed or produced them.
This locks the DAG together in an eternal embrace. No part of the DAG can be modified without modifying the entire DAG!
Outputs and the Contract state can contain any number of Tokens or Coins. When Tokens are Output from an Action, the totals for each Token are checked. The total Output for a Token cannot exceed the total Input for the same Token over the life of the Contract. This is just simple accounting enforced on Contracts.
The Computational DAG is portable, in that it is independent of any blockchain or consensus platform. Hence, it could be used as a common Smart Contract programming method.