Skip to content

Commit

Permalink
Merge PR cosmos#156: Add data structures in proto3 (wip)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwgoes authored Jul 29, 2019
1 parent e4aafe5 commit 421aa20
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ check_sections:
python ./scripts/check_sections.py

check_proto:
$(MAKE) -C spec/ics-002-consensus-verification check_proto
$(MAKE) -C spec/ics-003-connection-semantics check_proto
$(MAKE) -C spec/ics-004-channel-and-packet-semantics check_proto
$(MAKE) -C spec/ics-020-fungible-token-transfer check_proto
$(MAKE) -C spec/ics-026-relayer-module check_proto

Expand Down
Binary file modified spec.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions spec/ics-002-consensus-verification/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
check_proto:
/bin/bash -c 'TEMP=$$(mktemp); protoc data-structures.proto -o $$TEMP; rm -f $$TEMP'

.PHONY: check_proto
5 changes: 2 additions & 3 deletions spec/ics-002-consensus-verification/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ The `ConsensusState` of a chain is stored by other chains in order to verify the
```typescript
interface ConsensusState {
height: uint64
root: CommitmentRoot
validityPredicate: ValidityPredicate
equivocationPredicate: EquivocationPredicate
}
Expand Down Expand Up @@ -128,14 +127,14 @@ Headers can be submitted to an associated client to update the stored `Consensus
interface Header {
height: uint64
proof: HeaderProof
state: Maybe[ConsensusState]
predicate: Maybe[ValidityPredicate]
root: CommitmentRoot
}
```
where
* `height` is the height of the the consensus instance.
* `proof` is the commit proof used by `Consensus.ValidityPredicate` to verify the header.
* `state` is the new (or partially new) consensus state.
* `predicate` is the new (or partially new) consensus state.
* `root` is the new `CommitmentRoot` which will replace the existing one.

#### ValidityPredicate
Expand Down
14 changes: 14 additions & 0 deletions spec/ics-002-consensus-verification/data-structures.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = 'proto3';

message ConsensusState {
uint64 height = 1;
bytes validityPredicate = 2; // TODO
bytes equivocationPredicate = 3; // TODO
}

message Header {
uint64 height = 1;
bytes proof = 2;
bytes predicate = 3;
bytes commitmentRoot = 4;
}
5 changes: 4 additions & 1 deletion spec/ics-003-connection-semantics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ cleanup:
clean:
rm -f *.png

.PHONY: all clean cleanup
check_proto:
/bin/bash -c 'TEMP=$$(mktemp); protoc data-structures.proto -o $$TEMP; rm -f $$TEMP'

.PHONY: all clean cleanup check_proto
1 change: 0 additions & 1 deletion spec/ics-003-connection-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ This ICS defines the `ConnectionState` and `ConnectionEnd` types:
enum ConnectionState {
INIT,
TRYOPEN,
CLOSETRY,
OPEN,
CLOSED,
}
Expand Down
16 changes: 16 additions & 0 deletions spec/ics-003-connection-semantics/data-structures.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
syntax = 'proto3';

enum ConnectionState {
INIT = 0;
TRYOPEN = 1;
OPEN = 2;
CLOSED = 3;
}

message ConnectionEnd {
ConnectionState state = 1;
string counterpartyConnectionIdentifier = 2;
string clientIdentifier = 3;
string counterpartyClientIdentifier = 4;
uint64 nextTimeoutHeight = 5;
}
5 changes: 4 additions & 1 deletion spec/ics-004-channel-and-packet-semantics/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ cleanup:
clean:
rm -f *.png

.PHONY: all clean cleanup
check_proto:
/bin/bash -c 'TEMP=$$(mktemp); protoc data-structures.proto -o $$TEMP; rm -f $$TEMP'

.PHONY: all clean cleanup check_proto
5 changes: 2 additions & 3 deletions spec/ics-004-channel-and-packet-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ An *end* of a channel is a data structure on one chain storing channel metadata:

```typescript
interface ChannelEnd {
state: ChannelEndState
state: ChannelState
ordering: ChannelOrder
counterpartyPortIdentifier: Identifier
counterpartyChannelIdentifier: Identifier
Expand All @@ -85,11 +85,10 @@ interface ChannelEnd {
Channel ends have a *state*:

```typescript
enum ChannelEndState {
enum ChannelState {
INIT,
OPENTRY,
OPEN,
CLOSETRY,
CLOSED,
}
```
Expand Down
22 changes: 22 additions & 0 deletions spec/ics-004-channel-and-packet-semantics/data-structures.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = 'proto3';

enum ChannelOrder {
ORDERED = 0;
UNORDERED = 1;
}

enum ChannelState {
INIT = 0;
OPENTRY = 1;
OPEN = 2;
CLOSED = 3;
}

message ChannelEnd {
ChannelState state = 1;
ChannelOrder ordering = 2;
string counterpartyPortIdentifier = 3;
string counterpartyChannelIdentifier = 4;
repeated string connectionHops = 5;
uint64 nextTimeoutHeight = 6;
}

0 comments on commit 421aa20

Please sign in to comment.