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

Start 1.0.0-rc1 #157

Merged
merged 5 commits into from
Aug 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion spec.pdc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ toc-own-page: true
mainfont: DejaVuSerifCondensed
fontsize: 8pt
author: IBC Specification Team
date: \today \ - \textbf{1.0.0-rc0}
date: \today \ - \textbf{1.0.0-rc1}
urlcolor: cyan
header-includes:
- \usepackage{graphicx}
Expand Down
Binary file modified spec.pdf
Binary file not shown.
18 changes: 10 additions & 8 deletions spec/ics-003-connection-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ function connOpenInit(
function connOpenTry(
desiredIdentifier: Identifier, counterpartyConnectionIdentifier: Identifier,
counterpartyClientIdentifier: Identifier, clientIdentifier: Identifier,
proofInit: CommitmentProof, proofHeight: uint64,
proofInit: CommitmentProof, proofHeight: uint64, consensusHeight: uint64,
timeoutHeight: uint64, nextTimeoutHeight: uint64) {
assert(getConsensusState().getHeight() <= timeoutHeight)
assert(consensusHeight <= getCurrentHeight())
assert(getCurrentHeight() <= timeoutHeight)
counterpartyStateRoot = get(rootKey(connection.clientIdentifier, proofHeight))
expectedConsensusState = getConsensusState()
expectedConsensusState = getConsensusState(consensusHeight)
expected = ConnectionEnd{INIT, desiredIdentifier, counterpartyClientIdentifier, clientIdentifier, timeoutHeight}
assert(verifyMembership(counterpartyStateRoot, proofInit,
connectionKey(counterpartyConnectionIdentifier), expected))
Expand All @@ -199,12 +200,13 @@ function connOpenTry(
```typescript
function connOpenAck(
identifier: Identifier, proofTry: CommitmentProof, proofHeight: uint64,
timeoutHeight: uint64, nextTimeoutHeight: uint64) {
assert(getConsensusState().getHeight() <= timeoutHeight)
consensusHeight: uint64, timeoutHeight: uint64, nextTimeoutHeight: uint64) {
assert(consensusHeight <= getCurrentHeight())
assert(getCurrentHeight() <= timeoutHeight)
connection = get(connectionKey(identifier))
assert(connection.state === INIT)
counterpartyStateRoot = get(rootKey(connection.clientIdentifier, proofHeight))
expectedConsensusState = getConsensusState()
expectedConsensusState = getConsensusState(consensusHeight)
expected = ConnectionEnd{TRYOPEN, identifier, connection.counterpartyClientIdentifier,
connection.clientIdentifier, timeoutHeight}
assert(verifyMembership(counterpartyStateRoot, proofTry,
Expand All @@ -223,7 +225,7 @@ function connOpenAck(
function connOpenConfirm(
identifier: Identifier, proofAck: CommitmentProof,
proofHeight: uint64, timeoutHeight: uint64)
assert(getConsensusState().getHeight() <= timeoutHeight)
assert(getCurremtHeight() <= timeoutHeight)
connection = get(connectionKey(identifier))
assert(connection.state === TRYOPEN)
counterpartyStateRoot = get(rootKey(connection.clientIdentifier, proofHeight))
Expand Down Expand Up @@ -313,7 +315,7 @@ function connCloseInit(identifier: Identifier) {
```typescript
function connCloseConfirm(
identifier: Identifier, proofInit: CommitmentProof, proofHeight: uint64) {
assert(getConsensusState().getHeight() <= timeoutHeight)
assert(getCurrentHeight() <= timeoutHeight)
connection = get(connectionKey(identifier))
assert(connection.state === OPEN)
counterpartyStateRoot = get(rootKey(connection.clientIdentifier, proofHeight))
Expand Down
8 changes: 4 additions & 4 deletions spec/ics-004-channel-and-packet-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ In order to provide the desired ordering, exactly-once delivery, and module perm

`commit` is a generic collision-resistant hash function, the specifics of which must be agreed on by the modules utilizing the channel.

`Identifier`, `get`, `set`, `delete`, `getConsensusState`, and module-system related primitives are as defined in [ICS 24](../ics-024-host-requirements).
`Identifier`, `get`, `set`, `delete`, `getCurrentHeight`, and module-system related primitives are as defined in [ICS 24](../ics-024-host-requirements).

A *channel* is a pipeline for exactly-once packet delivery between specific modules on separate blockchains, which has at least one end capable of sending packets and one end capable of receiving packets.

Expand Down Expand Up @@ -242,7 +242,7 @@ function chanOpenTry(
timeoutHeight: uint64, nextTimeoutHeight: uint64,
proofInit: CommitmentProof, proofHeight: uint64) {
assert(connectionHops.length === 2)
assert(getConsensusState().height < timeoutHeight)
assert(getCurrentHeight() < timeoutHeight)
assert(get(channelKey(portIdentifier, channelIdentifier)) === null)
assert(authenticate(get(portKey(portIdentifier))))
connection = get(connectionKey(connectionHops[0]))
Expand Down Expand Up @@ -272,7 +272,7 @@ function chanOpenAck(
channelIdentifier: Identifier, portIdentifier: Identifier,
timeoutHeight: uint64, nextTimeoutHeight: uint64,
proofTry: CommitmentProof, proofHeight: uint64) {
assert(getConsensusState().height < timeoutHeight)
assert(getCurrentHeight() < timeoutHeight)
channel = get(channelKey(portIdentifier, channelIdentifier))
assert(channel.state === INIT)
assert(authenticate(get(portKey(portIdentifier))))
Expand All @@ -299,7 +299,7 @@ of the handshake-originating module on the other chain and finish the channel op
function chanOpenConfirm(
portIdentifier: Identifier, channelIdentifier: Identifier,
timeoutHeight: uint64, proofAck: CommitmentProof, proofHeight: uint64) {
assert(getConsensusState().height < timeoutHeight)
assert(getCurrentHeight() < timeoutHeight)
channel = get(channelKey(portIdentifier, channelIdentifier))
assert(channel.state === OPENTRY)
assert(authenticate(get(portKey(portIdentifier))))
Expand Down
27 changes: 19 additions & 8 deletions spec/ics-020-fungible-token-transfer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,54 +110,65 @@ function onChanOpenTry(

```typescript
function onChanOpenAck(portIdentifier: Identifier, channelIdentifier: Identifier, nextTimeoutHeight: uint64): boolean {
// accept all acknowledgements, port has already been validated
return true
}
```

```typescript
function onChanOpenConfirm(portIdentifier: Identifier, channelIdentifier: Identifier): boolean {
// accept confirmations, port has already been validated
return true
}
```

```typescript
function onChanOpenTimeout(portIdentifier: Identifier, channelIdentifier: Identifier): void {
// ??
// no action necessary
}
```

```typescript
function onChanCloseConfirm(portIdentifier: Identifier, channelIdentifier: Identifier): void {
return true
// no action necessary
}
```

```typescript
function onRecvPacket(packet: Packet): bytes {
FungibleTokenPacketData data = packet.data
// verify receiving denomination
// unescrow coins in amount (if source) or escrow (if destination)
// transfer coins to user
prefix = "{packet.destPort}/{packet.destChannel}"
assert(data.denomination.slice(0, len(prefix)) === prefix)
bank.TransferCoins(escrowAccount, data.denomination, data.amount, data.receiver)
return 0x
}
```

```typescript
function onTimeoutPacket(packet: Packet): boolean {
FungibleTokenPacketData data = packet.data
// refund tokens
prefix = "{packet.destPort}/{packet.destChannel}"
assert(data.denomination.slice(0, len(prefix)) === prefix)
bank.TransferCoins(escrowAccount, data.denomination.slice(len(prefix)), data.amount, data.sender)
}
```

```typescript
function sendPacket(packet: Packet): boolean {
prefix = "{packet/destPort}/{packet.destChannel}"
bank.TransferCoins(data.sender, data.denomination.slice(len(prefix)), data.amount, escrowAccount)
relayerModule.sendPacket(packet)
}

#### Reasoning

##### Correctness

This implementation preserves both fungibility & supply.

Fungibility: send back to other chain. If had previously sent, can send back.
Fungibility: If tokens have been sent to the coutnerparty chain, they can be redeemed back in the same denomination & amount on the source chain.

Supply: Redefine supply as unlocked tokens. All send-recv pairs are net zero. Source chain can change supply.
Supply: Redefine supply as unlocked tokens. All send-recv pairs sum to net zero. Source chain can change supply.

##### Multi-chain notes

Expand Down
10 changes: 8 additions & 2 deletions spec/ics-024-host-requirements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ These functions MUST be permissioned to the IBC handler module (the implementati

### Consensus State Introspection

Host chains MUST provide the ability to introspect their current height, with `getCurrentHeight`:

```
type getCurrentHeight = () => uint64
```

Host chains MUST define a unique `ConsensusState` type fulfilling the requirements of [ICS 2](../ics-002-consensus-verification):

```typescript
Expand All @@ -74,10 +80,10 @@ type ConsensusState object
Host chains MUST provide the ability to introspect their own consensus state, with `getConsensusState`:

```typescript
type getConsensusState = () => ConsensusState
type getConsensusState = (height: uint64) => ConsensusState
```

`getConsensusState` MUST return the current consensus state for the consensus algorithm of the host chain.
`getConsensusState` MUST return the consensus state for the consensus algorithm of the host chain at the specified height, for all heights greater than zero and less than or equal to the current height.

### Port system

Expand Down
12 changes: 9 additions & 3 deletions spec/ics-025-handler-interface/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ The default IBC relayer module will allow external calls to `connOpenTry`.
function connOpenTry(
desiredIdentifier: Identifier, counterpartyConnectionIdentifier: Identifier,
counterpartyClientIdentifier: Identifier, clientIdentifier: Identifier,
proofInit: CommitmentProof, timeoutHeight: uint64, nextTimeoutHeight: uint64) {
proofInit: CommitmentProof, proofHeight: uint64, consensusHeight: uint64,
timeoutHeight: uint64, nextTimeoutHeight: uint64) {
// defined in ICS 3
}
```
Expand All @@ -125,6 +126,7 @@ The default IBC relayer module will allow external calls to `connOpenAck`.
```typescript
function connOpenAck(
identifier: Identifier, proofTry: CommitmentProof,
proofHeight: uint64, consensusHeight: uint64,
timeoutHeight: uint64, nextTimeoutHeight: uint64) {
// defined in ICS 3
}
Expand All @@ -135,7 +137,9 @@ function connOpenAck(
The default IBC relayer module will allow external calls to `connOpenConfirm`.

```typescript
function connOpenConfirm(identifier: Identifier, proofAck: CommitmentProof, timeoutHeight: uint64) {
function connOpenConfirm(
identifier: Identifier, proofAck: CommitmentProof,
proofHeight: uint64, timeoutHeight: uint64) {
// defined in ICS 3
}
```
Expand All @@ -145,7 +149,9 @@ function connOpenConfirm(identifier: Identifier, proofAck: CommitmentProof, time
The default IBC relayer module will allow external calls to `connOpenTimeout`.

```typescript
function connOpenTimeout(identifier: Identifier, proofTimeout: CommitmentProof, timeoutHeight: uint64) {
function connOpenTimeout(
identifier: Identifier, proofTimeout: CommitmentProof,
proofHeight: uint64, timeoutHeight: uint64) {
// defined in ICS 3
}
```
Expand Down