-
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
feat: migrate x/capability to app wiring #12058
Conversation
@@ -216,6 +216,9 @@ func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) { | |||
case *storetypes.TransientStoreKey: | |||
app.MountStore(key, storetypes.StoreTypeTransient) | |||
|
|||
case *storetypes.MemoryStoreKey: |
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 if adding this to baseapp is the way to go
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.
What's the context here?
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.
runtime/builder uses baseApps' MountStores
. Without this addition we get this error Unrecognized store key type :*types.MemoryStoreKey
.
I think that if we filter out any MemoryStoreKey
s before calling this everything works just fine... I don't know enough about these things to know exactly what's up 😅
Lines 27 to 41 in 8eaff8f
// Build builds an *App instance. | |
func (a *AppBuilder) Build(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptions ...func(*baseapp.BaseApp)) *App { | |
for _, option := range a.app.baseAppOptions { | |
baseAppOptions = append(baseAppOptions, option) | |
} | |
// TODO: when the auth module is configured, fill-in txDecoder | |
bApp := baseapp.NewBaseApp(a.app.config.AppName, logger, db, nil, baseAppOptions...) | |
bApp.SetCommitMultiStoreTracer(traceStore) | |
bApp.SetVersion(version.Version) | |
bApp.SetInterfaceRegistry(a.app.interfaceRegistry) | |
bApp.MountStores(a.app.storeKeys...) | |
a.app.BaseApp = bApp | |
return a.app | |
} |
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.
nvm tried again removing it and it doesn't work
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.
I'm not really sure about this code. I'd have to delegate to @aaronc here.
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.
I think this addition is correct. IMHO the fact that the multi-store doesn't know how to map store keys -> store types is a really strange and error prone. So this patch is sort of needed, but really the multi-store design should be cleaned up a bit
@@ -14,7 +14,7 @@ const ( | |||
StoreKey = ModuleName | |||
|
|||
// MemStoreKey defines the in-memory store key | |||
MemStoreKey = "mem_capability" | |||
MemStoreKey = "memory:capability" |
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 is only used for testing, we might want to move it over. Same goes for StoreKey.
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 was this change necessary, just curious?
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 now the store keys are being registered through this function that has a fixed format:
Lines 115 to 119 in 8eaff8f
func provideMemoryStoreKey(key container.ModuleKey, app appWrapper) *storetypes.MemoryStoreKey { | |
storeKey := storetypes.NewMemoryStoreKey(fmt.Sprintf("memory:%s", key.Name())) | |
registerStoreKey(app, storeKey) | |
return storeKey | |
} |
I think this key is now deprecated and used only in tests because we don't use it anywhere else.
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.
got it. If so, can we prefix the variable with Test
or something? Or maybe just remove it completely and define it directly in tests?
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.
I think we should move it over to test. We still need it to create the MemoryStoreKey pass it to the Keeper in tests. @aaronc this is what I pinged you about on Slack
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 should maybe even have a copy of simapp/app.go before the app wiring (maybe simapp/legacy) that checks to make sure that way still works
I like that idea!
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.
Ok, just opened #12068 to track that
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.
And I will go back to MemStoreKey = "mem_capability"
and create a new constant in the tests
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.
I think it's okay to change the value of MemStoreKey
just not to delete the const
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.
Gotcha, will revert that last change then 👌
…/app-wiring-capability
All tests passing 🎉 |
return msk | ||
} | ||
|
||
sk := app.UnsafeFindStoreKey(storeKey) |
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.
When would a mem key be found in the list of real store keys?
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.
provideMemoryStoreKey
calls registerStoreKey
which appends the key to the list of store keys. Should we have a separate list for them?
Lines 115 to 119 in 8eaff8f
func provideMemoryStoreKey(key container.ModuleKey, app appWrapper) *storetypes.MemoryStoreKey { | |
storeKey := storetypes.NewMemoryStoreKey(fmt.Sprintf("memory:%s", key.Name())) | |
registerStoreKey(app, storeKey) | |
return storeKey | |
} |
@@ -216,6 +216,9 @@ func (app *BaseApp) MountStores(keys ...storetypes.StoreKey) { | |||
case *storetypes.TransientStoreKey: | |||
app.MountStore(key, storetypes.StoreTypeTransient) | |||
|
|||
case *storetypes.MemoryStoreKey: |
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.
What's the context here?
@@ -14,7 +14,7 @@ const ( | |||
StoreKey = ModuleName | |||
|
|||
// MemStoreKey defines the in-memory store key | |||
MemStoreKey = "mem_capability" | |||
MemStoreKey = "memory:capability" |
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 was this change necessary, just curious?
…s/cosmos-sdk into facu/app-wiring-capability
This reverts commit ad191ea.
@facundomedica could you fix the conflicts? |
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
am.keeper.InitMemStore(ctx) | ||
|
||
if am.sealKeeper && !am.keeper.IsSealed() { |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyBeginBlocker) | ||
|
||
am.keeper.InitMemStore(ctx) | ||
|
||
if am.sealKeeper && !am.keeper.IsSealed() { | ||
am.keeper.Seal() |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
protoiface "google.golang.org/protobuf/runtime/protoiface" | ||
protoimpl "google.golang.org/protobuf/runtime/protoimpl" | ||
io "io" | ||
reflect "reflect" |
Check notice
Code scanning / CodeQL
Sensitive package import
* feat: migrate x/capability to app wiring * added some fixes from Matt's PR + changed MemStoreKey * fix name * fix name * small change * rollback MemStoreKey change * Revert "rollback MemStoreKey change" This reverts commit ad191ea. * add suggestions by @aaronc * add IsSealed() * fix Co-authored-by: Aaron Craelius <aaron@regen.network>
Description
Migrate x/capability to the new app wiring (dependency injection).
Tracking progress at #12069
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