Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICS 2: Consensus Verification #20

Merged
merged 53 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
bd3f466
add README
mossid Feb 26, 2019
22a53a6
in progress
mossid Feb 26, 2019
bc02fbb
in progress
mossid Feb 26, 2019
06969cf
latex -> md
mossid Feb 27, 2019
822d40d
rename folder
mossid Feb 27, 2019
536299d
rm appendex, do todos
mossid Feb 27, 2019
7b88a58
add lightclients, port from docs/spec/ibc
mossid Feb 28, 2019
d646f3f
add impl
mossid Feb 28, 2019
7be1fc0
format with ics1
mossid Mar 5, 2019
6cf8a45
fix grammar
mossid Mar 6, 2019
ad95c82
add example
mossid Mar 6, 2019
5217fc7
copy summary from docs/ibc, add motivation
mossid Mar 6, 2019
d6eecfc
rename folder
mossid Mar 6, 2019
5778915
Update spec/ics-2-consensus-requirements/README.md
cwgoes Mar 14, 2019
6662828
Update spec/ics-2-consensus-requirements/README.md
cwgoes Mar 14, 2019
47c345c
address comments in progress
mossid Mar 20, 2019
dfe5366
Merge branch 'joon/ics-3-ibc-semantics' of github.com:cosmos/ics into…
mossid Mar 20, 2019
de89aa8
apply discussion
mossid Mar 29, 2019
946a881
add example
mossid Mar 29, 2019
e35778a
address comments typo/phrasing/etc.
mossid Apr 1, 2019
5e7581e
fix typo, add .gitignore, address comments
mossid Apr 2, 2019
6fa0cb0
Apply suggestions from code review
cwgoes Apr 2, 2019
0ecd41b
in progress
mossid Apr 3, 2019
b4582b3
move lc verifier to consensus, make vars readable
mossid Apr 4, 2019
a1d6fee
move update logic out
mossid Apr 4, 2019
784ecc6
address comments
mossid Apr 10, 2019
36c2245
restructured, separate verifier from consensus
mossid Apr 23, 2019
e2bcf68
Add subcomponents with pseudocode
mossid Apr 24, 2019
d156573
modify update, comment out example
mossid Apr 24, 2019
c59d7d3
add getter/setter, add comment for commit/blockchain
mossid Apr 24, 2019
f6c5174
Apply suggestions from code review
cwgoes Apr 25, 2019
d477958
address comments in progress
mossid Apr 29, 2019
384cef2
Create VERIFIER.md
mossid Apr 29, 2019
20ab792
move verifier-fullnode to VERIFIER.md
mossid Apr 29, 2019
308d046
Apply suggestions from code review
mossid Apr 30, 2019
0650090
apply comments
mossid May 16, 2019
bb8dfd6
Merge branch 'joon/ics-3-ibc-semantics' of github.com:cosmos/ics into…
mossid May 16, 2019
d294123
apply ICS25/ICS1
mossid May 20, 2019
76bde63
Apply suggestions from code review
mossid May 21, 2019
d425538
Merge branch 'master' into joon/ics-3-ibc-semantics
cwgoes May 21, 2019
4fc5bcd
Merge branch 'master' into joon/ics-3-ibc-semantics
cwgoes May 21, 2019
e3bafba
address comments in progress
mossid May 22, 2019
8847b89
address comments in progress
mossid May 22, 2019
2c37fb5
Merge branch 'joon/ics-3-ibc-semantics' of github.com:cosmos/ics into…
mossid May 22, 2019
6adcd74
in progres
mossid May 22, 2019
6cd10c9
address comments
mossid May 22, 2019
0f651a8
reformat, fix links
mossid May 22, 2019
34a302f
Merge branch 'master' into joon/ics-3-ibc-semantics
mossid May 22, 2019
b9e3d79
fix link section
mossid May 22, 2019
fe18de8
fix links
mossid May 22, 2019
bedd1fc
fix link
mossid May 22, 2019
da0da4c
fix section
mossid May 22, 2019
e8e560c
fix script to test only readmes
mossid May 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.swp
*.swo
219 changes: 219 additions & 0 deletions spec/ics-2-consensus-verification/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
---

