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

ics4-add active client check in sendpacket #1051

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Changes from 4 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
30 changes: 30 additions & 0 deletions spec/core/ics-004-channel-and-packet-semantics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,29 @@ function getCounterPartyHops(proof: CommitmentProof | MultihopProof, lastConnect
}
```

##### Helper functions

```typescript
// Returns the status of a client given its store.
function Status (client: clientState) {
if (client.FrozenHeight !== 0) {
return Frozen
}
// Get latest consensus state from clientStore to check for expiry
consState, err := client.latestClientHeight()
if err (!== nil) {
return Unknown
}
// Check if Expired
let expirationTime := consState.Timestamp + client.TrustingPeriod
if (expirationTime <== now){
return Expired
}

return Active
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this implementation of Status is specific to Tendermint, I think I would move it to ICS 07.

```

#### Packet flow & handling

![Packet State Machine](packet-state-machine.png)
Expand Down Expand Up @@ -743,6 +766,7 @@ The IBC handler performs the following steps in order:

- Checks that the channel is not closed to send packets
- Checks that the calling module owns the sending port (see [ICS 5](../ics-005-port-allocation))
- Checks that the client is not frozen or expired
- Checks that the timeout height specified has not already passed on the destination chain
- Increments the send sequence counter associated with the channel
- Stores a constant-size commitment to the packet data & packet timeout
Expand All @@ -763,8 +787,14 @@ function sendPacket(
// check that the channel must be OPEN to send packets;
abortTransactionUnless(channel !== null)
abortTransactionUnless(channel.state === OPEN)

connection = provableStore.get(connectionPath(channel.connectionHops[0]))
abortTransactionUnless(connection !== null)

client = provableStore.get(clientStatePath(connection.clientIdenfier))
Copy link
Contributor

Choose a reason for hiding this comment

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

You could do here clientState = queryClientState(connection.clientIdenfier) (queryClientState is defined in ICS 02)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gotcha, thank you @crodriguezvega! Please, verify if the latest commit c1637a9 address all of your comments.

abortTransactionUnless(client !== null)
// Checks that client is Active, abort otherwise.
abortTransactionUnless(Status(client) === Active)

// check if the calling module owns the sending port
abortTransactionUnless(authenticateCapability(channelCapabilityPath(sourcePort, sourceChannel), capability))
Expand Down
Loading