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

x{stake,slash,gov,distrib} In-place Store Migrations #8504

Merged
merged 60 commits into from
Feb 25, 2021
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
10d72d7
Add 1st version of migrate
amaury1093 Feb 1, 2021
8036fca
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-8…
amaury1093 Feb 2, 2021
a9a406e
Put migration logic into Configurator
amaury1093 Feb 2, 2021
9ed3987
add test to bank store migration
amaury1093 Feb 2, 2021
a095d3a
add test for configurator
amaury1093 Feb 2, 2021
d550bff
Merge branch 'master' into am-8345-migration
amaury1093 Feb 2, 2021
b7141f9
Error if no migration found
amaury1093 Feb 3, 2021
2d554ce
Remove RunMigrations from Configurator interface
amaury1093 Feb 3, 2021
3df3f44
Update spec
amaury1093 Feb 3, 2021
ba6bd44
Rename folders
amaury1093 Feb 3, 2021
197b7ce
Merge branch 'master' into am-8345-migration
amaury1093 Feb 3, 2021
424932c
copy-paste from keys.go
amaury1093 Feb 3, 2021
254a71f
Merge branch 'am-8345-migration' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Feb 3, 2021
b6c0714
Fix nil map
amaury1093 Feb 3, 2021
9ab7f13
rename function
amaury1093 Feb 3, 2021
fc076f5
Update simapp/app.go
amaury1093 Feb 5, 2021
ae7b7dc
Update simapp/app_test.go
amaury1093 Feb 5, 2021
2c26734
Adderss reviews
amaury1093 Feb 8, 2021
eb15047
Merge branch 'am-8345-migration' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Feb 8, 2021
291a9e6
Fix tests
amaury1093 Feb 8, 2021
41d29ed
Update testutil/context.go
amaury1093 Feb 8, 2021
33494dc
Update docs for ConsensusVersion
amaury1093 Feb 8, 2021
e3a2412
Rename to forVersion
amaury1093 Feb 8, 2021
6db31d4
Merge branch 'am-8345-migration' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Feb 8, 2021
55f547e
Fix tests
amaury1093 Feb 8, 2021
8f3b9d4
Check error early
amaury1093 Feb 8, 2021
29b85b7
Return 1 for intiial version
amaury1093 Feb 8, 2021
41e0339
Use MigrationKeeper
amaury1093 Feb 10, 2021
d922003
Fix test
amaury1093 Feb 10, 2021
f422b93
Revert adding marshaler to Configurator
amaury1093 Feb 10, 2021
8cf88fe
Godoc updates
amaury1093 Feb 10, 2021
5add13a
Update docs
amaury1093 Feb 10, 2021
74b761a
Add distrib legacy folder
amaury1093 Feb 3, 2021
2816a20
Add tests for distrib migration
amaury1093 Feb 3, 2021
f18f253
Add gov migrations
amaury1093 Feb 3, 2021
9e5999e
Copy paste whole keys file
amaury1093 Feb 3, 2021
b15f03d
Add gov migrations
amaury1093 Feb 3, 2021
236e46c
Add staking
amaury1093 Feb 3, 2021
a52441e
Fix staking tests
amaury1093 Feb 3, 2021
b403770
Update spec and module.go
amaury1093 Feb 3, 2021
9546583
Update to latest changes
amaury1093 Feb 8, 2021
33d4e70
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-8…
amaury1093 Feb 10, 2021
9e5d611
Update migration scripts
amaury1093 Feb 10, 2021
518b878
capability to 1
amaury1093 Feb 11, 2021
9b625b0
Fix tests
amaury1093 Feb 11, 2021
2392629
Merge branch 'master' into am-8345-modules
amaury1093 Feb 11, 2021
c734484
Add package godoc
amaury1093 Feb 11, 2021
9c11560
Merge branch 'master' into am-8345-modules
amaury1093 Feb 16, 2021
b0a665e
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-8…
amaury1093 Feb 18, 2021
0e24bad
Merge branch 'master' into am-8345-modules
amaury1093 Feb 22, 2021
4942857
Remove whitespace
amaury1093 Feb 23, 2021
30d9045
Remove global
amaury1093 Feb 23, 2021
828a41b
Use Migrator
amaury1093 Feb 23, 2021
f3ca3e5
Remove 042 keys files
amaury1093 Feb 23, 2021
0e17848
Fix build
amaury1093 Feb 23, 2021
95f524f
Merge branch 'am-8345-modules' of ssh://github.com/cosmos/cosmos-sdk …
amaury1093 Feb 23, 2021
5456591
Unlambda
amaury1093 Feb 23, 2021
b5ff927
Merge branch 'master' into am-8345-modules
amaury1093 Feb 23, 2021
036bd30
Rename to Migrate1to2
amaury1093 Feb 25, 2021
21e8a15
Merge branch 'master' into am-8345-modules
amaury1093 Feb 25, 2021
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
Prev Previous commit
Next Next commit
Remove 042 keys files
amaury1093 committed Feb 23, 2021
commit f3ca3e5e2afcd5850cf7c39c0c4643ebb29460f6
52 changes: 0 additions & 52 deletions x/bank/legacy/v042/keys.go