ics: 2
title: Consensus Verification
stage: draft
category: ibc-core
requires: 23
cwgoes marked this conversation as resolved.
Show resolved Hide resolved
required-by: 3
author: Juwoon Yun <joon@tendermint.com>, Christopher Goes <cwgoes@tendermint.com>
created: 2019-02-25
modified: 2019-04-02
mossid marked this conversation as resolved.
Show resolved Hide resolved

---

## Synopsis

This standard specifies the properties that consensus algorithms of chains implementing IBC are
expected to satisfy. The properties are needed for efficient and safe verification in the higher
mossid marked this conversation as resolved.
Show resolved Hide resolved
level protocol abstractions. The algorithm which uses these properties to verify substates of
another chain is referred to as a "light client".

## Specification
mossid marked this conversation as resolved.
Show resolved Hide resolved

### Motivation

`FullNode`s are procedures running a `Consensus`. Given a `([Transaction], Commit)`, a
`FullNode` can compute the result `RootOfTrust` that the `Consensus` is expected to commit on
with the same `[Transaction]`, if exists.

`Blockchain` defines required properties of the blockchain on the network. The implementors can
check whether the consensus that they are using is qualified to be connected to the network or
not. If not, they can modify the algorithm or wrap it with additional logic to make it
compatible with the specification. It also provides base layer for the protocol that the other
components can rely on.

### Desired Properties

This standard specification provides secure layer to verify other chains' canonical headers,
using the existing `RootOfTrust`. The higher level logics can be able to verify the substate
with the `AccumulatorRoot` stored in the `RootOfTrust`, which is guaranteed to be committed by
the other chain's consensus algorithm.

* Blockchains, defined as an infinite list of `Header` starting from a genesis `RootOfTrust`,
are linear; no conflicting `Header`s can be both validated, thus no past accumulator roots can
be changed after they have been committed. Two `Header`s are conflicting when they both have the
same height in a blockchain but are not equal.

* Verifiers can verify future `Header`s using an existing `RootOfTrust`. When the verifier
validates it, the verified header is in the canonical blockchain.

* `RootOfTrust`s contains an accumulator root (ICS23) that the downstream logic can use to
verify whether key-value pairs are present in the state or not.

### Technical Specification

#### Definitions

##### Types

* `RootOfTrust` is a blockchain commit which contains an accumulator root and the requisite
state to verify future roots, stored in one blockchain to verify the state of the other.
Defined as 2-tuple `(base :: VerifierBase, root :: AccumulatorRoot)`,
where
* `base` is a data used by `Consensus.Verifier` to verify `Header`s
* `root` is the `AccumuatorRoot`, used to prove internal state

* `Header` is a blockchain header which provides information to update `RootOfTrust`,
submitted to one blockchain to update the stored `RootOfTrust`.
Defined as 3-tuple `(proof :: HeaderProof, base :: Maybe<VerifierBase>, root :: AccumulatorRoot)`,
where
* `proof` is the commit proof used by `Consensus.Verifier` to be verified
* `base` is the new verify, if needed to be updated
* `root` is the new `AccumulatorRoot` which will replace the existing one

* `Consensus` is a blockchain consensus algorithm which generates valid `Header`s.
Defined as 2-tuple `(commit :: RootOfTrust -> [Message] -> Header, verify :: RootOfTrust ->
Header -> Error|RootOfTrust)` where
* `commit` is the header generation function from the base `RootOfTrust` and arbitrary messages
* `verify` is the verifier, proves `Header.proof` and returns the updated `RootOfTrust`

* `Blockchain` is defined as 3-tuple `(cons :: Consensus, genesis :: RootOfTrust,
headers :: [Header])`, where
* `cons` is the Consensus algorithm that is running the blockchain
* `genesis` is the genesis `RootOfTrust`
* `headers` is the list of header generated by `c`, starting from the `gen`. In detail,
`B.hs` is defined as `B.hs = fold(B.c, zip(B.gen:B.hs, msgs))` for arbitrary `msgs`
in `[Message]`
// XXX: make it readable

* `update` is a helper function using `Consensus.verify` to update the existing
`RootOfTrust`, defined as

