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

ICS33: Multi-hop Channel Spec #882

Merged
merged 52 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
fb716fc
feat: add spec for multi-hop channels
notbdu Nov 11, 2022
3bc1800
chore: naming
notbdu Nov 11, 2022
f7f1a6c
chore: add notes on chain registry
notbdu Nov 11, 2022
1421d33
Polymer/multihop (#1)
dshiell Dec 16, 2022
2be7894
update to ics-033
dshiell Dec 16, 2022
eb0193c
start updating channel spec for multihop; add diagram for relayer pro…
dshiell Dec 17, 2022
3e167eb
chore: update spec history
notbdu Dec 17, 2022
f773339
chore: spacing
notbdu Dec 17, 2022
437c6f9
remove TODO comment; per PR feedback, connection proof not require fo…
dshiell Dec 20, 2022
337d393
add comment to MultihopProof struct making the proof ordering more cl…
dshiell Dec 20, 2022
4d62c51
add verification proof pseudo code
dshiell Dec 20, 2022
280fc28
add/update multihop proof verification logic
dshiell Dec 20, 2022
c1f8bd0
Update spec/core/ics-004-channel-and-packet-semantics/README.md
dshiell Feb 13, 2023
6dcb58a
Update spec/core/ics-033-multi-hop/README.md
dshiell Feb 13, 2023
bb4f37e
remove consState var to simplify consensusState update assignment
dshiell Feb 13, 2023
1af38b5
rename VerifyMultihopConsensusStateProof --> VerifyMultihopConsensusA…
dshiell Feb 14, 2023
fc34fdf
simplify multihop proof logic steps further
dshiell Feb 14, 2023
ebc08ee
Ds/multihop (#4)
dshiell Feb 15, 2023
9ee66b2
start updating multihop spec to include client state information in t…
dshiell Feb 17, 2023
a7ecb58
check consensus/connection proof lengths immediately
dshiell Feb 24, 2023
87795f8
update spec with latest multihop solution
dshiell Mar 1, 2023
eca9ded
remove client state from multihop proofs
dshiell Mar 8, 2023
44e4ac1
update spec with chanCloseFrozen; fix/update other parts of multihop …
dshiell Mar 8, 2023
c85c8aa
revise and update multihop spec details
dshiell Mar 8, 2023
7f133d7
add check to match client id in ConnectionEnd with client id in subse…
dshiell Mar 11, 2023
1213e61
fix indentation
dshiell Mar 11, 2023
3784cef
Update spec/core/ics-033-multi-hop/README.md
dshiell Mar 14, 2023
bd6c39e
Update spec/core/ics-033-multi-hop/README.md
dshiell Mar 14, 2023
f4baac5
Update spec/core/ics-033-multi-hop/README.md
dshiell Mar 14, 2023
c04a201
Update spec/core/ics-004-channel-and-packet-semantics/README.md
dshiell Mar 14, 2023
5e0d503
Update spec/core/ics-004-channel-and-packet-semantics/README.md
dshiell Mar 14, 2023
4f91306
Update spec/core/ics-004-channel-and-packet-semantics/README.md
dshiell Mar 14, 2023
17da31d
fix typo prevChain --> previousChain
dshiell Mar 14, 2023
594a5bb
add comments for connection and multihopConnectionEnd
dshiell Mar 15, 2023
12e7ad5
Update spec/core/ics-003-connection-semantics/README.md
dshiell Mar 16, 2023
9265373
add frozen channel proof generation logic
dshiell Mar 15, 2023
dd84773
refactor getMaxDelayPeriod to return the time and block delay
dshiell Mar 16, 2023
4dd2204
use Identifier type instead of string for connectionHops array
dshiell Mar 16, 2023
243bd2e
cleanup proof gen pseudo code
dshiell Mar 16, 2023
804a828
check proof heights for consensus and connection states during multih…
dshiell Mar 17, 2023
b9ca4ca
Update spec/core/ics-033-multi-hop/README.md
dshiell Mar 17, 2023
9f13123
cleanup multihop proof gen pseudo code
dshiell Mar 17, 2023
7bebf3b
remove trailing whitespace; refactor multihop proof generation and ad…
dshiell Mar 21, 2023
f69e191
add extra info about connectionHops ordering; update proof ordering t…
dshiell Mar 22, 2023
56e0f0a
clarify multi-hop proof verification now that proof ordering matches …
dshiell Mar 24, 2023
73ef434
address latest PR feedback
dshiell Apr 11, 2023
4262a63
more pr feedback
dshiell Apr 11, 2023
6f52039
address more multihop PR feedback
dshiell Apr 19, 2023
c76b25a
update multi-hop proof query/verification specs and add frozen channe…
dshiell Jun 28, 2023
d0024c6
update multi-hop proof diagrams
dshiell Jun 29, 2023
e385e8d
wip address latest PR feedback
dshiell Jul 28, 2023
071b4ed
add more clarifying comments/explanations and incorporate more PR fee…
dshiell Aug 1, 2023
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ All standards at or past the "Draft" stage are listed here in order of their ICS
| [24](spec/core/ics-024-host-requirements/README.md) | Host Requirements | Candidate | [ibc-go](https://github.com/cosmos/ibc-go) | Protocol team |
| [25](spec/core/ics-025-handler-interface/README.md) | Handler Interface | Candidate | [ibc-go](https://github.com/cosmos/ibc-go) | Protocol team |
| [26](spec/core/ics-026-routing-module/README.md) | Routing Module | Candidate | [ibc-go](https://github.com/cosmos/ibc-go) | Protocol team |
| [33](spec/core/ics-033-multi-hop/README.md) | Multi-hop Messaging | Candidate | [ibc-go](https://github.com/cosmos/ibc-go) | Protocol team |

### Client

Expand Down
Binary file added spec/.DS_Store
Binary file not shown.
Binary file added spec/core/.DS_Store
Binary file not shown.
80 changes: 76 additions & 4 deletions spec/core/ics-003-connection-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,83 @@ function verifyNextSequenceRecv(
return verifyMembership(clientState, height, connection.delayPeriodTime, connection.delayPeriodBlocks, proof, path, nextSequenceRecv)
}

function verifyMultihopMembership(
connection: ConnectionEnd, // the connection end corresponding to the receiving chain.
height: Height,
proof: MultihopProof,
connectionHops: Identifier[],
key: CommitmentPath,
value: bytes) {

// the connectionEnd corresponding to the end of the multi-hop channel path (sending/counterparty chain).
multihopConnectionEnd = abortTransactionUnless(getMultihopConnectionEnd(proof))
prefix = multihopConnectionEnd.GetCounterparty().GetPrefix()
Comment on lines +270 to +271
Copy link
Contributor

Choose a reason for hiding this comment

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

Not clear to me why we do this only for proofing the key/value. We could get the store prefix at intermediate hops and applyPrefix when proving connection and consenus states.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, the PrefixKey is already stored with the intermediate multihop proofs so this step is not required. However the expected key/value are created on the receiver depending on what proof is expected so the PrefixKey is created using applyPrefix

client = queryClient(connection.clientIdentifier)
consensusState = queryConsensusState(connection.clientIdentifier, height)

abortTransactionUnless(client.Status() === "active")
abortTransactionUnless(client.GetLatestHeight() >= height)

// verify maximum delay period has passed
expectedTimePerBlock = queryMaxExpectedTimePerBlock()
delayPeriodTime = abortTransactionUnless(getMaximumDelayPeriod(proof, connection))
delayPeriodBlocks = getBlockDelay(delayPeriodTime, expectedTimePerBlock)
abortTransactionUnless(tendermint.VerifyDelayPeriodPassed(height, delayPeriodTime, delayPeriodBlocks))

return multihop.VerifyMultihopMembership(consensusState, connectionHops, proof, prefix, key, value) // see ics-033
}

function verifyMultihopNonMembership(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used anywhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should be added to the timeoutPacket pseudo code in ics-004 which I overlooked. Will add.

connection: ConnectionEnd, // the connection end corresponding to the receiving chain.
height: Height,
proof: MultihopProof,
connectionHops: Identifier[],
key: CommitmentPath) {

// the connectionEnd corresponding to the end of the multi-hop channel path (sending/counterparty chain).
multihopConnectionEnd = abortTransactionUnless(getMultihopConnectionEnd(proof))
prefix = multihopConnectionEnd.GetCounterparty().GetPrefix()
client = queryClient(connection.clientIdentifier)
consensusState = queryConsensusState(connection.clientIdentifier, height)

abortTransactionUnless(client.Status() === "active")
abortTransactionUnless(client.GetLatestHeight() >= height)

// verify maximum delay period has passed
expectedTimePerBlock = queryMaxExpectedTimePerBlock()
delayPeriodTime = abortTransactionUnless(getMaximumDelayPeriod(proof, connection))
delayPeriodBlocks = getBlockDelay(delayPeriodTime, expectedTimePerBlock)
abortTransactionUnless(tendermint.VerifyDelayPeriodPassed(height, delayPeriodTime, delayPeriodBlocks))

return multihop.VerifyMultihopNonMembership(consensusState, connectionHops, proof, prefix, key) // see ics-033
}

// Return the maximum expected time per block from the paramstore.
// See 03-connection - GetMaxExpectedTimePerBlock.
function queryMaxExpectedTimePerBlock(): uint64

function getTimestampAtHeight(
connection: ConnectionEnd,
height: Height) {
return queryConsensusState(connection.clientIdentifier, height).getTimestamp()
}

// Return the connectionEnd corresponding to the source chain.
function getMultihopConnectionEnd(proof: MultihopProof): ConnectionEnd {
return abortTransactionUnless(Unmarshal(proof.ConnectionProofs[proof.ConnectionProofs.length - 1].Value))
}

// Return the maximum delay period in seconds across all connections in the channel path.
function getMaximumDelayPeriod(proof: MultihopProof, lastConnection: ConnectionEnd): number {
Copy link
Member

Choose a reason for hiding this comment

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

This should return two numbers. The delayPeriodBlock and delayPeriodTime

Copy link
Contributor

Choose a reason for hiding this comment

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

no problem, the block delay is computed below, but I'll refactor this to return timeDelay and blockDelay

Copy link
Contributor

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

was this done?

delayPeriodTime = lastConnection.GetDelayPeriod()
for connData in range proofs.ConnectionProofs {
connectionEnd = abortTransactionUnless(Unmarshal(connData.Value))
if (connectionEnd.DelayPeriod > delayPeriodTime) {
delayPeriodTime = connectionEnd.DelayPeriod
}
}
return delayPeriodTime
}
```

### Sub-protocols
Expand All @@ -282,7 +354,7 @@ The validation function `validateConnectionIdentifier` MAY be provided.
type validateConnectionIdentifier = (id: Identifier) => boolean
```

If not provided, the default `validateConnectionIdentifier` function will always return `true`.
If not provided, the default `validateConnectionIdentifier` function will always return `true`.

#### Versioning

Expand All @@ -301,7 +373,7 @@ specifies IBC 1.0.0.

The `features` field specifies a list of features compatible with the specified
identifier. The values `"ORDER_UNORDERED"` and `"ORDER_ORDERED"` specify
unordered and ordered channels, respectively.
unordered and ordered channels, respectively.

Host state machine MUST utilise the version data to negotiate encodings,
priorities, or connection-specific metadata related to custom logic on top of
Expand Down Expand Up @@ -367,7 +439,7 @@ function connOpenInit(

abortTransactionUnless(queryClientState(clientIdentifier) !== null)
abortTransactionUnless(provableStore.get(connectionPath(identifier)) == null)

state = INIT
if version != "" {
// manually selected version must be one we can support
Expand Down Expand Up @@ -404,7 +476,7 @@ function connOpenTry(
) {
// generate a new identifier
identifier = generateIdentifier()

abortTransactionUnless(queryClientState(clientIdentifier) !== null)
abortTransactionUnless(validateSelfClient(clientState))
abortTransactionUnless(consensusHeight < getCurrentHeight())
Expand Down
Loading