Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export only active consensus validators #3445

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Export only validators that are participating in consensus
([\#3445](https://github.com/cosmos/gaia/pull/3445))
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would delete validators that are allowed to validate consumer chains but are not in the active validator set of the hub.

Would you mind expanding on the issue?

Copy link
Contributor Author

@fastfadingviolets fastfadingviolets Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. This assertion fails when you're importing a chain right now. This is because the provider keeper only answered with the consensus validators.

Would the validators actually be deleted? I was expecting them to still be in the app_state for staking so that once the chain starts up they get added back to the set, but I may be wrong

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command if for exporting when creating a new genesis.json if I'm not mistaken.

In that case, yes, they would be deleted and not available in the new chain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do some testing next week and come back to this

if len(validators) > int(maxVals) {
validators = validators[:maxVals]
}

return servertypes.ExportedApp{
AppState: appState,
Validators: validators,
Expand Down
Loading