From 892f3afb07faa5f2b00673337ead02e786da23ee Mon Sep 17 00:00:00 2001 From: violet Date: Wed, 11 Dec 2024 10:29:28 -0500 Subject: [PATCH] fix: export only active consensus validators Otherwise the genesis import will fail because the provider module will tell it to expect only those validators --- app/export.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/export.go b/app/export.go index b82996ea886..f9d9236f1c6 100644 --- a/app/export.go +++ b/app/export.go @@ -2,6 +2,7 @@ package gaia import ( "encoding/json" + "sort" tmproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -43,6 +44,18 @@ func (app *GaiaApp) ExportAppStateAndValidators( } validators, err := staking.WriteValidators(ctx, app.StakingKeeper) + if err != nil { + return servertypes.ExportedApp{}, err + } + sort.SliceStable(validators, func(i, j int) bool { + return validators[i].Power > validators[j].Power + }) + // we have to trim this to only active consensus validators + maxVals := app.ProviderKeeper.GetMaxProviderConsensusValidators(ctx) + if len(validators) > int(maxVals) { + validators = validators[:maxVals] + } + return servertypes.ExportedApp{ AppState: appState, Validators: validators,