You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
jaekwon
changed the title
crisis/invariant ConstantFee parameter check
crisis/invariant ConstantFee parameter check, and other missing parameters
Apr 4, 2019
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
Currently the code silently returns a zero constant fee if one isn't set properly:
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:
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.
The text was updated successfully, but these errors were encountered: