-
Notifications
You must be signed in to change notification settings - Fork 397
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
f940422
c8fcf03
1459931
4726da3
c1637a9
463c656
2ce67f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
} | ||
``` | ||
|
||
#### Packet flow & handling | ||
|
||
![Packet State Machine](packet-state-machine.png) | ||
|
@@ -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 | ||
|
@@ -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)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could do here There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
|
There was a problem hiding this comment.
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.