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

Abstract height type #447

Merged
merged 11 commits into from
Jul 21, 2020
Merged

Abstract height type #447

merged 11 commits into from
Jul 21, 2020

Conversation

cwgoes
Copy link
Contributor

@cwgoes cwgoes commented Jul 8, 2020

Closes #439

@cwgoes cwgoes added tao Transport, authentication, & ordering layer. wip Issues or pull requests which are in progress. labels Jul 8, 2020
```

```typescript
enum Ord {

Choose a reason for hiding this comment

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

can we rename it to Cmp instead? it's more widely used by various libraries in Go (eg big.Int)

Choose a reason for hiding this comment

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

actually, I think Cmp should be a function from Height

func (h Height) Cmp(b Height): int {
  if h.epochNumber < b.epochNumber {
    return -1
  } else if h.epochNumber == b.epochNumber {
    if a.epochHeight < b.epochHeight {
      return -1
    } else if h.epochHeight == b.epochHeight {
      return 0
    }
  }
  return 1
}

something in those lines

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I'm not a huge fan of returning an int since there are more valid values for int than valid return values for this function. It's fine if we use Cmp to implement this in the Cosmos SDK code, though.

@cwgoes
Copy link
Contributor Author

cwgoes commented Jul 9, 2020

Probably makes sense to add basic upgrade handling here as well.

@cwgoes
Copy link
Contributor Author

cwgoes commented Jul 15, 2020

We'll have to fix a key & commitment prefix for upgrade handling.

@cwgoes cwgoes marked this pull request as ready for review July 16, 2020 12:27
@cwgoes
Copy link
Contributor Author

cwgoes commented Jul 16, 2020

This is not yet ready to be merged, I need to check that the fields all match up to the ICS 7 implementation, but want to check that the upgrade method proposed here makes sense, cc @AdityaSripal.

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

My main concern is how we would know what the newClientState should be in advance of the upgrade so we can store it in the old chain

spec/ics-007-tendermint-client/README.md Outdated Show resolved Hide resolved
newClientState: ClientState,
height: Height,
proof: CommitmentPrefix) {
// check proof of updated client state in state at predetermined commitment prefix and key
Copy link
Member

Choose a reason for hiding this comment

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

How would we know what the updated client state is going to be before the upgrade, since we don't know the first header.

This could be fixed with the comment here: cosmos/cosmos-sdk#6736 (comment)

Tho we still wouldn't know something like LatestTimestamp uint64 beforehand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See below comment.

spec/ics-007-tendermint-client/README.md Show resolved Hide resolved
@AdityaSripal
Copy link
Member

The Tendermint ClientState contains things that we would only know after the upgrade happened
Currently it contains a Header
But as pointed out in cosmos/cosmos-sdk#6736 this is unnecessary, but we would still need a field like LatestTimestamp which we don't know ahead of time
So we cannot store it exactly on the old chain before upgrade
However, we could just store with that field zeroed out, and when we go to verify we set the newClientState to zero for verification purposes
and maybe just check that newClientState.Timestamp > clientstate.TimeStamp

Co-authored-by: Aditya <adityasripal@gmail.com>
@cwgoes
Copy link
Contributor Author

cwgoes commented Jul 17, 2020

but we would still need a field like LatestTimestamp which we don't know ahead of time

Hmm, the problem here is that latestTimestamp is required to determine whether a header is or is not within the trusting period. In the case of an upgrade, to preserve the same security model, we still want client updates to fail if they aren't submitted within the trusting period from when the new chain starts. Given that newClientState is expected to be written just when the old version halts, I think it is reasonable to expect an estimate to be put in for latestTimestamp (e.g. an hour into the future, depending on how long the restart is expected to take).

(this should be the genesis time of the new chain)

I'll add an explanatory note about this.

@cwgoes
Copy link
Contributor Author

cwgoes commented Jul 20, 2020

Just this one remaining question on client state - cosmos/cosmos-sdk#6736 (comment).

@cwgoes cwgoes merged commit a06d603 into master Jul 21, 2020
@cwgoes cwgoes deleted the cwgoes/epoch-height branch July 21, 2020 09:33
3100 added a commit to datachainlab/ics that referenced this pull request Aug 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tao Transport, authentication, & ordering layer. wip Issues or pull requests which are in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add epoch number to Tendermint light client, alter block height representation
3 participants