diff --git a/.changelog/unreleased/bug-fixes/3445-export-consensus-validators.md b/.changelog/unreleased/bug-fixes/3445-export-consensus-validators.md new file mode 100644 index 0000000000..daf910e347 --- /dev/null +++ b/.changelog/unreleased/bug-fixes/3445-export-consensus-validators.md @@ -0,0 +1,2 @@ +- Export only validators that are participating in consensus + ([\#3445](https://github.com/cosmos/gaia/pull/3445)) diff --git a/app/export.go b/app/export.go index b82996ea88..f9d9236f1c 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,