chore: remove consensus authority (#21734)

Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
Marko 2024-09-16 22:06:21 +02:00 committed by GitHub
parent ddc7740eca
commit a9f057bf70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 15 additions and 29 deletions

View File

@ -33,15 +33,14 @@ import (
var _ abci.Application = (*Consensus[transaction.Tx])(nil)
type Consensus[T transaction.Tx] struct {
logger log.Logger
appName, version string
consensusAuthority string // Set by the application to grant authority to the consensus engine to send messages to the consensus module
app *appmanager.AppManager[T]
txCodec transaction.Codec[T]
store types.Store
streaming streaming.Manager
snapshotManager *snapshots.Manager
mempool mempool.Mempool[T]
logger log.Logger
appName, version string
app *appmanager.AppManager[T]
txCodec transaction.Codec[T]
store types.Store
streaming streaming.Manager
snapshotManager *snapshots.Manager
mempool mempool.Mempool[T]
cfg Config
indexedEvents map[string]struct{}
@ -67,7 +66,6 @@ type Consensus[T transaction.Tx] struct {
func NewConsensus[T transaction.Tx](
logger log.Logger,
appName string,
consensusAuthority string, // TODO remove
app *appmanager.AppManager[T],
mp mempool.Mempool[T],
indexedEvents map[string]struct{},
@ -80,7 +78,6 @@ func NewConsensus[T transaction.Tx](
return &Consensus[T]{
appName: appName,
version: getCometBFTServerVersion(),
consensusAuthority: consensusAuthority,
grpcMethodsMap: gRPCMethodsMap,
app: app,
cfg: cfg,
@ -246,7 +243,6 @@ func (c *Consensus[T]) InitChain(ctx context.Context, req *abciproto.InitChainRe
if req.ConsensusParams != nil {
ctx = context.WithValue(ctx, corecontext.CometParamsInitInfoKey, &consensustypes.MsgUpdateParams{
Authority: c.consensusAuthority,
Block: req.ConsensusParams.Block,
Evidence: req.ConsensusParams.Evidence,
Validator: req.ConsensusParams.Validator,

View File

@ -686,7 +686,7 @@ func setUpConsensus(t *testing.T, gasLimit uint64, mempool mempool.Mempool[mock.
am, err := b.Build()
require.NoError(t, err)
return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", "authority", am, mempool, map[string]struct{}{}, nil, mockStore, Config{AppTomlConfig: DefaultAppTomlConfig()}, mock.TxCodec{}, "test")
return NewConsensus[mock.Tx](log.NewNopLogger(), "testing-app", am, mempool, map[string]struct{}{}, nil, mockStore, Config{AppTomlConfig: DefaultAppTomlConfig()}, mock.TxCodec{}, "test")
}
// Check target version same with store's latest version

View File

@ -104,7 +104,6 @@ func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], cfg map[string]any, logg
consensus := NewConsensus(
s.logger,
appI.Name(),
appI.GetConsensusAuthority(),
appI.GetAppManager(),
s.serverOptions.Mempool(cfg),
indexEvents,

View File

@ -16,7 +16,6 @@ type AppI[T transaction.Tx] interface {
Name() string
InterfaceRegistry() server.InterfaceRegistry
GetAppManager() *appmanager.AppManager[T]
GetConsensusAuthority() string // TODO remove
GetGPRCMethodsToMessageMap() map[string]func() gogoproto.Message
GetStore() any
}

View File

@ -266,10 +266,8 @@ var (
Config: appconfig.WrapAny(&govmodulev1.Module{}),
},
{
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{
Authority: "consensus", // TODO remove.
}),
Name: consensustypes.ModuleName,
Config: appconfig.WrapAny(&consensusmodulev1.Module{}),
},
{
Name: accounts.ModuleName,

View File

@ -13,7 +13,6 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/runtime/v2"
"cosmossdk.io/store/v2/root"
consensuskeeper "cosmossdk.io/x/consensus/keeper"
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
"github.com/cosmos/cosmos-sdk/client"
@ -38,8 +37,7 @@ type SimApp[T transaction.Tx] struct {
// required keepers during wiring
// others keepers are all in the app
UpgradeKeeper *upgradekeeper.Keeper
ConsensusParamsKeeper consensuskeeper.Keeper
UpgradeKeeper *upgradekeeper.Keeper
}
func init() {
@ -135,7 +133,6 @@ func NewSimApp[T transaction.Tx](
&app.txConfig,
&app.interfaceRegistry,
&app.UpgradeKeeper,
&app.ConsensusParamsKeeper,
); err != nil {
panic(err)
}
@ -186,11 +183,6 @@ func (app *SimApp[T]) TxConfig() client.TxConfig {
return app.txConfig
}
// GetConsensusAuthority gets the consensus authority.
func (app *SimApp[T]) GetConsensusAuthority() string {
return app.ConsensusParamsKeeper.GetAuthority()
}
// GetStore gets the app store.
func (app *SimApp[T]) GetStore() any {
return app.App.GetStore()

View File

@ -109,6 +109,8 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) {
return nil, err
}
ssDb, err = rocksdb.New(dir)
default:
return nil, fmt.Errorf("unknown storage type: %s", opts.Options.SSType)
}
if err != nil {
return nil, err
@ -168,12 +170,12 @@ func CreateRootStore(opts *FactoryOptions) (store.RootStore, error) {
}
oldTrees[string(key)] = tree
}
sc, err = commitment.NewCommitStore(trees, oldTrees, opts.SCRawDB, opts.Logger)
if err != nil {
return nil, err
}
pm := pruning.NewManager(sc, ss, storeOpts.SCPruningOption, storeOpts.SSPruningOption)
return New(opts.Logger, ss, sc, pm, nil, nil)
}