-
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: make validator key injectable by application developers #21608
Changes from 7 commits
9f7e8d8
70f541d
e169ad0
f2788ad
d30d546
2c8c887
d18491a
23cf89c
f0ae52b
c69aa19
f5e6e36
47de04d
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 |
---|---|---|
|
@@ -6,6 +6,8 @@ import ( | |
"slices" | ||
|
||
abci "github.com/cometbft/cometbft/api/cometbft/abci/v1" | ||
cmtcrypto "github.com/cometbft/cometbft/crypto" | ||
cmted25519 "github.com/cometbft/cometbft/crypto/ed25519" | ||
"google.golang.org/grpc" | ||
|
||
runtimev1alpha1 "cosmossdk.io/api/cosmos/app/runtime/v1alpha1" | ||
|
@@ -30,6 +32,8 @@ import ( | |
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" | ||
) | ||
|
||
type KeyGenF = func() (cmtcrypto.PrivKey, error) | ||
|
||
// App is a wrapper around BaseApp 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 | ||
|
@@ -308,3 +312,9 @@ var _ servertypes.Application = &App{} | |
type hasServicesV1 interface { | ||
RegisterServices(grpc.ServiceRegistrar) error | ||
} | ||
|
||
func (a *App) ValidatorKeyProvider() KeyGenF { | ||
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. go doc here too please |
||
return func() (cmtcrypto.PrivKey, error) { | ||
return cmted25519.GenPrivKey(), nil | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,26 @@ | ||
package cometbft | ||
|
||
import ( | ||
cmtcrypto "github.com/cometbft/cometbft/crypto" | ||
cmted22519 "github.com/cometbft/cometbft/crypto/ed25519" | ||
|
||
"cosmossdk.io/core/transaction" | ||
"cosmossdk.io/server/v2/cometbft/handlers" | ||
"cosmossdk.io/server/v2/cometbft/mempool" | ||
"cosmossdk.io/server/v2/cometbft/types" | ||
"cosmossdk.io/store/v2/snapshots" | ||
) | ||
|
||
type keyGenF = func() (cmtcrypto.PrivKey, error) | ||
|
||
// ServerOptions defines the options for the CometBFT server. | ||
type ServerOptions[T transaction.Tx] struct { | ||
Mempool mempool.Mempool[T] | ||
PrepareProposalHandler handlers.PrepareHandler[T] | ||
ProcessProposalHandler handlers.ProcessHandler[T] | ||
VerifyVoteExtensionHandler handlers.VerifyVoteExtensionhandler | ||
ExtendVoteHandler handlers.ExtendVoteHandler | ||
KeygenF keyGenF | ||
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. I really like that it doesn't leak in the app in v2 🙏🏾 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. Can we have a go doc here too? It's less descriptive than the above. |
||
|
||
SnapshotOptions snapshots.SnapshotOptions | ||
|
||
|
@@ -34,5 +40,6 @@ func DefaultServerOptions[T transaction.Tx]() ServerOptions[T] { | |
SnapshotOptions: snapshots.NewSnapshotOptions(0, 0), | ||
AddrPeerFilter: nil, | ||
IdPeerFilter: nil, | ||
KeygenF: func() (cmtcrypto.PrivKey, error) { return cmted22519.GenPrivKey(), nil }, | ||
} | ||
} |
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. you will probably need to revert this file to make the linter happy |
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.
can we have a godoc here?