Skip to content

Commit d8810da

Browse files
authored
refactor: Removed cudos related code (#420)
Removal of the CUDOS upgrade handle. This is preparation for cosmos-sdk `v0.20.0` (based on the canonical v0.53.4).
1 parent 644eddd commit d8810da

13 files changed

+12
-8812
lines changed

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88

99
jobs:
1010
build-and-test:
11-
runs-on: ubuntu-20.04
11+
runs-on: ubuntu-22.04
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Build Docker container

.github/workflows/build_push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
build-and-push:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-22.04
1010

1111
steps:
1212
- uses: actions/checkout@v2

app/app.go

Lines changed: 10 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,6 @@ type App struct {
217217

218218
invCheckPeriod uint
219219

220-
cudosGenesisPath string
221-
cudosGenesisSha256 string
222-
cudosMigrationConfigPath string
223-
cudosMigrationConfigSha256 string
224-
225220
// keys to access the substores
226221
keys map[string]*sdk.KVStoreKey
227222
tkeys map[string]*sdk.TransientStoreKey
@@ -261,7 +256,7 @@ type App struct {
261256
// NewSimApp returns a reference to an initialized SimApp.
262257
func New(
263258
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool,
264-
skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, cudosGenesisPath string, cudosMigrationConfigPath string, cudosGenesisSha256 string, cudosMigrationConfigSha256 string, encodingConfig appparams.EncodingConfig, enabledProposals []wasm.ProposalType,
259+
skipUpgradeHeights map[int64]bool, homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, enabledProposals []wasm.ProposalType,
265260
appOpts servertypes.AppOptions, wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp),
266261
) *App {
267262

@@ -285,18 +280,14 @@ func New(
285280
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
286281

287282
app := &App{
288-
BaseApp: bApp,
289-
legacyAmino: legacyAmino,
290-
appCodec: appCodec,
291-
interfaceRegistry: interfaceRegistry,
292-
invCheckPeriod: invCheckPeriod,
293-
cudosGenesisPath: cudosGenesisPath,
294-
cudosGenesisSha256: cudosGenesisSha256,
295-
cudosMigrationConfigPath: cudosMigrationConfigPath,
296-
cudosMigrationConfigSha256: cudosMigrationConfigSha256,
297-
keys: keys,
298-
tkeys: tkeys,
299-
memKeys: memKeys,
283+
BaseApp: bApp,
284+
legacyAmino: legacyAmino,
285+
appCodec: appCodec,
286+
interfaceRegistry: interfaceRegistry,
287+
invCheckPeriod: invCheckPeriod,
288+
keys: keys,
289+
tkeys: tkeys,
290+
memKeys: memKeys,
300291
}
301292

302293
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
@@ -378,7 +369,7 @@ func New(
378369

379370
app.GovKeeper = *govKeeper.SetHooks(
380371
govtypes.NewMultiGovHooks(
381-
// register the governance hooks
372+
// register the governance hooks
382373
),
383374
)
384375

@@ -727,124 +718,7 @@ func (app *App) GetSubspace(moduleName string) paramstypes.Subspace {
727718
return subspace
728719
}
729720

730-
func getNetworkInfo(app *App, ctx sdk.Context, manifest *UpgradeManifest, expectedChainIdOfMergeSourceGenesis string) (*NetworkConfig, error) {
731-
// Load network config from file if given
732-
var networkInfo *NetworkConfig
733-
var err error
734-
if app.cudosMigrationConfigPath != "" {
735-
app.Logger().Info("cudos merge: loading network config", "file", app.cudosMigrationConfigPath, "expected sha256", app.cudosMigrationConfigSha256)
736-
737-
networkInfo, err = LoadAndVerifyNetworkConfigFromFile(app.cudosMigrationConfigPath, &app.cudosMigrationConfigSha256)
738-
if err != nil {
739-
return nil, err
740-
}
741-
742-
if networkInfo.MergeSourceChainID != expectedChainIdOfMergeSourceGenesis {
743-
return nil, fmt.Errorf("mismatch of Merge Source ChainID: the \"merge_source_chain_id\" value in the NetworkConfig file contains \"%s\", expected value is chan-id from input merge source genesis json file, which is \"%s\"", networkInfo.MergeSourceChainID, expectedChainIdOfMergeSourceGenesis)
744-
}
745-
if networkInfo.DestinationChainID != ctx.ChainID() {
746-
return nil, fmt.Errorf("mismatch of Destination ChainID: the \"destination_chain_id\" value in the NetworkConfig file contains \"%s\", expected value is chan-id of the current running chain, which is \"%s\"", networkInfo.DestinationChainID, ctx.ChainID())
747-
}
748-
749-
manifest.NetworkConfigFileSha256 = app.cudosMigrationConfigSha256
750-
751-
// Config file not given, config from hardcoded map
752-
} else if info, ok := NetworkInfos[ctx.ChainID()]; ok {
753-
app.Logger().Info("cudos merge: loading network from map", "chain", ctx.ChainID())
754-
manifest.NetworkConfigFileSha256 = "config map"
755-
networkInfo = &info
756-
757-
} else {
758-
return nil, fmt.Errorf("network info not found for chain id: %s", ctx.ChainID())
759-
}
760-
761-
return networkInfo, nil
762-
}
763-
764-
func LoadAndParseMergeSourceInputFiles(app *App, ctx sdk.Context, manifest *UpgradeManifest) (*GenesisData, *NetworkConfig, error) {
765-
766-
cudosJsonData, cudosGenDoc, err := LoadCudosGenesis(app, manifest)
767-
768-
if err != nil {
769-
return nil, nil, fmt.Errorf("failed to load genesis data: %w", err)
770-
}
771-
772-
networkInfo, err := getNetworkInfo(app, ctx, manifest, cudosGenDoc.ChainID)
773-
if err != nil {
774-
return nil, nil, fmt.Errorf("failed to load network config: %w", err)
775-
}
776-
777-
cudosConfig := NewCudosMergeConfig(networkInfo.CudosMerge)
778-
779-
genesisData, err := ParseGenesisData(*cudosJsonData, cudosGenDoc, cudosConfig, manifest)
780-
if err != nil {
781-
return nil, nil, fmt.Errorf("failed to parse genesis data: %w", err)
782-
}
783-
784-
return genesisData, networkInfo, nil
785-
}
786-
787721
func (app *App) RegisterUpgradeHandlers(cfg module.Configurator) {
788-
app.UpgradeKeeper.SetUpgradeHandler("v0.14.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
789-
790-
manifest := NewUpgradeManifest()
791-
792-
cudosGenesisData, networkInfo, err := LoadAndParseMergeSourceInputFiles(app, ctx, manifest)
793-
if err != nil {
794-
return nil, fmt.Errorf("cudos merge: %w", err)
795-
}
796-
797-
manifest.DestinationChainBlockHeight = ctx.BlockHeight()
798-
manifest.DestinationChainID = ctx.ChainID()
799-
800-
manifest.GovProposalUpgradePlanName = plan.Name
801-
802-
err = app.DeleteContractStates(ctx, networkInfo, manifest)
803-
if err != nil {
804-
return nil, err
805-
}
806-
807-
err = app.UpgradeContractAdmins(ctx, networkInfo, manifest)
808-
if err != nil {
809-
return nil, err
810-
}
811-
812-
err = app.ChangeContractLabels(ctx, networkInfo, manifest)
813-
if err != nil {
814-
return nil, err
815-
}
816-
817-
err = app.ChangeContractVersions(ctx, networkInfo, manifest)
818-
if err != nil {
819-
return nil, err
820-
}
821-
822-
err = app.ProcessReconciliation(ctx, networkInfo, manifest)
823-
if err != nil {
824-
return nil, err
825-
}
826-
827-
cudosConfig := NewCudosMergeConfig(networkInfo.CudosMerge)
828-
829-
err = VerifyConfig(cudosConfig, cudosGenesisData.Prefix, AccountAddressPrefix)
830-
if err != nil {
831-
return nil, err
832-
}
833-
834-
err = CudosMergeUpgradeHandler(app, ctx, cudosConfig, cudosGenesisData, manifest)
835-
if err != nil {
836-
return nil, err
837-
}
838-
839-
err = SaveManifest(app, manifest, plan.Name)
840-
if err != nil {
841-
return nil, err
842-
}
843-
844-
// End of migration
845-
return app.mm.RunMigrations(ctx, cfg, fromVM)
846-
})
847-
848722
app.UpgradeKeeper.SetUpgradeHandler("v0.14.1", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
849723
return app.mm.RunMigrations(ctx, cfg, fromVM)
850724
})

0 commit comments

Comments
 (0)