Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
118 lines (99 sloc) 5.69 KB
oip title author discussions-to status type category (*only required for Standard Track) created requires (*optional) replaces (*optional)
8
Anchor - Immutably Archived State Roots
Martin Schenck (@schemar) <martin@ost.com>
Draft
Standards Track
Mosaic
2019-01-17
none
none

Anchor - Immutably Archived State Roots

Simple Summary

By copying state roots in between blockchains, we can assert state of each blockchain on the respective other chain.

Abstract

Anchoring a state root means storing the state root of a blockchain on another blockchain. The blockchain where the state root is from is therefore an anchored blockchain.

Storing the state root on a blockchain archives it immutably. Anyone can use the anchored state root to prove the state of the anchored blockchain on the blockchain where the state root is anchored.

As an example, we can use an anchor to prove, on-chain, that a certain state was included in the other, anchored chain. This way, we can for example prove, that a staker has staked a specific amount on origin and can mint the corresponding tokens on auxiliary.

Motivation

The anchor is an alternative to a mosaic core. It radically simplifies the process of how state roots are shared across chains. Instead of mosaic's set of staked PoS validators, the anchor relies solely on an organization to provide state roots across chains.

Depending on the use-case, an anchor or a mosaic core may be preferred. An anchor makes it much, much easier to deploy a side chain as compared to a mosaic core.

Specification

An Anchor provides a method to anchor a state root. It also implements the StateRootInterface to make the state root later available on-chain.

/**
 *  @notice Anchor new state root for a block height.
 *
 *  @param _blockHeight Block height at which the state root was valid.
 *  @param _stateRoot State root at given block height.
 *
 *  @return succes_ Whether anchoring was successful.
 */
function anchorStateRoot(
    uint256 _blockHeight,
    bytes32 _stateRoot
)
    external
    onlyOrganization
    returns (bool success_);
interface StateRootInterface {

    /**
     * @notice Gets the block number of latest committed state root.
     *
     * @return height_ Block height of the latest committed state root.
     */
    function getLatestStateRootBlockHeight()
        external
        view
        returns (uint256 height_);

    /**
     * @notice Get the state root for the given block height.
     *
     * @param _blockHeight The block height for which the state root is fetched.
     *
     * @return bytes32 State root at the given height.
     */
    function getStateRoot(uint256 _blockHeight)
        external
        view
        returns (bytes32 stateRoot_);

}

Rationale

The method anchorStateRoot is kept simple on purpose. The state root and the height of the block that contains that state root are sufficient to prove a certain state at a certain height. A relevant state to prove could be the fact that value was locked into a gateway or co-gateway.

We decided to implement the StateRootInterface with the Anchor as this enables interchangeability between implementations that provide the state root to other contracts, for example the gateway or co-gateway.

An alternative to the anchor is a mosaic core. The main difference is that the mosaic core requires a set of staked validators. The anchor on the other hand requires only an "organization" to anchor a state root.

Implementation

https://github.com/OpenSTFoundation/mosaic-contracts/blob/develop/contracts/gateway/Anchor.sol