mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
Key Concepts rewrite for open source day (#7)
First draft Re-structured Key Concepts; added plenty of diagrams; additional content. Added references to other security docs. Re-structured Key Concepts; added plenty of diagrams; additional content. Added references to other security docs. Updated information, indexes and images. Incorporated feedback from PR review comments (RGB, RW) Reformatted diagrams and incorporated feedback from PR reviewers. Addressed formatting problems. Updated Flow Framework diagram Added colour coding to Flow Framework diagram to aid readibility. Small clarification to vault unconsumed state usage. Added tutorial reference as suggested by RGB Updated TOC tree. Updates following PR review comment from Roger First pass updates following PR review comments from MH. Further updates following PR review (including 2 edited diagrams) Diagram changes and minor text edits following review with MGB Remove unused diagrams. Fixed spurious indentation errors. Changes following review and feedback from JD. Added clauses and merkle-trees back into TOC. Added small sub-section on transaction representation in Data Model. Added future work as note in Vault. Minor updates to diagrams following MH review. Updated Corda Ecosystem diagram. Minor changes to Core & Financial docs following PR review by MH. Updated following review by MBG.
This commit is contained in:
parent
1362a305c9
commit
ac1d14464c
@ -1,141 +0,0 @@
|
||||
Consensus model
|
||||
===============
|
||||
|
||||
The fundamental unit of consensus in Corda is the **state**. The concept of consensus can be divided into two parts:
|
||||
|
||||
1. Consensus over state **validity** -- parties can reach certainty that a transaction defining output states is accepted by the contracts pointed to by the states and has all the required signatures. This is achieved by parties independently running the same contract code and validation logic (as described in :doc:`data model <data-model>`)
|
||||
|
||||
2. Consensus over state **uniqueness** -- parties can reach certainty the output states created in a transaction are the unique successors to the input states consumed by that transaction (in other words -- a state has not been used as an input by more than one transaction)
|
||||
|
||||
This article presents an initial model for addressing the **uniqueness** problem.
|
||||
|
||||
.. note:: The current model is still a **work in progress** and everything described in this article can and is likely to change
|
||||
|
||||
Notary
|
||||
------
|
||||
|
||||
We introduce the concept of a **notary**, which is an authority responsible for attesting that for a given transaction, it had not signed another transaction consuming any of its input states.
|
||||
The data model is extended so that every **state** has an appointed notary:
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
/**
|
||||
* A wrapper for [ContractState] containing additional platform-level state information.
|
||||
* This is the definitive state that is stored on the ledger and used in transaction outputs
|
||||
*/
|
||||
data class TransactionState<out T : ContractState>(
|
||||
/** The custom contract state */
|
||||
val data: T,
|
||||
/** Identity of the notary that ensures the state is not used as an input to a transaction more than once */
|
||||
val notary: Party) {
|
||||
...
|
||||
}
|
||||
|
||||
All transactions have to be signed by their input state notary for the output states to be **valid** (apart from *issue* transactions, containing no input states).
|
||||
|
||||
.. note:: The notary is a logical concept and can itself be a distributed entity, potentially a cluster maintained by mutually distrusting parties
|
||||
|
||||
When the notary is requested to sign a transaction, it either signs over it, attesting that the outputs are the **unique** successors of the inputs,
|
||||
or provides conflict information for any input state that had been consumed by another transaction it had signed before.
|
||||
In doing so, the notary provides the point of finality in the system. Until the notary signature is obtained, parties cannot be sure that an equally valid, but conflicting transaction,
|
||||
will not be regarded as confirmed. After the signature is obtained, the parties know that the inputs to this transaction have been uniquely consumed by this transaction.
|
||||
Hence it is the point at which we can say finality has occurred.
|
||||
|
||||
Multiple notaries
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
More than one notary can exist in the network. This gives the following benefits:
|
||||
|
||||
* **Custom behaviour**. We can have both validating and privacy preserving notaries -- parties can make a choice based on their specific requirements
|
||||
* **Load balancing**. Spreading the transaction load over multiple notaries will allow higher transaction throughput in the platform overall
|
||||
* **Low latency**. Latency could be minimised by choosing a notary physically closer the transacting parties
|
||||
|
||||
A transaction should only be signed by a notary if all of its input states point to it.
|
||||
In cases where a transaction involves states controlled by multiple notaries, the states first have to be repointed to the same notary.
|
||||
This is achieved by using a special type of transaction that doesn't modify anything but the notary pointer of the state.
|
||||
Ensuring that all input states point to the same notary is the responsibility of each involved party
|
||||
(it is another condition for an output state of the transaction to be **valid**)
|
||||
|
||||
Changing notaries
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
To change the notary for an input state, use the ``NotaryChangeFlow``. For example:
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
@Suspendable
|
||||
fun changeNotary(originalState: StateAndRef<ContractState>,
|
||||
newNotary: Party): StateAndRef<ContractState> {
|
||||
val flow = NotaryChangeFlow.Instigator(originalState, newNotary)
|
||||
return subFlow(flow)
|
||||
}
|
||||
|
||||
The flow will:
|
||||
|
||||
1. Construct a transaction with the old state as the input and the new state as the output
|
||||
|
||||
2. Obtain signatures from all *participants* (a participant is any party that is able to consume this state in a valid transaction, as defined by the state itself)
|
||||
|
||||
3. Obtain the *old* notary signature
|
||||
|
||||
4. Record and distribute the final transaction to the participants so that everyone possesses the new state
|
||||
|
||||
.. note:: Eventually this will be handled automatically on demand.
|
||||
|
||||
Validation
|
||||
----------
|
||||
|
||||
One of the design decisions for a notary is whether or not to **validate** a transaction before committing its input states.
|
||||
|
||||
If a transaction is not checked for validity, it opens the platform to "denial of state" attacks, where anyone can build an invalid transaction consuming someone else's states and submit it to the notary to get the states "blocked".
|
||||
However, validation of a transaction requires the notary to be able to see the full contents of the transaction in question and its dependencies.
|
||||
This is an obvious privacy leak.
|
||||
|
||||
Our platform is flexible and we currently support both validating and non-validating notary implementations -- a party can select which one to use based on its own privacy requirements.
|
||||
|
||||
.. note:: In the non-validating model the "denial of state" attack is partially alleviated by requiring the calling
|
||||
party to authenticate and storing its identity for the request. The conflict information returned by the notary
|
||||
specifies the consuming transaction ID along with the identity of the party that had requested the commit. If the
|
||||
conflicting transaction is valid, the current one gets aborted; if not - a dispute can be raised and the input states
|
||||
of the conflicting invalid transaction are "un-committed" (to be covered by legal process).
|
||||
|
||||
.. note:: At present all notaries can see the entire contents of a transaction, but we have a separate piece of work to
|
||||
replace the parts of the transaction it does not require knowing about with hashes (only input references, timestamp
|
||||
information, overall transaction ID and the necessary digests of the rest of the transaction to prove that the
|
||||
referenced inputs/timestamps really do form part of the stated transaction ID should be visible).
|
||||
|
||||
Timestamping
|
||||
------------
|
||||
|
||||
In this model the notary also acts as a *timestamping authority*, verifying the transaction timestamp command.
|
||||
|
||||
For a timestamp to be meaningful, its implications must be binding on the party requesting it.
|
||||
A party can obtain a timestamp signature in order to prove that some event happened before/on/or after a particular point in time.
|
||||
However, if the party is not also compelled to commit to the associated transaction, it has a choice of whether or not to reveal this fact until some point in the future.
|
||||
As a result, we need to ensure that the notary either has to also sign the transaction within some time tolerance,
|
||||
or perform timestamping *and* notarisation at the same time, which is the chosen behaviour for this model.
|
||||
|
||||
There will never be exact clock synchronisation between the party creating the transaction and the notary.
|
||||
This is not only due to physics, network latencies, etc., but because between inserting the command and getting the
|
||||
notary to sign there may be many other steps, like sending the transaction to other parties involved in the trade
|
||||
as well, or even requesting human signoff. Thus the time observed by the notary may be quite different to the
|
||||
time observed in step 1.
|
||||
|
||||
For this reason, times in transactions are specified as time *windows*, not absolute times. Time windows can be
|
||||
open-ended, i.e. specify only one of "before" and "after" or they can be fully bounded. If a time window needs to
|
||||
be converted to an absolute time for e.g. display purposes, there is a utility method on ``Timestamp`` to
|
||||
calculate the mid point -- but in a distributed system there can never be "true time", only an approximation of it.
|
||||
|
||||
In this way we express that the *true value* of the fact "the current time" is actually unknowable. Even when both before and
|
||||
after times are included, the transaction could have occurred at any point between those two timestamps. Here
|
||||
"occurrence" could mean the execution date, the value date, the trade date etc ... the notary doesn't care what precise
|
||||
meaning the timestamp has to the contract.
|
||||
|
||||
By creating a range that can be either closed or open at one end, we allow all of the following facts to be modelled:
|
||||
|
||||
* This transaction occurred at some point after the given time (e.g. after a maturity event)
|
||||
* This transaction occurred at any time before the given time (e.g. before a bankruptcy event)
|
||||
* This transaction occurred at some point roughly around the given time (e.g. on a specific day)
|
||||
|
||||
.. note:: It is assumed that the time feed for a notary is GPS/NaviStar time as defined by the atomic
|
||||
clocks at the US Naval Observatory. This time feed is extremely accurate and available globally for free.
|
@ -1,275 +0,0 @@
|
||||
Data model
|
||||
==========
|
||||
|
||||
This article covers the data model: how *states*, *transactions* and *code contracts* interact with each other and
|
||||
how they are represented in software.
|
||||
|
||||
Overview
|
||||
--------
|
||||
|
||||
We begin with the idea of a global ledger. In our model although the ledger is shared, it is not always the case that
|
||||
transactions and ledger entries are globally visible. In cases where a set of transactions stays within a small subgroup of
|
||||
users it should be possible to keep the relevant data purely within that group.
|
||||
|
||||
To ensure consistency in a global, shared system where not all data may be visible to all participants, we rely
|
||||
heavily on secure hashes like SHA-256 to identify things. The ledger is defined as a set of immutable **states**, which
|
||||
are created and destroyed by digitally signed **transactions**. Each transaction points to a set of states that it will
|
||||
consume/destroy, these are called **inputs**, and contains a set of new states that it will create, these are called
|
||||
**outputs**.
|
||||
|
||||
States contain arbitrary data, but they always contain at minimum a hash of the bytecode of a
|
||||
**contract code** file, which is a program expressed in JVM byte code that runs sandboxed inside a Java virtual machine.
|
||||
Contract code (or just "contracts" in the rest of this document) are globally shared pieces of business logic.
|
||||
|
||||
.. note:: In the current code dynamic loading of contracts is not implemented, so states currently point at
|
||||
statically created object instances. This will change in the near future.
|
||||
|
||||
Contracts define a **verify function**, which is a pure function given the entire transaction as input. To be considered
|
||||
valid, the transaction must be **accepted** by the verify function of every contract pointed to by the input and output
|
||||
states.
|
||||
|
||||
Beyond inputs and outputs, transactions may also contain **commands**, small data packets that
|
||||
the platform does not interpret itself but which can parameterise execution of the contracts. They can be thought of as
|
||||
arguments to the verify function. Each command has a list of **public keys** associated with it. The platform ensures
|
||||
that the transaction is signed by every key listed in the commands before the contracts start to execute. Thus, a verify
|
||||
function can trust that all listed keys have signed the transaction but is responsible for verifying that any keys required
|
||||
for the transaction to be valid from the verify function's perspective are included in the list. Public keys
|
||||
may be random/identityless for privacy, or linked to a well known legal identity, for example via a
|
||||
*public key infrastructure* (PKI).
|
||||
|
||||
.. note:: Linkage of keys with identities via a PKI is only partially implemented in the current code.
|
||||
|
||||
Commands are always embedded inside a transaction. Sometimes, there's a larger piece of data that can be reused across
|
||||
many different transactions. For this use case, we have **attachments**. Every transaction can refer to zero or more
|
||||
attachments by hash. Attachments are always ZIP/JAR files, which may contain arbitrary content. These files are
|
||||
then exposed on the classpath and so can be opened by contract code in the same manner as any JAR resources
|
||||
would be loaded.
|
||||
|
||||
.. note:: Attachments must be opened explicitly in the current code.
|
||||
|
||||
Note that there is nothing that explicitly binds together specific inputs, outputs, commands or attachments. Instead
|
||||
it's up to the contract code to interpret the pieces inside the transaction and ensure they fit together correctly. This
|
||||
is done to maximise flexibility for the contract developer.
|
||||
|
||||
Transactions may sometimes need to provide a contract with data from the outside world. Examples may include stock
|
||||
prices, facts about events or the statuses of legal entities (e.g. bankruptcy), and so on. The providers of such
|
||||
facts are called **oracles** and they provide facts to the ledger by signing transactions that contain commands they
|
||||
recognise, or by creating signed attachments. The commands contain the fact and the signature shows agreement to that fact.
|
||||
|
||||
Time is also modelled as a fact, with the signature of a special kind of service called a **notary**. A notary is
|
||||
a (very likely) decentralised service which fulfils the role that miners play in other blockchain systems:
|
||||
notaries ensure only one transaction can consume any given output. Additionally they may verify a **timestamping
|
||||
command** placed inside the transaction, which specifies a time window in which the transaction is considered
|
||||
valid for notarisation. The time window can be open ended (i.e. with a start but no end or vice versa). In this
|
||||
way transactions can be linked to the notary's clock.
|
||||
|
||||
It is possible for a single Corda network to have multiple competing notaries. Each state points to the notary that
|
||||
controls it. Whilst a single transaction may only consume states if they are all controlled by the same notary,
|
||||
a special type of transaction is provided that moves a state (or set of states) from one notary to another.
|
||||
|
||||
.. note:: Currently the platform code will not re-assign states to a single notary as needed for you, in case of
|
||||
a mismatch. This is a future planned feature.
|
||||
|
||||
As the same terminology often crops up in different distributed ledger designs, let's compare this to other
|
||||
systems you may be familiar with. The key differences are:
|
||||
|
||||
* Improved contract flexibility vs Bitcoin
|
||||
* Improved scalability vs Ethereum, as well as ability to keep parts of the transaction graph private (yet still uniquely addressable)
|
||||
* No reliance on proof of work
|
||||
* Re-use of existing sandboxing virtual machines
|
||||
* Use of type safe GCd implementation languages
|
||||
* Simplified auditing
|
||||
|
||||
Comparison with Bitcoin
|
||||
-----------------------
|
||||
|
||||
Similarities:
|
||||
|
||||
* The basic notion of immutable states that are consumed and created by transactions is the same.
|
||||
* The notion of transactions having multiple inputs and outputs is the same. Bitcoin sometimes refers to the ledger
|
||||
as the unspent transaction output set (UTXO set) as a result.
|
||||
* Like in Bitcoin, a contract is pure function. Contracts do not have storage or the ability to interact with anything.
|
||||
Given the same transaction, a contract's accept function always yields exactly the same result.
|
||||
* Bitcoin output scripts are parameterised by the input scripts in the spending transaction. This is somewhat similar
|
||||
to our notion of a *command*.
|
||||
* Bitcoin has a global distributed notary service; that's the famous block chain. However, there is only one. Whilst
|
||||
there is a notion of a "side chain", this isn't integrated with the core Bitcoin data model and thus adds large
|
||||
amounts of additional complexity meaning in practice side chains are not used.
|
||||
* Bitcoin transactions, like ours, refer to the states they consume by using a (txhash, index) pair. The Bitcoin
|
||||
protocol calls these "outpoints". In our code they are known as ``StateRefs`` but the concept is identical.
|
||||
* Bitcoin transactions have an associated timestamp (the time at which they are mined).
|
||||
|
||||
Differences:
|
||||
|
||||
* A Bitcoin transaction has a single, rigid data format. A "state" in Bitcoin is always a (quantity of bitcoin, script)
|
||||
pair and cannot hold any other data. Some people have been known to try and hack around this limitation by embedding
|
||||
data in semi-standardised places in the contract code so the data can be extracted through pattern matching, but this
|
||||
is a poor approach. Our states can include arbitrary typed data.
|
||||
* A Bitcoin transaction's acceptance is controlled only by the contract code in the consumed input states. In practice
|
||||
this has proved limiting. Our transactions invoke not only input contracts but also the contracts of the outputs.
|
||||
* A Bitcoin script can only be given a fixed set of byte arrays as the input. This means there's no way for a contract
|
||||
to examine the structure of the entire transaction, which severely limits what contracts can do.
|
||||
* Our contracts are Turing-complete and can be written in any ordinary programming language that targets the JVM.
|
||||
* Our transactions and contracts get their time from an attached timestamp rather than a block. This is
|
||||
important given that we use block-free conflict resolution algorithms. The timestamp can be arbitrarily precise.
|
||||
* We use the term "contract" to refer to a bundle of business logic that may handle various different tasks, beyond
|
||||
transaction verification. For instance, currently our contracts also include code for creating valid transactions
|
||||
(this is often called "wallet code" in Bitcoin).
|
||||
|
||||
Comparison with Ethereum
|
||||
------------------------
|
||||
|
||||
Similarities:
|
||||
|
||||
* Like Ethereum, code runs inside a relatively powerful virtual machine and can contain complex logic. Non-assembly
|
||||
based programming languages can be used for contract programming.
|
||||
* They are both intended for the modelling of many different kinds of financial contract.
|
||||
|
||||
Differences:
|
||||
|
||||
* The term "contract" in Ethereum refers to an *instantiation* of a program that is replicated and maintained by
|
||||
every participating node. This instantiation is very much like an object in an OO program: it can receive and send
|
||||
messages, update local storage and so on. In contrast, we use the term "contract" to refer to a set of functions, only
|
||||
one of which is a part of keeping the system synchronised (the verify function). That function is pure and
|
||||
stateless i.e. it may not interact with any other part of the system whilst executing.
|
||||
* There is no notion of an "account", as there is in Ethereum.
|
||||
* As contracts don't have any kind of mutable storage, there is no notion of a "message" as in Ethereum.
|
||||
* Ethereum claims to be a platform not only for financial logic, but literally any kind of application at all. Our
|
||||
platform considers non-financial applications to be out of scope.
|
||||
|
||||
Rationale for and tradeoffs in adopting a UTXO-style model
|
||||
----------------------------------------------------------
|
||||
|
||||
As discussed above, Corda uses the so-called "UTXO set" model (unspent transaction output). In this model, the database
|
||||
does not track accounts or balances. Instead all database entries are immutable. An entry is either spent or not spent
|
||||
but it cannot be changed. In Bitcoin, spentness is implemented simply as deletion – the inputs of an accepted transaction
|
||||
are deleted and the outputs created.
|
||||
|
||||
This approach has some advantages and some disadvantages, which is why some platforms like Ethereum have tried
|
||||
(or are trying) to abstract this choice away and support a more traditional account-like model. We have explicitly
|
||||
chosen *not* to do this and our decision to adopt a UTXO-style model is a deliberate one. In the section below,
|
||||
the rationale for this decision and its pros and cons of this choice are outlined.
|
||||
|
||||
Rationale
|
||||
---------
|
||||
|
||||
Corda, in common with other blockchain-like platforms, is designed to bring parties to shared sets of data into
|
||||
consensus as to the existence, content and allowable evolutions of those data sets. However, Corda is designed with the
|
||||
explicit aim of avoiding, to the extent possible, the scalability and privacy implications that arise from those platforms'
|
||||
decisions to adopt a global broadcast model.
|
||||
|
||||
Whilst the privacy implications of a global consensus model are easy to understand, the scalability implications are
|
||||
perhaps more subtle, yet serious. In a consensus system, it is critical that all processors of a transaction reach
|
||||
precisely the same conclusion as to its effects. In situations where two transactions may act on the same data set,
|
||||
it means that the two transactions must be processed in the same *order* by all nodes. If this were not the case then it
|
||||
would be possible to devise situations where nodes processed transactions in different orders and reached different
|
||||
conclusions as to the state of the system. It is for this reason that systems like Ethereum effectively run
|
||||
single-threaded, meaning the speed of the system is limited by the single-threaded performance of the slowest
|
||||
machine on the network.
|
||||
|
||||
In Corda, we assume the data being processed represents financial agreements between identifiable parties and that these
|
||||
institutions will adopt the system only if a significant number of such agreements can be managed by the platform.
|
||||
As such, the system has to be able to support parallelisation of execution to the greatest extent possible,
|
||||
whilst ensuring correct transaction ordering when two transactions seek to act on the same piece of shared state.
|
||||
|
||||
To achieve this, we must minimise the number of parties who need to receive and process copies of any given
|
||||
transaction and we must minimise the extent to which two transactions seek to mutate (or supersede) any given piece
|
||||
of shared state.
|
||||
|
||||
A key design decision, therefore, is what should be the most atomic unit of shared data in the system. This decision
|
||||
also has profound privacy implications: the more coarsely defined the shared data units, the larger the set of
|
||||
actors who will likely have a stake in its accuracy and who must process and observe any update to it.
|
||||
|
||||
This becomes most obvious when we consider two models for representing cash balances and payments.
|
||||
|
||||
A simple account model for cash would define a data structure that maintained a balance at a particular bank for each
|
||||
"account holder". Every holder of a balance would need a copy of this structure and would thus need to process and
|
||||
validate every payment transaction, learning about everybody else's payments and balances in the process.
|
||||
All payments across that set of accounts would have to be single-threaded across the platform, limiting maximum
|
||||
throughput.
|
||||
|
||||
A more sophisticated example might create a data structure per account holder.
|
||||
But, even here, I would leak my account balance to anybody to whom I ever made
|
||||
a payment and I could only ever make one payment at a time, for the same reasons above.
|
||||
|
||||
A UTXO model would define a data structure that represented an *instance* of a claim against the bank. An account
|
||||
holder could hold *many* such instances, the aggregate of which would reveal their balance at that institution. However,
|
||||
the account holder now only needs to reveal to their payee those instances consumed in making a payment to that payee.
|
||||
This also means the payer could make several payments in parallel. A downside is that the model is harder to understand.
|
||||
However, we consider the privacy and scalability advantages to overwhelm the modest additional cognitive load this places
|
||||
on those attempting to learn the system.
|
||||
|
||||
In what follows, further advantages and disadvantages of this design decision are explored.
|
||||
|
||||
Pros
|
||||
----
|
||||
|
||||
The UTXO model has these advantages:
|
||||
|
||||
* Immutable ledger entries gives the usual advantages that a more functional approach brings: it's easy to do analysis
|
||||
on a static snapshot of the data and reason about the contents.
|
||||
* Because there are no accounts, it's very easy to apply transactions in parallel even for high traffic legal entities
|
||||
assuming sufficiently granular entries.
|
||||
* Transaction ordering becomes trivial: it is impossible to mis-order transactions due to the reliance on hash functions
|
||||
to identify previous states. There is no need for sequence numbers or other things that are hard to provide in a
|
||||
fully distributed system.
|
||||
* Conflict resolution boils down to the double spending problem, which places extremely minimal demands on consensus
|
||||
algorithms (as the variable you're trying to reach consensus on is a set of booleans).
|
||||
|
||||
Cons
|
||||
----
|
||||
|
||||
It also comes with some pretty serious complexities that in practice must be abstracted from developers:
|
||||
|
||||
* Representing numeric amounts using immutable entries is unnatural. For instance, if you receive $1000 and wish
|
||||
to send someone $100, you have to consume the $1000 output and then create two more: a $100 for the recipient and
|
||||
$900 back to yourself as change. The fact that this happens can leak private information to an observer.
|
||||
* Because users do need to think in terms of balances and statements, you have to layer this on top of the
|
||||
underlying ledger: you can't just read someone's balance out of the system. Hence, the "wallet" / position manager.
|
||||
Experience from those who have developed wallets for Bitcoin and other systems is that they can be complex pieces of code,
|
||||
although the bulk of wallets' complexity in public systems is handling the lack of finality (and key management).
|
||||
* Whilst transactions can be applied in parallel, it is much harder to create them in parallel due to the need to
|
||||
strictly enforce a total ordering.
|
||||
|
||||
With respect to parallel creation, if the user is single threaded this is fine, but in a more complex situation
|
||||
where you might want to be preparing multiple transactions in flight this can prove a limitation – in
|
||||
the worst case where you have a single output that represents all your value, this forces you to serialise
|
||||
the creation of every transaction. If transactions can be created and signed very fast that's not a concern.
|
||||
If there's only a single user, that's not a concern.
|
||||
|
||||
Both cases are typically true in the Bitcoin world, so users don't suffer from this much. In the context of a
|
||||
complex business with a large pool of shared funds, in which creation of transactions may be very slow due to the
|
||||
need to get different humans to approve a tx using a signing device, this could quickly lead to frustrating
|
||||
conflicts where someone approves a transaction and then discovers that it has become a double spend and
|
||||
they must sign again. In the absolute worst case you could get a form of human livelock.
|
||||
|
||||
The tricky part about solving these problems is that the simplest way to express a payment request
|
||||
("send me $1000 to public key X") inherently results in you receiving a single output, which then can
|
||||
prove insufficiently granular to be convenient. In the Bitcoin space Mike Hearn and Gavin Andresen designed "BIP 70"
|
||||
to solve this: it's a simple binary format for requesting a payment and specifying exactly how you'd like to get paid,
|
||||
including things like the shape of the transaction. It may seem that it's an over complex approach: could you not
|
||||
just immediately respend the big output back to yourself in order to split it? And yes, you could, until you hit
|
||||
scenarios like "the machine requesting the payment doesn't have the keys needed to spend it",
|
||||
which turn out to be very common. So it's really more effective for a recipient to be able to say to the
|
||||
sender, "here's the kind of transaction I want you to send me". The :doc:`flow framework <flow-state-machines>`
|
||||
may provide a vehicle to make such negotiations simpler.
|
||||
|
||||
A further challenge is privacy. Whilst our goal of not sending transactions to nodes that don't "need to know"
|
||||
helps, to verify a transaction you still need to verify all its dependencies and that can result in you receiving
|
||||
lots of transactions that involve random third parties. The problems start when you have received lots of separate
|
||||
payments and been careful not to make them linkable to your identity, but then you need to combine them all in a
|
||||
single transaction to make a payment.
|
||||
|
||||
Mike Hearn wrote an article about this problem and techniques to minimise it in
|
||||
`this article <https://medium.com/@octskyward/merge-avoidance-7f95a386692f>`_ from 2013. This article
|
||||
coined the term "merge avoidance", which has never been implemented in the Bitcoin space,
|
||||
although not due to lack of practicality.
|
||||
|
||||
A piece of future work for the wallet implementation will be to implement automated "grooming" of the wallet
|
||||
to "reshape" outputs to useful/standardised sizes, for example, and to send outputs of complex transactions
|
||||
back to their issuers for reissuance to "sever" long privacy-breaching chains.
|
||||
|
||||
Finally, it should be noted that some of the issues described here are not really "cons" of
|
||||
the UTXO model; they're just fundamental. If you used many different anonymous accounts to preserve some privacy
|
||||
and then needed to spend the contents of them all simultaneously, you'd hit the same problem, so it's not
|
||||
something that can be trivially fixed with data model changes.
|
@ -50,11 +50,15 @@ Documentation Contents:
|
||||
:maxdepth: 2
|
||||
:caption: Key concepts
|
||||
|
||||
data-model
|
||||
transaction-data-types
|
||||
merkle-trees
|
||||
consensus
|
||||
clauses
|
||||
key-concepts
|
||||
key-concepts-ecosystem
|
||||
key-concepts-data-model
|
||||
key-concepts-core-types
|
||||
key-concepts-financial-model
|
||||
key-concepts-flow-framework
|
||||
key-concepts-consensus-notaries
|
||||
key-concepts-vault
|
||||
key-concepts-security-model
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
@ -100,6 +104,8 @@ Documentation Contents:
|
||||
:caption: Other
|
||||
|
||||
network-simulator
|
||||
clauses
|
||||
merkle-trees
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
@ -119,6 +125,7 @@ Documentation Contents:
|
||||
release-notes
|
||||
codestyle
|
||||
building-the-docs
|
||||
further-notes-on-kotlin
|
||||
publishing-corda
|
||||
azure-vm
|
||||
|
||||
|
163
docs/source/key-concepts-consensus-notaries.rst
Normal file
163
docs/source/key-concepts-consensus-notaries.rst
Normal file
@ -0,0 +1,163 @@
|
||||
Consensus and notaries
|
||||
======================
|
||||
|
||||
A notary is a service that provides transaction ordering and timestamping.
|
||||
|
||||
Notaries are expected to be composed of multiple mutually distrusting parties who use a standard consensus algorithm.
|
||||
Notaries are identified by and sign with :ref:`composite-keys`. Notaries accept transactions submitted to them for processing
|
||||
and either return a signature over the transaction, or a rejection error that states that a double spend attempt has occurred.
|
||||
|
||||
Corda has "pluggable" notary services to improve privacy, scalability, legal-system compatibility and algorithmic agility.
|
||||
The platform currently provides validating and non-validating notaries, and a distributed RAFT implementation.
|
||||
|
||||
Consensus model
|
||||
---------------
|
||||
|
||||
The fundamental unit of consensus in Corda is the **state**. Consensus can be divided into two parts:
|
||||
|
||||
1. Consensus over state **validity** -- parties can reach certainty that a transaction is accepted by the contracts pointed
|
||||
to by the input and output states, and has all the required signatures. This is achieved by parties independently running
|
||||
the same contract code and validation logic (as described in :doc:`data model <data-model>`)
|
||||
|
||||
2. Consensus over state **uniqueness** -- parties can reach certainty the output states created in a transaction are the
|
||||
unique successors to the input states consumed by that transaction (in other words -- an input state has not been previously
|
||||
consumed)
|
||||
|
||||
.. note:: The current model is still a **work in progress** and everything described in this article can and is likely to change
|
||||
|
||||
Notary
|
||||
------
|
||||
|
||||
A **notary** is an authority responsible for attesting that for a given transaction, it has not signed another transaction
|
||||
consuming any of the same input states. Every **state** has an appointed notary:
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
/**
|
||||
* A wrapper for [ContractState] containing additional platform-level state information.
|
||||
* This is the definitive state that is stored on the ledger and used in transaction outputs
|
||||
*/
|
||||
data class TransactionState<out T : ContractState>(
|
||||
/** The custom contract state */
|
||||
val data: T,
|
||||
/** Identity of the notary that ensures the state is not used as an input to a transaction more than once */
|
||||
val notary: Party) {
|
||||
...
|
||||
}
|
||||
|
||||
Transactions are signed by a notary to ensure their input states are **valid** (apart from *issue* transactions, containing no input states).
|
||||
Furthermore, when using a validating notary, a transaction is only valid if all its dependencies are also valid.
|
||||
|
||||
.. note:: The notary is a logical concept and can itself be a distributed entity, potentially a cluster maintained by mutually distrusting parties
|
||||
|
||||
When the notary is requested to sign a transaction, it either signs it, attesting that the outputs are the **unique**
|
||||
successors of the inputs, or provides conflict information for any input state that has been consumed by another transaction
|
||||
it has already signed. In doing so, the notary provides the point of finality in the system. Until the notary signature
|
||||
is obtained, parties cannot be sure that an equally valid, but conflicting, transaction will not be regarded as confirmed.
|
||||
After the signature is obtained, the parties know that the inputs to this transaction have been uniquely consumed by this transaction.
|
||||
Hence, it is the point at which we can say finality has occurred.
|
||||
|
||||
Multiple notaries
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
More than one notary can exist in a network. This gives the following benefits:
|
||||
|
||||
* **Custom behaviour**. We can have both validating and privacy preserving Notaries -- parties can make a choice based
|
||||
on their specific requirements.
|
||||
* **Load balancing**. Spreading the transaction load over multiple notaries will allow higher transaction throughput in
|
||||
the platform overall
|
||||
* **Low latency**. Latency could be minimised by choosing a notary physically closer the transacting parties
|
||||
|
||||
Changing notaries
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
A transaction should only be signed by a notary if all of its input states point to the same notary.
|
||||
In cases where a transaction involves states controlled by multiple notaries, the states first have to be repointed to the same notary.
|
||||
This is achieved by using a special type of transaction whose sole output state is identical to its sole input state except for its designated notary.
|
||||
Ensuring that all input states point to the same notary is the responsibility of each involved party
|
||||
(it is another condition for an output state of the transaction to be **valid**)
|
||||
|
||||
To change the notary for an input state, use the ``NotaryChangeFlow``. For example:
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
@Suspendable
|
||||
fun changeNotary(originalState: StateAndRef<ContractState>,
|
||||
newNotary: Party): StateAndRef<ContractState> {
|
||||
val flow = NotaryChangeFlow.Instigator(originalState, newNotary)
|
||||
return subFlow(flow)
|
||||
}
|
||||
|
||||
The flow will:
|
||||
|
||||
1. Construct a transaction with the old state as the input and the new state as the output
|
||||
|
||||
2. Obtain signatures from all *participants* (a participant is any party that is able to consume this state in a valid transaction, as defined by the state itself)
|
||||
|
||||
3. Obtain the *old* notary signature
|
||||
|
||||
4. Record and distribute the final transaction to the participants so that everyone possesses the new state
|
||||
|
||||
.. note:: Eventually, changing notaries will be handled automatically on demand.
|
||||
|
||||
Validation
|
||||
----------
|
||||
|
||||
One of the design decisions for a notary is whether or not to **validate** a transaction before accepting it.
|
||||
|
||||
If a transaction is not checked for validity, it opens the platform to "denial of state" attacks, where anyone can build an invalid transaction consuming someone else's states and submit it to the notary to get the states "blocked".
|
||||
However, if the transaction is validated, this requires the notary to be able to see the full contents of the transaction in question and its dependencies.
|
||||
This is an obvious privacy leak.
|
||||
|
||||
The platform is flexible and currently supports both validating and non-validating notary implementations -- a party can select which one to use based on its own privacy requirements.
|
||||
|
||||
.. note:: In the non-validating model, the "denial of state" attack is partially alleviated by requiring the calling
|
||||
party to authenticate and storing its identity for the request. The conflict information returned by the notary
|
||||
specifies the consuming transaction ID along with the identity of the party that had created the transaction. If the
|
||||
conflicting transaction is valid, the current one is aborted; if not, a dispute can be raised and the input states
|
||||
of the conflicting invalid transaction are "un-committed" (via a legal process).
|
||||
|
||||
.. note:: At present, all notaries can see the entire contents of a submitted transaction. A future piece of work
|
||||
will enable the processing of :doc:`merkle-trees`, thus providing data hiding of sensitive information.
|
||||
|
||||
Timestamping
|
||||
------------
|
||||
|
||||
A notary can also act as a *timestamping authority*, verifying the transaction timestamp command.
|
||||
|
||||
For a timestamp to be meaningful, its implications must be binding on the party requesting it.
|
||||
A party can obtain a timestamp signature in order to prove that some event happened *before*, *on*, or *after* a particular point in time.
|
||||
However, if the party is not also compelled to commit to the associated transaction, it has a choice of whether or not to reveal this fact until some point in the future.
|
||||
As a result, we need to ensure that the notary either has to also sign the transaction within some time tolerance,
|
||||
or perform timestamping *and* notarisation at the same time, which is the chosen behaviour for this model.
|
||||
|
||||
There will never be exact clock synchronisation between the party creating the transaction and the notary.
|
||||
This is not only due to physics, network latencies, etc. but also because between inserting the command and getting the
|
||||
notary to sign there may be many other steps, like sending the transaction to other parties involved in the trade, or
|
||||
even requesting human sign-off. Thus the time observed by the notary may be quite different to the time observed by the
|
||||
party creating the transaction.
|
||||
|
||||
For this reason, times in transactions are specified as time *windows*, not absolute times.
|
||||
In a distributed system there can never be "true time", only an approximation of it. Time windows can be
|
||||
open-ended (i.e. specify only one of "before" and "after") or they can be fully bounded. If a time window needs to
|
||||
be converted to an absolute time (e.g. for display purposes), there is a utility method on ``Timestamp`` to
|
||||
calculate the mid point.
|
||||
|
||||
In this way, we express the idea that the *true value* of the fact "the current time" is actually unknowable. Even when both before and
|
||||
after times are included, the transaction could have occurred at any point between those two timestamps. Here,
|
||||
"occurrence" could mean the execution date, the value date, the trade date etc ... The notary doesn't care what precise
|
||||
meaning the timestamp has to the contract.
|
||||
|
||||
By creating a range that can be either closed or open at one end, we allow all of the following facts to be modelled:
|
||||
|
||||
* This transaction occurred at some point after the given time (e.g. after a maturity event)
|
||||
* This transaction occurred at any time before the given time (e.g. before a bankruptcy event)
|
||||
* This transaction occurred at some point roughly around the given time (e.g. on a specific day)
|
||||
|
||||
.. note:: It is assumed that the time feed for a notary is GPS/NaviStar time as defined by the atomic
|
||||
clocks at the US Naval Observatory. This time feed is extremely accurate and available globally for free.
|
||||
|
||||
Also see section 7 of the `Technical white paper`_ which covers this topic in significantly more depth.
|
||||
|
||||
.. _`Technical white paper`: _static/corda-technical-whitepaper.pdf
|
||||
|
@ -1,73 +1,30 @@
|
||||
Data types
|
||||
Core types
|
||||
==========
|
||||
|
||||
Corda provides a large standard library of data types used in financial transactions and contract state objects.
|
||||
These provide a common language for states and contracts.
|
||||
Corda provides a large standard library of data types used to represent the :doc:`key-concepts-data-model` previously described.
|
||||
In addition, there are a series of helper libraries which provide date manipulation, maths and cryptography functions.
|
||||
|
||||
Amount
|
||||
------
|
||||
State and References
|
||||
--------------------
|
||||
State objects contain mutable data which we would expect to evolve over the lifetime of a contract.
|
||||
|
||||
The `Amount <api/kotlin/corda/net.corda.core.contracts/-amount/index.html>`_ class is used to represent an amount of some
|
||||
fungible asset. It is a generic class which wraps around a type used to define the underlying product, called
|
||||
the *token*. For instance it can be the standard JDK type ``Currency``, or an ``Issued`` instance, or this can be
|
||||
a more complex type such as an obligation contract issuance definition (which in turn contains a token definition
|
||||
for whatever the obligation is to be settled in).
|
||||
|
||||
.. note:: Fungible is used here to mean that instances of an asset is interchangeable for any other identical instance,
|
||||
and that they can be split/merged. For example a £5 note can reasonably be exchanged for any other £5 note, and a
|
||||
£10 note can be exchanged for two £5 notes, or vice-versa.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
.. container:: codeset
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
// A quantity of some specific currency like pounds, euros, dollars etc.
|
||||
Amount<Currency>
|
||||
// A quantity of currency that is issued by a specific issuer, for instance central bank vs other bank dollars
|
||||
Amount<Issued<Currency>>
|
||||
// A quantity of obligations to deliver currency of any issuer.
|
||||
Amount<Obligation.State<Currency>>
|
||||
|
||||
``Amount`` represents quantities as integers. For currencies the quantity represents pennies, cents or whatever
|
||||
else the smallest integer amount for that currency is. You cannot use ``Amount`` to represent negative quantities
|
||||
or fractional quantities: if you wish to do this then you must use a different type e.g. ``BigDecimal``. ``Amount``
|
||||
defines methods to do addition and subtraction and these methods verify that the tokens on both sides of the operator
|
||||
are equal (these are operator overloads in Kotlin and can be used as regular methods from Java). There are also
|
||||
methods to do multiplication and division by integer amounts.
|
||||
|
||||
State
|
||||
-----
|
||||
|
||||
A Corda contract is composed of three parts; the executable code, the legal prose, and the state objects that represent
|
||||
the details of a specific deal or asset (see :doc:`data-model` for further detail). In relational database terms
|
||||
a state is like a row in a database. A reference to a state in the ledger (whether it has been consumed or not)
|
||||
is represented with a ``StateRef`` object. If the state ref has been looked up from storage, you will have a
|
||||
``StateAndRef`` which is simply a ``StateRef`` plus the data.
|
||||
A reference to a state in the ledger (whether it has been consumed or not) is represented with a ``StateRef`` object.
|
||||
If the state ref has been looked up from storage, you will have a ``StateAndRef`` which is simply a ``StateRef`` plus the data.
|
||||
|
||||
The ``ContractState`` type is an interface that all states must implement. A ``TransactionState`` is a simple
|
||||
container for a ``ContractState`` (the custom data used by a contract program) and additional platform-level state
|
||||
information, such as the *notary* pointer (see :doc:`consensus`).
|
||||
information, such as the *notary* pointer (see :doc:`key-concepts-consensus-notaries`).
|
||||
|
||||
A number of interfaces then extend ``ContractState``, representing standardised functionality for common kinds
|
||||
of state:
|
||||
of state such as:
|
||||
|
||||
``OwnableState``
|
||||
A state which has an owner (represented as a ``PublicKey``, discussed later). Exposes the owner and a function
|
||||
for replacing the owner e.g. when an asset is sold.
|
||||
``OwnableState``
|
||||
A state which has an owner (represented as a ``CompositeKey``, discussed later). Exposes the owner and a function
|
||||
for replacing the owner e.g. when an asset is sold.
|
||||
|
||||
``LinearState``
|
||||
A state which links back to its previous state, creating a thread of states over time. A linear state is
|
||||
useful when modelling an indivisible/non-fungible thing like a specific deal, or an asset that can't be
|
||||
split (like a rare piece of art).
|
||||
|
||||
``DealState``
|
||||
A LinearState representing an agreement between two or more parties. Intended to simplify implementing generic
|
||||
flows that manipulate many agreement types.
|
||||
|
||||
``FixableDealState``
|
||||
A deal state, with further functions exposed to support fixing of interest rates.
|
||||
``SchedulableState``
|
||||
A state to indicate whether there is some activity to be performed at some future point in time with respect to this
|
||||
contract, what that activity is and at what point in time it should be initiated.
|
||||
|
||||
NamedByHash and UniqueIdentifier
|
||||
--------------------------------
|
||||
@ -81,30 +38,27 @@ This is a combination of a (Java) ``UUID`` representing a globally unique 128 bi
|
||||
string which can be paired with it. For instance the string may represent an existing "weak" (not guaranteed unique)
|
||||
identifier for convenience purposes.
|
||||
|
||||
FungibleAssets and Cash
|
||||
-----------------------
|
||||
|
||||
There is a common ``FungibleAsset`` superclass for contracts which model fungible assets, which also provides a standard
|
||||
interface for its subclasses' state objects to implement. The clear use-case is ``Cash``, however ``FungibleAsset`` is
|
||||
intended to be readily extensible to cover other assets, for example commodities could be modelled by using a subclass
|
||||
whose state objects include further details (location of the commodity, origin, grade, etc.) as needed.
|
||||
|
||||
Transaction lifecycle types
|
||||
---------------------------
|
||||
|
||||
The ``WireTransaction`` class contains the core of a transaction without signatures, and with references to attachments
|
||||
in place of the attachments themselves (see also :doc:`data-model`). Once signed these are encapsulated in the
|
||||
``SignedTransaction`` class. For processing a transaction (i.e. to verify it) it is first converted to a
|
||||
in place of the attachments themselves (see also :doc:`key-concepts-data-model`). Once signed these are encapsulated in the
|
||||
``SignedTransaction`` class. For processing a transaction (i.e. to verify it) a ``SignedTransaction`` is then converted to a
|
||||
``LedgerTransaction``, which involves verifying the signatures and associating them to the relevant command(s), and
|
||||
resolving the attachment references to the attachments. Commands with valid signatures are encapsulated in the
|
||||
``AuthenticatedObject`` type.
|
||||
|
||||
.. note:: A ``LedgerTransaction`` has not necessarily had its contracts be run, and thus could be contract-invalid
|
||||
(but not signature-invalid). You can use the ``verify`` method as shown below to run the contracts.
|
||||
.. note:: A ``LedgerTransaction`` has not necessarily had its contract code executed, and thus could be contract-invalid
|
||||
(but not signature-invalid). You can use the ``verify`` method as shown below to validate the contracts.
|
||||
|
||||
When constructing a new transaction from scratch, you use ``TransactionBuilder``, which is a mutable transaction that
|
||||
can be signed once modification of the internals is complete. It is typical for contract classes to expose helper
|
||||
methods that can contribute to a ``TransactionBuilder``.
|
||||
can be signed once its construction is complete. This builder class should be used to create the initial transaction representation
|
||||
(before signature, before verification). It is intended to be passed around code that may edit it by adding new states/commands.
|
||||
Then once the states and commands are right, this class can be used as a holding bucket to gather signatures from multiple parties.
|
||||
It is typical for contract classes to expose helper methods that can contribute to a ``TransactionBuilder``. Once a transaction
|
||||
has been constructed using the builders ``toWireTransaction`` or ``toSignedTransaction`` function, it shared with other
|
||||
participants using the :doc:`key-concepts-flow-framework`.
|
||||
|
||||
Here's an example of building a transaction that creates an issuance of bananas (note that bananas are not a real
|
||||
contract type in the library):
|
||||
@ -127,25 +81,22 @@ contract type in the library):
|
||||
In a unit test, you would typically use a freshly created ``MockServices`` object, or more realistically, you would
|
||||
write your tests using the :doc:`domain specific language for writing tests <tutorial-test-dsl>`.
|
||||
|
||||
Party and PublicKey
|
||||
-------------------
|
||||
Party and CompositeKey
|
||||
----------------------
|
||||
|
||||
Entities using the network are called *parties*. Parties can sign structures using keys, and a party may have many
|
||||
keys under their control.
|
||||
|
||||
Parties may sometimes be identified pseudonymously, for example, in a transaction sent to your node as part of a
|
||||
Parties may sometimes be identified pseudonymously. For example, in a transaction sent to your node as part of a
|
||||
chain of custody it is important you can convince yourself of the transaction's validity, but equally important that
|
||||
you don't learn anything about who was involved in that transaction. In these cases a public key may be present
|
||||
without any identifying information about who owns it.
|
||||
|
||||
Identities of parties involved in signing a transaction can be represented simply by a ``PublicKey``, or by further
|
||||
Identities of parties involved in signing a transaction can be represented simply by a ``CompositeKey``, or by further
|
||||
information (such as name) using the ``Party`` class. An ``AuthenticatedObject`` represents an object (like a command)
|
||||
that has been signed by a set of parties.
|
||||
|
||||
.. note:: These types are provisional and will change significantly in future as the identity framework becomes more
|
||||
fleshed out.
|
||||
|
||||
.. _composite-keys:
|
||||
.. note:: These types are provisional and will change significantly in future as the identity framework becomes more fleshed out.
|
||||
|
||||
Multi-signature support
|
||||
-----------------------
|
||||
@ -153,6 +104,8 @@ Multi-signature support
|
||||
Corda supports scenarios where more than one key or party is required to authorise a state object transition, for example:
|
||||
"Either the CEO or 3 out of 5 of his assistants need to provide signatures".
|
||||
|
||||
.. _composite-keys:
|
||||
|
||||
Composite Keys
|
||||
^^^^^^^^^^^^^^
|
||||
|
||||
@ -163,13 +116,15 @@ node specifies a *threshold* of how many child signatures it requires.
|
||||
An illustration of an *"either Alice and Bob, or Charlie"* composite key:
|
||||
|
||||
.. image:: resources/composite-key.png
|
||||
:width: 300px
|
||||
:align: center
|
||||
:width: 300px
|
||||
|
||||
To allow further flexibility, each child node can have an associated custom *weight* (the default is 1). The *threshold*
|
||||
then specifies the minimum total weight of all children required. Our previous example can also be expressed as:
|
||||
|
||||
.. image:: resources/composite-key-2.png
|
||||
:width: 300px
|
||||
:align: center
|
||||
:width: 300px
|
||||
|
||||
Verification
|
||||
^^^^^^^^^^^^
|
||||
@ -184,7 +139,7 @@ Signature verification is performed in two stages:
|
||||
Date support
|
||||
------------
|
||||
|
||||
There are a number of supporting interfaces and classes for use by contract which deal with dates (especially in the
|
||||
There are a number of supporting interfaces and classes for use by contracts which deal with dates (especially in the
|
||||
context of deadlines). As contract negotiation typically deals with deadlines in terms such as "overnight", "T+3",
|
||||
etc., it's desirable to allow conversion of these terms to their equivalent deadline. ``Tenor`` models the interval
|
||||
before a deadline, such as 3 days, etc., while ``DateRollConvention`` describes how deadlines are modified to take
|
||||
@ -196,11 +151,11 @@ bank holidays). The ``BusinessCalendar`` class models these calendars of busines
|
||||
from files on disk, but in future this is likely to involve reference data oracles in order to ensure consensus on the
|
||||
dates used.
|
||||
|
||||
Cryptography & maths support
|
||||
----------------------------
|
||||
Cryptography and maths support
|
||||
------------------------------
|
||||
|
||||
The ``SecureHash`` class represents a secure hash of unknown algorithm. We currently define only a single subclass,
|
||||
``SecureHash.SHA256``. There are utility methods to create them, parse them and so on.
|
||||
|
||||
We also provide some mathematical utilities, in particular a set of interpolators and classes for working with
|
||||
splines. These can be found in the `maths package <api/kotlin/corda/net.corda.core.math/index.html>`_.
|
||||
splines. These can be found in the `maths package <api/net.corda.core.math/index.html>`_.
|
142
docs/source/key-concepts-data-model.rst
Normal file
142
docs/source/key-concepts-data-model.rst
Normal file
@ -0,0 +1,142 @@
|
||||
Data model
|
||||
==========
|
||||
|
||||
Overview
|
||||
--------
|
||||
Corda uses the so-called "UTXO set" model (unspent transaction output). In this model, the database
|
||||
does not track accounts or balances. An entry is either spent or not spent but it cannot be changed. In this model the
|
||||
database is a set of immutable rows keyed by (hash:output index). Transactions define outputs that append new rows and
|
||||
inputs which consume existing rows.
|
||||
|
||||
The Corda ledger is defined as a set of immutable **states**, which are created and destroyed by digitally signed **transactions**.
|
||||
Each transaction points to a set of states that it will consume/destroy, these are called **inputs**, and contains a set
|
||||
of new states that it will create, these are called **outputs**.
|
||||
Although the ledger is shared, it is not always the case that transactions and ledger entries are globally visible.
|
||||
In cases where a set of transactions stays within a small subgroup of users it is possible to keep the relevant
|
||||
data purely within that group. To ensure consistency, we rely heavily on secure hashes like SHA-256 to identify things.
|
||||
|
||||
The Corda model provides the following additional features:
|
||||
|
||||
* There is no global broadcast at any point.
|
||||
* States can include arbitrary typed data.
|
||||
* Transactions invoke not only input contracts but also the contracts of the outputs.
|
||||
* Contracts refer to a bundle of business logic that may handle various different tasks, beyond transaction verification.
|
||||
* Contracts are Turing-complete and can be written in any ordinary programming language that targets the JVM.
|
||||
* Arbitrarily-precise time-bounds may be specified in transactions (which must be attested to by a notary)
|
||||
* Primary consensus implementations use block-free conflict resolution algorithms.
|
||||
* Transactions are not ordered using a block chain and by implication Corda does not use miners or proof-of-work.
|
||||
Instead each state points to a notary, which is a service that guarantees it will sign a transaction only if all the
|
||||
input states are un-consumed.
|
||||
|
||||
Corda provides three main tools to achieve global distributed consensus:
|
||||
|
||||
* Smart contract logic to ensure state transitions are valid according to the pre-agreed rules.
|
||||
* Uniqueness and timestamping services to order transactions temporally and eliminate conflicts.
|
||||
* An :doc:`orchestration framework <key-concepts-flow-framework>` which simplifies the process of writing complex multi-step protocols between multiple different parties.
|
||||
|
||||
Comparisons of the Corda data model with Bitcoin and Ethereum can be found in the white papers.
|
||||
|
||||
States
|
||||
------
|
||||
A state object represents an agreement between two or more parties, the evolution of which governed by machine-readable contract code.
|
||||
This code references, and is intended to implement, portions of human-readable legal prose.
|
||||
It is intended to be shared only with those who have a legitimate reason to see it.
|
||||
|
||||
The following diagram illustrates a state object:
|
||||
|
||||
.. image:: resources/contract.png
|
||||
|
||||
In the diagram above, we see a state object representing a cash claim of £100 against a commercial bank, owned by a fictional shipping company.
|
||||
|
||||
.. note:: Legal prose (depicted above in grey-shade) is currently implemented as an unparsed reference to the natural language
|
||||
contract that the code is supposed to express (usually a hash of the contract's contents).
|
||||
|
||||
States contain arbitrary data, but they always contain at minimum a hash of the bytecode of a
|
||||
**contract code** file, which is a program expressed in JVM byte code that runs sandboxed inside a Java virtual machine.
|
||||
Contract code (or just "contracts" in the rest of this document) are globally shared pieces of business logic.
|
||||
|
||||
.. note:: In the current code dynamic loading of contracts is not implemented. This will change in the near future.
|
||||
|
||||
Contracts
|
||||
---------
|
||||
Contracts define part of the business logic of the ledger.
|
||||
|
||||
Corda enforces business logic through smart contract code, which is constructed as a pure function (called "verify") that either accepts
|
||||
or rejects a transaction, and which can be composed from simpler, reusable functions. The functions interpret transactions
|
||||
as taking states as inputs and producing output states through the application of (smart contract) commands, and accept
|
||||
the transaction if the proposed actions are valid. Given the same transaction, a contract’s “verify” function always yields
|
||||
exactly the same result. Contracts do not have storage or the ability to interact with anything.
|
||||
|
||||
.. note:: In the future, contracts will be mobile. Nodes will download and run contracts inside a sandbox without any review in some deployments,
|
||||
although we envisage the use of signed code for Corda deployments in the regulated sphere. Corda will use an augmented
|
||||
JVM custom sandbox that is radically more restrictive than the ordinary JVM sandbox, and it will enforce not only
|
||||
security requirements but also deterministic execution.
|
||||
|
||||
To further aid writing contracts we introduce the concept of :doc:`clauses` which provide a means of re-using common
|
||||
verification logic.
|
||||
|
||||
Transactions
|
||||
------------
|
||||
Transaction are used to update the ledger by consuming existing state objects and producing new state objects.
|
||||
|
||||
A transaction update is accepted according to the following two aspects of consensus:
|
||||
|
||||
#. Transaction validity: parties can ensure that the proposed transaction and all its ancestors are valid
|
||||
by checking that the associated contract code runs successfully and has all the required signatures
|
||||
#. Transaction uniqueness: parties can ensure there exists no other transaction, over which we have previously reached
|
||||
consensus (validity and uniqueness), that consumes any of the same states. This is the responsibility of a notary service.
|
||||
|
||||
Beyond inputs and outputs, transactions may also contain **commands**, small data packets that
|
||||
the platform does not interpret itself but which parameterise execution of the contracts. They can be thought of as
|
||||
arguments to the verify function. Each command has a list of **composite keys** associated with it. The platform ensures
|
||||
that the transaction has signatures matching every key listed in the commands before the contracts start to execute. Thus, a verify
|
||||
function can trust that all listed keys have signed the transaction, but is responsible for verifying that any keys required
|
||||
for the transaction to be valid from the verify function's perspective are included in the list. Public keys
|
||||
may be random/identityless for privacy, or linked to a well known legal identity, for example via a
|
||||
*public key infrastructure* (PKI).
|
||||
|
||||
.. note:: Linkage of keys with identities via a PKI is only partially implemented in the current code.
|
||||
|
||||
Commands are always embedded inside a transaction. Sometimes, there's a larger piece of data that can be reused across
|
||||
many different transactions. For this use case, we have **attachments**. Every transaction can refer to zero or more
|
||||
attachments by hash. Attachments are always ZIP/JAR files, which may contain arbitrary content. These files are
|
||||
then exposed on the classpath and so can be opened by contract code in the same manner as any JAR resources
|
||||
would be loaded.
|
||||
|
||||
Note that there is nothing that explicitly binds together specific inputs, outputs, commands or attachments. Instead,
|
||||
it's up to the contract code to interpret the pieces inside the transaction and ensure they fit together correctly. This
|
||||
is done to maximise flexibility for the contract developer.
|
||||
|
||||
Transactions may sometimes need to provide a contract with data from the outside world. Examples may include stock
|
||||
prices, facts about events or the statuses of legal entities (e.g. bankruptcy), and so on. The providers of such
|
||||
facts are called **oracles** and they provide facts to the ledger by signing transactions that contain commands they
|
||||
recognise, or by creating signed attachments. The commands contain the fact and the signature shows agreement to that fact.
|
||||
|
||||
Time is also modelled as a fact and represented as a **timestamping command** placed inside the transaction. This specifies a
|
||||
time window in which the transaction is considered valid for notarisation. The time window can be open ended (i.e. with a start but no end or vice versa).
|
||||
In this way transactions can be linked to the notary's clock.
|
||||
|
||||
It is possible for a single Corda network to have multiple competing notaries. A new (output) state is tied to a specific
|
||||
notary when it is created. Transactions can only consume (input) states that are all associated with the same notary.
|
||||
A special type of transaction is provided that can move a state (or set of states) from one notary to another.
|
||||
|
||||
.. note:: Currently the platform code will not automatically re-assign states to a single notary. This is a future planned feature.
|
||||
|
||||
Transaction Validation
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
When a transaction is presented to a node as part of a flow it may need to be checked. Checking original transaction validity is
|
||||
the responsibility of the ``ResolveTransactions`` flow. This flow performs a breadth-first search over the transaction graph,
|
||||
downloading any missing transactions into local storage and validating them. The search bottoms out at transactions without inputs
|
||||
(eg. these are mostly created from issuance transactions). A transaction is not considered valid if any of its transitive dependencies are invalid.
|
||||
|
||||
.. note:: Non-validating notaries assume transaction validity and do not request transaction data or their dependencies
|
||||
beyond the list of states consumed.
|
||||
|
||||
The tutorial " :doc:`tutorial-contract` "provides a hand-ons walk-through using these concepts.
|
||||
|
||||
Transaction Representation
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
By default, all transaction data (input and output states, commands, attachments) is visible to all participants in
|
||||
a multi-party, multi-flow business workflow. :doc:`merkle-trees` describes how Corda uses Merkle trees to
|
||||
ensure data integrity and hiding of sensitive data within a transaction that shouldn't be visible in its entirety to all
|
||||
participants (eg. oracles nodes providing facts).
|
47
docs/source/key-concepts-ecosystem.rst
Normal file
47
docs/source/key-concepts-ecosystem.rst
Normal file
@ -0,0 +1,47 @@
|
||||
Corda ecosystem
|
||||
===============
|
||||
|
||||
A Corda network consists of the following components:
|
||||
|
||||
* Nodes, where each node represents a JVM run-time environment hosting Corda services and executing applications ("CorDapps").
|
||||
Nodes communicate using AMQP/1.0 over TLS.
|
||||
* A permissioning service that automates the process of provisioning TLS certificates.
|
||||
* A network map service that publishes information about nodes on the network.
|
||||
* One or more pluggable notary service types (which may be distributed over multiple nodes).
|
||||
A notary guarantees uniqueness and validity of transactions.
|
||||
* Zero or more oracle services. An oracle is a well known service that signs transactions if they state a fact and that fact is considered to be true.
|
||||
* CorDapps which represent participant applications that execute contract code and communicate using the flow framework to achieve consensus over some business activity
|
||||
* Standalone Corda applications that provide manageability and tooling support to a Corda network.
|
||||
|
||||
These components are illustrated in the following diagram:
|
||||
|
||||
.. image:: resources/cordaNetwork.png
|
||||
:align: center
|
||||
|
||||
Note:
|
||||
|
||||
* Corda infrastructure services are those which all participants depend upon, such as the network map and notaries.
|
||||
* Corda services can be deployed by participants, third parties or a central network operator (eg. such as R3);
|
||||
this diagram is not intended to imply only a centralised model is supported
|
||||
|
||||
It is important to highlight the following:
|
||||
|
||||
* Corda is designed for semi-private networks in which admission requires obtaining an identity signed by a root authority.
|
||||
* Nodes are arranged in an authenticated peer to peer network. All communication is direct.
|
||||
* Data is shared on a need-to-know basis. Nodes provide the dependency graph of a transaction they are sending to another node on demand, but there is no global broadcast of all transactions.
|
||||
* Nodes are backed by a relational database and data placed in the ledger can be queried using SQL
|
||||
* The network map publishes the IP addresses through which every node on the network can be reached, along with the identity certificates of those nodes and the services they provide.
|
||||
* All communication takes the form of small multi-party sub-protocols called flows.
|
||||
* Oracles represent gateways to proprietary (or other) business logic executors (e.g., central counterparties or valuation agents) that can be verified on-ledger by participants.
|
||||
|
||||
CorDapps
|
||||
--------
|
||||
Corda is a platform for the writing of “CorDapps”: applications that extend the distributed ledger with new capabilities.
|
||||
Such apps define new data types, new inter-node protocol flows and the “smart contracts” that determine allowed changes.
|
||||
The combination of state objects (data), contract code (allowable operations), transaction flows (business logic
|
||||
choreography), any necessary APIs, vault plugins, and UI components can be thought of as a shared ledger application,
|
||||
or corda distributed application (“CorDapp”). This is the core set of components a contract developer on the platform
|
||||
should expect to build.
|
||||
|
||||
Examples of CorDapps include asset trading (see :ref:`irs-demo` and :ref:`trader-demo`), portfolio valuations (see :ref:`simm-demo`), trade finance,
|
||||
post-trade order matching, KYC/AML, etc.
|
71
docs/source/key-concepts-financial-model.rst
Normal file
71
docs/source/key-concepts-financial-model.rst
Normal file
@ -0,0 +1,71 @@
|
||||
Financial model
|
||||
===============
|
||||
|
||||
Corda provides a large standard library of data types used in financial applications and contract state objects.
|
||||
These provide a common language for states and contracts.
|
||||
|
||||
Amount
|
||||
------
|
||||
|
||||
The `Amount <api/net.corda.core.contracts/-amount/index.html>`_ class is used to represent an amount of some
|
||||
fungible asset. It is a generic class which wraps around a type used to define the underlying product, called
|
||||
the *token*. For instance it can be the standard JDK type ``Currency``, or an ``Issued`` instance, or this can be
|
||||
a more complex type such as an obligation contract issuance definition (which in turn contains a token definition
|
||||
for whatever the obligation is to be settled in).
|
||||
|
||||
.. note:: Fungible is used here to mean that instances of an asset is interchangeable for any other identical instance,
|
||||
and that they can be split/merged. For example a £5 note can reasonably be exchanged for any other £5 note, and
|
||||
a £10 note can be exchanged for two £5 notes, or vice-versa.
|
||||
|
||||
Here are some examples:
|
||||
|
||||
.. container:: codeset
|
||||
|
||||
.. sourcecode:: kotlin
|
||||
|
||||
// A quantity of some specific currency like pounds, euros, dollars etc.
|
||||
Amount<Currency>
|
||||
// A quantity of currency that is issued by a specific issuer, for instance central bank vs other bank dollars
|
||||
Amount<Issued<Currency>>
|
||||
// A quantity of a product governed by specific obligation terms
|
||||
Amount<Obligation.Terms<P>>
|
||||
|
||||
``Amount`` represents quantities as integers. For currencies the quantity represents pennies, cents or whatever
|
||||
else the smallest integer amount for that currency is. You cannot use ``Amount`` to represent negative quantities
|
||||
or fractional quantities: if you wish to do this then you must use a different type e.g. ``BigDecimal``. ``Amount``
|
||||
defines methods to do addition and subtraction and these methods verify that the tokens on both sides of the operator
|
||||
are equal (these are operator overloads in Kotlin and can be used as regular methods from Java). There are also
|
||||
methods to do multiplication and division by integer amounts.
|
||||
|
||||
``Issued`` refers to a product (which can be cash, a cash-like thing, assets, or generally anything else that's
|
||||
quantifiable with integer quantities) and an associated ``PartyAndReference`` that describes the issuer of that contract.
|
||||
An issued product typically follows a lifecycle which includes issuance, movement and exiting from the ledger (for example,
|
||||
see the ``Cash`` contract and its associated *state* and *commands*)
|
||||
|
||||
Financial states
|
||||
----------------
|
||||
In additional to the common state types, a number of interfaces extend ``ContractState`` to model financial state such as:
|
||||
|
||||
``LinearState``
|
||||
A state which has a unique identifier beyond its StateRef and carries it through state transitions.
|
||||
Such a state cannot be duplicated, merged or split in a transaction: only continued or deleted. A linear state is
|
||||
useful when modelling an indivisible/non-fungible thing like a specific deal, or an asset that can't be
|
||||
split (like a rare piece of art).
|
||||
|
||||
``DealState``
|
||||
A LinearState representing an agreement between two or more parties. Intended to simplify implementing generic
|
||||
protocols that manipulate many agreement types.
|
||||
|
||||
``FungibleAsset``
|
||||
A FungibleAsset is intended to be used for contract states representing assets which are fungible, countable and issued by a
|
||||
specific party. States contain assets which are equivalent (such as cash of the same currency), so records of their existence
|
||||
can be merged or split as needed where the issuer is the same. For instance, dollars issued by the Fed are fungible and
|
||||
countable (in cents), barrels of West Texas crude are fungible and countable (oil from two small containers can be poured into one large
|
||||
container), shares of the same class in a specific company are fungible and countable, and so on.
|
||||
|
||||
The following diagram illustrates the complete Contract State hierarchy:
|
||||
|
||||
.. image:: resources/financialContractStateModel.png
|
||||
|
||||
Note there are currently two packages, a core library and a finance model specific library.
|
||||
Developers may re-use or extend the Finance types directly or write their own by extending the base types from the Core library.
|
37
docs/source/key-concepts-flow-framework.rst
Normal file
37
docs/source/key-concepts-flow-framework.rst
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
Flow framework
|
||||
--------------
|
||||
In Corda all communication takes the form of structured sequences of messages passed between parties which we call flows.
|
||||
|
||||
Flows enable complex multi-step, multi-party business interactions to be modelled as blocking code without a central controller.
|
||||
The code is transformed into an asynchronous state machine, with checkpoints written to the node’s backing database when messages are sent and received.
|
||||
A node may potentially have millions of flows active at once and they may last days, across node restarts and even upgrades.
|
||||
|
||||
A flow library is provided to enable developers to re-use common flow types such as notarisation, membership broadcast,
|
||||
transaction resolution and recording, and so on.
|
||||
|
||||
APIs are provided to send and receive object graphs to and from other identities on the network, embed sub-flows,
|
||||
report progress information to observers and even interact with people (for manual resolution of exceptional scenarios)
|
||||
|
||||
Flows are embedded within CorDapps and deployed to a participant's node for execution.
|
||||
|
||||
.. note:: We will be implementing the concept of a flow hospital to provide a means for a node administrator to decide
|
||||
whether a paused flow should be killed or repaired. Flows enter this state if they throw exceptions or explicitly request human assistance.
|
||||
|
||||
Section 4 of the `Technical white paper`_ provides further detail of the above features.
|
||||
|
||||
The following diagram illustrates a sample multi-party business flow:
|
||||
|
||||
.. image:: resources/flowFramework.png
|
||||
|
||||
Note the following:
|
||||
|
||||
* there are 3 participants in this workflow including the notary
|
||||
* the Buyer and Seller flows (depicted in green) are custom written by developers and deployed within a CorDapp
|
||||
* the custom written flows invoke both financial library flows such as ``TwoPartyTradeFlow`` (depicted in orange) and core
|
||||
library flows such as ``ResolveTransactionsFlow`` and ``NotaryFlow`` (depicted in yellow)
|
||||
* each side of the flow illustrates the stage of execution with a progress tracker notification
|
||||
* activities within a flow directly or indirectly interact with its node's ledger (eg. to record a signed, notarised transaction) and vault (eg. to perform a spend of some fungible asset)
|
||||
* flows interact across parties using send, receive and sendReceive messaging semantics (by implementing the ``FlowLogic`` interface)
|
||||
|
||||
.. _`Technical white paper`: _static/corda-technical-whitepaper.pdf
|
46
docs/source/key-concepts-security-model.rst
Normal file
46
docs/source/key-concepts-security-model.rst
Normal file
@ -0,0 +1,46 @@
|
||||
Security model
|
||||
==============
|
||||
|
||||
Corda has been designed from the ground up to implement a global, decentralised database where all nodes are assumed to be
|
||||
untrustworthy. This means that each node must actively cross-check each other's work to reach consensus
|
||||
amongst a group of interacting participants.
|
||||
|
||||
The security model plays a role in the following areas:
|
||||
|
||||
* Identity:
|
||||
Corda is designed for semi-private networks in which admission requires obtaining an identity signed by a root authority.
|
||||
This assumption is pervasive – the flow API provides messaging in terms of identities, with routing and delivery to underlying nodes being handled automatically.
|
||||
See sections 3.2 of the `Technical white paper`_ for further details on identity and the permissioning service.
|
||||
|
||||
* Notarisation: pluggable notaries and algorithms offering different levels of trust.
|
||||
Notaries may be validating or non-validating. A validating notary will resolve and fully check transactions they are asked to deconflict.
|
||||
Without the use of any other privacy features, they gain full visibility into every transaction.
|
||||
On the other hand, non-validating notaries assume transaction validity and do not request transaction data or their dependencies
|
||||
beyond the list of states consumed (and thus, their level of trust is much lower and exposed to malicious use of transaction inputs).
|
||||
From an algorithm perspective, Corda currently provides a distributed notary implementation that uses Raft.
|
||||
|
||||
.. note:: Future notary algorithms may include BFT and hardware assisted non-BFT algorithms (where non-BFT algorithms
|
||||
are converted into a more trusted form using remote attestation and hardware protection).
|
||||
|
||||
* Authentication, authorisation and entitlements:
|
||||
Network permissioning, including node to node authentication, is performed using TLS and certificates.
|
||||
See :doc:`permissioning` for further detail.
|
||||
|
||||
.. warning:: API level authentication (RPC, Web) is currently simple username/password for demonstration purposes and will be revised.
|
||||
Similarly, authorisation is currently based on permission groups applied to flow execution.
|
||||
This is subject to design review with views to selecting a proven, mature entitlements solution.
|
||||
|
||||
Privacy techniques
|
||||
|
||||
* Partial data visibility: transactions are not globally broadcast as in many other systems.
|
||||
* Transaction tear-offs: Transactions are structured as Merkle trees, and may have individual subcomponents be revealed to parties who already know the Merkle root hash. Additionally, they may sign the transaction without being able to see all of it.
|
||||
|
||||
See :doc:`merkle-trees` for further detail.
|
||||
|
||||
* Multi-signature support: Corda uses composite keys to support scenarios where more than one key or party is required to authorise a state object transition.
|
||||
|
||||
.. note:: Future privacy techniques will include key randomisation, graph pruning, deterministic JVM sandboxing and support for secure signing devices.
|
||||
See sections 10 and 13 of the `Technical white paper`_ for detailed descriptions of these techniques and features.
|
||||
|
||||
.. _`Technical white paper`: _static/corda-technical-whitepaper.pdf
|
||||
|
52
docs/source/key-concepts-vault.rst
Normal file
52
docs/source/key-concepts-vault.rst
Normal file
@ -0,0 +1,52 @@
|
||||
Vault
|
||||
=====
|
||||
|
||||
The vault contains data extracted from the ledger that is considered relevant to the node’s owner, stored in a relational model
|
||||
that can be easily queried and worked with.
|
||||
|
||||
The vault keeps track of both unconsumed and consumed states:
|
||||
|
||||
* Unconsumed (or unspent) states represent fungible states available for spending (including spend-to-self transactions)
|
||||
and linear states available for evolution (eg. in response to a lifecycle event on a deal) or transfer to another party.
|
||||
* Consumed (or spent) states represent ledger immutable state for the purpose of transaction reporting, audit and archival, including the ability to perform joins with app-private data (like customer notes)
|
||||
|
||||
By fungible we refer to assets of measurable quantity (eg. a cash currency, units of stock) which can be combined
|
||||
together to represent a single ledger state.
|
||||
|
||||
Like with a cryptocurrency wallet, the Corda vault can create transactions that send value (eg. transfer of state) to someone else
|
||||
by combining fungible states and possibly adding a change output that makes the values balance (this process is usually referred to as ‘coin selection’).
|
||||
Vault spending ensures that transactions respect the fungibility rules in order to ensure that the issuer and reference data is preserved as the assets pass from hand to hand.
|
||||
|
||||
.. note:: Basic 'coin selection' is currently implemented. Future work includes fungible state optimisation (splitting and
|
||||
merging of states in the background), 'soft locking' (ability to automatically or explicitly reserve states to prevent
|
||||
multiple transactions trying to use the same output simultaneously), 'state re-issuance' (sending of states back to the
|
||||
issuer for re-issuance, thus pruning long transaction chains and improving privacy).
|
||||
|
||||
There is also a facility for attaching descriptive textual notes against any transaction stored in the vault.
|
||||
|
||||
The vault supports the management of data in both authoritative ("on-ledger") form and, where appropriate, shadow ("off-ledger") form:
|
||||
|
||||
* "On-ledger" data refers to distributed ledger state (cash, deals, trades) to which a firm is participant.
|
||||
* "Off-ledger" data refers to a firm's internal reference, static and systems data.
|
||||
|
||||
The following diagram illustrates the breakdown of the vault into sub-system components:
|
||||
|
||||
.. image:: resources/vault.png
|
||||
|
||||
Note the following:
|
||||
|
||||
* the vault "On Ledger" store tracks unconsumed state and is updated internally by the node upon recording of a transaction on the ledger
|
||||
(following successful smart contract verification and signature by all participants)
|
||||
* the vault "Off Ledger" store refers to additional data added by the node owner subsequent to transaction recording
|
||||
* the vault performs fungible state spending (and in future, fungible state optimisation management including merging, splitting and re-issuance)
|
||||
* vault extensions represent additional custom plugin code a developer may write to query specific custom contract state attributes.
|
||||
* customer "Off Ledger" (private store) represents internal organisational data that may be joined with the vault data to perform additional reporting or processing
|
||||
* a vault query API is exposed to developers using standard Corda RPC and CorDapp plugin mechanisms
|
||||
* a vault update API is internally used by transaction recording flows.
|
||||
* the vault database schemas are directly accessible via JDBC for customer joins and queries
|
||||
|
||||
Section 8 of the `Technical white paper`_ describes features of the vault yet to be implemented including private key managament,
|
||||
soft state locking, state splitting and merging, asset re-issuance and node event scheduling.
|
||||
|
||||
.. _`Technical white paper`: _static/corda-technical-whitepaper.pdf
|
||||
|
21
docs/source/key-concepts.rst
Normal file
21
docs/source/key-concepts.rst
Normal file
@ -0,0 +1,21 @@
|
||||
Overview
|
||||
========
|
||||
|
||||
This section describes the fundamental concepts and features that underpin the Corda platform, to include:
|
||||
|
||||
* :doc:`key-concepts-ecosystem`
|
||||
* :doc:`key-concepts-data-model`
|
||||
* :doc:`key-concepts-core-types`
|
||||
* :doc:`key-concepts-financial-model`
|
||||
* :doc:`key-concepts-flow-framework`
|
||||
* :doc:`key-concepts-consensus-notaries`
|
||||
* :doc:`key-concepts-vault`
|
||||
* :doc:`key-concepts-security-model`
|
||||
|
||||
Detailed thinking and rationale behind these concepts are presented in the following published white papers:
|
||||
|
||||
* `Corda: An Introduction`_
|
||||
* `Corda: A Distributed Ledger`_ (Technical White Paper)
|
||||
|
||||
.. _`Corda: An Introduction`: _static/corda-introductory-whitepaper.pdf
|
||||
.. _`Corda: A Distributed Ledger`: _static/corda-technical-whitepaper.pdf
|
BIN
docs/source/resources/contract.png
Normal file
BIN
docs/source/resources/contract.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 120 KiB |
BIN
docs/source/resources/cordaNetwork.png
Normal file
BIN
docs/source/resources/cordaNetwork.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 100 KiB |
BIN
docs/source/resources/financialContractStateModel.png
Normal file
BIN
docs/source/resources/financialContractStateModel.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 117 KiB |
BIN
docs/source/resources/flowFramework.png
Normal file
BIN
docs/source/resources/flowFramework.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 KiB |
BIN
docs/source/resources/vault.png
Normal file
BIN
docs/source/resources/vault.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 233 KiB |
@ -21,6 +21,8 @@ extend the demos. For more details about running via the command line or from wi
|
||||
|
||||
.. note:: If any of the demos don't work, please raise an issue on GitHub.
|
||||
|
||||
.. _trader-demo:
|
||||
|
||||
Trader demo
|
||||
-----------
|
||||
|
||||
@ -55,6 +57,8 @@ To run from IntelliJ:
|
||||
5. In the "Trader Demo: Run Nodes" run configuration window, you should see some log lines scroll past. Within a few seconds, the message
|
||||
"Purchase complete - we are a happy customer!" should be printed.
|
||||
|
||||
.. _irs-demo:
|
||||
|
||||
IRS demo
|
||||
--------
|
||||
|
||||
@ -260,6 +264,8 @@ Using the following login details:
|
||||
|
||||
See https://docs.corda.net/node-explorer.html for further details on usage.
|
||||
|
||||
.. _simm-demo:
|
||||
|
||||
SIMM and Portfolio Demo - aka the Initial Margin Agreement Demo
|
||||
---------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user