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
// Param around Tallying votes in governancetypeTallyParamsstruct {
Quorum sdk.Dec`json:"quorum"`// Minimum percentage of total stake needed to vote for a result to be considered validThreshold sdk.Dec`json:"threshold"`// Minimum propotion of Yes votes for proposal to pass. Initial value: 0.5Veto sdk.Dec`json:"veto"`// Minimum value of Veto votes to Total votes ratio for proposal to be vetoed. Initial value: 1/3
}
And say the current param is TallyParams{Quorum: q, Threshold: t, Veto: v}. If a proposal wants to update only the Veto field, it has to submit a proposal contaning TallyParams{Quorum: q, Threshold: t, Veto: v_updated} as its value, not only the Veto field.
To solve this, add omitempty to all the parameter fields. This will make the decoder not override the existing value if the unmarshalling json text does not contain the corresponding value. So the proposer only has to write the fields that are going to be updated. In the example above, now the proposer can submit TallyFields{Veto: v_updated}.
The paramchange logic also should have to be updated, not just setting the provided parameter, but first unmarshalling it to the copy of the existing parameter, and then setting it.
For most of the parameter types, we need to duplicate the existing fields to not make it empty. For example in the gov(https://github.com/cosmos/cosmos-sdk/blob/master/x/gov/params.go),
And say the current param is
TallyParams{Quorum: q, Threshold: t, Veto: v}
. If a proposal wants to update only theVeto
field, it has to submit a proposal contaningTallyParams{Quorum: q, Threshold: t, Veto: v_updated}
as its value, not only theVeto
field.To solve this, add
omitempty
to all the parameter fields. This will make the decoder not override the existing value if the unmarshalling json text does not contain the corresponding value. So the proposer only has to write the fields that are going to be updated. In the example above, now the proposer can submitTallyFields{Veto: v_updated}
.The paramchange logic also should have to be updated, not just setting the provided parameter, but first unmarshalling it to the copy of the existing parameter, and then setting it.
Depending on: tendermint/go-amino#262
The text was updated successfully, but these errors were encountered: