Corda - open source blockchain for business

    Corda is a distributed ledger for storing, managing and synchronizing financial obligations between various financial institutions.

    Corda has pretty good documentation with video lectures, which can be found here . I will try to briefly describe how Corda is built inside.

    Consider the main features of Corda and its uniqueness among other blockchains:

    • Corda does not have its own cryptocurrency.
    • Corda does not use the mining concept and the Proof-of-Work system.
    • Data transfer occurs only between participants of the transaction / contract. There is no global broadcasting to all network nodes.
    • There is no central controller that manages all transactions.
    • Corda supports various consensus mechanisms.
    • Consensus is reached between participants at the level of a separate agreement / contract, and not at the level of the entire system.
    • A transaction is confirmed only by the participants related to it.
    • Corda offers a direct link between formal human legal language and smart contract code.

    The ledger


    The concept of ledger in Corda is subjective. There is no single central data warehouse. Instead, each node maintains a separate database of facts known to it.

    For example, imagine a network of 5 nodes, where the circle is a fact known to the node.



    As we can see, Ed, Carl and Demi know about fact 3, and Alice and Bob do not even suspect him. Corda guarantees the preservation of general facts in the database of each node, and the data will be identical.

    States


    A state is an immutable object, which is a fact known to one or more network nodes at a particular point in time.

    States can store arbitrary data, for example, stocks, bonds, loans, identification information.

    For example, the following state is an IOU - an agreement that Alice owes Bob the amount of X:


    The life cycle of a fact over time is represented by a sequence of states. When it is necessary to update the current state, we create a new one, and mark the current one as historical.



    Transactions


    Transactions are suggestions for updating ledger-a. They are not broadcast to all ledger participants and are available only to those network members who have the legal right to view and manage them.

    A transaction will be added to ledger if it:

    • contract valid
    • signed by all necessary participants
    • does not contain double wastes (doble-spends)

    Corda uses the UTXO (unspent transaction output) model, in which each ledger state is immutable.

    When a transaction is created, the input state of the previous transaction (by hash and index) is transmitted to the input.


    Transaction Lifecycle:

    • Creation (At the moment, the transaction is just a proposal to upgrade ledger-a)
    • Signature collection (Required participants in the transaction approve the update proposal by adding a signature to the transaction)
    • Transmit commit in ledger

    After adding a transaction to ledger, the input states are marked as historical and cannot be used in future transactions.


    In addition to input and output states, a transaction may contain:

    • Commands (transaction parameter indicating the purpose of the transaction)
    • Attachments (holiday calendar, currency converter)
    • Temporary windows (validity period)
    • Notary (Notary, special network members, validating transactions)


    Contracts


    When we talk about transaction validity, we mean not only the availability of the necessary signatures, but also contract validity. Each transaction is associated with a contract that accepts it and validates input and output states. A transaction is considered valid only if all its states are valid.

    Contracts in Corda are written in any JVM language (for example, Java, Kotlin).

    class CommercialPaper : Contract {
        override fun verify(tx: LedgerTransaction) {
            TODO()
        }
    }
    

    You must inherit from the Contract class and override the verify method . In case of invalid validation, an exception is thrown.

    Vadidation of transactions must be deterministic, i.e. The contract must always either accept or decline the transaction. In connection with this, the validity of the transaction cannot depend on time, random numbers, host files, etc.

    In Corda, contracts are executed in the so-called sandbox - a slightly modified JVM that guarantees deterministic execution of contracts.

    Streams


    To automate the communication of hosts, threads have been added.

    A stream is a sequence of steps that tells the node how to perform a specific ledger update, at which point it is necessary to sign and validate the transaction.



    Sometimes it takes hours, days until the transaction is signed by all parties and ends up in ledger. What happens if you disconnect the node involved in the transaction? Streams have breakpoints at which the state of the stream is written to the node database. When restoring a node in the network, it will continue from the place where it stopped.

    Consensus


    To get into ledger, a transaction must reach 2 consensus: on validity and on uniqueness.

    The decision on the validity of a transaction is made only by the parties directly involved.

    Notarized nodes verify the transaction for uniqueness, prevent double spending.

    Suppose Bob has $ 100, and he wants to transfer $ 80 to Charlie and $ 70 to Dan using the same input state.



    Such a trick Corda will not allow to crank. Although the transaction will pass a validation check, the uniqueness check will fail.

    Conclusion


    The Corda platform, developed by the R3 blockchain consortium, is not a pure example of the use of blockchain technology. Corda is a highly specialized tool for financial institutions.

    Also popular now: