-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Conversation
store := ak.storeSvc.OpenKVStore(ctx) | ||
has, err := store.Has(types.AddressStoreKey(addr)) | ||
if err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
store := ak.storeSvc.OpenKVStore(ctx) | ||
bz, err := store.Get(types.AddressStoreKey(addr)) | ||
if err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
…-sdk into facu/auth-storesvc
func KVStoreAdapter(store store.KVStore) storetypes.KVStore { | ||
return &kvStoreAdapter{store} | ||
} |
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.
Not sure where to put this adapter, accepting suggestions :D
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.
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense thank you
x/feegrant/go.mod
Outdated
@@ -158,3 +158,4 @@ require ( | |||
// Fix upstream GHSA-h395-qcrw-5vmq vulnerability. | |||
// TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 | |||
replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1 | |||
replace github.com/cosmos/cosmos-sdk => ../../ |
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.
We can remove this once we tag
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.
We won't tag the SDK in a while, best to use a pseudo version of the SDK from this branch.
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, I realized later that we are not tagging x/auth separately
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
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
func (s kvStoreAdapter) Delete(key []byte) { | ||
err := s.store.Delete(key) | ||
if err != nil { | ||
panic(err) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
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
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
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as before about UPGRADING.md + changelog.
I think now the category can be generalized under simapp. Moreover, we should add that if chains are generating mocks for their own testing, they will need to re-generate them.
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.
Github is taking a while to update stuff here, but I've added a changelog entry and modified the upgrading doc.
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.
lgtm! left 2 comments.
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
func KVStoreAdapter(store store.KVStore) storetypes.KVStore { | ||
return &kvStoreAdapter{store} | ||
} |
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.
makes sense thank you
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Description
Right now we still pass the StoreKey to the Keeper instead of the service because we need it for pagination and prefix iteration (prefix.NewStore
andquery.Paginate
). Should we do something about that now?query.Paginate
andprefix.NewStore
(not sure about where to put it)Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change