Skip to content

Commit

Permalink
Merge branch 'main' into nina/e2e-as-executables
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters authored Apr 17, 2024
2 parents 0ebc97a + 9db2f8b commit b2d8d40
Show file tree
Hide file tree
Showing 18 changed files with 613 additions and 442 deletions.
462 changes: 143 additions & 319 deletions app/app.go

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ func TestNew(t *testing.T) {
logger := log.NewNopLogger()
db := tmdb.NewMemDB()
traceStore := &NoopWriter{}
loadLatest := true
invCheckPeriod := uint(1)
encodingConfig := encoding.MakeConfig(app.ModuleEncodingRegisters...)
upgradeHeight := int64(0)
appOptions := NoopAppOptions{}

got := app.New(logger, db, traceStore, loadLatest, invCheckPeriod, encodingConfig, upgradeHeight, appOptions)
got := app.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeight, appOptions)

t.Run("initializes ICAHostKeeper", func(t *testing.T) {
assert.NotNil(t, got.ICAHostKeeper)
Expand Down
31 changes: 28 additions & 3 deletions app/module/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ func (m *Manager) assertNoForgottenModules(setOrderFnName string, moduleNames []
// MigrationHandler is the migration function that each module registers.
type MigrationHandler func(sdk.Context) error

// VersionMap is a map of moduleName -> version
type VersionMap map[string]uint64

// RunMigrations performs in-place store migrations for all modules. This
// function MUST be called when the state machine changes appVersion
func (m Manager) RunMigrations(ctx sdk.Context, cfg sdkmodule.Configurator, fromVersion, toVersion uint64) error {
Expand Down Expand Up @@ -335,6 +332,22 @@ func (m *Manager) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
}
}

// GetVersionMap gets consensus version from all modules
func (m *Manager) GetVersionMap(version uint64) sdkmodule.VersionMap {
vermap := make(sdkmodule.VersionMap)
if version > m.lastVersion || version < m.firstVersion {
return vermap
}

for _, v := range m.versionedModules[version] {
version := v.ConsensusVersion()
name := v.Name()
vermap[name] = version
}

return vermap
}

// ModuleNames returns list of all module names, without any particular order.
func (m *Manager) ModuleNames(version uint64) []string {
modules, ok := m.versionedModules[version]
Expand All @@ -351,6 +364,7 @@ func (m *Manager) ModuleNames(version uint64) []string {
return ms
}

// SupportedVersions returns all the supported versions for the module manager
func (m *Manager) SupportedVersions() []uint64 {
output := make([]uint64, 0, m.lastVersion-m.firstVersion+1)
for version := m.firstVersion; version <= m.lastVersion; version++ {
Expand Down Expand Up @@ -385,6 +399,17 @@ func (m *Manager) checkUpgradeSchedule() error {
return nil
}

// assertMatchingModules performs a sanity check that the basic module manager
// contains all the same modules present in the module manager
func (m *Manager) AssertMatchingModules(basicModuleManager sdkmodule.BasicManager) error {
for _, module := range m.allModules {
if _, exists := basicModuleManager[module.Name()]; !exists {
return fmt.Errorf("module %s not found in basic module manager", module.Name())
}
}
return nil
}

// DefaultMigrationsOrder returns a default migrations order: ascending alphabetical by module name,
// except x/auth which will run last, see:
// https://github.com/cosmos/cosmos-sdk/issues/10591
Expand Down
Loading

0 comments on commit b2d8d40

Please sign in to comment.