Corda - open source blockchain for business

Rope is a distributed Ledger for storing, managing and synchronizing financial obligations between various financial institutions.
Corda - open source blockchain for business
Corda has pretty good documentation with video lectures that you can find here. I will try to briefly describe how Corda works 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 concept of mining and the Proof-of-Work system.
  • Data transfer occurs only between the participants of the transaction/contract. There is no global broadcasting to all network nodes.
  • There is no central controller managing all transactions.
  • Corda supports various consensus mechanisms.
  • Consensus is reached between the participants at the level of an individual agreement/contract, and not at the level of the entire system.
  • The 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.

Corda - open source blockchain for business

As we can see, Ed, Carl and Demi are aware of fact 3, while Alice and Bob are not even aware of it. Corda guarantees that the common facts are stored in the database of each node, and the data will be identical.

States

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

States can store arbitrary data, such as stocks, bonds, loans, and identification information.

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

Corda - open source blockchain for business
The life cycle of a fact over time is represented by a sequence of states. When we need to update the current state, we create a new one and mark the current one as historical.

Corda - open source blockchain for business

  Transactions

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

A transaction will be added to the ledger if it:

  • contractually valid
  • signed by all required participants
  • does not contain double spending (doble-spends)

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

When creating a transaction, the state of the previous transaction (by hash and index) is passed to the output as input.

Corda - open source blockchain for business
Transaction lifecycle:

  • Creation (At the moment, the transaction is just a proposal to update the ledger)
  • Collection of signatures (Required participants in the transaction approve the update proposal by adding a signature to the transaction)
  • Commit transaction in ledger

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

Corda - open source blockchain for business
In addition to input and output states, a transaction can contain:

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

Corda - open source blockchain for business

Contracts.

When we talk about the validity of a transaction, we mean not only the presence of the necessary signatures, but also the validity of the contract. Each transaction is associated with a contract that accepts it and validates the input and output states. A transaction is considered valid only if all of 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()
    }
}

Must be inherited from a class Contract and override the method verify. Throw an exception if the transaction is invalid.

Transaction vadidation must be deterministic, i.e. the contract must always either accept or reject the transaction. In connection with this, the validity of a transaction cannot depend on time, random numbers, host files, etc.

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

Streams

To automate the communication of network nodes, flows have been added.

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

Corda - open source blockchain for business

Sometimes it takes hours, days until the transaction is signed by all parties and gets into the ledger. What happens if you disable the node participating in the transaction? Threads have checkpoints, at which the state of the thread is written to the host database. When a node is restored to the network, it will continue where it left off.

Consensus

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

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

Notary nodes check the transaction for uniqueness and prevent double spending.

Let's say Bob has $100 and wants to transfer $80 to Charlie and $70 to Dan using the same input state.

Corda - open source blockchain for business

This Corda trick won't let you do it. Although the transaction will pass the validation check, the uniqueness check will fail.

Conclusion

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

Source: habr.com

Add a comment