-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: standalone to consumer changeover part 1 (#757)
* on-chain upgrade to consumer chain wip * add preCCV store and use it on democracy staking * add TODOs and one more packet possibility * status update * Resolve hermes start issue for trusted validator set by changing revision height * remove intermediary logs * remove further unused codebase * updates for endblocker test, existing test fixes, get last validators * update for slashing sovereign validators for the fault made before consumer chain upgrade height * resolve comments on github and slack communication * update sovereign app to use v4 ibc from v3 & resolve consumer module merge conflict fix issue * Update app/sovereign/upgrades/v3/upgrades.go Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com> * rm sovereign chain and tests. Will be replaced by simapp and integration tests * duplicate module name * add comment * small rename * remove democracy staking changes * consumer ccv beginblock, endblock, and initgenesis order shouldn't matter * add mock calls to compile * adjust tests for new keeper field * add registerDemocConsumer method * split out preCCV flag and initial valset * cleanup consumer module * cleanup * more cleanup * temp changes to validators.go * comment out test * rm bad code from merge * comment * Update app.go * UTs for CRUD * UTs for keys * use make for mocks * todo * changeover method and test * resolve #783 * comment * comments * add appropriate TODOs, restore changes to main * final nits before non-draft * comment on ChangeoverToConsumer * more clear comment * small comment change * update InitGenesis comment * sovereign -> standalone * missed a file * builds now * update comment after debug * naming refactor * edge case for val in old and new sets * restore keys after rebase --------- Co-authored-by: jstr1121 <jun@stridelabs.co> Co-authored-by: jstr1121 <118450565+jstr1121@users.noreply.github.com> Co-authored-by: yaruwangway <69694322+yaruwangway@users.noreply.github.com>
- Loading branch information
1 parent
45afa5c
commit 9fa783f
Showing
17 changed files
with
766 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
) | ||
|
||
// ChangeoverToConsumer includes the logic that needs to execute during the process of a | ||
// standalone to consumer changeover, where the previously standalone chain has | ||
// just been upgraded to include the consumer ccv module, but the provider valset is not | ||
// yet responsible for POS/block production. This method constructs validator updates | ||
// that will be given to tendermint, which allows the consumer chain to | ||
// start using the provider valset, while the standalone valset is given zero voting power where appropriate. | ||
func (k Keeper) ChangeoverToConsumer(ctx sdk.Context) (initialValUpdates []abci.ValidatorUpdate) { | ||
|
||
initialValUpdates = k.GetInitialValSet(ctx) | ||
// set last standalone height | ||
k.SetLastStandaloneHeight(ctx, ctx.BlockHeight()) | ||
// populate cross chain validators states with initial valset | ||
k.ApplyCCValidatorChanges(ctx, initialValUpdates) | ||
|
||
// Add validator updates to initialValUpdates, such that the "old" validators returned from standalone staking module | ||
// are given zero power, and the provider validators are given their full power. | ||
initialUpdatesFlag := make(map[string]bool) | ||
for _, val := range initialValUpdates { | ||
initialUpdatesFlag[val.PubKey.String()] = true | ||
} | ||
for _, val := range k.GetLastStandaloneValidators(ctx) { | ||
zeroPowerUpdate := val.ABCIValidatorUpdateZero() | ||
if !initialUpdatesFlag[zeroPowerUpdate.PubKey.String()] { | ||
initialValUpdates = append(initialValUpdates, zeroPowerUpdate) | ||
} | ||
} | ||
|
||
// Note: this method should only be executed once as a part of the changeover process. | ||
// Therefore we set the PreCCV state to false so the endblocker caller doesn't call this method again. | ||
k.DeletePreCCV(ctx) | ||
|
||
return initialValUpdates | ||
} |
Oops, something went wrong.