Skip to content

Commit

Permalink
build: Cherry pick commits for patch release (merge #414)
Browse files Browse the repository at this point in the history
  • Loading branch information
gibson042 authored Apr 12, 2024
2 parents a1ec2f2 + 3468c72 commit 33c8d96
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 6 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG-Agoric.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ Ref: https://keepachangelog.com/en/1.0.0/

* (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

### Bug Fixes

* (baseapp) [#413](https://github.com/agoric-labs/cosmos-sdk/pull/413) Ignore events from simulated transactions

## `v0.46.16-alpha.agoric.2.1` - 2024-03-08

### Improvements
Expand Down
2 changes: 1 addition & 1 deletion baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
35 changes: 32 additions & 3 deletions server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions server/start_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
})
}
}

0 comments on commit 33c8d96

Please sign in to comment.