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

crisis/invariant ConstantFee parameter check, and other missing parameters #4052

Closed
jaekwon opened this issue Apr 4, 2019 · 3 comments · Fixed by #4054
Closed

crisis/invariant ConstantFee parameter check, and other missing parameters #4052

jaekwon opened this issue Apr 4, 2019 · 3 comments · Fixed by #4054
Assignees

Comments

@jaekwon
Copy link
Contributor

jaekwon commented Apr 4, 2019

Currently the code silently returns a zero constant fee if one isn't set properly:

+// GetConstantFee get's the constant fee from the paramSpace
+func (k Keeper) GetConstantFee(ctx sdk.Context) (constantFee sdk.Coin) {
+       if err := k.paramSpace.Get(ctx, ParamStoreKeyConstantFee, &constantFee); err != nil {
+               // TODO: return error - needs rewrite interfaces
+               // and handle error on the caller side
+               // check PR #3782
+       }
+       return
+}

We should at least panic here instead of returning a zero fee regardless of the current state of refactoring to return an error (I don't think we should change parameter reads to return an error though, since the run-time expectation is that the parameter exists, return an error just makes the codebase messier).

We also should check somehow during chain init that the parameter exists and is nonzero, otherwise we may forget to set this in the genesis state, and result in a DDoS vector.


Update: I found more code with the comment for parameters getting/setting:

+               // TODO: return error - needs rewrite interfaces
+               // and handle error on the caller side
+               // check PR #3782

They should all panic rather than returning silently.

I think they should all have some check to ensure that they exist prior to usage (maybe in initchain, though maybe that isn't possible yet, I'm not sure where this check should happen), and that required parameters should panic rather than error.

@jaekwon jaekwon changed the title crisis/invariant ConstantFee parameter check crisis/invariant ConstantFee parameter check, and other missing parameters Apr 4, 2019
@rigelrozanski
Copy link
Contributor

Correct it looks like there are in fact many panic->error which don't make sense introduced in #3782 / here, this error should panic if it's not set properly

@alexanderbez
Copy link
Contributor

Wait, is this blocking v0.34.0? #3782 was never introduced into release/v0.34.0. I opened up a PR against develop that reverts it.

@rigelrozanski
Copy link
Contributor

you're correct, this bug was never introduced in the release 0.34 branch, and must only be reverted on develop

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 a pull request may close this issue.

4 participants