Skip to content

Commit

Permalink
fix: export only active consensus validators
Browse files Browse the repository at this point in the history
Otherwise the genesis import will fail because the provider module will
tell it to expect only those validators
  • Loading branch information
fastfadingviolets committed Dec 11, 2024
1 parent 9643139 commit 892f3af
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gaia

import (
"encoding/json"
"sort"

tmproto "github.com/cometbft/cometbft/proto/tendermint/types"

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 892f3af

Please sign in to comment.