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

implement 09-localhost per specification #5769

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

gregdhill
Copy link
Contributor

@gregdhill gregdhill commented Mar 9, 2020

Closes: #5543

Description

Mostly a stripped down copy of 07-tendermint, implementing 09-localhost.


For contributor use:

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer

For admin use:

  • Added appropriate labels to PR (ex. WIP, R4R, docs, etc)
  • Reviewers assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@jackzampolin
Copy link
Member

A great start @gregdhill! Can't wait to review when this is r4r!

@cwgoes
Copy link
Contributor

cwgoes commented Apr 6, 2020

@gregdhill Let me know when this is ready, glad to review it.

@gregdhill
Copy link
Contributor Author

@jackzampolin @cwgoes I have rebased this work which should be ready to review.

@codecov
Copy link

codecov bot commented Apr 10, 2020

Codecov Report

Merging #5769 into master will increase coverage by 0.12%.
The diff coverage is 37.95%.

@@            Coverage Diff             @@
##           master    #5769      +/-   ##
==========================================
+ Coverage   55.54%   55.67%   +0.12%     
==========================================
  Files         420      426       +6     
  Lines       25293    25962     +669     
==========================================
+ Hits        14049    14454     +405     
- Misses      10275    10515     +240     
- Partials      969      993      +24     

@fedekunze fedekunze changed the base branch from ibc-alpha to master April 10, 2020 17:10
@fedekunze
Copy link
Collaborator

@gregdhill ibc-alpha was merged to master 2 days ago. I'm sorry this has taken so long to review. Mind fixing the conflicts on last time? 🙏

@gregdhill gregdhill force-pushed the 09-localhost branch 2 times, most recently from 712124e to f03e020 Compare April 12, 2020 17:01
Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Thanks @gregdhill for taking care of this. Some minor comments

CHANGELOG.md Outdated Show resolved Hide resolved

// GetLatestHeight returns zero.
func (cs ClientState) GetLatestHeight() uint64 {
return 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

correct me if I'm wrong @cwgoes but I think this should return ctx.BlockHeight()

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's right.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return 0
return cs.ctx.BlockHeight()

x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/evidence.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/misbehaviour.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/update.go Outdated Show resolved Hide resolved
@gregdhill gregdhill force-pushed the 09-localhost branch 2 times, most recently from 03b99fb to 5b43c26 Compare April 16, 2020 09:26
@gregdhill
Copy link
Contributor Author

Thanks for reviewing @fedekunze! Please see my latest changes.

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

utACK. Minor suggestions. Thanks @gregdhill!

x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
cwgoes
cwgoes previously requested changes Apr 16, 2020
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, one change req'd, one question


// GetLatestHeight returns zero.
func (cs ClientState) GetLatestHeight() uint64 {
return 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that's right.


// GetChainID returns an empty string
func (cs ClientState) GetChainID() string {
return ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, I don't know about this, maybe this should be ctx.ChainID()? Maybe non-essential though

Copy link
Collaborator

Choose a reason for hiding this comment

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

@cwgoes I think we need to add a ctx sdk.Context to the ClientState field.

// ClientState requires (read-only) access to keys outside the client prefix.
type ClientState struct {
	ctx   sdk.Context
	store sdk.KVStore
}

@gregdhill can you add it and add this following function too?:

// WithContext updates the client state context to provide the chain ID and latest height
func (cs *ClientState) WithContext(ctx sdk.Context) {
    cs.ctx = ctx
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return ""
return cs.ctx.ChainID()

Copy link
Collaborator

@fedekunze fedekunze left a comment

Choose a reason for hiding this comment

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

Final comments @gregdhill and we're good to go. Thanks again!

x/ibc/09-localhost/client_state.go Show resolved Hide resolved

// GetChainID returns an empty string
func (cs ClientState) GetChainID() string {
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

@cwgoes I think we need to add a ctx sdk.Context to the ClientState field.

// ClientState requires (read-only) access to keys outside the client prefix.
type ClientState struct {
	ctx   sdk.Context
	store sdk.KVStore
}

@gregdhill can you add it and add this following function too?:

// WithContext updates the client state context to provide the chain ID and latest height
func (cs *ClientState) WithContext(ctx sdk.Context) {
    cs.ctx = ctx
}


// GetChainID returns an empty string
func (cs ClientState) GetChainID() string {
return ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return ""
return cs.ctx.ChainID()


// GetLatestHeight returns zero.
func (cs ClientState) GetLatestHeight() uint64 {
return 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return 0
return cs.ctx.BlockHeight()

x/ibc/09-localhost/client_state.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/evidence.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/header.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/header.go Outdated Show resolved Hide resolved
x/ibc/09-localhost/header.go Outdated Show resolved Hide resolved
Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
@fedekunze fedekunze merged commit de00a7f into cosmos:master Apr 17, 2020
@gregdhill gregdhill deleted the 09-localhost branch April 17, 2020 15:22
x/ibc/02-client/keeper/keeper.go Show resolved Hide resolved
x/ibc/09-localhost/consensus_state.go Show resolved Hide resolved
x/ibc/02-client/handler.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ICS09 loopback (localhost) client
7 participants