This file was deleted.

3 changes: 2 additions & 1 deletion x/bank/legacy/v042/store.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040"
v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

// MigrateStore performs in-place store migrations from v0.40 to v0.42. The
@@ -27,7 +28,7 @@ func MigrateStore(ctx sdk.Context, storeKey sdk.StoreKey) error {
for ; oldStoreIter.Valid(); oldStoreIter.Next() {
addr := v040bank.AddressFromBalancesStore(oldStoreIter.Key())
denom := oldStoreIter.Key()[v040auth.AddrLen:]
newStoreKey := append(CreateAccountBalancesPrefix(addr), denom...)
newStoreKey := append(types.CreateAccountBalancesPrefix(addr), denom...)

// Set new key on store. Values don't change.
store.Set(newStoreKey, oldStoreIter.Value())
3 changes: 2 additions & 1 deletion x/bank/legacy/v042/store_test.go
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v040"
v042bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v042"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

func TestStoreMigration(t *testing.T) {
@@ -27,7 +28,7 @@ func TestStoreMigration(t *testing.T) {
err := v042bank.MigrateStore(ctx, bankKey)
require.NoError(t, err)

newKey := append(v042bank.CreateAccountBalancesPrefix(addr), denom...)
newKey := append(types.CreateAccountBalancesPrefix(addr), denom...)
// -7 because we replaced "balances" with 0x02,
// +1 because we added length-prefix to address.
require.Equal(t, len(oldKey)-7+1, len(newKey))
216 changes: 0 additions & 216 deletions x/distribution/legacy/v042/keys.go

This file was deleted.

19 changes: 10 additions & 9 deletions x/distribution/legacy/v042/store_test.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
v040distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v040"
v042distribution "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v042"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
)

func TestStoreMigration(t *testing.T) {
@@ -32,47 +33,47 @@ func TestStoreMigration(t *testing.T) {
{
"FeePoolKey",
v040distribution.FeePoolKey,
v042distribution.FeePoolKey,
types.FeePoolKey,
},
{
"ProposerKey",
v040distribution.ProposerKey,
v042distribution.ProposerKey,
types.ProposerKey,
},
{
"ValidatorOutstandingRewards",
v040distribution.GetValidatorOutstandingRewardsKey(valAddr),
v042distribution.GetValidatorOutstandingRewardsKey(valAddr),
types.GetValidatorOutstandingRewardsKey(valAddr),
},
{
"DelegatorWithdrawAddr",
v040distribution.GetDelegatorWithdrawAddrKey(addr2),
v042distribution.GetDelegatorWithdrawAddrKey(addr2),
types.GetDelegatorWithdrawAddrKey(addr2),
},
{
"DelegatorStartingInfo",
v040distribution.GetDelegatorStartingInfoKey(valAddr, addr2),
v042distribution.GetDelegatorStartingInfoKey(valAddr, addr2),
types.GetDelegatorStartingInfoKey(valAddr, addr2),
},
{
"ValidatorHistoricalRewards",
v040distribution.GetValidatorHistoricalRewardsKey(valAddr, 6),
v042distribution.GetValidatorHistoricalRewardsKey(valAddr, 6),
types.GetValidatorHistoricalRewardsKey(valAddr, 6),
},
{
"ValidatorCurrentRewards",
v040distribution.GetValidatorCurrentRewardsKey(valAddr),
v042distribution.GetValidatorCurrentRewardsKey(valAddr),
types.GetValidatorCurrentRewardsKey(valAddr),
},
{
"ValidatorAccumulatedCommission",
v040distribution.GetValidatorAccumulatedCommissionKey(valAddr),
v042distribution.GetValidatorAccumulatedCommissionKey(valAddr),
types.GetValidatorAccumulatedCommissionKey(valAddr),
},
{
"ValidatorSlashEvent",
v040distribution.GetValidatorSlashEventKey(valAddr, 6, 8),
v042distribution.GetValidatorSlashEventKey(valAddr, 6, 8),
types.GetValidatorSlashEventKey(valAddr, 6, 8),
},
}

Loading