chore: add a logged warning for merged proto registry when creating baseapp (#24450)

This commit is contained in:
Alex | Interchain Labs 2025-04-09 13:21:00 -04:00 committed by GitHub
parent a0a79bee9a
commit 49862cc712
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 20 deletions

View File

@ -33,6 +33,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/mempool"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
type (
@ -251,6 +252,18 @@ func NewBaseApp(
// Unless SetInterfaceRegistry is called with an interface registry with proper address codecs baseapp will panic.
app.cdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
protoFiles, err := proto.MergedRegistry()
if err != nil {
logger.Warn("error creating merged proto registry", "error", err)
} else {
err = msgservice.ValidateProtoAnnotations(protoFiles)
if err != nil {
// Once we switch to using protoreflect-based antehandlers, we might
// want to panic here instead of logging a warning.
logger.Warn("error validating merged proto registry annotations", "error", err)
}
}
return app
}

View File

@ -5,14 +5,12 @@ package simapp
import (
"encoding/json"
"fmt"
"io"
"maps"
"os"
abci "github.com/cometbft/cometbft/abci/types"
dbm "github.com/cosmos/cosmos-db"
"github.com/cosmos/gogoproto/proto"
"github.com/spf13/cast"
"io"
"maps"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
@ -56,7 +54,6 @@ import (
testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/types/msgservice"
sigtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
@ -469,7 +466,7 @@ func NewSimApp(
app.GovKeeper = *govKeeper.SetHooks(
govtypes.NewMultiGovHooks(
// register the governance hooks
// register the governance hooks
),
)
@ -499,7 +496,7 @@ func NewSimApp(
app.EpochsKeeper.SetHooks(
epochstypes.NewMultiEpochHooks(
// insert epoch hooks receivers here
// insert epoch hooks receivers here
),
)
@ -686,19 +683,6 @@ func NewSimApp(
// upgrade.
app.setPostHandler()
// At startup, after all modules have been registered, check that all prot
// annotations are correct.
protoFiles, err := proto.MergedRegistry()
if err != nil {
panic(err)
}
err = msgservice.ValidateProtoAnnotations(protoFiles)
if err != nil {
// Once we switch to using protoreflect-based antehandlers, we might
// want to panic here instead of logging a warning.
fmt.Fprintln(os.Stderr, err.Error())
}
if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
panic(fmt.Errorf("error loading last version: %w", err))