-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
chore: upstream runtime/v2 #20320
Merged
Merged
chore: upstream runtime/v2 #20320
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
88ebae1
chore: upstream runtime/v2
kocubinski df04a11
draft required TransactionService impl
kocubinski 3debde3
feat(server/v2): router service (#19696)
julienrbrt 5833090
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocu/runtime-v2
kocubinski 70cba3a
Merge branch 'kocu/runtime-v2' of github.com:cosmos/cosmos-sdk into k…
kocubinski b2816b1
updates, proto
kocubinski 8f7b04c
upstreaming from server/v2 dev
kocubinski 6064c73
fix errors, use core/transaction.Msg rename
kocubinski 509b8fd
fix store bugs, update go.work.example
kocubinski caca61c
rm odd deref
kocubinski a72ddaf
rm deref
kocubinski f910346
comments in store/v2
kocubinski d5d3469
docs snd further updates to go.work.example
kocubinski 612f0fc
lint fix
kocubinski 6bdbbe6
update store/v2 iavl dep
kocubinski 3b953a2
rm comment
kocubinski 70156d0
Merge branch 'main' into kocu/runtime-v2
kocubinski b3d165c
remove nolint, usage is broken
kocubinski f9907f0
InvokeTyped not supported
kocubinski bb2413e
improve apis and solve todo
julienrbrt 182578c
updates
julienrbrt 85d0581
Merge branch 'main' of github.com:cosmos/cosmos-sdk into kocu/runtime-v2
kocubinski e3fa7e0
fixes
kocubinski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
syntax = "proto3"; | ||
|
||
package cosmos.app.runtime.v2; | ||
|
||
import "cosmos/app/v1alpha1/module.proto"; | ||
|
||
// Module is the config object for the runtime module. | ||
message Module { | ||
option (cosmos.app.v1alpha1.module) = { | ||
go_import: "cosmossdk.io/runtime/v2" | ||
use_package: {name: "cosmos.app.v1alpha1"} | ||
}; | ||
|
||
// app_name is the name of the app. | ||
string app_name = 1; | ||
|
||
// pre_blockers specifies the module names of pre blockers | ||
// to call in the order in which they should be called. If this is left empty | ||
// no pre blocker will be registered. | ||
repeated string pre_blockers = 2; | ||
|
||
// begin_blockers specifies the module names of begin blockers | ||
// to call in the order in which they should be called. If this is left empty | ||
// no begin blocker will be registered. | ||
repeated string begin_blockers = 3; | ||
|
||
// end_blockers specifies the module names of the end blockers | ||
// to call in the order in which they should be called. If this is left empty | ||
// no end blocker will be registered. | ||
repeated string end_blockers = 4; | ||
|
||
// tx_validators specifies the module names for tx validators | ||
// If this is left empty, no tx validation will be registered. | ||
repeated string tx_validators = 5; | ||
|
||
// init_genesis specifies the module names of init genesis functions | ||
// to call in the order in which they should be called. If this is left empty | ||
// no init genesis function will be registered. | ||
repeated string init_genesis = 6; | ||
|
||
// export_genesis specifies the order in which to export module genesis data. | ||
// If this is left empty, the init_genesis order will be used for export genesis | ||
// if it is specified. | ||
repeated string export_genesis = 7; | ||
|
||
// order_migrations defines the order in which module migrations are performed. | ||
// If this is left empty, it uses the default migration order (alphabeticaly). | ||
repeated string order_migrations = 8; | ||
|
||
// GasConfig is the config object for gas limits. | ||
GasConfig gas_config = 9; | ||
|
||
// override_store_keys is an optional list of overrides for the module store keys | ||
// to be used in keeper construction. | ||
repeated StoreKeyConfig override_store_keys = 10; | ||
} | ||
|
||
// GasConfig is the config object for gas limits. | ||
message GasConfig { | ||
uint64 validate_tx_gas_limit = 1; | ||
uint64 query_gas_limit = 2; | ||
uint64 simulation_gas_limit = 3; | ||
} | ||
|
||
// StoreKeyConfig may be supplied to override the default module store key, which | ||
// is the module name. | ||
message StoreKeyConfig { | ||
// name of the module to override the store key of | ||
string module_name = 1; | ||
|
||
// the kv store key to use instead of the module name. | ||
string kv_store_key = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
package runtime | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"errors" | ||
|
||
"golang.org/x/exp/slices" | ||
|
||
runtimev2 "cosmossdk.io/api/cosmos/app/runtime/v2" | ||
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" | ||
coreappmanager "cosmossdk.io/core/app" | ||
"cosmossdk.io/core/store" | ||
"cosmossdk.io/core/transaction" | ||
"cosmossdk.io/log" | ||
"cosmossdk.io/server/v2/appmanager" | ||
"cosmossdk.io/server/v2/stf" | ||
|
||
"github.com/cosmos/cosmos-sdk/codec" | ||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
) | ||
|
||
var _ AppI[transaction.Tx] = (*App)(nil) | ||
|
||
// AppI is an interface that defines the methods required by the App. | ||
type AppI[T transaction.Tx] interface { | ||
DeliverBlock( | ||
ctx context.Context, | ||
block *coreappmanager.BlockRequest[T], | ||
) (*coreappmanager.BlockResponse, store.WriterMap, error) | ||
ValidateTx(ctx context.Context, tx T) (coreappmanager.TxResult, error) | ||
Simulate(ctx context.Context, tx T) (coreappmanager.TxResult, store.WriterMap, error) | ||
Query(ctx context.Context, version uint64, request transaction.Msg) (transaction.Msg, error) | ||
QueryWithState(ctx context.Context, state store.ReaderMap, request transaction.Msg) (transaction.Msg, error) | ||
|
||
Logger() log.Logger | ||
ModuleManager() *MM | ||
Close() error | ||
} | ||
|
||
// App is a wrapper around AppManager and ModuleManager that can be used in hybrid | ||
// app.go/app config scenarios or directly as a servertypes.Application instance. | ||
// To get an instance of *App, *AppBuilder must be requested as a dependency | ||
// in a container which declares the runtime module and the AppBuilder.Build() | ||
// method must be called. | ||
// | ||
// App can be used to create a hybrid app.go setup where some configuration is | ||
// done declaratively with an app config and the rest of it is done the old way. | ||
// See simapp/app_.go for an example of this setup. | ||
type App struct { | ||
*appmanager.AppManager[transaction.Tx] | ||
|
||
// app manager dependencies | ||
stf *stf.STF[transaction.Tx] | ||
msgRouterBuilder *stf.MsgRouterBuilder | ||
queryRouterBuilder *stf.MsgRouterBuilder | ||
db Store | ||
|
||
// app configuration | ||
logger log.Logger | ||
config *runtimev2.Module | ||
appConfig *appv1alpha1.Config | ||
|
||
// modules configuration | ||
storeKeys []string | ||
interfaceRegistry codectypes.InterfaceRegistry | ||
cdc codec.Codec | ||
amino *codec.LegacyAmino | ||
moduleManager *MM | ||
} | ||
|
||
// Logger returns the app logger. | ||
func (a *App) Logger() log.Logger { | ||
return a.logger | ||
} | ||
|
||
// ModuleManager returns the module manager. | ||
func (a *App) ModuleManager() *MM { | ||
return a.moduleManager | ||
} | ||
|
||
// DefaultGenesis returns a default genesis from the registered modules. | ||
func (a *App) DefaultGenesis() map[string]json.RawMessage { | ||
return a.moduleManager.DefaultGenesis() | ||
} | ||
|
||
// LoadLatest loads the latest version. | ||
func (a *App) LoadLatest() error { | ||
return a.db.LoadLatestVersion() | ||
} | ||
|
||
// LoadHeight loads a particular height | ||
func (a *App) LoadHeight(height uint64) error { | ||
return a.db.LoadVersion(height) | ||
} | ||
|
||
// Close is called in start cmd to gracefully cleanup resources. | ||
func (a *App) Close() error { | ||
return nil | ||
} | ||
|
||
// RegisterStores registers the provided store keys. | ||
// This method should only be used for registering extra stores | ||
// wiich is necessary for modules that not registered using the app config. | ||
// To be used in combination of RegisterModules. | ||
func (a *App) RegisterStores(keys ...string) error { | ||
a.storeKeys = append(a.storeKeys, keys...) | ||
|
||
return nil | ||
} | ||
|
||
// GetStoreKeys returns all the stored store keys. | ||
func (a *App) GetStoreKeys() []string { | ||
return a.storeKeys | ||
} | ||
|
||
// UnsafeFindStoreKey fetches a registered StoreKey from the App in linear time. | ||
// NOTE: This should only be used in testing. | ||
func (a *App) UnsafeFindStoreKey(storeKey string) (string, error) { | ||
i := slices.IndexFunc(a.storeKeys, func(s string) bool { return s == storeKey }) | ||
if i == -1 { | ||
return "", errors.New("store key not found") | ||
} | ||
|
||
return a.storeKeys[i], nil | ||
} | ||
|
||
func (a *App) GetStore() Store { | ||
return a.db | ||
} | ||
|
||
func (a *App) GetLogger() log.Logger { | ||
return a.logger | ||
} | ||
|
||
func (a *App) ExecuteGenesisTx(_ []byte) error { | ||
panic("not implemented") | ||
} | ||
|
||
func (a *App) SetAppVersion(context.Context, uint64) error { | ||
panic("not implemented") | ||
} | ||
|
||
func (a *App) AppVersion(context.Context) (uint64, error) { | ||
panic("not implemented") | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@tac0turtle is it possible to decouple
cosmossdk.io/core and gogoproto dependency tree wise?
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.
Gogoproto is already a type within core. Since it's directly related to how the system works it's not needed to decouple. This import also does not prevent compiling down to rv32. What is the reason you would want to avoid this?
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.
Don't see why it can't be
type Marshallalable interface {
Marshal()
Unmarshal()
}
Having core abstracted from any implementation details around serialization seems like good practice.
cosmossdk.io/core should be over the wire agnostic imo.
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.
If we continue on the path of enshrining protobuf into base types of the system we will never get rid of the nightmares.
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.
proto.message is an interface,
its annoying I understand but this isn't defining serialisation either.
Marshal and unmarshal dont work here since you cant assume a type has those