Skip to content

Commit

Permalink
fix(rollapp): Enforce revision 1 on create rollapps (#1352)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Oct 25, 2024
1 parent 68c9090 commit 600e3c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 1 addition & 2 deletions ibctesting/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ import (
)

// chainIDPrefix defines the default chain ID prefix for Evmos test chains
var chainIDPrefix = "evmos_9000-"
var chainIDPrefix = "evmos_9000"

func init() {
ibctesting.ChainIDPrefix = chainIDPrefix
ibctesting.ChainIDSuffix = ""
ibctesting.DefaultTestingAppInit = func() (ibctesting.TestingApp, map[string]json.RawMessage) {
return apptesting.SetupTestingApp()
}
Expand Down
6 changes: 5 additions & 1 deletion x/rollapp/keeper/msg_server_create_rollapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func (suite *RollappTestSuite) TestCreateRollappAlreadyExists() {
suite.App.RollappKeeper.SetRollapp(suite.Ctx, r)
},
expErr: nil,
}, {
name: "different rollapp, revision not 1",
rollappId: "trollapp_2345-2",
expErr: types.ErrInvalidRollappID,
},
}
for _, test := range tests {
Expand Down Expand Up @@ -152,7 +156,7 @@ func (suite *RollappTestSuite) TestCreateRollappId() {
},
{
name: "invalid revision",
rollappId: "rollapp-1-1",
rollappId: "rollapp_1234-x",
expErr: types.ErrInvalidRollappID,
},
}
Expand Down
4 changes: 4 additions & 0 deletions x/rollapp/keeper/rollapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ func (k Keeper) CheckIfRollappExists(ctx sdk.Context, rollappId types.ChainID) e
if _, isFound = k.GetRollappByName(ctx, rollappId.GetName()); isFound {
return types.ErrRollappExists
}
// when creating a new Rollapp, the revision number should always be 1
if rollappId.GetRevisionNumber() != 1 {
return errorsmod.Wrapf(types.ErrInvalidRollappID, "revision number should be 1, got: %d", rollappId.GetRevisionNumber())
}
return nil
}
if !existingRollapp.Frozen {
Expand Down

0 comments on commit 600e3c8

Please sign in to comment.