Skip to content

Commit

Permalink
Merge branch 'develop' into trailofbits-4-duplicate-check-observer-set
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD authored Aug 9, 2024
2 parents 9208295 + f78ff55 commit faecf24
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

* [2615](https://github.com/zeta-chain/node/pull/2615) - Refactor cleanup of outbound trackers

### Fixes

* [2654](https://github.com/zeta-chain/node/pull/2654) - add validation for authorization list in when validating genesis state for authorization module

## v19.0.0

### Breaking Changes
Expand Down
1 change: 1 addition & 0 deletions x/authority/migrations/v2/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func MigrateStore(
ctx sdk.Context,
keeper authorityKeeper,
) error {
// It is okay to not validate here, as the authorization list is fixed and will not change
keeper.SetAuthorizationList(ctx, types.DefaultAuthorizationsList())
return nil
}
9 changes: 7 additions & 2 deletions x/authority/types/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ func (gs GenesisState) Validate() error {
if err := gs.Policies.Validate(); err != nil {
return err
}

return gs.ChainInfo.Validate()
if err := gs.AuthorizationList.Validate(); err != nil {
return err
}
if err := gs.ChainInfo.Validate(); err != nil {
return err
}
return nil
}
36 changes: 32 additions & 4 deletions x/authority/types/genesis_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types_test

import (
"fmt"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -26,8 +27,9 @@ func TestGenesisState_Validate(t *testing.T) {
{
name: "valid genesis",
gs: &types.GenesisState{
Policies: sample.Policies(),
ChainInfo: sample.ChainInfo(42),
Policies: sample.Policies(),
ChainInfo: sample.ChainInfo(42),
AuthorizationList: sample.AuthorizationList("testMessage"),
},
errContains: "",
},
Expand All @@ -42,12 +44,13 @@ func TestGenesisState_Validate(t *testing.T) {
},
},
},
ChainInfo: sample.ChainInfo(42),
ChainInfo: sample.ChainInfo(42),
AuthorizationList: sample.AuthorizationList("testMessage"),
},
errContains: "invalid address",
},
{
name: "invalid if policies is invalid",
name: "invalid if chainInfo is invalid",
gs: &types.GenesisState{
Policies: sample.Policies(),
ChainInfo: types.ChainInfo{
Expand All @@ -63,9 +66,34 @@ func TestGenesisState_Validate(t *testing.T) {
},
},
},
AuthorizationList: sample.AuthorizationList("testMessage"),
},
errContains: "chain ID must be positive",
},
{
name: "invalid if authorization list is invalid",
gs: &types.GenesisState{
Policies: sample.Policies(),
ChainInfo: sample.ChainInfo(42),
AuthorizationList: types.AuthorizationList{
Authorizations: []types.Authorization{
{
MsgUrl: fmt.Sprintf("/zetachain/%d%s", 0, "testMessage"),
AuthorizedPolicy: types.PolicyType_groupEmergency,
},
{
MsgUrl: fmt.Sprintf("/zetachain/%d%s", 0, "testMessage"),
AuthorizedPolicy: types.PolicyType_groupAdmin,
},
{
MsgUrl: fmt.Sprintf("/zetachain/%d%s", 0, "testMessage"),
AuthorizedPolicy: types.PolicyType_groupOperational,
},
},
},
},
errContains: "duplicate message url",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit faecf24

Please sign in to comment.