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

Conversation

sangier
Copy link
Contributor

@sangier sangier commented Dec 13, 2023

Closes: #555

Add:

  • Status function (in helper function section) to retrieve the client status
  • Check that client is active in sendPacket

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Thank you, @sangier. I think you could add the Status function to ICS 02, together with the other functions defined for client state (e.g. verifyClientMessage, updateState, etc).

Comment on lines 710 to 727
// 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.

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.

The function is defined as:

```typescript
type Status = (Client) => Void
Copy link
Member

Choose a reason for hiding this comment

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

SHouldn't the return value not be Void? Since it is returning a status

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uh, definitively should not be void. @AdityaSripal would be correct to return bytes or shall we define a type Status = bytes in the Data Structure section and return Status itself?

@@ -201,6 +201,28 @@ function verifyClientMessage(clientMsg: ClientMessage) {
}
```

### Retrieve client status

Return the status of the wasm client. Status can be either `Active`, `Expired`, `Unknown` or `Frozen`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need the Unknown status for the wasm-client? Where it is used?

@@ -337,6 +337,25 @@ Once misbehaviour is detected, clients SHOULD be frozen so that no future update
A permissioned entity such as a chain governance system or trusted multi-signature MAY be allowed
to intervene to unfreeze a frozen client & provide a new correct ClientMessage which updates the client to a valid state.

#### Retrieve client status

Status is an opaque function defined by a client type to retrieve the current clientState. Status can be either `Active`, `Expired`, `Unknown` or `Frozen`.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

similarly here, If Unknown status is not needed in the wasm-client we can remove it from client-semantics too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

ICS4: sendPacket should add a check to ensure client is not frozen
3 participants