-
Notifications
You must be signed in to change notification settings - Fork 138
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
fix: Fix inactive vals and min stake handling in ConsumerAdditionProposal conversion #2181
Changes from all commits
c16992c
d712823
062ee57
8aedb09
975d583
ec73f3e
6367057
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,7 +299,9 @@ func (tr Chain) submitConsumerAdditionProposal( | |
"validator_set_cap": %d, | ||
"allowlist": %s, | ||
"denylist": %s, | ||
"authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" | ||
"authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", | ||
"allow_inactive_vals": %t, | ||
"min_stake": "%d" | ||
} | ||
], | ||
"metadata": "ipfs://CID", | ||
|
@@ -327,6 +329,8 @@ func (tr Chain) submitConsumerAdditionProposal( | |
action.ValidatorSetCap, | ||
action.Allowlist, | ||
action.Denylist, | ||
action.AllowInactiveVals, | ||
action.MinStake, | ||
action.Deposit) | ||
|
||
//#nosec G204 -- bypass unsafe quoting warning (no production code) | ||
|
@@ -587,13 +591,14 @@ type SubmitConsumerModificationProposalAction struct { | |
ValidatorSetCap uint32 | ||
Allowlist []string | ||
Denylist []string | ||
AllowInactiveVals bool | ||
MinStake uint64 | ||
Comment on lines
+594
to
+595
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor Suggestion: Consistent Parameter Ordering The addition of Consider reordering the parameters to match the order used in other related structs or function signatures for consistency. type SubmitConsumerModificationProposalAction struct {
Chain ChainID
From ValidatorID
Deposit uint
ConsumerChain ChainID
TopN uint32
ValidatorsPowerCap uint32
ValidatorSetCap uint32
Allowlist []string
Denylist []string
+ AllowInactiveVals bool
+ MinStake uint64
- AllowInactiveVals bool
- MinStake uint64
}
|
||
} | ||
|
||
func (tr Chain) submitConsumerModificationProposal( | ||
action SubmitConsumerModificationProposalAction, | ||
verbose bool, | ||
) { | ||
|
||
template := ` | ||
|
||
{ | ||
|
@@ -609,8 +614,8 @@ func (tr Chain) submitConsumerModificationProposal( | |
"allowlist": %s, | ||
"denylist": %s, | ||
"authority": "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", | ||
"min_stake": "0", | ||
"allow_inactive_vals": false | ||
"min_stake": %d, | ||
"allow_inactive_vals": %t | ||
Comment on lines
+617
to
+618
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code Quality Improvement: Use Struct for Parameters The function Consider defining a struct for these parameters and marshal it to JSON. This approach enhances code readability and maintainability. type ConsumerModificationParams struct {
MinStake uint64 `json:"min_stake"`
AllowInactiveVals bool `json:"allow_inactive_vals"`
// include other fields...
}
params := ConsumerModificationParams{
MinStake: action.MinStake,
AllowInactiveVals: action.AllowInactiveVals,
// set other fields...
}
jsonStr, err := json.Marshal(params)
if err != nil {
log.Fatal(err)
} Use this |
||
} | ||
], | ||
"metadata": "ipfs://CID", | ||
|
@@ -629,6 +634,8 @@ func (tr Chain) submitConsumerModificationProposal( | |
action.Allowlist, | ||
action.Denylist, | ||
action.Deposit, | ||
action.MinStake, | ||
action.AllowInactiveVals, | ||
) | ||
|
||
// #nosec G204 -- bypass unsafe quoting warning (no production code) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Security Issue: Exposed API Key
The hardcoded API key in the JSON template might expose sensitive operations to unauthorized access.
Consider removing the hardcoded API key or replacing it with a secure method of fetching it, such as environment variables or secure vault solutions.
Ensure to import the
os
package at the beginning of the file.Tools
Gitleaks