Skip to content

Commit

Permalink
disallow chaning fee denom
Browse files Browse the repository at this point in the history
  • Loading branch information
beer-1 committed Aug 24, 2024
1 parent 0daf3f0 commit 958ff2c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/minitiad/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/initia-labs/OPinit/contrib/launchtools/steps"
"github.com/initia-labs/initia/app/params"
minitiaapp "github.com/initia-labs/minievm/app"
"github.com/initia-labs/minievm/types"
)

// DefaultLaunchStepFactories is a list of default launch step factories.
Expand Down Expand Up @@ -50,6 +51,12 @@ func LaunchCommand(ac *appCreator, enc params.EncodingConfig, mbm module.BasicMa
return launchtools.LaunchCmd(
ac,
func(denom string) map[string]json.RawMessage {
// default denom in OPinit is "umin"
if denom == "umin" {
// convert to "GAS"
denom = types.BaseDenom
}

return minitiaapp.NewDefaultGenesisState(enc.Codec, mbm, denom)
},
DefaultLaunchStepFactories,
Expand Down
2 changes: 1 addition & 1 deletion types/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ package types

const (
// BaseDenom base denom for genesis boot
BaseDenom = "umin"
BaseDenom = "GAS"
)
9 changes: 9 additions & 0 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,15 @@ func (ms *msgServerImpl) UpdateParams(ctx context.Context, msg *types.MsgUpdateP
return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s, got %s", ms.authority, msg.Authority)
}

params, err := ms.Params.Get(ctx)
if err != nil {
return nil, err
}

Check warning on line 185 in x/evm/keeper/msg_server.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/msg_server.go#L184-L185

Added lines #L184 - L185 were not covered by tests

if params.FeeDenom != msg.Params.FeeDenom {
return nil, sdkerrors.ErrInvalidRequest.Wrap("fee denom cannot be changed")
}

// validate params
if err := msg.Params.Validate(ms.ac); err != nil {
return nil, err
Expand Down
9 changes: 9 additions & 0 deletions x/evm/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,15 @@ func Test_MsgServer_UpdateParams(t *testing.T) {
})
require.Error(t, err)

// cannot change fee denom
params = types.DefaultParams()
params.FeeDenom = "otherdenom"
_, err = msgServer.UpdateParams(ctx, &types.MsgUpdateParams{
Authority: input.EVMKeeper.GetAuthority(),
Params: params,
})
require.ErrorContains(t, err, "fee denom cannot be changed")

// valid
_, _, addr := keyPubAddr()
params = types.DefaultParams()
Expand Down

0 comments on commit 958ff2c

Please sign in to comment.