-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #541 from PeggyJV/collin/v3-upgrade
Consensus version 3 upgrade/migration
- Loading branch information
Showing
10 changed files
with
123 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# v3 upgrade | ||
|
||
This upgrade moves the gravity module from consensus version 2 to 3. | ||
|
||
## Summary of changes | ||
|
||
* Bumps cosmos-sdk to v0.45.10 and ibc-go to v3.4.0 | ||
* Bumps minor dependency versions | ||
* Fix signer set signature sorting inconsistency between orchestrator and chain when powers are equal | ||
* Add CompletedOutgoingTx store for marking transactions as executed | ||
* Refactor slashing logic and include CompletedOutgoingTx in unslashed tx getter | ||
* Add tx confirmation pruning | ||
* Add event vote record pruning | ||
* Fix bug that iterated the entire key store when SetDelegateKeys was called | ||
* Refactor address lookups used in SetDelegateKeys to not require scanning entire list of validators | ||
* Remove MsgRequestBatchTx and handlers | ||
* Add missing Amino registrations | ||
* Fix minor CLI bugs | ||
* Improve and correct terminology in function names and comments | ||
* Update queries | ||
|
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,4 @@ | ||
package v3 | ||
|
||
// UpgradeName defines the on-chain upgrade name for the Gravity v3 upgrade | ||
const UpgradeName = "v3" |
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,18 @@ | ||
package v3 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("v3 upgrade: entering handler") | ||
|
||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} |
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 @@ | ||
package v3 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package v2 | ||
|
||
import ( | ||
sdktypes "github.com/cosmos/cosmos-sdk/types" | ||
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
"github.com/peggyjv/gravity-bridge/module/v3/x/gravity/types" | ||
) | ||
|
||
func MigrateParamStore(ctx sdktypes.Context, subspace paramstypes.Subspace) error { | ||
// Don't want to overwrite values if they were set in an upgrade handler | ||
if !subspace.Has(ctx, types.ParamStoreConfirmedOutgoingTxWindow) { | ||
subspace.Set(ctx, types.ParamStoreConfirmedOutgoingTxWindow, types.DefaultParams().ConfirmedOutgoingTxWindow) | ||
} | ||
if !subspace.Has(ctx, types.ParamStoreEthereumEventVoteWindow) { | ||
subspace.Set(ctx, types.ParamStoreEthereumEventVoteWindow, types.DefaultParams().EthereumEventVoteWindow) | ||
} | ||
|
||
return nil | ||
} |
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,37 @@ | ||
package v2_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
storetypes "github.com/cosmos/cosmos-sdk/store/types" | ||
"github.com/cosmos/cosmos-sdk/testutil" | ||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" | ||
v2 "github.com/peggyjv/gravity-bridge/module/v3/x/gravity/migrations/v2" | ||
"github.com/peggyjv/gravity-bridge/module/v3/x/gravity/types" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
ModuleName = "gravity" | ||
) | ||
|
||
func TestStoreMigration(t *testing.T) { | ||
gravityKey := storetypes.NewKVStoreKey(ModuleName) | ||
tGravityKey := storetypes.NewTransientStoreKey("transient_test") | ||
ctx := testutil.DefaultContext(gravityKey, tGravityKey) | ||
aminoCodec := codec.NewLegacyAmino() | ||
paramstore := paramtypes.NewSubspace(nil, aminoCodec, gravityKey, tGravityKey, ModuleName) | ||
|
||
// Check no params | ||
require.False(t, paramstore.Has(ctx, types.ParamStoreConfirmedOutgoingTxWindow)) | ||
require.False(t, paramstore.Has(ctx, types.ParamStoreEventVoteWindow)) | ||
|
||
// Run migrations. | ||
err := v2.MigrateParamStore(ctx, paramstore) | ||
require.NoError(t, err) | ||
|
||
// Make sure the new params are set. | ||
require.True(t, paramstore.Has(ctx, types.ParamStoreConfirmedOutgoingTxWindow)) | ||
require.True(t, paramstore.Has(ctx, types.ParamStoreEventVoteWindow)) | ||
} |
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