Customizing Minitia

Overview

For those working within the Initia ecosystem and considering modifications to core components like cometbft and cosmos-sdk, we strongly recommend minimizing custom logic to ensure system stability and maintainability. If customization is unavoidable, it's critical to fork the specific versions of initia-labs/cometbft and initia-labs/cosmos-sdk to reduce integration efforts and potential conflicts.

Customization Guidelines for Minitia

Minitia supports the integration of custom Cosmos modules, but it's advisable to refrain from modifying or adding modules that are directly related to staking, such as the staking, distribution, and gov modules. Instead, these functionalities are replaced by the opchild module to streamline operations.

For maintaining uniformity in the IBC setup, we recommend forking repositories like minimove/miniwasm/minievm and implementing changes there instead of directly integrating the opchild module into your app chain.

Adding Whitelisted Cosmos Queries

MOVE

When customizing queries within the MOVE module, avoid including queries related to bank balances since they're already integrated within the move fungible asset. Due to the isolated state during execution, the results may differ from the actual Cosmos state.

// in app.go

queryWhitelist := movetypes.DefaultVMQueryWhiteList(ac)
queryWhitelist.Custom["chain_id"] = func(ctx context.Context, _ []byte) ([]byte, error) {
	return []byte(sdk.UnwrapSDKContext(ctx).ChainID()), nil
}
queryWhitelist.Stargate["/slinky.oracle.v1.Query/GetPrices"] = movetypes.ProtoSet{
	Request:  &oracletypes.GetPricesRequest{},
	Response: &oracletypes.GetPricesResponse{},
}

*app.MoveKeeper = movekeeper.NewKeeper(...).WithVMQueryWhitelist(queryWhitelist)

WASM

For the WASM module, you can specify which queries to allow through the system:

// in app.go

// add the query list you want to add
queryAllowlist := make(map[string]proto.Message)
queryAllowlist["/slinky.oracle.v1.Query/GetAllCurrencyPairs"] = &oracletypes.GetAllCurrencyPairsResponse{}
queryAllowlist["/slinky.oracle.v1.Query/GetPrice"] = &oracletypes.GetPriceResponse{}
queryAllowlist["/slinky.oracle.v1.Query/GetPrices"] = &oracletypes.GetPricesResponse{}


// use accept list stargate querier
wasmOpts = append(wasmOpts, wasmkeeper.WithQueryPlugins(&wasmkeeper.QueryPlugins{
	Stargate: wasmkeeper.AcceptListStargateQuerier(queryAllowlist, app.GRPCQueryRouter(), appCodec),
}))


*app.WasmKeeper = wasmkeeper.NewKeeper(
	...
	wasmOpts...,
)

EVM

Enabling Custom Queries from the Contract

In the EVM module, it's important to avoid adding queries related to bank balances, similar to the MOVE and WASM configurations:

// in app.go

whitelist := evmtypes.DefaultQueryCosmosWhitelist()

// append module queries
whitelist["/custom.module.v1.Query/Info"]  = evmtypes.ProtoSet{
	Request:  &customtypes.GetInfoRequest{},
	Response: &customtypes.GetInfoResponse{},
}

app.EVMKeeper = evmkeeper.NewKeeper(
	...,
	whitelist,
)

Disabling Custom ERC-20 Deployment

You can disable custom ERC-20 support in genesis.

// $HOME/.minitia/config/genesis.json
{
  ...
  "app_state": {
    ...
    "evm": {
      ...
      "params": {
        ...
        allow_custom_erc20: false,
        // used only allow_custom_erc20 is true.
        // empty means allow all custom contracts.
        allowed_custom_erc20s: ["0xContractAddr"], 
      }
    }
  }
}

Or, you can modify this via MsgUpdateParams.

minitiad tx opchild execute-messages ~/add-currency.json
// add-currency.json
{
    "messages": [{
        "@type": "/minievm.evm.v1.MsgUpdateParams",
        "authority": "init1gz9n8jnu9fgqw7vem9ud67gqjk5q4m2w0aejne",
        "params": {
            "extra_eips": [],
            "allowed_publishers": [],
            "allow_custom_erc20": false,
            "allowed_custom_erc20s": [],
        }
    }]
}

Conclusion

While customizing core components of the Initia infrastructure, it's crucial to adhere to best practices for maintaining system integrity and functionality. Careful consideration of these guidelines ensures that any necessary modifications align with the overall stability and operational efficiency of the ecosystem.

Last updated

Logo

© 2024 Initia Foundation, All rights reserved.