Skip to content

Commit

Permalink
remove mention of hasgenesis from core
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Aug 29, 2023
1 parent 6fe54cc commit f8f414c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 19 deletions.
25 changes: 10 additions & 15 deletions docs/docs/building-modules/01-module-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ There are 4 main application module interfaces:

* [`appmodule.AppModule` / `module.AppModule`](#appmodule) for inter-dependent module functionalities (except genesis-related functionalities).
* (legacy) [`module.AppModuleBasic`](#appmodulebasic) for independent module functionalities. New modules can use `module.CoreAppModuleBasicAdaptor` instead.
* (legacy) [`module.AppModuleGenesis`](#appmodulegenesis) for inter-dependent genesis-related module functionalities.
* (legacy) [`module.HasGenesis`](#hasgenesis) for inter-dependent genesis-related module functionalities.
* (legacy) [`module.HasABCIGenesis`](#hasabcigenesis) for inter-dependent genesis-related module functionalities.
* (legacy) `module.GenesisOnlyAppModule`: Defines an `AppModule` that only has import/export functionality

The above interfaces are mostly embedding smaller interfaces (extension interfaces), that defines specific functionalities:

* (legacy) `module.HasName`: Allows the module to provide its own name for legacy purposes.
* (legacy) [`module.HasGenesisBasics`](#hasgenesisbasics): The legacy interface for stateless genesis methods.
* [`appmodule.HasGenesis` / `module.HasGenesis`](#hasgenesis): The extension interface for stateful genesis methods.
* [`appmodule.HasBeginBlocker`](#hasbeginblocker): The extension interface that contains information about the `AppModule` and `BeginBlock`.
* [`appmodule.HasEndBlocker`](#hasendblocker): The extension interface that contains information about the `AppModule` and `EndBlock`.
* [`appmodule.HasPrecommit`](#hasprecommit): The extension interface that contains information about the `AppModule` and `Precommit`.
Expand Down Expand Up @@ -96,32 +96,27 @@ Let us go through the methods:
* `DefaultGenesis(codec.JSONCodec)`: Returns a default [`GenesisState`](./08-genesis.md#genesisstate) for the module, marshalled to `json.RawMessage`. The default `GenesisState` need to be defined by the module developer and is primarily used for testing.
* `ValidateGenesis(codec.JSONCodec, client.TxEncodingConfig, json.RawMessage)`: Used to validate the `GenesisState` defined by a module, given in its `json.RawMessage` form. It will usually unmarshall the `json` before running a custom [`ValidateGenesis`](./08-genesis.md#validategenesis) function defined by the module developer.

### `AppModuleGenesis`

:::note
Use `appmodule.HasGenesis` instead.
:::
### `HasGenesis`

The `AppModuleGenesis` interface is a simple embedding of the `AppModuleBasic` and `HasGenesis` interfaces.
`HasGenesis` is an extension interface for allowing modules to implement genesis functionalities. If you

```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go#L183-L186
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go#L189-L193
```

It does not have its own manager, and exists separately from [`AppModule`](#appmodule) only for modules that exist only to implement genesis functionalities, so that they can be managed without having to implement all of `AppModule`'s methods.

### `HasGenesis`
### `HasABCIGenesis`

The `HasGenesis` interface is an extension interface of `HasGenesisBasics`.
`HasABCIGenesis` is an extension interface for allowing modules to implement genesis functionalities and returns validator set updates.

```go reference
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/core/appmodule/genesis.go#L10-L24
https://github.com/cosmos/cosmos-sdk/blob/v0.50.0-alpha.0/types/module/module.go#L189-L193
```
<!-- TODO change link above after merge -->

Let us go through the two added methods:
It does not have its own manager, and exists separately from [`AppModule`](#appmodule) only for modules that exist only to implement genesis functionalities, so that they can be managed without having to implement all of `AppModule`'s methods.

* `InitGenesis(context.Context, codec.JSONCodec, json.RawMessage)`: Initializes the subset of the state managed by the module. It is called at genesis (i.e. when the chain is first started).
* `ExportGenesis(context.Context, codec.JSONCodec)`: Exports the latest subset of the state managed by the module to be used in a new genesis file. `ExportGenesis` is called for each module when a new chain is started from the state of an existing chain.

### `AppModule`

Expand Down
5 changes: 1 addition & 4 deletions types/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Package module contains application module patterns and associated "manager" functionality.
The module pattern has been broken down by:
- independent module functionality (AppModuleBasic)
- inter-dependent module genesis functionality (AppModuleGenesis)
- inter-dependent module simulation functionality (AppModuleSimulation)
- inter-dependent module full functionality (AppModule)
Expand All @@ -21,7 +20,7 @@ have to manually register all of the codecs for all the modules. This basic
procedure as well as other basic patterns are handled through the use of
BasicManager.
Lastly the interface for genesis functionality (AppModuleGenesis) has been
Lastly the interface for genesis functionality (HasGenesis & HasABCIGenesis) has been
separated out from full module functionality (AppModule) so that modules which
are only used for genesis can take advantage of the Module patterns without
needlessly defining many placeholder functions
Expand Down Expand Up @@ -182,8 +181,6 @@ func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command) {
}
}

// AppModuleGenesis is the standard form for an application module genesis functions

// HasGenesis is the extension interface for stateful genesis methods.
type HasGenesis interface {
HasGenesisBasics
Expand Down

0 comments on commit f8f414c

Please sign in to comment.