-
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(core)!: clean-up core and simplify preblock #19672
Changes from 6 commits
3975577
e652da9
7766454
8723606
b4a4bd3
f2ef59a
f346ead
f5246df
24679de
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 | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -54,10 +54,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ | |||||||
* Add `MsgHandler` as an alternative to grpc handlers | ||||||||
* Provide separate `MigrationRegistrar` instead of grouping with `RegisterServices` | ||||||||
|
||||||||
### Improvements | ||||||||
|
||||||||
### API Breaking Changes | ||||||||
|
||||||||
* [#19672](https://github.com/cosmos/cosmos-sdk/pull/19672) `PreBlock` now returns only an error for consistency with server/v2. The SDK has upgraded x/upgrade accordingly. | ||||||||
* [#18857](https://github.com/cosmos/cosmos-sdk/pull/18857) Moved `FormatCoins` to `x/tx`. | ||||||||
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. The URL for PR #18861 contains a typo: - * [#18861](httpes://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`.
+ * [#18861](https://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`. Committable suggestion
Suggested change
|
||||||||
* [#18861](httpes://github.com/cosmos/cosmos-sdk/pull/18861) Moved `coin.ParseCoin` to `client/v2/internal`. | ||||||||
* [#18866](https://github.com/cosmos/cosmos-sdk/pull/18866) All items related to depinject have been moved to `cosmossdk.io/depinject` (`Provide`, `Invoke`, `Register`) | ||||||||
Comment on lines
54
to
62
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.
There's a missing space after the period in the entry for PR #18457. This is a minor formatting issue but important for readability. - * [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit.
+ * [#18457](https://github.com/cosmos/cosmos-sdk/pull/18457) Add branch.ExecuteWithGasLimit. |
||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
package appmodule | ||
|
||
import "context" | ||
import ( | ||
"cosmossdk.io/core/appmodule/v2" | ||
) | ||
|
||
type MigrationRegistrar interface { | ||
// Register registers an in-place store migration for a module. The | ||
// handler is a migration script to perform in-place migrations from version | ||
// `fromVersion` to version `fromVersion+1`. | ||
// | ||
// EACH TIME a module's ConsensusVersion increments, a new migration MUST | ||
// be registered using this function. If a migration handler is missing for | ||
// a particular function, the upgrade logic (see RunMigrations function) | ||
// will panic. If the ConsensusVersion bump does not introduce any store | ||
// changes, then a no-op function must be registered here. | ||
Register(moduleName string, fromVersion uint64, handler func(context.Context) error) error | ||
} | ||
// HasConsensusVersion is the interface for declaring a module consensus version. | ||
type HasConsensusVersion = appmodule.HasConsensusVersion | ||
|
||
// HasMigrations is implemented by a module which upgrades or has upgraded to a new consensus version. | ||
type HasMigrations = appmodule.HasMigrations | ||
|
||
// MigrationRegistrar is the interface for registering in-place store migrations. | ||
type MigrationRegistrar = appmodule.MigrationRegistrar | ||
|
||
// MigrationHandler is the migration function that each module registers. | ||
type MigrationHandler = appmodule.MigrationHandler |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ import ( | |
"context" | ||
|
||
"google.golang.org/grpc" | ||
"google.golang.org/protobuf/runtime/protoiface" | ||
|
||
"cosmossdk.io/core/appmodule/v2" | ||
) | ||
|
@@ -15,16 +14,22 @@ import ( | |
// by other modules (usually via depinject) as app modules. | ||
type AppModule = appmodule.AppModule | ||
|
||
// HasMigrations is the extension interface that modules should implement to register migrations. | ||
type HasMigrations interface { | ||
AppModule | ||
// HasPreBlocker is the extension interface that modules should implement to run | ||
// custom logic before BeginBlock. | ||
// It can modify consensus parameters in storage and signal the caller through the return value. | ||
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.
This is not like this anymore, should be removed right? |
||
// The new context (ctx) must be passed to all the other lifecycle methods. | ||
type HasPreBlocker = appmodule.HasPreBlocker | ||
|
||
// RegisterMigrations registers the module's migrations with the app's migrator. | ||
RegisterMigrations(MigrationRegistrar) error | ||
} | ||
// HasBeginBlocker is the extension interface that modules should implement to run | ||
// custom logic before transaction processing in a block. | ||
type HasBeginBlocker = appmodule.HasBeginBlocker | ||
|
||
// HasEndBlocker is the extension interface that modules should implement to run | ||
// custom logic after transaction processing in a block. | ||
type HasEndBlocker = appmodule.HasEndBlocker | ||
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. The removal of the |
||
|
||
// HasConsensusVersion is the interface for declaring a module consensus version. | ||
type HasConsensusVersion = appmodule.HasConsensusVersion | ||
// HasRegisterInterfaces is the interface for modules to register their msg types. | ||
type HasRegisterInterfaces = appmodule.HasRegisterInterfaces | ||
|
||
// HasServices is the extension interface that modules should implement to register | ||
// implementations of services defined in .proto files. | ||
|
@@ -46,48 +51,6 @@ type HasServices interface { | |
RegisterServices(grpc.ServiceRegistrar) error | ||
} | ||
|
||
// ResponsePreBlock represents the response from the PreBlock method. | ||
// It can modify consensus parameters in storage and signal the caller through the return value. | ||
// When it returns ConsensusParamsChanged=true, the caller must refresh the consensus parameter in the finalize context. | ||
// The new context (ctx) must be passed to all the other lifecycle methods. | ||
type ResponsePreBlock interface { | ||
IsConsensusParamsChanged() bool | ||
} | ||
|
||
// HasPreBlocker is the extension interface that modules should implement to run | ||
// custom logic before BeginBlock. | ||
type HasPreBlocker interface { | ||
appmodule.AppModule | ||
// PreBlock is method that will be run before BeginBlock. | ||
PreBlock(context.Context) (ResponsePreBlock, error) | ||
} | ||
|
||
// HasBeginBlocker is the extension interface that modules should implement to run | ||
// custom logic before transaction processing in a block. | ||
type HasBeginBlocker = appmodule.HasBeginBlocker | ||
|
||
// HasEndBlocker is the extension interface that modules should implement to run | ||
// custom logic after transaction processing in a block. | ||
type HasEndBlocker = appmodule.HasEndBlocker | ||
|
||
// HasRegisterInterfaces is the interface for modules to register their msg types. | ||
type HasRegisterInterfaces = appmodule.HasRegisterInterfaces | ||
|
||
// MsgHandlerRouter is implemented by the runtime provider. | ||
type MsgHandlerRouter interface { | ||
// RegisterHandler is called by modules to register msg handler functions. | ||
RegisterHandler(name string, handler func(ctx context.Context, msg protoiface.MessageV1) (msgResp protoiface.MessageV1, err error)) | ||
} | ||
|
||
// HasMsgHandler is implemented by modules that instead of exposing msg server expose | ||
// a set of handlers. | ||
type HasMsgHandler interface { | ||
// RegisterMsgHandlers is implemented by the module that will register msg handlers. | ||
RegisterMsgHandlers(router MsgHandlerRouter) | ||
} | ||
|
||
// ---------------------------------------------------------------------------- // | ||
|
||
// HasPrepareCheckState is an extension interface that contains information about the AppModule | ||
// and PrepareCheckState. | ||
type HasPrepareCheckState interface { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,7 +113,9 @@ func (a *autocliConfigurator) RegisterMigration(string, uint64, module.Migration | |
return nil | ||
} | ||
|
||
func (a *autocliConfigurator) Register(string, uint64, func(context.Context) error) error { return nil } | ||
func (a *autocliConfigurator) Register(string, uint64, appmodule.MigrationHandler) error { | ||
return nil | ||
} | ||
Comment on lines
+116
to
+118
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. Updating the |
||
|
||
func (a *autocliConfigurator) RegisterService(sd *grpc.ServiceDesc, ss interface{}) { | ||
if a.registryCache == nil { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 like this being removed 👍