📜 ⬆️ ⬇️

Corda - open source blockchain for business

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

Corda has quite good video lecture documentation that can be found here . I will try to briefly describe how Corda is arranged inside.

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


The ledger


The concept of ledger in Corda is subjective. There is no single central data repository. Instead, each node maintains a separate database of facts known to it.
')
For example, imagine a network of 5 nodes, where a circle is a fact known to a node.



As we see, Ed, Carl and Demi know about fact 3, and Alice and Bob don't even suspect him. Corda ensures that common facts are saved to the base of each node, and the data will be identical.

States


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

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

For example, the following state is an IOU — an agreement that Alice owes Bob the sum 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 historic.



Transactions


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

A transaction will be added to the ledger if it:


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

At creation, a transaction for entry transmits the output state of the previous transaction (by hash and index).


Transaction life cycle:


After adding a transaction to the 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:



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 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 non-validity of the transaction, an exception is thrown.

Transaction wadding 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, network 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 hosts, streams have been added.

A flow 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 falls into the ledger. What happens if you disable the node involved in the transaction? Threads have checkpoints in which the state of the thread is written to the node database. When restoring a node in the network, it will continue from where it left off.

Consensus


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

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

The notary nodes check the transaction for uniqueness, prevent double spending.

Imagine that Bob-a has $ 100, and he wants to transfer $ 80 Charlie and $ 70 Dan-y, using the same input state.



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

Conclusion


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

Source: https://habr.com/ru/post/452258/


All Articles