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

chore: disallow localhost client creation in 02-client #3114

Merged
merged 3 commits into from
Feb 8, 2023

Conversation

damiannolan
Copy link
Member

@damiannolan damiannolan commented Feb 7, 2023

Description

  • This PR prevents creation of 09-localhost clients in 02-client

ref: #3034

Commit Message / Changelog Entry

chore: disallow localhost client creation in 02-client

see the guidelines for commit messages. (view raw markdown for examples)


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • 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 and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/).
  • Added relevant godoc comments.
  • Provide a commit message to be used for the changelog entry in the PR description for review.
  • Re-reviewed Files changed in the Github PR explorer.
  • Review Codecov Report in the comment section below once CI passes.

Comment on lines +34 to +37
"success: 06-solomachine client type supported",
solomachine.NewClientState(0, &solomachine.ConsensusState{PublicKey: suite.solomachine.ConsensusState().PublicKey, Diversifier: suite.solomachine.Diversifier, Timestamp: suite.solomachine.Time}),
&solomachine.ConsensusState{PublicKey: suite.solomachine.ConsensusState().PublicKey, Diversifier: suite.solomachine.Diversifier, Timestamp: suite.solomachine.Time},
true,
Copy link
Member Author

Choose a reason for hiding this comment

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

I've adapted the tests here slightly. This one was actually setup incorrectly and the case was failing on clientState.Initialise() due to non-matching consensus state, rather than it being an unsupported client. Solomachine is now in the list of allowed clients so this test case should pass.

@damiannolan
Copy link
Member Author

Initially I removed the localhost client type from AllowedClients but noticed some failing tests as this is used in InitGenesis. I decided to keep localhost as an allowed client so genesis can continue to work as normal but added an additional check explicitly for client creation.

@@ -17,7 +17,7 @@ func (k Keeper) CreateClient(
ctx sdk.Context, clientState exported.ClientState, consensusState exported.ConsensusState,
) (string, error) {
params := k.GetParams(ctx)
if !params.IsAllowedClient(clientState.ClientType()) {
if !params.IsAllowedClient(clientState.ClientType()) || clientState.ClientType() == exported.Localhost {
return "", sdkerrors.Wrapf(
types.ErrInvalidClientType,
"client state type %s is not registered in the allowlist", clientState.ClientType(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a nit, but wouldn't this error be a bit misleading for localhost? I mean, the reader of the error would see that localhost is in the allow list...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I suppose it would!

We can either change the error msg or put the localhost check in its own conditional, what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I would prefer then to have it in its own conditional.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated!

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, @damiannolan!

@damiannolan damiannolan merged commit c7d798b into 09-localhost Feb 8, 2023
@damiannolan damiannolan deleted the damian/disallow-create-client branch February 8, 2023 10:07
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.

3 participants