testnet
GitHub

Module Authority

mechanism core

The designated account, typically governance, that is authorized to execute privileged messages for a module.

A Module Authority is a design pattern in the Cosmos SDK where sensitive, state-changing functions of a module are restricted to a single, pre-defined address. This ensures that critical operations, like updating parameters, can only be performed by an authorized entity. For the x/okrw module, the authority is responsible for executing MsgUpdateParams.

Default Authority

By convention and for security, the default authority for most Cosmos SDK modules is the x/gov module account. This means that to execute a privileged message like MsgUpdateParams, a user must wrap it in a governance proposal. The proposal must then be voted on and passed by the network's stakeholders. The x/okrw module follows this pattern, ensuring parameter changes are a result of decentralized consensus.

Configuration

As seen in depinject.go, the authority address is configurable during the application's setup. While it defaults to the governance module, a custom authority can be specified in the application's configuration. This provides flexibility for different chain configurations, such as testnets or chains with alternative governance mechanisms. The NewKeeper function requires the authority address to be non-empty, enforcing that this critical role is always assigned.

Verification

Within the message server (e.g., msg_server.go), any message handler that performs a privileged action must first validate the signer. The x/okrw keeper provides a validateAuthority helper function for this purpose. The UpdateParams handler calls this function, comparing the authority field from the incoming message with the authority address configured in the keeper. If they do not match, the transaction is rejected with an ErrUnauthorized error.
Source: maroo
ESC
Type to search