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

Refactor CLIContext to allow multi-chain verifiers #5136

Merged
merged 6 commits into from
Oct 3, 2019

Conversation

alexanderbez
Copy link
Contributor

@alexanderbez alexanderbez commented Oct 2, 2019

  • Remove global verifier
  • Remove verifier home (unused)
  • Add chain ID and home dir to CLIContext
  • Implement CreateVerifier which any CLIContext may call
  • Each verifier directory will exist under {home}/{chainID}/.lite_verifier

Example:

// main or parent chain (chain as if you're running without IBC)
mainCtx := context.NewCLIContext()

// connecting IBC chain
sideCtx := context.NewCLIContext().
  WithChainID(sideChainID).
  WithNodeURI(sideChainNodeURI) // or .WithClient(...)

sideCtx = sideCtx.WithVerifier(
  context.CreateVerifier(sideCtx, context.DefaultVerifierCacheSize),
)

Note: All contexts share the same home directory for a CLI binary (i.e. there is no WithHomeDir).

closes: #5116


  • 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.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • 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, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@codecov
Copy link

codecov bot commented Oct 2, 2019

Codecov Report

Merging #5136 into master will increase coverage by 0.08%.
The diff coverage is 39.28%.

@@            Coverage Diff             @@
##           master    #5136      +/-   ##
==========================================
+ Coverage   54.89%   54.98%   +0.08%     
==========================================
  Files         296      297       +1     
  Lines       18232    18224       -8     
==========================================
+ Hits        10009    10020      +11     
+ Misses       7486     7466      -20     
- Partials      737      738       +1

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.

One comment which can be resolved by updating the comment and godoc.

Comment on lines +86 to +102
when connecting to multiple chains. The connecting chain's `CLIContext` will have to have the correct
chain ID and node URI or client set. To use a `CLIContext` with a verifier for another chain:

```go
// main or parent chain (chain as if you're running without IBC)
mainCtx := context.NewCLIContext()

// connecting IBC chain
sideCtx := context.NewCLIContext().
WithChainID(sideChainID).
WithNodeURI(sideChainNodeURI) // or .WithClient(...)

sideCtx = sideCtx.WithVerifier(
context.CreateVerifier(sideCtx, context.DefaultVerifierCacheSize),
)
```

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this is necessary, the description on the PR suffices imho

Copy link
Contributor Author

@alexanderbez alexanderbez Oct 3, 2019

Choose a reason for hiding this comment

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

True, but how often do people read PRs 😄

client/context/context.go Show resolved Hide resolved
client/context/context.go Show resolved Hide resolved
@alexanderbez alexanderbez requested a review from fedekunze October 2, 2019 20:54
testCases := []struct {
name string
ctx context.CLIContext
expectErr bool
Copy link
Member

Choose a reason for hiding this comment

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

Can we have one case with expectErr = false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the Tendermint verifier code, unfortunately, I think that will require a running chain. So I don't think it's possible :-/

@jackzampolin
Copy link
Member

A couple of Q's:

  • Should this be merged into @mossid 's PR which contains all the IBC work so that gaiacli will be able to handle multiple verifiers there?
  • Is there a follow up PR required to integrate this into this the IBC demo?

@alexanderbez
Copy link
Contributor Author

@jackzampolin to answer your questions, I believe this PR should generally be supported and merged into master (if that makes sense). However, what I will do is make an accompanying PR into joon's joon/ibc-sdk-interface branch which Gaia uses.

@alexanderbez alexanderbez merged commit f84d9fa into master Oct 3, 2019
@alexanderbez alexanderbez deleted the bez/5116-multi-ctx-verifier branch October 3, 2019 00:29
@alexanderbez alexanderbez mentioned this pull request Oct 3, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Client context uses singleton lite verifier
4 participants