```
function update(cons :: Consensus, rot :: RootOfTrust, h :: Header) returns (Error|RootOfTrust) {
if cons.verify(rot, h):
if h.base != Nothing:
return RootOfTrust(h.base, h.root)
else:
return RoofOfTrust(rot.base, h.root)
else:
return Error

}
```

##### Functions

* `Height :: Blockchain -> Header -> Uint` returns the position of the header in the
Blockchain's header list.

#### Requirements

Consensus verification requires the following accumulator primitives with datastructures and
properties as defined in ICS23:

* `AccumulatorRoot`

#### Subprotocols

##### Verifier

The verifier algorithm checks that new `Header`s were in fact generated by a blockchain. It is expected to verify a `Header`
efficiently; far more efficiently than replaying `Consensus` logic for the given parent `Header` and the
list of network messages, idealy in O(1) time. `Header.p` provides the proof that the verifier can use.
Verifiers assume the following properties will be satisfied for the `Header`s:

1. `Header`s have no more than one direct child

* Satisfied if: deterministic safety
* Possible violation scenario: validator double signing, chain reorganization (Nakamoto consensus)

2. `Header`s eventually have at least one direct child

* Satisfied if: liveness, light-client verifier continuity
* Possible violation scenario: synchronized halt, incompatible hard fork

3. `Header`s are generated from the `Consensus`, which ensures valid transition of the state

* Satisfied if: correct block generation & state machine
* Possible violation scenario: invariant break, validator cartel

##### Accumulator Root

`RootOfTrust` contains an accumulator root, which identifies the whole state of the
corresponding blockchain at the point of time that the commit is generated. It is expected that
the verifying inclusion or exclusion of certain data in the accumulator can be done efficiently. See
ICS23 for the details about the `AccumulatorRoot`s.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ICS23 does not mention pubkey (at least currently)


##### Consensus

`Consensus` is a blockchain protocol which actually generates a list of `Header`s from the latest
state and the incoming transactions. While the chains on the network does not directly proving the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by this sentence?

consensus process, it is expected that the consensus algorithms will generate valid `Header`s.

### Example Implementation

An example blockchain `B` runs on a single operator consensus algorithm, called `Op`. If a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great example! Do you think we can use at least two or three-letter variable names? It would make it easier to read. e.g. - Hdr

block is signed by the operator, then it is valid. The operator signing key can be changed while
the chain is running. In that case, the new header stores the updated pubkey.

`H` contains `LogStore`, which is a list with type of `[bytes]`. The whole state is serialized
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not clear what LogStore is...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change the example to a simple KVStore, which seems more appropriate

and stored as `AccumulatorRoot`

#### Consensus

`B` is defined as `(Op, Gen, [H])`. `B` satisfies `Blockchain`:

```
TX = Append(bytes) or ChangeOperator(Pubkey)

function commit(h :: H, txs :: [TX]) returns C {
store := c.AccumulatorRoot
newpubkey := c.Pubkey

foreach tx in txs:
case Append(data):
state = state + data
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be confused here, but are store and state supposed to be the same thing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, fixed!

case ChangeOperator(pubkey):
newpubkey = pubkey

result := H(newpubkey, store)
sig := Privkey.Sign(result)
return C(sig, result)
}

function verify(rot :: ROT, h :: H) returns rot.Pubkey.VerifySignature(h.Sig)

Op = (commit, verify)

Gen = ROT(InitialPubkey, EmptyLogStore)
```

The `[H]` is generated by `Op.commit`, recursivly applied on the genesis and its successors.
The `[TX]` applied on the `Op.commit` can be any value, but when the `B` is instantiated
in the real world, the `[TX]` is fixed to a single value to satisfy consensus properties. In
this example, we assume that it is enforced by a legal authority.

#### RootOfTrust

Type `ROT` is defined as `(Pubkey, LogStore)`. `ROT` satisfies `RootOfTrust`:

```
function ROT.base() returns ROT.Pubkey
function ROT.root() returns ROT.LogStore
```

#### Header

Type `H` is defined as `(Sig, Maybe<Pubkey>, LogStore)`. `H` satisfies `Header`:

```
function H.proof() returns H.Sig
function H.base() returns H.Pubkey
function H.root() returns H.LogStore
```

## History

March 5th 2019: Initial ICS 2 draft finished and submitted as a PR