-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Launchpad Migration #6829
Merged
Merged
Launchpad Migration #6829
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6021d40
fix migration
alexanderbez 85ba661
add 039 pkg
alexanderbez 60557e2
lint
alexanderbez b85d399
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez 2de3222
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez 8a2b81f
Fix pkg name
alexanderbez 75a7c08
add v0.39 auth types
alexanderbez a92b063
remove file
alexanderbez c80b029
updates
alexanderbez 5220993
updates
alexanderbez d22305f
update godoc
alexanderbez 01c5f26
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez d833860
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez 375acf2
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez 407aa2f
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez 2d4811a
Merge branch 'master' into bez/6828-fix-0_39-migration
fedekunze 6dbfe29
Merge branch 'master' into bez/6828-fix-0_39-migration
alexanderbez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
x/auth/legacy/v0_39/migrate.go → x/auth/legacy/v0_40/migrate.go
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
package v039 | ||
package v040 | ||
|
||
import ( | ||
"fmt" | ||
|
||
v038auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_38" | ||
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_39" | ||
) | ||
|
||
// Migrate accepts exported x/auth genesis state from v0.38 and migrates it to | ||
// v0.39 x/auth genesis state. The migration includes: | ||
// Migrate accepts exported x/auth genesis state from v0.38/v0.39 and migrates | ||
// it to v0.40 x/auth genesis state. The migration includes: | ||
// | ||
// - Removing coins from account encoding. | ||
func Migrate(authGenState v038auth.GenesisState) v038auth.GenesisState { | ||
func Migrate(authGenState v039auth.GenesisState) v039auth.GenesisState { | ||
for _, account := range authGenState.Accounts { | ||
// set coins to nil and allow the JSON encoding to omit coins | ||
if err := account.SetCoins(nil); err != nil { | ||
panic(fmt.Sprintf("failed to set account coins to nil: %s", err)) | ||
} | ||
} | ||
|
||
authGenState.Accounts = v038auth.SanitizeGenesisAccounts(authGenState.Accounts) | ||
authGenState.Accounts = v039auth.SanitizeGenesisAccounts(authGenState.Accounts) | ||
return authGenState | ||
} |
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,8 @@ | ||
package v040 | ||
|
||
// DONTCOVER | ||
// nolint | ||
|
||
const ( | ||
ModuleName = "auth" | ||
) |
10 changes: 5 additions & 5 deletions
10
x/bank/legacy/v0_39/migrate.go → x/bank/legacy/v0_40/migrate.go
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package v039 | ||
package v040 | ||
|
||
// DONTCOVER | ||
// nolint | ||
|
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
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,55 @@ | ||
package v040 | ||
|
||
import ( | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
v039auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_39" | ||
v040auth "github.com/cosmos/cosmos-sdk/x/auth/legacy/v0_40" | ||
v038bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v0_38" | ||
v040bank "github.com/cosmos/cosmos-sdk/x/bank/legacy/v0_40" | ||
"github.com/cosmos/cosmos-sdk/x/genutil/types" | ||
) | ||
|
||
// Migrate migrates exported state from v0.39 to a v0.40 genesis state. | ||
func Migrate(appState types.AppMap) types.AppMap { | ||
v039Codec := codec.New() | ||
cryptocodec.RegisterCrypto(v039Codec) | ||
v039auth.RegisterCodec(v039Codec) | ||
|
||
v040Codec := codec.New() | ||
cryptocodec.RegisterCrypto(v040Codec) | ||
v039auth.RegisterCodec(v040Codec) | ||
|
||
// remove balances from existing accounts | ||
if appState[v039auth.ModuleName] != nil { | ||
// unmarshal relative source genesis application state | ||
var authGenState v039auth.GenesisState | ||
v039Codec.MustUnmarshalJSON(appState[v039auth.ModuleName], &authGenState) | ||
|
||
// delete deprecated x/auth genesis state | ||
delete(appState, v039auth.ModuleName) | ||
|
||
// Migrate relative source genesis application state and marshal it into | ||
// the respective key. | ||
appState[v040auth.ModuleName] = v040Codec.MustMarshalJSON(v040auth.Migrate(authGenState)) | ||
} | ||
|
||
if appState[v038bank.ModuleName] != nil { | ||
// unmarshal relative source genesis application state | ||
var bankGenState v038bank.GenesisState | ||
v039Codec.MustUnmarshalJSON(appState[v038bank.ModuleName], &bankGenState) | ||
|
||
// unmarshal x/auth genesis state to retrieve all account balances | ||
var authGenState v039auth.GenesisState | ||
v039Codec.MustUnmarshalJSON(appState[v039auth.ModuleName], &authGenState) | ||
|
||
// delete deprecated x/bank genesis state | ||
delete(appState, v038bank.ModuleName) | ||
|
||
// Migrate relative source genesis application state and marshal it into | ||
// the respective key. | ||
appState[v040bank.ModuleName] = v040Codec.MustMarshalJSON(v040bank.Migrate(bankGenState, authGenState)) | ||
} | ||
|
||
return appState | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
supply is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, noticed that too. In #6839 i'll comb through all genesis states and see if a migration is needed for each of them, if supply is not here then i'll do it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR isn't for 0.40, it's for 0.39. There is a separate issue to wrap up 0.40 which @amaurymartiny already pointed to.