Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Fix missing ICA controller configuration [#257](https://github.com/atomone-hub/atomone/pull/257)
- Fix wrapper converters for `x/gov` [#276](https://github.com/atomone-hub/atomone/pull/276)
- Add min-stake filtering for cosmos-sdk votes in the gov ante handler [#279](https://github.com/atomone-hub/atomone/pull/279)
- Prevent the designated authority to be set as the Oversight or Steering DAO address [#314](https://github.com/atomone-hub/atomone/pull/314)

### DEPENDENCIES

Expand Down
24 changes: 24 additions & 0 deletions x/coredaos/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,30 @@ func TestMsgServerUpdateParams(t *testing.T) {
m.StakingKeeper.EXPECT().GetDelegatorUnbonding(ctx, sdk.MustAccAddressFromBech32(unbondedAcc)).Return(math.NewInt(0), nil).Times(2)
},
},
{
name: "steeringdao set to authority address",
msg: &types.MsgUpdateParams{
Authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
Params: types.Params{
SteeringDaoAddress: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
VotingPeriodExtensionDuration: &timeDuration,
},
},
expectedErr: "authority address cannot be the same as steering DAO address: invalid address",
setupMocks: func(ctx sdk.Context, m *testutil.Mocks) {},
},
{
name: "oversightdao set to authority address",
msg: &types.MsgUpdateParams{
Authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
Params: types.Params{
OversightDaoAddress: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn",
VotingPeriodExtensionDuration: &timeDuration,
},
},
expectedErr: "authority address cannot be the same as oversight DAO address: invalid address",
setupMocks: func(ctx sdk.Context, m *testutil.Mocks) {},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
24 changes: 22 additions & 2 deletions x/coredaos/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,29 @@ func (msg *MsgUpdateParams) Type() string {

// ValidateBasic implements the sdk.Msg interface.
func (msg *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
authority, err := sdk.AccAddressFromBech32(msg.Authority)
if err != nil {
return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err)
}

return msg.Params.ValidateBasic()
if err := msg.Params.ValidateBasic(); err != nil {
return err
}

// none of the dao addresses can be same as the authority
// assumes address validation has already been done in Params.ValidateBasic
if msg.Params.OversightDaoAddress != "" {
oversightDaoAddr := sdk.MustAccAddressFromBech32(msg.Params.OversightDaoAddress)
if authority.Equals(oversightDaoAddr) {
return sdkerrors.ErrInvalidAddress.Wrapf("authority address cannot be the same as oversight DAO address")
}
}
if msg.Params.SteeringDaoAddress != "" {
steeringDaoAddr := sdk.MustAccAddressFromBech32(msg.Params.SteeringDaoAddress)
if authority.Equals(steeringDaoAddr) {
return sdkerrors.ErrInvalidAddress.Wrapf("authority address cannot be the same as steering DAO address")
}
}

return nil
}
Loading