Skip to content

Commit

Permalink
extend 03-connection with a proof object for chains that can't intros…
Browse files Browse the repository at this point in the history
…pect their own consensus state. (#839)

* extend 03-connection with HostConsensusStateProof

* make hostConsensusStateProof optional
  • Loading branch information
seunlanlege authored Nov 30, 2022
1 parent 01dbba9 commit 17d62c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions spec/core/ics-003-connection-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,15 @@ function connOpenTry(
proofClient: CommitmentProof,
proofConsensus: CommitmentProof,
proofHeight: Height,
consensusHeight: Height) {
consensusHeight: Height,
hostConsensusStateProof?: bytes,
) {
// generate a new identifier
identifier = generateIdentifier()

abortTransactionUnless(validateSelfClient(clientState))
abortTransactionUnless(consensusHeight < getCurrentHeight())
expectedConsensusState = getConsensusState(consensusHeight)
expectedConsensusState = getConsensusState(consensusHeight, hostConsensusStateProof)
expectedConnectionEnd = ConnectionEnd{INIT, "", getCommitmentPrefix(), counterpartyClientIdentifier,
clientIdentifier, counterpartyVersions, delayPeriodTime, delayPeriodBlocks}

Expand Down Expand Up @@ -413,12 +415,14 @@ function connOpenAck(
proofClient: CommitmentProof,
proofConsensus: CommitmentProof,
proofHeight: Height,
consensusHeight: Height) {
consensusHeight: Height,
hostConsensusStateProof?: bytes,
) {
abortTransactionUnless(consensusHeight < getCurrentHeight())
abortTransactionUnless(validateSelfClient(clientState))
connection = provableStore.get(connectionPath(identifier))
abortTransactionUnless((connection.state === INIT && connection.version.indexOf(version) !== -1)
expectedConsensusState = getConsensusState(consensusHeight)
expectedConsensusState = getConsensusState(consensusHeight, hostConsensusStateProof)
expectedConnectionEnd = ConnectionEnd{TRYOPEN, identifier, getCommitmentPrefix(),
connection.counterpartyClientIdentifier, connection.clientIdentifier,
version, connection.delayPeriodTime, connection.delayPeriodBlocks}
Expand Down
8 changes: 6 additions & 2 deletions spec/core/ics-024-host-requirements/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ requires: 23
required-by: 2, 3, 4, 5, 18
author: Christopher Goes <[email protected]>
created: 2019-04-16
modified: 2022-07-05
modified: 2022-09-14
---

## Synopsis
Expand Down Expand Up @@ -170,11 +170,15 @@ Host state machines MUST define a unique `ConsensusState` type fulfilling the re
Host state machines MUST provide the ability to introspect their own consensus state, with `getConsensusState`:
```typescript
type getConsensusState = (height: Height) => ConsensusState
type getConsensusState = (height: Height, proof?: bytes) => ConsensusState
```
`getConsensusState` MUST return the consensus state for at least some number `n` of contiguous recent heights, where `n` is constant for the host state machine. Heights older than `n` MAY be safely pruned (causing future calls to fail for those heights).
We provide an optional proof data which comes from the `MsgConnectionOpenAck` or `MsgConnectionOpenTry` for host state machines which are unable to introspect their own `ConsensusState` and must rely on off-chain data.
<br />
In this case host state machines MUST maintain a map of `n` block numbers to header hashes where the proof would contain full header which can be hashed and compared with the on-chain record.
Host state machines MUST provide the ability to introspect this stored recent consensus state count `n`, with `getStoredRecentConsensusStateCount`:
```typescript
Expand Down

0 comments on commit 17d62c0

Please sign in to comment.