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

refactor(x/auth): Fix system test #20531

Merged
merged 40 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
214605b
change initial version to 0
sontrinh16 May 31, 2024
aefee6a
Revert "change initial version to 0"
sontrinh16 Jun 1, 2024
495ab79
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk
sontrinh16 Jun 1, 2024
f761eb1
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk
sontrinh16 Jun 3, 2024
13cd0df
Merge branch 'main' of https://github.com/cosmos/cosmos-sdk
sontrinh16 Jun 3, 2024
9c3170a
fix system test
sontrinh16 Jun 3, 2024
c32693e
Merge branch 'main' into son/quick_fix
sontrinh16 Jun 3, 2024
af58812
move acc num sync to upgarde handler
sontrinh16 Jun 4, 2024
3b33ae9
revert main logic for now
sontrinh16 Jun 4, 2024
e6afd5e
Merge branch 'son/quick_fix' of https://github.com/cosmos/cosmos-sdk …
sontrinh16 Jun 4, 2024
521c566
minor
sontrinh16 Jun 4, 2024
c1a08da
fix accounts init genesis problem and fix system and sim test
sontrinh16 Jun 4, 2024
dfebc64
go mod tidy
sontrinh16 Jun 4, 2024
d1244ae
minor
sontrinh16 Jun 4, 2024
94e9b2b
Merge branch 'main' into son/quick_fix
sontrinh16 Jun 4, 2024
1d9cfcf
address comments
sontrinh16 Jun 5, 2024
d4d9a11
Merge branch 'son/quick_fix' of https://github.com/cosmos/cosmos-sdk …
sontrinh16 Jun 5, 2024
ba123e6
Merge branch 'main' into son/quick_fix
sontrinh16 Jun 9, 2024
c43114f
make deprecate
sontrinh16 Jun 9, 2024
e5206f6
add test case
sontrinh16 Jun 10, 2024
179641d
address comments
sontrinh16 Jun 10, 2024
663ef59
update upgrade doc
sontrinh16 Jun 10, 2024
610ef6f
minor
sontrinh16 Jun 10, 2024
7388cbd
add test for upgrade logic
sontrinh16 Jun 10, 2024
3441aae
minor
sontrinh16 Jun 10, 2024
e68685a
duplicate comment
sontrinh16 Jun 10, 2024
51742cc
Merge branch 'main' into son/quick_fix
sontrinh16 Jun 10, 2024
f60aa6b
Update simapp/upgrades_test.go
sontrinh16 Jun 10, 2024
49ef1e3
fix simapp test
sontrinh16 Jun 10, 2024
5f9818b
Merge branch 'son/quick_fix' of https://github.com/cosmos/cosmos-sdk …
sontrinh16 Jun 10, 2024
053ae26
address comment
sontrinh16 Jun 11, 2024
eae8154
changelog, add detail err log
sontrinh16 Jun 11, 2024
3ef3407
address comments
sontrinh16 Jun 11, 2024
c9aa0f2
lint
sontrinh16 Jun 11, 2024
6cf6894
fix upgrading doc
sontrinh16 Jun 11, 2024
c22d05c
Merge branch 'main' into son/quick_fix
sontrinh16 Jun 11, 2024
75d5bab
more lint
sontrinh16 Jun 12, 2024
c2c2b1c
fix conflict
sontrinh16 Jun 12, 2024
69d6738
lint
sontrinh16 Jun 12, 2024
1d1b745
lint more
sontrinh16 Jun 12, 2024
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
7 changes: 4 additions & 3 deletions x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ type AccountKeeper struct {
authority string

// State
Schema collections.Schema
Params collections.Item[types.Params]

Schema collections.Schema
Params collections.Item[types.Params]
AccountNumber collections.Sequence
sontrinh16 marked this conversation as resolved.
Show resolved Hide resolved
// Accounts key: AccAddr | value: AccountI | index: AccountsIndex
Accounts *collections.IndexedMap[sdk.AccAddress, sdk.AccountI, AccountsIndexes]
}
Expand Down Expand Up @@ -135,6 +135,7 @@ func NewAccountKeeper(
permAddrs: permAddrs,
authority: authority,
Params: collections.NewItem(sb, types.ParamsKey, "params", codec.CollValue[types.Params](cdc)),
AccountNumber: collections.NewSequence(sb, types.GlobalAccountNumberKey, "account_number"),
Accounts: collections.NewIndexedMap(sb, types.AddressStoreKeyPrefix, "accounts", sdk.AccAddressKey, codec.CollInterfaceValue[sdk.AccountI](cdc), NewAccountIndexes(sb)),
}
schema, err := sb.Build()
Expand Down
12 changes: 3 additions & 9 deletions x/auth/keeper/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package keeper
import (
"context"

"cosmossdk.io/collections"
v5 "cosmossdk.io/x/auth/migrations/v5"
"cosmossdk.io/x/auth/types"

Expand All @@ -13,16 +12,11 @@ import (
// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper AccountKeeper
// accNum is use in v4 to v5 and v5 to v6 migration
accNum collections.Sequence
}

// NewMigrator returns a new Migrator.
func NewMigrator(keeper AccountKeeper) Migrator {
sb := collections.NewSchemaBuilder(keeper.Environment.KVStoreService)
accNumSeq := collections.NewSequence(sb, types.GlobalAccountNumberKey, "account_number")

return Migrator{keeper: keeper, accNum: accNumSeq}
return Migrator{keeper: keeper}
}

// Migrate1to2 migrates from version 1 to 2.
Expand All @@ -48,13 +42,13 @@ func (m Migrator) Migrate3to4(ctx context.Context) error {
// It migrates the GlobalAccountNumber from being a protobuf defined value to a
// big-endian encoded uint64, it also migrates it to use a more canonical prefix.
func (m Migrator) Migrate4To5(ctx context.Context) error {
return v5.Migrate(ctx, m.keeper.KVStoreService, m.accNum)
return v5.Migrate(ctx, m.keeper.KVStoreService, m.keeper.AccountNumber)
}

// Migrate5To6 migrates the x/auth module state from the consensus version 5 to 6.
// It migrates the GlobalAccountNumber from x/auth to x/accounts .
func (m Migrator) Migrate5To6(ctx context.Context) error {
currentAccNum, err := m.accNum.Peek(ctx)
currentAccNum, err := m.keeper.AccountNumber.Peek(ctx)
if err != nil {
return err
}
Expand Down
Loading