-
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
refactor!: use KVStoreService in x/auth #15520
Changes from all commits
65e40ff
c3f100b
bbc4059
b7fa375
e72edb1
a8876c6
7967507
ea197a1
ba37db7
7736215
d23760e
3bb304d
2aeb2c0
9bc07f8
479238b
e7ffab5
802aa1b
9a19133
9689f99
2bbbd41
759e21b
2abacf7
40b76e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,14 @@ package runtime | |
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"cosmossdk.io/core/store" | ||
|
||
storetypes "cosmossdk.io/store/types" | ||
|
||
dbm "github.com/cosmos/cosmos-db" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
|
@@ -90,3 +93,72 @@ func (store coreKVStore) Iterator(start, end []byte) (store.Iterator, error) { | |
func (store coreKVStore) ReverseIterator(start, end []byte) (store.Iterator, error) { | ||
return store.kvStore.ReverseIterator(start, end), nil | ||
} | ||
|
||
// Adapter | ||
var _ storetypes.KVStore = kvStoreAdapter{} | ||
|
||
type kvStoreAdapter struct { | ||
store store.KVStore | ||
} | ||
|
||
func (kvStoreAdapter) CacheWrap() storetypes.CacheWrap { | ||
panic("unimplemented") | ||
} | ||
|
||
func (kvStoreAdapter) CacheWrapWithTrace(w io.Writer, tc storetypes.TraceContext) storetypes.CacheWrap { | ||
panic("unimplemented") | ||
} | ||
|
||
func (kvStoreAdapter) GetStoreType() storetypes.StoreType { | ||
panic("unimplemented") | ||
} | ||
|
||
func (s kvStoreAdapter) Delete(key []byte) { | ||
err := s.store.Delete(key) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
|
||
func (s kvStoreAdapter) Get(key []byte) []byte { | ||
bz, err := s.store.Get(key) | ||
if err != nil { | ||
panic(err) | ||
Check warning Code scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
|
||
} | ||
return bz | ||
} | ||
|
||
func (s kvStoreAdapter) Has(key []byte) bool { | ||
has, err := s.store.Has(key) | ||
if err != nil { | ||
panic(err) | ||
Check warning Code scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
|
||
} | ||
return has | ||
} | ||
|
||
func (s kvStoreAdapter) Set(key []byte, value []byte) { | ||
err := s.store.Set(key, value) | ||
if err != nil { | ||
panic(err) | ||
Check warning Code scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
|
||
} | ||
} | ||
|
||
func (s kvStoreAdapter) Iterator(start []byte, end []byte) dbm.Iterator { | ||
it, err := s.store.Iterator(start, end) | ||
if err != nil { | ||
panic(err) | ||
Check warning Code scanning / CodeQL Panic in BeginBock or EndBlock consensus methods
Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
|
||
} | ||
return it | ||
} | ||
|
||
func (s kvStoreAdapter) ReverseIterator(start []byte, end []byte) dbm.Iterator { | ||
it, err := s.store.ReverseIterator(start, end) | ||
if err != nil { | ||
panic(err) | ||
} | ||
return it | ||
} | ||
|
||
func KVStoreAdapter(store store.KVStore) storetypes.KVStore { | ||
return &kvStoreAdapter{store} | ||
} | ||
Comment on lines
+162
to
+164
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure where to put this adapter, accepting suggestions :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this needed? the new interface returns errors can we use that or? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because there's the prefix store and the query.Paginate that take in the KVStore from /store/types instead of core. Once we migrate all modules we could remove this adapter and modify the other methods to take in the core KVStore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So yes, because the new interface returns errors so it's not compatible There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense thank you |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,7 +289,7 @@ func NewSimApp( | |
bApp.SetParamStore(&app.ConsensusParamsKeeper) | ||
|
||
// add keepers | ||
app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, keys[authtypes.StoreKey], authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) | ||
app.AccountKeeper = authkeeper.NewAccountKeeper(appCodec, runtime.NewKVStoreService(keys[authtypes.StoreKey]), authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as before about UPGRADING.md + changelog. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Github is taking a while to update stuff here, but I've added a changelog entry and modified the upgrading doc. |
||
|
||
app.BankKeeper = bankkeeper.NewBaseKeeper( | ||
appCodec, | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods