Optimistic Contracts

Allowing for cheaper data submission when validation is expensive

At Devcon4, Richard Moore, Nick Johnson and I got into a conversation about counterfactuality and what that means in the context of smart contracts that are trying to find efficient schemes for validating data on-chain. We realized that there is another model for smart contracts that is not really counterfactual. Counterfactual smart contracts are contracts where things could be happening on-chain but do not. They allow any participant in a transaction to make something happen on-chain, meaning participants can act as though a transaction happened on-chain without it happening on-chain. For a more in-depth description, check out the terminology section of the “Counterfactual: Generalized State Channels on Ethereum” blog post. After a bit of discussion, Nick coined the term “optimistic contracts”, inspired by Georgios Konstantopoulos’ Plasma Cash talk at devcon.

So what are optimistic contracts?

In short they are contracts that accept all information as fact until proven to be non-factual. This allows for a reduction in the cost of verifying data, as on-chain verification would only be necessary when one is sure that the data is false.

We can incentivize this type of fact checking with a bond and slash model.

The 2 types of optimists

Immediate Optimist: The immediate optimist is an optimistic smart contract that accepts the submission of data immediately, and keeps the stake allowing slashing to happen at any time.

This of course can be limited by saying that slashing is allowed for a certain period of time after data was accepted and after which the stake can be claimed back by the submitter.

A timeline of an immediate optimist with a limited slashing period.

Deferred Optimist: The second type of optimist is one that accepts data submissions, there is then a slashing period within which any challenger can try and win the stake. The data is not yet committed. After the challenge period the data can be committed and the stake is returned to the submitter.

The deferred optimist is best used when we need to ensure that all data submitted is correct, waiting before committing helps mitigate false data being stored temporarily.

A timeline of the deferred optimist with submission after the slashing period.

Service Provider Model

In certain scenarios the stakes required for data submission might be too high for certain users to carry, in this case we propose a service provider model to allow for submission through a third party.

The third party would provide the assets required for the actual data submission and handle everything on their end, such as submitting the actual data. Users in turn would pay a minor fee to the service provider that is smaller than the fee required to submit the data.

In turn these service providers would make a profit by being watchtowers and slashing data they have found to be incorrect submitted by others. An interesting point to make, is that if data is valid we defer computation from all full nodes to just one economically incentivized verifier. Making all full nodes perform the computation has bad economic consequences for the submitter.

Generic Optimists Library

To aid in the development of optimistic contracts, I have created a generic library which should allow developers to create many types of optimists. The code is still a work in development, but make sure to check it out here.

In order to present a real use case, a proof of concept version of ENS’s dns registrar has been implemented in an optimistic manner. Allowing for proofs to be submitted in a far cheaper way. The code can be found on github.