From 61a6f2ea66b866e7a608704d3ae0f58de44e237e Mon Sep 17 00:00:00 2001 From: Jim Larson Date: Thu, 11 Apr 2024 16:25:14 -0700 Subject: [PATCH 1/5] feat: feature flag to select ABCI client type --- server/start.go | 35 ++++++++++++++++++++++++++++++--- server/start_test.go | 46 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 server/start_test.go diff --git a/server/start.go b/server/start.go index 4f88ba8f2411..b60cbaa9cf55 100644 --- a/server/start.go +++ b/server/start.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/cobra" "github.com/tendermint/tendermint/abci/server" + abcitypes "github.com/tendermint/tendermint/abci/types" tcmd "github.com/tendermint/tendermint/cmd/cometbft/commands" tmos "github.com/tendermint/tendermint/libs/os" "github.com/tendermint/tendermint/node" @@ -59,6 +60,7 @@ const ( FlagIAVLCacheSize = "iavl-cache-size" FlagDisableIAVLFastNode = "iavl-disable-fastnode" FlagIAVLLazyLoading = "iavl-lazy-loading" + FlagAbciClientType = "abci-client-type" // state sync-related flags FlagStateSyncSnapshotInterval = "state-sync.snapshot-interval" @@ -82,6 +84,11 @@ const ( flagGRPCWebAddress = "grpc-web.address" ) +const ( + abciClientTypeCommitting = "committing" + abciClientTypeLocal = "local" +) + // StartCmd runs the service passed in, either stand-alone or in-process with // Tendermint. func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command { @@ -142,9 +149,18 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. }) } + abciClientType, err := cmd.Flags().GetString(FlagAbciClientType) + if err != nil { + return err + } + clientCreator, err := getAbciClientCreator(abciClientType) + if err != nil { + return err + } + // amino is needed here for backwards compatibility of REST routes err = wrapCPUProfile(serverCtx, func() error { - return startInProcess(serverCtx, clientCtx, appCreator) + return startInProcess(serverCtx, clientCtx, appCreator, clientCreator) }) errCode, ok := err.(ErrorCode) if !ok { @@ -194,6 +210,7 @@ is performed. Note, when enabled, gRPC will also be automatically enabled. cmd.Flags().Uint32(FlagStateSyncSnapshotKeepRecent, 2, "State sync snapshot to keep") cmd.Flags().Bool(FlagDisableIAVLFastNode, false, "Disable fast node for IAVL tree") + cmd.Flags().String(FlagAbciClientType, abciClientTypeCommitting, fmt.Sprintf(`Type of ABCI client ("%s" or "%s")`, abciClientTypeCommitting, abciClientTypeLocal)) // add support for all Tendermint-specific command line options tcmd.AddNodeFlags(cmd) @@ -254,7 +271,9 @@ func startStandAlone(ctx *Context, appCreator types.AppCreator) error { return WaitForQuitSignals() } -func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator) error { +type abciClientCreator func(abcitypes.Application) proxy.ClientCreator + +func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.AppCreator, clientCreator abciClientCreator) error { cfg := ctx.Config home := cfg.RootDir @@ -302,7 +321,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App cfg, pvm.LoadOrGenFilePV(cfg.PrivValidatorKeyFile(), cfg.PrivValidatorStateFile()), nodeKey, - proxy.NewCommittingClientCreator(app), + clientCreator(app), genDocProvider, node.DefaultDBProvider, node.DefaultMetricsProvider(cfg.Instrumentation), @@ -501,6 +520,16 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App return WaitForQuitSignals() } +func getAbciClientCreator(abciClientType string) (abciClientCreator, error) { + switch abciClientType { + case abciClientTypeCommitting: + return proxy.NewCommittingClientCreator, nil + case abciClientTypeLocal: + return proxy.NewLocalClientCreator, nil + } + return nil, fmt.Errorf(`unknown ABCI client type "%s"`, abciClientType) +} + func startTelemetry(cfg serverconfig.Config) (*telemetry.Metrics, error) { if !cfg.Telemetry.Enabled { return nil, nil diff --git a/server/start_test.go b/server/start_test.go new file mode 100644 index 000000000000..8e546a9ace6d --- /dev/null +++ b/server/start_test.go @@ -0,0 +1,46 @@ +package server + +import ( + "reflect" + "runtime" + "testing" +) + +func TestAbciClientType(t *testing.T) { + for _, tt := range []struct { + clientType string + creatorName string + wantErr bool + }{ + { + clientType: "committing", + creatorName: "github.com/tendermint/tendermint/proxy.NewCommittingClientCreator", + }, + { + clientType: "local", + creatorName: "github.com/tendermint/tendermint/proxy.NewLocalClientCreator", + }, + { + clientType: "cool ranch", + wantErr: true, + }, + } { + t.Run(tt.clientType, func(t *testing.T) { + creator, err := getAbciClientCreator(tt.clientType) + if tt.wantErr { + if err == nil { + t.Error("wanted error, got none") + } + } else { + if err != nil { + t.Errorf("unexpected error %v", err) + } else { + creatorName := runtime.FuncForPC(reflect.ValueOf(creator).Pointer()).Name() + if creatorName != tt.creatorName { + t.Errorf(`want creator "%s", got "%s"`, tt.creatorName, creatorName) + } + } + } + }) + } +} From 8db9c69a124f71764365c434072eb254fcc52531 Mon Sep 17 00:00:00 2001 From: Jim Larson Date: Thu, 11 Apr 2024 16:31:45 -0700 Subject: [PATCH 2/5] docs: changelog --- CHANGELOG-Agoric.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG-Agoric.md b/CHANGELOG-Agoric.md index 0ff514930d8e..7ff4d10af632 100644 --- a/CHANGELOG-Agoric.md +++ b/CHANGELOG-Agoric.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * (auth) [#407](https://github.com/agoric-labs/cosmos-sdk/pull/407) Configurable fee collector module account in DeductFeeDecorator. +* (server) [#409](https://github.com/agoric-labs/cosmos-sdk/pull/409) Flag to select ABCI client type. ### API Breaking From 0b554fc472cb9a6a2a666f084e09e8de46c5b2f9 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 12 Apr 2024 14:42:47 -0400 Subject: [PATCH 3/5] build(deps): Bump iavl to v0.19.7 (merge #412) --- CHANGELOG-Agoric.md | 1 + go.mod | 2 ++ go.sum | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-Agoric.md b/CHANGELOG-Agoric.md index 7ff4d10af632..52422e1b3188 100644 --- a/CHANGELOG-Agoric.md +++ b/CHANGELOG-Agoric.md @@ -41,6 +41,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (auth) [#407](https://github.com/agoric-labs/cosmos-sdk/pull/407) Configurable fee collector module account in DeductFeeDecorator. * (server) [#409](https://github.com/agoric-labs/cosmos-sdk/pull/409) Flag to select ABCI client type. +* (deps) [#412](https://github.com/agoric-labs/cosmos-sdk/pull/412) Bump iavl to v0.19.7 ### API Breaking diff --git a/go.mod b/go.mod index 8e3a6e9c72b3..39e7adba01ca 100644 --- a/go.mod +++ b/go.mod @@ -167,6 +167,8 @@ require ( replace ( // use cosmos fork of keyring github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + // replace broken iavl + github.com/cosmos/iavl => github.com/cosmos/iavl v0.19.7 // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // TODO: remove it: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 diff --git a/go.sum b/go.sum index c79c39f82f4c..7d635194dbf5 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,8 @@ github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= -github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU= -github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= +github.com/cosmos/iavl v0.19.7 h1:ij32FaEnwxfEurtK0QKDNhTWFnz6NUmrI5gky/WnoY0= +github.com/cosmos/iavl v0.19.7/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= From 23324f65356f521d3a1768e7571bf4c24268ddec Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 12 Apr 2024 14:43:58 -0400 Subject: [PATCH 4/5] fix(baseapp): Ignore events from simulated transactions (#413) --- CHANGELOG-Agoric.md | 4 ++++ baseapp/baseapp.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-Agoric.md b/CHANGELOG-Agoric.md index 52422e1b3188..d42d499f673d 100644 --- a/CHANGELOG-Agoric.md +++ b/CHANGELOG-Agoric.md @@ -43,6 +43,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (server) [#409](https://github.com/agoric-labs/cosmos-sdk/pull/409) Flag to select ABCI client type. * (deps) [#412](https://github.com/agoric-labs/cosmos-sdk/pull/412) Bump iavl to v0.19.7 +### Bug Fixes + +* (baseapp) [#413](https://github.com/agoric-labs/cosmos-sdk/pull/413) Ignore events from simulated transactions + ### API Breaking * (auth, bank) Agoric/agoric-sdk#8989 Remove deprecated lien support diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 420af527bea8..df0d6e8e92d0 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -767,7 +767,7 @@ func (app *BaseApp) runTx(mode runTxMode, txBytes []byte) (gInfo sdk.GasInfo, re if len(anteEvents) > 0 && (mode == runTxModeDeliver || mode == runTxModeSimulate) { // append the events in the order of occurrence result.Events = append(anteEvents, result.Events...) - if app.deliverState != nil { + if app.deliverState != nil && mode == runTxModeDeliver { app.deliverState.eventHistory = append(app.deliverState.eventHistory, result.Events...) } } From 3468c72e5548a30e3e5719e9449b0c7fb209ae0c Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 12 Apr 2024 14:58:32 -0400 Subject: [PATCH 5/5] docs: Update changelog --- CHANGELOG-Agoric.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG-Agoric.md b/CHANGELOG-Agoric.md index d42d499f673d..472a30acff6d 100644 --- a/CHANGELOG-Agoric.md +++ b/CHANGELOG-Agoric.md @@ -40,6 +40,15 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * (auth) [#407](https://github.com/agoric-labs/cosmos-sdk/pull/407) Configurable fee collector module account in DeductFeeDecorator. + +### API Breaking + +* (auth, bank) Agoric/agoric-sdk#8989 Remove deprecated lien support + +## `v0.46.16-alpha.agoric.2.2` - 2024-04-12 + +### Improvements + * (server) [#409](https://github.com/agoric-labs/cosmos-sdk/pull/409) Flag to select ABCI client type. * (deps) [#412](https://github.com/agoric-labs/cosmos-sdk/pull/412) Bump iavl to v0.19.7 @@ -47,10 +56,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (baseapp) [#413](https://github.com/agoric-labs/cosmos-sdk/pull/413) Ignore events from simulated transactions -### API Breaking - -* (auth, bank) Agoric/agoric-sdk#8989 Remove deprecated lien support - ## `v0.46.16-alpha.agoric.2.1` - 2024-03-08 ### Improvements