diff --git a/.gitignore b/.gitignore index 1ce4f5cfa123..3f074d204f6d 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,8 @@ vagrant # IDE .idea *.iml +*.ipr +*.iws .dir-locals.el .vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index 655a8a5eb04d..0893e25dcbef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## Unreleased -* nothing +### Features + +* [#404](https://github.com/provenance-io/cosmos-sdk/pull/404) Add ADR-038 State Listening with Go Plugin System --- diff --git a/Makefile b/Makefile index 77871c1bcfcc..803f738278e9 100644 --- a/Makefile +++ b/Makefile @@ -273,6 +273,12 @@ test-sim-nondeterminism: @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h +test-sim-nondeterminism-streaming: + @echo "Running non-determinism-streaming test..." + @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ + -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h \ + -EnableStreaming=true + test-sim-custom-genesis-fast: @echo "Running custom genesis simulation..." @echo "By default, ${HOME}/.gaiad/config/genesis.json will be used." diff --git a/baseapp/abci.go b/baseapp/abci.go index 25e4d49ecbfa..e8f096d59766 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -12,11 +12,13 @@ import ( "time" "github.com/gogo/protobuf/proto" - abci "github.com/tendermint/tendermint/abci/types" - tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/hashicorp/go-plugin" "google.golang.org/grpc/codes" grpcstatus "google.golang.org/grpc/status" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/telemetry" @@ -186,10 +188,12 @@ func (app *BaseApp) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeg // set the signed validators for addition to context in deliverTx app.voteInfos = req.LastCommitInfo.GetVotes() - // call the hooks with the BeginBlock messages - for _, streamingListener := range app.abciListeners { - if err := streamingListener.ListenBeginBlock(app.deliverState.ctx, req, res); err != nil { - panic(fmt.Errorf("BeginBlock listening hook failed, height: %d, err: %w", req.Header.Height, err)) + // call the streaming service hook with the BeginBlock messages + for _, abciListener := range app.streamingManager.AbciListeners { + ctx := app.deliverState.ctx + blockHeight := ctx.BlockHeight() + if err := abciListener.ListenBeginBlock(ctx, req, res); err != nil { + app.logger.Error("BeginBlock listening hook failed", "height", blockHeight, "err", err) } } @@ -213,10 +217,12 @@ func (app *BaseApp) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBloc res.ConsensusParamUpdates = cp } - // call the streaming service hooks with the EndBlock messages - for _, streamingListener := range app.abciListeners { - if err := streamingListener.ListenEndBlock(app.deliverState.ctx, req, res); err != nil { - panic(fmt.Errorf("EndBlock listening hook failed, height: %d, err: %w", req.Height, err)) + // call the streaming service hook with the EndBlock messages + for _, abciListener := range app.streamingManager.AbciListeners { + ctx := app.deliverState.ctx + blockHeight := ctx.BlockHeight() + if err := abciListener.ListenEndBlock(ctx, req, res); err != nil { + app.logger.Error("EndBlock listening hook failed", "height", blockHeight, "err", err) } } @@ -263,14 +269,18 @@ func (app *BaseApp) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx { // Otherwise, the ResponseDeliverTx will contain releveant error information. // Regardless of tx execution outcome, the ResponseDeliverTx will contain relevant // gas execution context. -func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliverTx) { +func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx { gInfo := sdk.GasInfo{} resultStr := "successful" + var res abci.ResponseDeliverTx defer func() { - for _, streamingListener := range app.abciListeners { - if err := streamingListener.ListenDeliverTx(app.deliverState.ctx, req, res); err != nil { - panic(fmt.Errorf("DeliverTx listening hook failed: %w", err)) + // call the streaming service hook with the EndBlock messages + for _, abciListener := range app.streamingManager.AbciListeners { + ctx := app.deliverState.ctx + blockHeight := ctx.BlockHeight() + if err := abciListener.ListenDeliverTx(ctx, req, res); err != nil { + app.logger.Error("DeliverTx listening hook failed", "height", blockHeight, "err", err) } } }() @@ -288,13 +298,15 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv return sdkerrors.ResponseDeliverTxWithEvents(err, gInfo.GasWanted, gInfo.GasUsed, sdk.MarkEventsToIndex(anteEvents, app.indexEvents), app.trace) } - return abci.ResponseDeliverTx{ + res = abci.ResponseDeliverTx{ GasWanted: int64(gInfo.GasWanted), // TODO: Should type accept unsigned ints? GasUsed: int64(gInfo.GasUsed), // TODO: Should type accept unsigned ints? Log: result.Log, Data: result.Data, Events: sdk.MarkEventsToIndex(result.Events, app.indexEvents), } + + return res } // Commit implements the ABCI interface. It will commit all state that exists in @@ -305,6 +317,7 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv // against that height and gracefully halt if it matches the latest committed // height. func (app *BaseApp) Commit() abci.ResponseCommit { + header := app.deliverState.ctx.BlockHeader() retainHeight := app.GetBlockRetentionHeight(header.Height) @@ -319,11 +332,18 @@ func (app *BaseApp) Commit() abci.ResponseCommit { RetainHeight: retainHeight, } - // call the hooks with the Commit message - for _, streamingListener := range app.abciListeners { - if err := streamingListener.ListenCommit(app.deliverState.ctx, res); err != nil { - panic(fmt.Errorf("Commit listening hook failed, height: %d, err: %w", header.Height, err)) + // call the streaming service hook with the EndBlock messages + abciListeners := app.streamingManager.AbciListeners + if len(abciListeners) > 0 { + ctx := app.deliverState.ctx + blockHeight := ctx.BlockHeight() + changeSet := app.cms.PopStateCache() + for _, abciListener := range abciListeners { + if err := abciListener.ListenCommit(ctx, res, changeSet); err != nil { + app.logger.Error("ListenCommit listening hook failed", "height", blockHeight, "err", err) + } } + changeSet = nil } app.logger.Info("commit synced", "commit", fmt.Sprintf("%X", commitID)) @@ -376,6 +396,9 @@ func (app *BaseApp) halt() { } } + // Stop any running streaming plugins + plugin.CleanupClients() + // Resort to exiting immediately if the process could not be found or killed // via SIGINT/SIGTERM signals. app.logger.Info("failed to send SIGINT/SIGTERM; exiting...") diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7b0a162910dc..349c402dfb85 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -107,9 +107,8 @@ type BaseApp struct { // nolint: maligned // which informs Tendermint what to index. If empty, all events will be indexed. indexEvents map[string]struct{} - // abciListeners for hooking into the ABCI message processing of the BaseApp - // and exposing the requests and responses to external consumers - abciListeners []ABCIListener + // streamingManager for managing instances and configuration of ABCIListener services + streamingManager storetypes.StreamingManager feeHandler sdk.FeeHandler diff --git a/baseapp/baseapp_test.go b/baseapp/baseapp_test.go index 50baf0341ac5..cc02236c2f2e 100644 --- a/baseapp/baseapp_test.go +++ b/baseapp/baseapp_test.go @@ -2265,3 +2265,82 @@ func TestDefaultStoreLoader(t *testing.T) { require.Equal(t, storetypes.StoreTypeIAVL, store.GetStoreType()) } } + +var ( + distKey1 = storetypes.NewKVStoreKey("distKey1") +) + +func TestABCI_MultiListener_StateChanges(t *testing.T) { + // increment the tx counter + anteKey := []byte("ante-key") + anteOpt := func(bapp *BaseApp) { bapp.SetAnteHandler(anteHandlerTxTest(t, capKey1, anteKey)) } + + // increment the msg counter + deliverKey := []byte("deliver-key") + deliverKey2 := []byte("deliver-key2") + routerOpt := func(bapp *BaseApp) { + r1 := sdk.NewRoute(routeMsgCounter, handlerMsgCounter(t, capKey1, deliverKey)) + r2 := sdk.NewRoute(routeMsgCounter2, handlerMsgCounter(t, capKey1, deliverKey2)) + bapp.Router().AddRoute(r1) + bapp.Router().AddRoute(r2) + } + + distOpt := func(bapp *BaseApp) { bapp.MountStores(distKey1) } + mockListener1 := NewMockABCIListener("lis_1") + mockListener2 := NewMockABCIListener("lis_2") + streamingManager := storetypes.StreamingManager{AbciListeners: []storetypes.ABCIListener{&mockListener1, &mockListener2}} + streamingManagerOpt := func(bapp *BaseApp) { bapp.SetStreamingManager(streamingManager) } + addListenerOpt := func(bapp *BaseApp) { bapp.CommitMultiStore().AddListeners([]storetypes.StoreKey{distKey1}) } + + app := setupBaseApp(t, anteOpt, routerOpt, distOpt, streamingManagerOpt, addListenerOpt) + app.InitChain(abci.RequestInitChain{}) + + // Create same codec used in txDecoder + codec := codec.NewLegacyAmino() + registerTestCodec(codec) + + nBlocks := 3 + txPerHeight := 5 + + for blockN := 0; blockN < nBlocks; blockN++ { + header := tmproto.Header{Height: int64(blockN) + 1} + app.BeginBlock(abci.RequestBeginBlock{Header: header}) + var expectedChangeSet []*storetypes.StoreKVPair + + for i := 0; i < txPerHeight; i++ { + counter := int64(blockN*txPerHeight + i) + tx := newTxCounter(counter, counter) + + txBytes, err := codec.Marshal(tx) + require.NoError(t, err) + + sKey := []byte(fmt.Sprintf("distKey%d", i)) + sVal := []byte(fmt.Sprintf("distVal%d", i)) + + ctx := app.getState(runTxModeDeliver).ctx + store := ctx.KVStore(distKey1) + store.Set(sKey, sVal) + + expectedChangeSet = append(expectedChangeSet, &storetypes.StoreKVPair{ + StoreKey: distKey1.Name(), + Delete: false, + Key: sKey, + Value: sVal, + }) + + res := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes}) + require.True(t, res.IsOK(), fmt.Sprintf("%v", res)) + + events := res.GetEvents() + require.Len(t, events, 3, "should contain ante handler, message type and counter events respectively") + require.Equal(t, sdk.MarkEventsToIndex(counterEvent("ante_handler", counter).ToABCIEvents(), map[string]struct{}{})[0], events[0], "ante handler event") + require.Equal(t, sdk.MarkEventsToIndex(counterEvent(sdk.EventTypeMessage, counter).ToABCIEvents(), map[string]struct{}{})[0], events[2], "msg handler update counter event") + } + + app.EndBlock(abci.RequestEndBlock{}) + app.Commit() + + require.Equal(t, expectedChangeSet, mockListener1.ChangeSet, "should contain the same changeSet") + require.Equal(t, expectedChangeSet, mockListener2.ChangeSet, "should contain the same changeSet") + } +} diff --git a/baseapp/options.go b/baseapp/options.go index c24bc1f45c2e..7dee4f54b88d 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/snapshots" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -234,17 +235,6 @@ func (app *BaseApp) SetInterfaceRegistry(registry types.InterfaceRegistry) { app.msgServiceRouter.SetInterfaceRegistry(registry) } -// SetStreamingService is used to set a streaming service into the BaseApp hooks and load the listeners into the multistore -func (app *BaseApp) SetStreamingService(s StreamingService) { - // add the listeners for each StoreKey - for key, lis := range s.Listeners() { - app.cms.AddListeners(key, lis) - } - // register the StreamingService within the BaseApp - // BaseApp will pass BeginBlock, DeliverTx, and EndBlock requests and responses to the streaming services to update their ABCI context - app.abciListeners = append(app.abciListeners, s) -} - // SetQueryMultiStore set a alternative MultiStore implementation to support grpc query service. // // Ref: https://github.com/cosmos/cosmos-sdk/issues/13317 @@ -272,3 +262,8 @@ func (app *BaseApp) SetAggregateEventsFunc(aggregateEventsFunc func(resultEvents app.aggregateEventsFunc = aggregateEventsFunc } + +// SetStreamingManager sets the streaming manager for the BaseApp.test +func (app *BaseApp) SetStreamingManager(manager storetypes.StreamingManager) { + app.streamingManager = manager +} diff --git a/baseapp/streaming.go b/baseapp/streaming.go index b8b382ae05b3..48fba65e439c 100644 --- a/baseapp/streaming.go +++ b/baseapp/streaming.go @@ -1,37 +1,85 @@ package baseapp import ( - "context" - "io" - "sync" + "fmt" + "sort" - abci "github.com/tendermint/tendermint/abci/types" + "github.com/spf13/cast" - store "github.com/cosmos/cosmos-sdk/store/types" + servertypes "github.com/cosmos/cosmos-sdk/server/types" + storetypes "github.com/cosmos/cosmos-sdk/store/types" ) -// ABCIListener interface used to hook into the ABCI message processing of the BaseApp. -// the error results are propagated to consensus state machine, -// if you don't want to affect consensus, handle the errors internally and always return `nil` in these APIs. -type ABCIListener interface { - // ListenBeginBlock updates the streaming service with the latest BeginBlock messages - ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error - // ListenEndBlock updates the steaming service with the latest EndBlock messages - ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error - // ListenDeliverTx updates the steaming service with the latest DeliverTx messages - ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error - // ListenCommit updates the steaming service with the latest Commit event - ListenCommit(ctx context.Context, res abci.ResponseCommit) error +const ( + StreamingTomlKey = "streaming" + StreamingABCITomlKey = "abci" + StreamingABCIPluginTomlKey = "plugin" + StreamingABCIKeysTomlKey = "keys" + StreamingABCIStopNodeOnErrTomlKey = "stop-node-on-err" +) + +// RegisterStreamingPlugin registers streaming plugins with the App. +func RegisterStreamingPlugin( + bApp *BaseApp, + appOpts servertypes.AppOptions, + keys map[string]*storetypes.KVStoreKey, + streamingPlugin interface{}, +) error { + switch t := streamingPlugin.(type) { + case storetypes.ABCIListener: + registerABCIListenerPlugin(bApp, appOpts, keys, t) + default: + return fmt.Errorf("unexpected plugin type %T", t) + } + return nil +} + +func registerABCIListenerPlugin( + bApp *BaseApp, + appOpts servertypes.AppOptions, + keys map[string]*storetypes.KVStoreKey, + abciListener storetypes.ABCIListener, +) { + stopNodeOnErrKey := fmt.Sprintf("%s.%s.%s", StreamingTomlKey, StreamingABCITomlKey, StreamingABCIStopNodeOnErrTomlKey) + stopNodeOnErr := cast.ToBool(appOpts.Get(stopNodeOnErrKey)) + keysKey := fmt.Sprintf("%s.%s.%s", StreamingTomlKey, StreamingABCITomlKey, StreamingABCIKeysTomlKey) + exposeKeysStr := cast.ToStringSlice(appOpts.Get(keysKey)) + exposedKeys := exposeStoreKeysSorted(exposeKeysStr, keys) + bApp.cms.AddListeners(exposedKeys) + bApp.streamingManager = storetypes.StreamingManager{ + AbciListeners: []storetypes.ABCIListener{abciListener}, + StopNodeOnErr: stopNodeOnErr, + } } -// StreamingService interface for registering WriteListeners with the BaseApp and updating the service with the ABCI messages using the hooks -type StreamingService interface { - // Stream is the streaming service loop, awaits kv pairs and writes them to some destination stream or file - Stream(wg *sync.WaitGroup) error - // Listeners returns the streaming service's listeners for the BaseApp to register - Listeners() map[store.StoreKey][]store.WriteListener - // ABCIListener interface for hooking into the ABCI messages from inside the BaseApp - ABCIListener - // Closer interface - io.Closer +func exposeAll(list []string) bool { + for _, ele := range list { + if ele == "*" { + return true + } + } + return false +} + +func exposeStoreKeysSorted(keysStr []string, keys map[string]*storetypes.KVStoreKey) []storetypes.StoreKey { + var exposeStoreKeys []storetypes.StoreKey + if exposeAll(keysStr) { + exposeStoreKeys = make([]storetypes.StoreKey, 0, len(keys)) + for key := range keys { + exposeStoreKeys = append(exposeStoreKeys, keys[key]) + } + } else { + exposeStoreKeys = make([]storetypes.StoreKey, 0, len(keysStr)) + for _, keyStr := range keysStr { + if storeKey, ok := keys[keyStr]; ok { + exposeStoreKeys = append(exposeStoreKeys, storeKey) + } + } + } + // sort storeKeys for deterministic output + sort.SliceStable(exposeStoreKeys, func(i, j int) bool { + return exposeStoreKeys[i].Name() < exposeStoreKeys[j].Name() + }) + + return exposeStoreKeys } diff --git a/baseapp/streaming_test.go b/baseapp/streaming_test.go new file mode 100644 index 000000000000..fd80faae8eb2 --- /dev/null +++ b/baseapp/streaming_test.go @@ -0,0 +1,38 @@ +package baseapp + +import ( + "context" + + abci "github.com/tendermint/tendermint/abci/types" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" +) + +type mockABCIListener struct { + name string + ChangeSet []*storetypes.StoreKVPair +} + +func NewMockABCIListener(name string) mockABCIListener { + return mockABCIListener{ + name: name, + ChangeSet: make([]*storetypes.StoreKVPair, 0), + } +} + +func (m mockABCIListener) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + return nil +} + +func (m mockABCIListener) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + return nil +} + +func (m mockABCIListener) ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + return nil +} + +func (m *mockABCIListener) ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*storetypes.StoreKVPair) error { + m.ChangeSet = changeSet + return nil +} diff --git a/go.mod b/go.mod index 7ef388c5fe95..2b79a4ce0053 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/coinbase/rosetta-sdk-go v0.7.9 github.com/confio/ics23/go v0.9.0 github.com/cosmos/btcutil v1.0.5 - github.com/cosmos/cosmos-proto v1.0.0-alpha7 + github.com/cosmos/cosmos-proto v1.0.0-beta.1 github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 github.com/cosmos/go-bip39 v1.0.0 github.com/cosmos/iavl v0.19.4 @@ -30,6 +30,8 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/hashicorp/go-getter v1.6.1 + github.com/hashicorp/go-hclog v1.2.0 + github.com/hashicorp/go-plugin v1.4.8 github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 github.com/improbable-eng/grpc-web v0.15.0 @@ -53,18 +55,19 @@ require ( github.com/tendermint/tm-db v0.6.7 golang.org/x/crypto v0.2.0 golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e - google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a - google.golang.org/grpc v1.50.1 + google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 + google.golang.org/grpc v1.51.0 google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 - pgregory.net/rapid v0.4.7 + pgregory.net/rapid v0.5.3 sigs.k8s.io/yaml v1.3.0 ) require ( - cloud.google.com/go v0.102.1 // indirect - cloud.google.com/go/compute v1.7.0 // indirect - cloud.google.com/go/iam v0.4.0 // indirect - cloud.google.com/go/storage v1.22.1 // indirect + cloud.google.com/go v0.105.0 // indirect + cloud.google.com/go/compute v1.12.1 // indirect + cloud.google.com/go/compute/metadata v0.2.1 // indirect + cloud.google.com/go/iam v0.7.0 // indirect + cloud.google.com/go/storage v1.27.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect @@ -84,6 +87,7 @@ require ( github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect + github.com/fatih/color v1.13.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/go-kit/kit v0.12.0 // indirect @@ -96,9 +100,8 @@ require ( github.com/google/btree v1.0.1 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/orderedcode v0.0.1 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect - github.com/googleapis/gax-go/v2 v2.4.0 // indirect - github.com/googleapis/go-type-adapters v1.0.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/gax-go/v2 v2.6.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/gtank/merlin v0.1.1 // indirect @@ -108,6 +111,7 @@ require ( github.com/hashicorp/go-safetemp v1.0.0 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect github.com/inconshreveable/mousetrap v1.0.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect @@ -123,6 +127,7 @@ require ( github.com/mitchellh/go-testing-interface v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect + github.com/oklog/run v1.0.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect @@ -142,12 +147,12 @@ require ( go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/net v0.2.0 // indirect - golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 // indirect + golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 // indirect golang.org/x/sys v0.2.0 // indirect golang.org/x/term v0.2.0 // indirect golang.org/x/text v0.4.0 // indirect - golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect - google.golang.org/api v0.93.0 // indirect + golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect + google.golang.org/api v0.102.0 // indirect google.golang.org/appengine v1.6.7 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index 17c4d86dc549..636a5f1a9ef5 100644 --- a/go.sum +++ b/go.sum @@ -19,21 +19,8 @@ cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHOb cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1 h1:vpK6iQWv/2uUeFJth4/cBHsQAGjn1iIE6AAlxipRaA0= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= +cloud.google.com/go v0.105.0 h1:DNtEKRBAAzeS4KyIory52wWHuClNaXJ5x1F7xa4q+5Y= +cloud.google.com/go v0.105.0/go.mod h1:PrLgOJNe5nfE9UMxKxgXj4mD3voiP+YQ6gdt6KMFOKM= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= @@ -41,18 +28,15 @@ cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUM cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= cloud.google.com/go/bigtable v1.2.0/go.mod h1:JcVAOl45lrTmQfLj7T6TxyMzIN/3FGGcFm+2xVAli2o= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0 h1:v/k9Eueb8aAJ0vZuxKMrgm6kPhCLZU9HxFU+AFDs9Uk= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= +cloud.google.com/go/compute v1.12.1 h1:gKVJMEyqV5c/UnpzjjQbo3Rjvvqpr9B1DFSbJC4OXr0= +cloud.google.com/go/compute v1.12.1/go.mod h1:e8yNOBcBONZU1vJKCvCoDw/4JQsA0dpM4x/6PIIOocU= +cloud.google.com/go/compute/metadata v0.2.1 h1:efOwf5ymceDhK6PKMnnrTHP4pppY5L22mle96M1yP48= +cloud.google.com/go/compute/metadata v0.2.1/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/iam v0.4.0 h1:YBYU00SCDzZJdHqVc4I5d6lsklcYIjQZa1YmEz4jlSE= -cloud.google.com/go/iam v0.4.0/go.mod h1:cbaZxyScUhxl7ZAkNWiALgihfP75wS/fUsVNaa1r3vA= +cloud.google.com/go/iam v0.7.0 h1:k4MuwOsS7zGJJ+QfZ5vBK8SgHBAvYN/23BWsiihJ1vs= +cloud.google.com/go/iam v0.7.0/go.mod h1:H5Br8wRaDGNc8XP3keLc4unfUUZeyH3Sfl9XpQEYOeg= +cloud.google.com/go/longrunning v0.3.0 h1:NjljC+FYPV3uh5/OwWT6pVU+doBqMg2x/rZlE+CamDs= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -63,8 +47,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.22.1 h1:F6IlQJZrZM++apn9V5/VfS3gbTUYg98PS3EMQAzqtfg= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= +cloud.google.com/go/storage v1.27.0 h1:YOO045NZI9RKfCj1c5A/ZtuuENUc8OAW+gHdGnDgyMQ= +cloud.google.com/go/storage v1.27.0/go.mod h1:x9DOL8TK/ygDUMieqwfhdpQryTeEkhGKMi80i/iqR2s= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= @@ -203,12 +187,6 @@ github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3h github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= @@ -231,8 +209,8 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= -github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= -github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbShIocllGaXx/0= +github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE= github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1 h1:6YvzjQtc+cDwCe9XwYPPa8zFCxNG79N7vmCjpK+vGOg= github.com/cosmos/cosmos-sdk/db v1.0.0-beta.1/go.mod h1:JUMM2MxF9wuwzRWZJjb8BjXsn1BmPmdBd3a75pIct4I= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -306,16 +284,13 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= @@ -403,7 +378,6 @@ github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -422,7 +396,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -446,9 +419,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= @@ -460,7 +430,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= @@ -473,11 +442,6 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -485,19 +449,12 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0 h1:zO8WHNx/MYiAKJ3d5spxZXZE6KHmIQGQcAzwUzV7qQw= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= +github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs= +github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0 h1:dS9eYAjhrE2RjmzYw2XAPvcXfmcQLtFEQWn0CR82awk= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/go-type-adapters v1.0.0 h1:9XdMn+d/G57qq1s8dNc5IesGCXHf6V2HZ2JwRxfA2tA= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= +github.com/googleapis/gax-go/v2 v2.6.0 h1:SXk3ABtQYDT/OH8jAyvEOQ58mgawq5C4o/4/89qN2ZU= +github.com/googleapis/gax-go/v2 v2.6.0/go.mod h1:1mjbznJAPHFpesgE5ucqfYEscaz5kMdcIDwU/6+DDoY= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= @@ -540,11 +497,15 @@ github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9n github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= +github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= +github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-plugin v1.4.8 h1:CHGwpxYDOttQOY7HOWgETU9dyVjOXzniXDqJcYJE1zM= +github.com/hashicorp/go-plugin v1.4.8/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= @@ -569,6 +530,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS4/qyk21ZsHyb6Mxv/jykxvNTkU4M= +github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= @@ -683,6 +646,7 @@ github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GW github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -693,6 +657,7 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= @@ -756,6 +721,7 @@ github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= +github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= @@ -1007,7 +973,6 @@ go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1071,7 +1036,6 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= @@ -1131,9 +1095,7 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= @@ -1141,11 +1103,6 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1157,19 +1114,10 @@ golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2 h1:+jnHzr9VPj32ykQVai5DNahi9+NSp7yYuCsl5eAQtL0= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783 h1:nt+Q6cXKz4MosCSpnbMtqiQ8Oz0pxTef2B4Vca2lvfk= +golang.org/x/oauth2 v0.0.0-20221014153046-6fdb5e3db783/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1181,7 +1129,6 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1209,6 +1156,7 @@ golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1244,46 +1192,25 @@ golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1370,19 +1297,14 @@ golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.2.0 h1:G6AHpWxTMGY1KyEYoAQ5WTtIekUUvDNjan3ugu60JvE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f h1:uF6paiQQebLeSXkrTqHqz0MXhXXS1KgF41eUdBNvxK0= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= @@ -1409,28 +1331,8 @@ google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz513 google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.93.0 h1:T2xt9gi0gHdxdnRkVQhT8mIvPaXKNsDNWz+L696M66M= -google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= +google.golang.org/api v0.102.0 h1:JxJl2qQ85fRMPNvlZY/enexbxpCjLwGhZUtgfGeQ51I= +google.golang.org/api v0.102.0/go.mod h1:3VFl6/fzoA+qNuS1N1/VfXY4LjoXN/wzeIp7TweWwGo= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1483,54 +1385,9 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a h1:GH6UPn3ixhWcKDhpnEC55S75cerLPdpp3hrhfKYjZgw= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= +google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6 h1:a2S6M0+660BgMNl++4JPlcAO/CjkqYItDEZwkoDQK7c= +google.golang.org/genproto v0.0.0-20221118155620-16455021b5e6/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1555,23 +1412,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= -google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/grpc v1.51.0 h1:E1eGv1FTqoLIdnBCZufiSHgKjlqG6fKFf6pPWtMTh8U= +google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1585,8 +1427,6 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 h1:KR8+MyP7/qOlV+8Af01LtjL04bu7on42eVsxT4EyBQk= google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= @@ -1635,8 +1475,8 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g= -pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= +pgregory.net/rapid v0.5.3 h1:163N50IHFqr1phZens4FQOdPgfJscR7a562mjQqeo4M= +pgregory.net/rapid v0.5.3/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/proto/cosmos/streaming/abci/v1/grpc.proto b/proto/cosmos/streaming/abci/v1/grpc.proto new file mode 100644 index 000000000000..06b3f3021684 --- /dev/null +++ b/proto/cosmos/streaming/abci/v1/grpc.proto @@ -0,0 +1,60 @@ +syntax = "proto3"; + +package cosmos.streaming.abci.v1; + +import "tendermint/abci/types.proto"; +import "cosmos/base/store/v1beta1/listening.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/streaming/plugins/abci/v1"; + +// ListenBeginBlockRequest is the request type for the ListenBeginBlock RPC method +message ListenBeginBlockRequest { + tendermint.abci.RequestBeginBlock req = 1; + tendermint.abci.ResponseBeginBlock res = 2; +} + +// ListenBeginBlockResponse is the response type for the ListenBeginBlock RPC method +message ListenBeginBlockResponse {} + +// ListenEndBlockRequest is the request type for the ListenEndBlock RPC method +message ListenEndBlockRequest { + tendermint.abci.RequestEndBlock req = 1; + tendermint.abci.ResponseEndBlock res = 2; +} + +// ListenBeginBlockResponse is the response type for the ListenEndBlock RPC method +message ListenEndBlockResponse {} + +// ListenDeliverTxRequest is the request type for the ListenDeliverTx RPC method +message ListenDeliverTxRequest { + // explicitly pass in block height as neither RequestDeliverTx or ResponseDeliverTx contain it + int64 block_height = 1; + tendermint.abci.RequestDeliverTx req = 2; + tendermint.abci.ResponseDeliverTx res = 3; +} + +// ListenBeginBlockResponse is the response type for the ListenDeliverTx RPC method +message ListenDeliverTxResponse {} + +// ListenCommitRequest is the request type for the ListenCommit RPC method +message ListenCommitRequest { + // explicitly pass in block height as ResponseCommit does not contain this info + int64 block_height = 1; + tendermint.abci.ResponseCommit res = 2; + repeated cosmos.base.store.v1beta1.StoreKVPair change_set = 3; +} + +// ListenBeginBlockResponse is the response type for the ListenCommit RPC method +message ListenCommitResponse {} + +// ABCIListenerService is the service for the BaseApp ABCIListener interface +service ABCIListenerService { + // ListenBeginBlock is the corresponding endpoint for ABCIListener.ListenBeginBlock + rpc ListenBeginBlock(ListenBeginBlockRequest) returns (ListenBeginBlockResponse); + // ListenEndBlock is the corresponding endpoint for ABCIListener.ListenEndBlock + rpc ListenEndBlock(ListenEndBlockRequest) returns (ListenEndBlockResponse); + // ListenDeliverTx is the corresponding endpoint for ABCIListener.ListenDeliverTx + rpc ListenDeliverTx(ListenDeliverTxRequest) returns (ListenDeliverTxResponse); + // ListenCommit is the corresponding endpoint for ABCIListener.ListenCommit + rpc ListenCommit(ListenCommitRequest) returns (ListenCommitResponse); +} diff --git a/server/config/config.go b/server/config/config.go index 84b16f7dea06..d08b38ded660 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -199,34 +199,17 @@ type StateSyncConfig struct { SnapshotKeepRecent uint32 `mapstructure:"snapshot-keep-recent"` } +// State Streaming configuration type ( - // StoreConfig defines application configuration for state streaming and other - // storage related operations. - StoreConfig struct { - Streamers []string `mapstructure:"streamers"` + // StreamingConfig defines application configuration for external streaming services + StreamingConfig struct { + ABCI ABCIListenerConfig `mapstructure:"abci"` } - - // StreamersConfig defines concrete state streaming configuration options. These - // fields are required to be set when state streaming is enabled via a non-empty - // list defined by 'StoreConfig.Streamers'. - StreamersConfig struct { - File FileStreamerConfig `mapstructure:"file"` - } - - // FileStreamerConfig defines the file streaming configuration options. - FileStreamerConfig struct { - Keys []string `mapstructure:"keys"` - WriteDir string `mapstructure:"write_dir"` - Prefix string `mapstructure:"prefix"` - // OutputMetadata specifies if output the block metadata file which includes - // the abci requests/responses, otherwise only the data file is outputted. - OutputMetadata bool `mapstructure:"output-metadata"` - // StopNodeOnError specifies if propagate the streamer errors to the consensus - // state machine, it's nesserary for data integrity of output. - StopNodeOnError bool `mapstructure:"stop-node-on-error"` - // Fsync specifies if calling fsync after writing the files, it slows down - // the commit, but don't lose data in face of system crash. - Fsync bool `mapstructure:"fsync"` + // ABCIListenerConfig defines application configuration for ABCIListener streaming service + ABCIListenerConfig struct { + Keys []string `mapstructure:"keys"` + Plugin string `mapstructure:"plugin"` + StopNodeOnErr bool `mapstructure:"stop-node-on-err"` } ) @@ -241,8 +224,7 @@ type Config struct { Rosetta RosettaConfig `mapstructure:"rosetta"` GRPCWeb GRPCWebConfig `mapstructure:"grpc-web"` StateSync StateSyncConfig `mapstructure:"state-sync"` - Store StoreConfig `mapstructure:"store"` - Streamers StreamersConfig `mapstructure:"streamers"` + Streaming StreamingConfig `mapstructure:"streaming"` } // SetMinGasPrices sets the validator's minimum gas prices. @@ -324,18 +306,10 @@ func DefaultConfig() *Config { SnapshotInterval: 0, SnapshotKeepRecent: 2, }, - Store: StoreConfig{ - Streamers: []string{}, - }, - Streamers: StreamersConfig{ - File: FileStreamerConfig{ - Keys: []string{"*"}, - WriteDir: "", - OutputMetadata: true, - StopNodeOnError: true, - // NOTICE: The default config doesn't protect the streamer data integrity - // in face of system crash. - Fsync: false, + Streaming: StreamingConfig{ + ABCI: ABCIListenerConfig{ + Keys: []string{}, + StopNodeOnErr: true, }, }, } diff --git a/server/config/config_test.go b/server/config/config_test.go index c18244d36220..c15186e73a2d 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -2,10 +2,12 @@ package config import ( "bytes" + "os" "path/filepath" "testing" "github.com/spf13/viper" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,24 +36,65 @@ func TestIndexEventsMarshalling(t *testing.T) { require.Contains(t, actual, expectedIn, "config file contents") } -func TestParseStoreStreaming(t *testing.T) { - expectedContents := `[store] -streamers = ["file", ] +func TestStreamingConfig(t *testing.T) { + cfg := Config{ + Streaming: StreamingConfig{ + ABCI: ABCIListenerConfig{ + Keys: []string{"one", "two"}, + Plugin: "plugin-A", + StopNodeOnErr: false, + }, + }, + } + + testDir := t.TempDir() + cfgFile := filepath.Join(testDir, "app.toml") + WriteConfigFile(cfgFile, &cfg) + + cfgFileBz, err := os.ReadFile(cfgFile) + require.NoError(t, err, "reading %s", cfgFile) + cfgFileContents := string(cfgFileBz) + t.Logf("Config file contents: %s:\n%s", cfgFile, cfgFileContents) + + expectedLines := []string{ + `keys = ["one", "two", ]`, + `plugin = "plugin-A"`, + `stop-node-on-err = false`, + } + + for _, line := range expectedLines { + assert.Contains(t, cfgFileContents, line+"\n", "config file contents") + } + + vpr := viper.New() + vpr.SetConfigFile(cfgFile) + err = vpr.ReadInConfig() + require.NoError(t, err, "reading config file into viper") + + var actual Config + err = vpr.Unmarshal(&actual) + require.NoError(t, err, "vpr.Unmarshal") + + assert.Equal(t, cfg.Streaming, actual.Streaming, "Streaming") +} -[streamers] -[streamers.file] -keys = ["*", ] -write_dir = "/foo/bar" -prefix = ""` +func TestParseStreaming(t *testing.T) { + expectedKeys := `keys = ["*", ]` + "\n" + expectedPlugin := `plugin = "abci_v1"` + "\n" + expectedStopNodeOnErr := `stop-node-on-err = true` + "\n" cfg := DefaultConfig() - cfg.Store.Streamers = []string{FileStreamer} - cfg.Streamers.File.Keys = []string{"*"} - cfg.Streamers.File.WriteDir = "/foo/bar" + cfg.Streaming.ABCI.Keys = []string{"*"} + cfg.Streaming.ABCI.Plugin = "abci_v1" + cfg.Streaming.ABCI.StopNodeOnErr = true var buffer bytes.Buffer - require.NoError(t, configTemplate.Execute(&buffer, cfg), "executing template") - require.Contains(t, buffer.String(), expectedContents, "config file contents") + err := configTemplate.Execute(&buffer, cfg) + require.NoError(t, err, "executing template") + actual := buffer.String() + require.Contains(t, actual, expectedKeys, "config file contents") + require.Contains(t, actual, expectedPlugin, "config file contents") + require.Contains(t, actual, expectedStopNodeOnErr, "config file contents") } func TestReadConfig(t *testing.T) { diff --git a/server/config/toml.go b/server/config/toml.go index 57fdafa3262a..67cfaf78cf0c 100644 --- a/server/config/toml.go +++ b/server/config/toml.go @@ -237,27 +237,30 @@ snapshot-interval = {{ .StateSync.SnapshotInterval }} snapshot-keep-recent = {{ .StateSync.SnapshotKeepRecent }} ############################################################################### -### Store / State Streaming ### +### State Streaming ### ############################################################################### -[store] -streamers = [{{ range .Store.Streamers }}{{ printf "%q, " . }}{{end}}] +# Streaming allows nodes to stream state to external systems. +[streaming] -[streamers] -[streamers.file] -keys = [{{ range .Streamers.File.Keys }}{{ printf "%q, " . }}{{end}}] -write_dir = "{{ .Streamers.File.WriteDir }}" -prefix = "{{ .Streamers.File.Prefix }}" +# streaming.abci specifies the configuration for the ABCI Listener streaming service. +[streaming.abci] -# output-metadata specifies if output the metadata file which includes the abci request/responses -# during processing the block. -output-metadata = "{{ .Streamers.File.OutputMetadata }}" +# List of kv store keys to stream out via gRPC. +# The store key names MUST match the module's StoreKey name. +# +# Example: +# ["acc", "bank", "gov", "staking", "mint"[,...]] +# ["*"] to expose all keys. +keys = [{{ range .Streaming.ABCI.Keys }}{{ printf "%q, " . }}{{end}}] -# stop-node-on-error specifies if propagate the file streamer errors to consensus state machine. -stop-node-on-error = "{{ .Streamers.File.StopNodeOnError }}" +# The plugin name used for streaming via gRPC. +# Streaming is only enabled if this is set. +# Supported plugins: abci_v1 +plugin = "{{ .Streaming.ABCI.Plugin }}" -# fsync specifies if call fsync after writing the files. -fsync = "{{ .Streamers.File.Fsync }}" +# stop-node-on-err specifies whether to stop the node on message delivery error. +stop-node-on-err = {{ .Streaming.ABCI.StopNodeOnErr }} ` var configTemplate *template.Template diff --git a/server/mock/store.go b/server/mock/store.go index d427806f72e9..2c0c2a0c26f3 100644 --- a/server/mock/store.go +++ b/server/mock/store.go @@ -34,7 +34,7 @@ func (ms multiStore) CacheWrapWithTrace(_ io.Writer, _ sdk.TraceContext) storety panic("not implemented") } -func (ms multiStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.WriteListener) storetypes.CacheWrap { +func (ms multiStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.MemoryListener) storetypes.CacheWrap { panic("not implemented") } @@ -50,7 +50,7 @@ func (ms multiStore) SetTracer(w io.Writer) sdk.MultiStore { panic("not implemented") } -func (ms multiStore) AddListeners(key storetypes.StoreKey, listeners []storetypes.WriteListener) { +func (ms multiStore) AddListeners(keys []storetypes.StoreKey) { panic("not implemented") } @@ -58,6 +58,10 @@ func (ms multiStore) ListeningEnabled(key storetypes.StoreKey) bool { panic("not implemented") } +func (ms multiStore) PopStateCache() []*storetypes.StoreKVPair { + panic("not implemented") +} + func (ms multiStore) Commit() storetypes.CommitID { panic("not implemented") } @@ -170,7 +174,7 @@ func (kv kvStore) CacheWrapWithTrace(w io.Writer, tc sdk.TraceContext) storetype panic("not implemented") } -func (kv kvStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.WriteListener) storetypes.CacheWrap { +func (kv kvStore) CacheWrapWithListeners(_ storetypes.StoreKey, _ []storetypes.MemoryListener) storetypes.CacheWrap { panic("not implemented") } diff --git a/simapp/app.go b/simapp/app.go index b2c2b5877645..4dd96a4003c9 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "path/filepath" + "strings" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" @@ -18,6 +19,7 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" "github.com/cosmos/cosmos-sdk/codec" @@ -26,8 +28,8 @@ import ( "github.com/cosmos/cosmos-sdk/server/config" servertypes "github.com/cosmos/cosmos-sdk/server/types" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" - "github.com/cosmos/cosmos-sdk/store/streaming" storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/streaming" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" @@ -239,11 +241,8 @@ func NewSimApp( // not include this key. memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, "testingkey") - // load state streaming if enabled - if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, keys); err != nil { - fmt.Printf("failed to load state streaming: %s", err) - os.Exit(1) - } + // register streaming services + RegisterStreamingServices(bApp, appOpts, keys) app := &SimApp{ BaseApp: bApp, @@ -688,3 +687,24 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino return paramsKeeper } + +func RegisterStreamingServices(bApp *baseapp.BaseApp, appOpts servertypes.AppOptions, keys map[string]*storetypes.KVStoreKey) { + // register streaming services + streamingCfg := cast.ToStringMap(appOpts.Get(baseapp.StreamingTomlKey)) + for service := range streamingCfg { + pluginKey := fmt.Sprintf("%s.%s.%s", baseapp.StreamingTomlKey, service, baseapp.StreamingABCIPluginTomlKey) + pluginName := strings.TrimSpace(cast.ToString(appOpts.Get(pluginKey))) + if len(pluginName) > 0 { + logLevel := cast.ToString(appOpts.Get(flags.FlagLogLevel)) + plugin, err := streaming.NewStreamingPlugin(pluginName, logLevel) + if err != nil { + fmt.Printf("failed to load streaming plugin: %s", err) + os.Exit(1) + } + if err := baseapp.RegisterStreamingPlugin(bApp, appOpts, keys, plugin); err != nil { + fmt.Printf("failed to register streaming plugin: %s", err) + os.Exit(1) + } + } + } +} diff --git a/simapp/sim_test.go b/simapp/sim_test.go index bde9aa5859e4..61dbf13ff16e 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -2,6 +2,7 @@ package simapp import ( "encoding/json" + "flag" "fmt" "math/rand" "os" @@ -9,6 +10,8 @@ import ( "strings" "testing" + "github.com/spf13/viper" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" @@ -35,9 +38,14 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) +var ( + FlagEnableStreamingValue bool +) + // Get flags every time the simulator is run func init() { GetSimulatorFlags() + flag.BoolVar(&FlagEnableStreamingValue, "EnableStreaming", false, "Enable streaming service") } type StoreKeysPrefixes struct { @@ -290,6 +298,17 @@ func TestAppStateDeterminism(t *testing.T) { t.Skip("skipping application simulation") } + vpr := viper.New() + if FlagEnableStreamingValue { + m := make(map[string]interface{}) + m["streaming.abci.keys"] = []string{"*"} + m["streaming.abci.plugin"] = "abci_v1" + m["streaming.abci.stop-node-on-err"] = true + for key, value := range m { + vpr.SetDefault(key, value) + } + } + config := NewConfigFromFlags() config.InitialBlockHeight = 1 config.ExportParamsPath = "" @@ -313,7 +332,7 @@ func TestAppStateDeterminism(t *testing.T) { } db := dbm.NewMemDB() - app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt()) + app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, FlagPeriodValue, MakeTestEncodingConfig(), vpr, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/store/listenkv/store.go b/store/listenkv/store.go index 4595d0fe56d1..3497cf654961 100644 --- a/store/listenkv/store.go +++ b/store/listenkv/store.go @@ -13,14 +13,14 @@ var _ types.KVStore = &Store{} // underlying listeners with the proper key and operation permissions type Store struct { parent types.KVStore - listeners []types.WriteListener + listener *types.MemoryListener parentStoreKey types.StoreKey } // NewStore returns a reference to a new traceKVStore given a parent // KVStore implementation and a buffered writer. -func NewStore(parent types.KVStore, parentStoreKey types.StoreKey, listeners []types.WriteListener) *Store { - return &Store{parent: parent, listeners: listeners, parentStoreKey: parentStoreKey} +func NewStore(parent types.KVStore, parentStoreKey types.StoreKey, listener *types.MemoryListener) *Store { + return &Store{parent: parent, listener: listener, parentStoreKey: parentStoreKey} } // Get implements the KVStore interface. It traces a read operation and @@ -35,14 +35,14 @@ func (s *Store) Get(key []byte) []byte { func (s *Store) Set(key []byte, value []byte) { types.AssertValidKey(key) s.parent.Set(key, value) - s.onWrite(false, key, value) + s.listener.OnWrite(s.parentStoreKey, key, value, false) } // Delete implements the KVStore interface. It traces a write operation and // delegates the Delete call to the parent KVStore. func (s *Store) Delete(key []byte) { s.parent.Delete(key) - s.onWrite(true, key, nil) + s.listener.OnWrite(s.parentStoreKey, key, nil, true) } // Has implements the KVStore interface. It delegates the Has call to the @@ -74,16 +74,16 @@ func (s *Store) iterator(start, end []byte, ascending bool) types.Iterator { parent = s.parent.ReverseIterator(start, end) } - return newTraceIterator(parent, s.listeners) + return newTraceIterator(parent, s.listener) } type listenIterator struct { - parent types.Iterator - listeners []types.WriteListener + parent types.Iterator + listener *types.MemoryListener } -func newTraceIterator(parent types.Iterator, listeners []types.WriteListener) types.Iterator { - return &listenIterator{parent: parent, listeners: listeners} +func newTraceIterator(parent types.Iterator, listener *types.MemoryListener) types.Iterator { + return &listenIterator{parent: parent, listener: listener} } // Domain implements the Iterator interface. @@ -140,10 +140,3 @@ func (s *Store) CacheWrap() types.CacheWrap { func (s *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.CacheWrap { panic("cannot CacheWrapWithTrace a ListenKVStore") } - -// onWrite writes a KVStore operation to all of the WriteListeners -func (s *Store) onWrite(delete bool, key, value []byte) { - for _, l := range s.listeners { - l.OnWrite(s.parentStoreKey, key, value, delete) - } -} diff --git a/store/listenkv/store_test.go b/store/listenkv/store_test.go index 44be4120427b..081f29871fc1 100644 --- a/store/listenkv/store_test.go +++ b/store/listenkv/store_test.go @@ -1,13 +1,9 @@ package listenkv_test import ( - "bytes" "fmt" - "io" "testing" - "github.com/cosmos/cosmos-sdk/codec" - codecTypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/store/dbadapter" "github.com/cosmos/cosmos-sdk/store/listenkv" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -29,14 +25,10 @@ var kvPairs = []types.KVPair{ {Key: keyFmt(3), Value: valFmt(3)}, } -var ( - testStoreKey = types.NewKVStoreKey("listen_test") - interfaceRegistry = codecTypes.NewInterfaceRegistry() - testMarshaller = codec.NewProtoCodec(interfaceRegistry) -) +var testStoreKey = types.NewKVStoreKey("listen_test") -func newListenKVStore(w io.Writer) *listenkv.Store { - store := newEmptyListenKVStore(w) +func newListenKVStore(listener *types.MemoryListener) *listenkv.Store { + store := newEmptyListenKVStore(listener) for _, kvPair := range kvPairs { store.Set(kvPair.Key, kvPair.Value) @@ -45,11 +37,10 @@ func newListenKVStore(w io.Writer) *listenkv.Store { return store } -func newEmptyListenKVStore(w io.Writer) *listenkv.Store { - listener := types.NewStoreKVPairWriteListener(w, testMarshaller) +func newEmptyListenKVStore(listener *types.MemoryListener) *listenkv.Store { memDB := dbadapter.Store{DB: dbm.NewMemDB()} - return listenkv.NewStore(memDB, testStoreKey, []types.WriteListener{listener}) + return listenkv.NewStore(memDB, testStoreKey, listener) } func TestListenKVStoreGet(t *testing.T) { @@ -68,10 +59,9 @@ func TestListenKVStoreGet(t *testing.T) { } for _, tc := range testCases { - var buf bytes.Buffer + listener := types.NewMemoryListener() - store := newListenKVStore(&buf) - buf.Reset() + store := newListenKVStore(listener) value := store.Get(tc.key) require.Equal(t, tc.expectedValue, value) @@ -117,19 +107,17 @@ func TestListenKVStoreSet(t *testing.T) { } for _, tc := range testCases { - var buf bytes.Buffer + listener := types.NewMemoryListener() - store := newEmptyListenKVStore(&buf) - buf.Reset() + store := newEmptyListenKVStore(listener) store.Set(tc.key, tc.value) - storeKVPair := new(types.StoreKVPair) - testMarshaller.UnmarshalLengthPrefixed(buf.Bytes(), storeKVPair) + storeKVPair := listener.PopStateCache()[0] require.Equal(t, tc.expectedOut, storeKVPair) } - var buf bytes.Buffer - store := newEmptyListenKVStore(&buf) + listener := types.NewMemoryListener() + store := newEmptyListenKVStore(listener) require.Panics(t, func() { store.Set([]byte(""), []byte("value")) }, "setting an empty key should panic") require.Panics(t, func() { store.Set(nil, []byte("value")) }, "setting a nil key should panic") } @@ -151,13 +139,13 @@ func TestListenKVStoreDelete(t *testing.T) { } for _, tc := range testCases { - var buf bytes.Buffer + listener := types.NewMemoryListener() - store := newListenKVStore(&buf) - buf.Reset() + store := newListenKVStore(listener) store.Delete(tc.key) - storeKVPair := new(types.StoreKVPair) - testMarshaller.UnmarshalLengthPrefixed(buf.Bytes(), storeKVPair) + cache := listener.PopStateCache() + require.NotEmpty(t, cache) + storeKVPair := cache[len(cache)-1] require.Equal(t, tc.expectedOut, storeKVPair) } @@ -175,10 +163,9 @@ func TestListenKVStoreHas(t *testing.T) { } for _, tc := range testCases { - var buf bytes.Buffer + listener := types.NewMemoryListener() - store := newListenKVStore(&buf) - buf.Reset() + store := newListenKVStore(listener) ok := store.Has(tc.key) require.Equal(t, tc.expected, ok) @@ -186,9 +173,9 @@ func TestListenKVStoreHas(t *testing.T) { } func TestTestListenKVStoreIterator(t *testing.T) { - var buf bytes.Buffer + listener := types.NewMemoryListener() - store := newListenKVStore(&buf) + store := newListenKVStore(listener) iterator := store.Iterator(nil, nil) s, e := iterator.Domain() @@ -229,9 +216,9 @@ func TestTestListenKVStoreIterator(t *testing.T) { } func TestTestListenKVStoreReverseIterator(t *testing.T) { - var buf bytes.Buffer + listener := types.NewMemoryListener() - store := newListenKVStore(&buf) + store := newListenKVStore(listener) iterator := store.ReverseIterator(nil, nil) s, e := iterator.Domain() diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index ed1a4c17cd48..1c3b097dd018 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -60,7 +60,9 @@ type Store struct { interBlockCache types.MultiStorePersistentCache - listeners map[types.StoreKey][]types.WriteListener + listeners map[types.StoreKey]*types.MemoryListener + + listenersMx sync.Mutex } var ( @@ -81,7 +83,7 @@ func NewStore(db dbm.DB, logger log.Logger) *Store { storesParams: make(map[types.StoreKey]storeParams), stores: make(map[types.StoreKey]types.CommitKVStore), keysByName: make(map[string]types.StoreKey), - listeners: make(map[types.StoreKey][]types.WriteListener), + listeners: make(map[types.StoreKey]*types.MemoryListener), removalMap: make(map[types.StoreKey]bool), pruningManager: pruning.NewManager(db, logger), } @@ -378,23 +380,46 @@ func (rs *Store) TracingEnabled() bool { return rs.traceWriter != nil } -// AddListeners adds listeners for a specific KVStore -func (rs *Store) AddListeners(key types.StoreKey, listeners []types.WriteListener) { - if ls, ok := rs.listeners[key]; ok { - rs.listeners[key] = append(ls, listeners...) - } else { - rs.listeners[key] = listeners +// AddListeners adds a listener for the KVStore belonging to the provided StoreKey +func (rs *Store) AddListeners(keys []types.StoreKey) { + rs.listenersMx.Lock() + defer rs.listenersMx.Unlock() + for i := range keys { + listener := rs.listeners[keys[i]] + if listener == nil { + rs.listeners[keys[i]] = types.NewMemoryListener() + } } } // ListeningEnabled returns if listening is enabled for a specific KVStore func (rs *Store) ListeningEnabled(key types.StoreKey) bool { if ls, ok := rs.listeners[key]; ok { - return len(ls) != 0 + return ls != nil } return false } +// PopStateCache returns the accumulated state change messages from the CommitMultiStore +// Calling PopStateCache destroys only the currently accumulated state in each listener +// not the state in the store itself. This is a mutating and destructive operation. +// This method has been synchronized. +func (rs *Store) PopStateCache() []*types.StoreKVPair { + rs.listenersMx.Lock() + defer rs.listenersMx.Unlock() + var cache []*types.StoreKVPair + for key := range rs.listeners { + ls := rs.listeners[key] + if ls != nil { + cache = append(cache, ls.PopStateCache()...) + } + } + sort.SliceStable(cache, func(i, j int) bool { + return cache[i].StoreKey < cache[j].StoreKey + }) + return cache +} + // LatestVersion returns the latest version in the store func (rs *Store) LatestVersion() int64 { return rs.LastCommitID().Version @@ -465,6 +490,8 @@ func (rs *Store) CacheWrapWithTrace(_ io.Writer, _ types.TraceContext) types.Cac // CacheMultiStore creates ephemeral branch of the multi-store and returns a CacheMultiStore. // It implements the MultiStore interface. func (rs *Store) CacheMultiStore() types.CacheMultiStore { + rs.listenersMx.Lock() + defer rs.listenersMx.Unlock() stores := make(map[types.StoreKey]types.CacheWrapper) for k, v := range rs.stores { store := types.KVStore(v) @@ -483,6 +510,8 @@ func (rs *Store) CacheMultiStore() types.CacheMultiStore { // any store cannot be loaded. This should only be used for querying and // iterating at past heights. func (rs *Store) CacheMultiStoreWithVersion(version int64) (types.CacheMultiStore, error) { + rs.listenersMx.Lock() + defer rs.listenersMx.Unlock() cachedStores := make(map[types.StoreKey]types.CacheWrapper) for key, store := range rs.stores { var cacheStore types.KVStore @@ -537,6 +566,8 @@ func (rs *Store) GetStore(key types.StoreKey) types.Store { // NOTE: The returned KVStore may be wrapped in an inter-block cache if it is // set on the root store. func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore { + rs.listenersMx.Lock() + defer rs.listenersMx.Unlock() s := rs.stores[key] if s == nil { panic(fmt.Sprintf("store does not exist for key: %s", key.Name())) diff --git a/store/rootmulti/store_test.go b/store/rootmulti/store_test.go index 26204bceb21b..d1ce255d58ba 100644 --- a/store/rootmulti/store_test.go +++ b/store/rootmulti/store_test.go @@ -17,7 +17,6 @@ import ( "github.com/cosmos/cosmos-sdk/store/cachemulti" "github.com/cosmos/cosmos-sdk/store/iavl" sdkmaps "github.com/cosmos/cosmos-sdk/store/internal/maps" - "github.com/cosmos/cosmos-sdk/store/listenkv" "github.com/cosmos/cosmos-sdk/store/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -632,13 +631,8 @@ func TestAddListenersAndListeningEnabled(t *testing.T) { enabled := multi.ListeningEnabled(testKey) require.False(t, enabled) - multi.AddListeners(testKey, []types.WriteListener{}) - enabled = multi.ListeningEnabled(testKey) - require.False(t, enabled) - - mockListener := types.NewStoreKVPairWriteListener(nil, nil) - multi.AddListeners(testKey, []types.WriteListener{mockListener}) wrongTestKey := types.NewKVStoreKey("wrong_listening_test_key") + multi.AddListeners([]types.StoreKey{testKey}) enabled = multi.ListeningEnabled(wrongTestKey) require.False(t, enabled) @@ -655,83 +649,6 @@ var ( testValue2 = []byte{6, 5, 4, 3, 2} ) -func TestGetListenWrappedKVStore(t *testing.T) { - buf := new(bytes.Buffer) - var db dbm.DB = dbm.NewMemDB() - ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) - ms.LoadLatestVersion() - mockListeners := []types.WriteListener{types.NewStoreKVPairWriteListener(buf, testMarshaller)} - ms.AddListeners(testStoreKey1, mockListeners) - ms.AddListeners(testStoreKey2, mockListeners) - - listenWrappedStore1 := ms.GetKVStore(testStoreKey1) - require.IsType(t, &listenkv.Store{}, listenWrappedStore1) - - listenWrappedStore1.Set(testKey1, testValue1) - expectedOutputKVPairSet1, err := testMarshaller.MarshalLengthPrefixed(&types.StoreKVPair{ - Key: testKey1, - Value: testValue1, - StoreKey: testStoreKey1.Name(), - Delete: false, - }) - require.Nil(t, err) - kvPairSet1Bytes := buf.Bytes() - buf.Reset() - require.Equal(t, expectedOutputKVPairSet1, kvPairSet1Bytes) - - listenWrappedStore1.Delete(testKey1) - expectedOutputKVPairDelete1, err := testMarshaller.MarshalLengthPrefixed(&types.StoreKVPair{ - Key: testKey1, - Value: nil, - StoreKey: testStoreKey1.Name(), - Delete: true, - }) - require.Nil(t, err) - kvPairDelete1Bytes := buf.Bytes() - buf.Reset() - require.Equal(t, expectedOutputKVPairDelete1, kvPairDelete1Bytes) - - listenWrappedStore2 := ms.GetKVStore(testStoreKey2) - require.IsType(t, &listenkv.Store{}, listenWrappedStore2) - - listenWrappedStore2.Set(testKey2, testValue2) - expectedOutputKVPairSet2, err := testMarshaller.MarshalLengthPrefixed(&types.StoreKVPair{ - Key: testKey2, - Value: testValue2, - StoreKey: testStoreKey2.Name(), - Delete: false, - }) - require.NoError(t, err) - kvPairSet2Bytes := buf.Bytes() - buf.Reset() - require.Equal(t, expectedOutputKVPairSet2, kvPairSet2Bytes) - - listenWrappedStore2.Delete(testKey2) - expectedOutputKVPairDelete2, err := testMarshaller.MarshalLengthPrefixed(&types.StoreKVPair{ - Key: testKey2, - Value: nil, - StoreKey: testStoreKey2.Name(), - Delete: true, - }) - require.NoError(t, err) - kvPairDelete2Bytes := buf.Bytes() - buf.Reset() - require.Equal(t, expectedOutputKVPairDelete2, kvPairDelete2Bytes) - - unwrappedStore := ms.GetKVStore(testStoreKey3) - require.IsType(t, &iavl.Store{}, unwrappedStore) - - unwrappedStore.Set(testKey2, testValue2) - kvPairSet3Bytes := buf.Bytes() - buf.Reset() - require.Equal(t, []byte{}, kvPairSet3Bytes) - - unwrappedStore.Delete(testKey2) - kvPairDelete3Bytes := buf.Bytes() - buf.Reset() - require.Equal(t, []byte{}, kvPairDelete3Bytes) -} - func TestCacheWraps(t *testing.T) { db := dbm.NewMemDB() multi := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) @@ -927,36 +844,30 @@ func (tl *MockListener) OnWrite(storeKey types.StoreKey, key []byte, value []byt func TestStateListeners(t *testing.T) { var db dbm.DB = dbm.NewMemDB() ms := newMultiStoreWithMounts(db, pruningtypes.NewPruningOptions(pruningtypes.PruningNothing)) + require.Empty(t, ms.listeners) - listener := &MockListener{} - ms.AddListeners(testStoreKey1, []types.WriteListener{listener}) + ms.AddListeners([]types.StoreKey{testStoreKey1}) + require.Equal(t, 1, len(ms.listeners)) require.NoError(t, ms.LoadLatestVersion()) cacheMulti := ms.CacheMultiStore() - store1 := cacheMulti.GetKVStore(testStoreKey1) - store1.Set([]byte{1}, []byte{1}) - require.Empty(t, listener.stateCache) + store := cacheMulti.GetKVStore(testStoreKey1) + store.Set([]byte{1}, []byte{1}) + require.Empty(t, ms.PopStateCache()) // writes are observed when cache store commit. cacheMulti.Write() - require.Equal(t, 1, len(listener.stateCache)) - - // test nested cache store - listener.stateCache = []types.StoreKVPair{} - nested := cacheMulti.CacheMultiStore() - - store1 = nested.GetKVStore(testStoreKey1) - store1.Set([]byte{1}, []byte{1}) - require.Empty(t, listener.stateCache) + require.Equal(t, 1, len(ms.PopStateCache())) - // writes are not observed when nested cache store commit - nested.Write() - require.Empty(t, listener.stateCache) + // test no listening on unobserved store + store = cacheMulti.GetKVStore(testStoreKey2) + store.Set([]byte{1}, []byte{1}) + require.Empty(t, ms.PopStateCache()) - // writes are observed when inner cache store commit + // writes are not observed when cache store commit cacheMulti.Write() - require.Equal(t, 1, len(listener.stateCache)) + require.Empty(t, ms.PopStateCache()) } type commitKVStoreStub struct { diff --git a/store/streaming/README.md b/store/streaming/README.md deleted file mode 100644 index 9eb962ac862c..000000000000 --- a/store/streaming/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# State Streaming Service - -This package contains the constructors for the `StreamingService`s used to write -state changes out from individual KVStores to a file or stream, as described in -[ADR-038](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-038-state-listening.md) -and defined in [types/streaming.go](https://github.com/cosmos/cosmos-sdk/blob/main/baseapp/streaming.go). -The child directories contain the implementations for specific output destinations. - -Currently, a `StreamingService` implementation that writes state changes out to -files is supported, in the future support for additional output destinations can -be added. - -The `StreamingService` is configured from within an App using the `AppOptions` -loaded from the `app.toml` file: - -```toml -# ... - -[store] -# streaming is enabled if one or more streamers are defined -streamers = [ - # name of the streaming service, used by constructor - "file" -] - -[streamers] -[streamers.file] - keys = ["list", "of", "store", "keys", "we", "want", "to", "expose", "for", "this", "streaming", "service"] - write_dir = "path to the write directory" - prefix = "optional prefix to prepend to the generated file names" -``` - -The `store.streamers` field contains a list of the names of the `StreamingService` -implementations to employ which are used by `ServiceTypeFromString` to return -the `ServiceConstructor` for that particular implementation: - -```go -listeners := cast.ToStringSlice(appOpts.Get("store.streamers")) -for _, listenerName := range listeners { - constructor, err := ServiceTypeFromString(listenerName) - if err != nil { - // handle error - } -} -``` - -The `streamers` field contains a mapping of the specific `StreamingService` -implementation name to the configuration parameters for that specific service. - -The `streamers.x.keys` field contains the list of `StoreKey` names for the -KVStores to expose using this service and is required by every type of -`StreamingService`. In order to expose *ALL* KVStores, we can include `*` in -this list. An empty list is equivalent to turning the service off. - -Additional configuration parameters are optional and specific to the implementation. -In the case of the file streaming service, the `streamers.file.write_dir` field -contains the path to the directory to write the files to, and `streamers.file.prefix` -contains an optional prefix to prepend to the output files to prevent potential -collisions with other App `StreamingService` output files. - -The `ServiceConstructor` accepts `AppOptions`, the store keys collected using -`streamers.x.keys`, a `BinaryMarshaller` and returns a `StreamingService -implementation. - -The `AppOptions` are passed in to provide access to any implementation specific -configuration options, e.g. in the case of the file streaming service the -`streamers.file.write_dir` and `streamers.file.prefix`. - -```go -streamingService, err := constructor(appOpts, exposeStoreKeys, appCodec) -if err != nil { - // handler error -} -``` - -The returned `StreamingService` is loaded into the BaseApp using the BaseApp's -`SetStreamingService` method. - -The `Stream` method is called on the service to begin the streaming process. -Depending on the implementation this process may be synchronous or asynchronous -with the message processing of the state machine. - -```go -bApp.SetStreamingService(streamingService) -wg := new(sync.WaitGroup) -quitChan := make(chan struct{}) -streamingService.Stream(wg, quitChan) -``` diff --git a/store/streaming/constructor.go b/store/streaming/constructor.go deleted file mode 100644 index 02b5f34f472c..000000000000 --- a/store/streaming/constructor.go +++ /dev/null @@ -1,195 +0,0 @@ -package streaming - -import ( - "fmt" - "os" - "path" - "strings" - "sync" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec" - serverTypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/store/streaming/file" - "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/spf13/cast" -) - -// ServiceConstructor is used to construct a streaming service -type ServiceConstructor func(serverTypes.AppOptions, []types.StoreKey, codec.BinaryCodec) (baseapp.StreamingService, error) - -// ServiceType enum for specifying the type of StreamingService -type ServiceType int - -const ( - Unknown ServiceType = iota - File -) - -// Streaming option keys -const ( - OptStreamersFilePrefix = "streamers.file.prefix" - OptStreamersFileWriteDir = "streamers.file.write_dir" - OptStreamersFileOutputMetadata = "streamers.file.output-metadata" - OptStreamersFileStopNodeOnError = "streamers.file.stop-node-on-error" - OptStreamersFileFsync = "streamers.file.fsync" - - OptStoreStreamers = "store.streamers" -) - -// ServiceTypeFromString returns the streaming.ServiceType corresponding to the -// provided name. -func ServiceTypeFromString(name string) ServiceType { - switch strings.ToLower(name) { - case "file", "f": - return File - - default: - return Unknown - } -} - -// String returns the string name of a streaming.ServiceType -func (sst ServiceType) String() string { - switch sst { - case File: - return "file" - - default: - return "unknown" - } -} - -// ServiceConstructorLookupTable is a mapping of streaming.ServiceTypes to -// streaming.ServiceConstructors types. -var ServiceConstructorLookupTable = map[ServiceType]ServiceConstructor{ - File: NewFileStreamingService, -} - -// NewServiceConstructor returns the streaming.ServiceConstructor corresponding -// to the provided name. -func NewServiceConstructor(name string) (ServiceConstructor, error) { - ssType := ServiceTypeFromString(name) - if ssType == Unknown { - return nil, fmt.Errorf("unrecognized streaming service name %s", name) - } - - if constructor, ok := ServiceConstructorLookupTable[ssType]; ok && constructor != nil { - return constructor, nil - } - - return nil, fmt.Errorf("streaming service constructor of type %s not found", ssType.String()) -} - -// NewFileStreamingService is the streaming.ServiceConstructor function for -// creating a FileStreamingService. -func NewFileStreamingService( - opts serverTypes.AppOptions, - keys []types.StoreKey, - marshaller codec.BinaryCodec, -) (baseapp.StreamingService, error) { - homePath := cast.ToString(opts.Get(flags.FlagHome)) - filePrefix := cast.ToString(opts.Get(OptStreamersFilePrefix)) - fileDir := cast.ToString(opts.Get(OptStreamersFileWriteDir)) - outputMetadata := cast.ToBool(opts.Get(OptStreamersFileOutputMetadata)) - stopNodeOnErr := cast.ToBool(opts.Get(OptStreamersFileStopNodeOnError)) - fsync := cast.ToBool(opts.Get(OptStreamersFileFsync)) - - // relative path is based on node home directory. - if !path.IsAbs(fileDir) { - fileDir = path.Join(homePath, fileDir) - } - - // try to create output directory if it does not exist - if _, err := os.Stat(fileDir); os.IsNotExist(err) { - if err = os.MkdirAll(fileDir, os.ModePerm); err != nil { - return nil, err - } - } - - return file.NewStreamingService(fileDir, filePrefix, keys, marshaller, outputMetadata, stopNodeOnErr, fsync) -} - -// LoadStreamingServices is a function for loading StreamingServices onto the -// BaseApp using the provided AppOptions, codec, and keys. It returns the -// WaitGroup and quit channel used to synchronize with the streaming services -// and any error that occurs during the setup. -func LoadStreamingServices( - bApp *baseapp.BaseApp, - appOpts serverTypes.AppOptions, - appCodec codec.BinaryCodec, - keys map[string]*types.KVStoreKey, -) ([]baseapp.StreamingService, *sync.WaitGroup, error) { - // waitgroup and quit channel for optional shutdown coordination of the streaming service(s) - wg := new(sync.WaitGroup) - - // configure state listening capabilities using AppOptions - streamers := cast.ToStringSlice(appOpts.Get(OptStoreStreamers)) - activeStreamers := make([]baseapp.StreamingService, 0, len(streamers)) - - for _, streamerName := range streamers { - var exposeStoreKeys []types.StoreKey - - // get the store keys allowed to be exposed for this streaming service - exposeKeyStrs := cast.ToStringSlice(appOpts.Get(fmt.Sprintf("streamers.%s.keys", streamerName))) - - // if list contains '*', expose all store keys - if sdk.SliceContains(exposeKeyStrs, "*") { - exposeStoreKeys = make([]types.StoreKey, 0, len(keys)) - for _, storeKey := range keys { - exposeStoreKeys = append(exposeStoreKeys, storeKey) - } - } else { - exposeStoreKeys = make([]types.StoreKey, 0, len(exposeKeyStrs)) - for _, keyStr := range exposeKeyStrs { - if storeKey, ok := keys[keyStr]; ok { - exposeStoreKeys = append(exposeStoreKeys, storeKey) - } - } - } - - if len(exposeStoreKeys) == 0 { - continue - } - - constructor, err := NewServiceConstructor(streamerName) - if err != nil { - // Close any services we may have already spun up before hitting the error - // on this one. - for _, activeStreamer := range activeStreamers { - activeStreamer.Close() - } - - return nil, nil, err - } - - // Generate the streaming service using the constructor, appOptions, and the - // StoreKeys we want to expose. - streamingService, err := constructor(appOpts, exposeStoreKeys, appCodec) - if err != nil { - // Close any services we may have already spun up before hitting the error - // on this one. - for _, activeStreamer := range activeStreamers { - activeStreamer.Close() - } - - return nil, nil, err - } - - // register the streaming service with the BaseApp - bApp.SetStreamingService(streamingService) - - // kick off the background streaming service loop - streamingService.Stream(wg) - - // add to the list of active streamers - activeStreamers = append(activeStreamers, streamingService) - } - - // If there are no active streamers, activeStreamers is empty (len == 0) and - // the waitGroup is not waiting on anything. - return activeStreamers, wg, nil -} diff --git a/store/streaming/constructor_test.go b/store/streaming/constructor_test.go deleted file mode 100644 index d85de2569ccd..000000000000 --- a/store/streaming/constructor_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package streaming_test - -import ( - "testing" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - codecTypes "github.com/cosmos/cosmos-sdk/codec/types" - serverTypes "github.com/cosmos/cosmos-sdk/server/types" - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/cosmos/cosmos-sdk/store/streaming" - "github.com/cosmos/cosmos-sdk/store/streaming/file" - "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/tendermint/tendermint/libs/log" - dbm "github.com/tendermint/tm-db" - - "github.com/stretchr/testify/require" -) - -type fakeOptions struct{} - -func (f *fakeOptions) Get(key string) interface{} { - if key == "streamers.file.write_dir" { - return "data/file_streamer" - - } - return nil -} - -var ( - mockOptions = new(fakeOptions) - mockKeys = []types.StoreKey{sdk.NewKVStoreKey("mockKey1"), sdk.NewKVStoreKey("mockKey2")} - interfaceRegistry = codecTypes.NewInterfaceRegistry() - testMarshaller = codec.NewProtoCodec(interfaceRegistry) -) - -func TestStreamingServiceConstructor(t *testing.T) { - _, err := streaming.NewServiceConstructor("unexpectedName") - require.NotNil(t, err) - - constructor, err := streaming.NewServiceConstructor("file") - require.Nil(t, err) - var expectedType streaming.ServiceConstructor - require.IsType(t, expectedType, constructor) - - serv, err := constructor(mockOptions, mockKeys, testMarshaller) - require.Nil(t, err) - require.IsType(t, &file.StreamingService{}, serv) - listeners := serv.Listeners() - for _, key := range mockKeys { - _, ok := listeners[key] - require.True(t, ok) - } -} - -func TestLoadStreamingServices(t *testing.T) { - db := dbm.NewMemDB() - encCdc := simapp.MakeTestEncodingConfig() - keys := sdk.NewKVStoreKeys("mockKey1", "mockKey2") - bApp := baseapp.NewBaseApp("appName", log.NewNopLogger(), db, nil) - - testCases := map[string]struct { - appOpts serverTypes.AppOptions - activeStreamersLen int - }{ - "empty app options": { - appOpts: simapp.EmptyAppOptions{}, - }, - "all StoreKeys exposed": { - appOpts: streamingAppOptions{keys: []string{"*"}}, - activeStreamersLen: 1, - }, - "some StoreKey exposed": { - appOpts: streamingAppOptions{keys: []string{"mockKey1"}}, - activeStreamersLen: 1, - }, - "not exposing anything": { - appOpts: streamingAppOptions{keys: []string{"mockKey3"}}, - }, - } - - for name, tc := range testCases { - t.Run(name, func(t *testing.T) { - activeStreamers, _, err := streaming.LoadStreamingServices(bApp, tc.appOpts, encCdc.Codec, keys) - require.NoError(t, err) - require.Equal(t, tc.activeStreamersLen, len(activeStreamers)) - }) - } -} - -type streamingAppOptions struct { - keys []string -} - -func (ao streamingAppOptions) Get(o string) interface{} { - switch o { - case "store.streamers": - return []string{"file"} - case "streamers.file.keys": - return ao.keys - case "streamers.file.write_dir": - return "data/file_streamer" - default: - return nil - } -} diff --git a/store/streaming/file/README.md b/store/streaming/file/README.md deleted file mode 100644 index 0c34de7f3bea..000000000000 --- a/store/streaming/file/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# File Streaming Service - -This pkg contains an implementation of the [StreamingService](../../../baseapp/streaming.go) that writes -the data stream out to files on the local filesystem. This process is performed synchronously with the message processing -of the state machine. - -## Configuration - -The `file.StreamingService` is configured from within an App using the `AppOptions` loaded from the app.toml file: - -```toml -[store] - streamers = [ # if len(streamers) > 0 we are streaming - "file", # name of the streaming service, used by constructor - ] - -[streamers] - [streamers.file] - keys = ["list", "of", "store", "keys", "we", "want", "to", "expose", "for", "this", "streaming", "service"] - write_dir = "path to the write directory" - prefix = "optional prefix to prepend to the generated file names" -``` - -We turn the service on by adding its name, "file", to `store.streamers`- the list of streaming services for this App to employ. - -In `streamers.file` we include three configuration parameters for the file streaming service: - -1. `streamers.file.keys` contains the list of `StoreKey` names for the KVStores to expose using this service. - In order to expose *all* KVStores, we can include `*` in this list. An empty list is equivalent to turning the service off. -2. `streamers.file.write_dir` contains the path to the directory to write the files to. -3. `streamers.file.prefix` contains an optional prefix to prepend to the output files to prevent potential collisions - with other App `StreamingService` output files. -4. `streamers.file.output-metadata` specifies if output the metadata file, otherwise only data file is outputted. -5. `streamers.file.stop-node-on-error` specifies if propagate the error to consensus state machine, it's nesserary for data integrity when node restarts. -6. `streamers.file.fsync` specifies if call fsync after writing the files, it's nesserary for data integrity when system crash, but slows down the commit time. - -### Encoding - -For each block, two files are created and names `block-{N}-meta` and `block-{N}-data`, where `N` is the block number. - -The meta file contains the protobuf encoded message `BlockMetadata` which contains the abci event requests and responses of the block: - -```protobuf -message BlockMetadata { - message DeliverTx { - tendermint.abci.RequestDeliverTx request = 1; - tendermint.abci.ResponseDeliverTx response = 2; - } - tendermint.abci.RequestBeginBlock request_begin_block = 1; - tendermint.abci.ResponseBeginBlock response_begin_block = 2; - repeated DeliverTx deliver_txs = 3; - tendermint.abci.RequestEndBlock request_end_block = 4; - tendermint.abci.ResponseEndBlock response_end_block = 5; - tendermint.abci.ResponseCommit response_commit = 6; -} -``` - -The data file contains a series of length-prefixed protobuf encoded `StoreKVPair`s representing `Set` and `Delete` operations within the KVStores during the execution of block. - -Both meta and data files are prefixed with the length of the data content for consumer to detect completeness of the file, the length is encoded as 8 bytes with big endianness. - -The files are written at abci commit event, by default the error happens will be propagated to interuppted consensus state machine, but fsync is not called, it'll have good performance but have the risk of lossing data in face of rare event of system crash. - -### Decoding - -The pseudo-code for decoding is like this: - -```python -def decode_meta_file(file): - bz = file.read(8) - if len(bz) < 8: - raise "incomplete file exception" - size = int.from_bytes(bz, 'big') - - if file.size != size + 8: - raise "incomplete file exception" - - return decode_protobuf_message(BlockMetadata, file) - -def decode_data_file(file): - bz = file.read(8) - if len(bz) < 8: - raise "incomplete file exception" - size = int.from_bytes(bz, 'big') - - if file.size != size + 8: - raise "incomplete file exception" - - while not file.eof(): - yield decode_length_prefixed_protobuf_message(StoreKVStore, file) -``` diff --git a/store/streaming/file/example_config.toml b/store/streaming/file/example_config.toml deleted file mode 100644 index 8202bd8ef559..000000000000 --- a/store/streaming/file/example_config.toml +++ /dev/null @@ -1,10 +0,0 @@ -[store] - streamers = [ # if len(streamers) > 0 we are streaming - "file", # name of the streaming service, used by constructor - ] - -[streamers] - [streamers.file] - keys = ["list", "of", "store", "keys", "we", "want", "to", "expose", "for", "this", "streaming", "service"] - write_dir = "path to the write directory" - prefix = "optional prefix to prepend to the generated file names" diff --git a/store/streaming/file/service.go b/store/streaming/file/service.go deleted file mode 100644 index 97badfc40336..000000000000 --- a/store/streaming/file/service.go +++ /dev/null @@ -1,243 +0,0 @@ -package file - -import ( - "bytes" - "context" - "fmt" - "io" - "os" - "path" - "sort" - "sync" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" -) - -var _ baseapp.StreamingService = &StreamingService{} - -// StreamingService is a concrete implementation of StreamingService that writes -// state changes out to files. -type StreamingService struct { - storeListeners []*types.MemoryListener // a series of KVStore listeners for each KVStore - filePrefix string // optional prefix for each of the generated files - writeDir string // directory to write files into - codec codec.BinaryCodec // marshaller used for re-marshalling the ABCI messages to write them out to the destination files - - currentBlockNumber int64 - blockMetadata types.BlockMetadata - - // outputMetadata, if true, writes additional metadata to file per block - outputMetadata bool - - // stopNodeOnErr, if true, will panic and stop the node during ABCI Commit - // to ensure eventual consistency of the output, otherwise, any errors are - // logged and ignored which could yield data loss in streamed output. - stopNodeOnErr bool - - // fsync, if true, will execute file Sync to make sure the data is persisted - // onto disk, otherwise there is a risk of data loss during any crash. - fsync bool -} - -func NewStreamingService( - writeDir, filePrefix string, - storeKeys []types.StoreKey, - cdc codec.BinaryCodec, - outputMetadata, stopNodeOnErr, fsync bool, -) (*StreamingService, error) { - // sort storeKeys for deterministic output - sort.SliceStable(storeKeys, func(i, j int) bool { - return storeKeys[i].Name() < storeKeys[j].Name() - }) - - // NOTE: We use the same listener for each store. - listeners := make([]*types.MemoryListener, len(storeKeys)) - for i, key := range storeKeys { - listeners[i] = types.NewMemoryListener(key) - } - - // Check that the writeDir exists and is writable so that we can catch the - // error here at initialization. If it is not we don't open a dstFile until we - // receive our first ABCI message. - if err := isDirWriteable(writeDir); err != nil { - return nil, err - } - - return &StreamingService{ - storeListeners: listeners, - filePrefix: filePrefix, - writeDir: writeDir, - codec: cdc, - outputMetadata: outputMetadata, - stopNodeOnErr: stopNodeOnErr, - fsync: fsync, - }, nil -} - -// Listeners satisfies the StreamingService interface. It returns the -// StreamingService's underlying WriteListeners. Use for registering the -// underlying WriteListeners with the BaseApp. -func (fss *StreamingService) Listeners() map[types.StoreKey][]types.WriteListener { - listeners := make(map[types.StoreKey][]types.WriteListener, len(fss.storeListeners)) - for _, listener := range fss.storeListeners { - listeners[listener.StoreKey()] = []types.WriteListener{listener} - } - - return listeners -} - -// ListenBeginBlock satisfies the ABCIListener interface. It sets the received -// BeginBlock request, response and the current block number. Note, these are -// not written to file until ListenCommit is executed and outputMetadata is set, -// after which it will be reset again on the next block. -func (fss *StreamingService) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { - fss.blockMetadata.RequestBeginBlock = &req - fss.blockMetadata.ResponseBeginBlock = &res - fss.currentBlockNumber = req.Header.Height - return nil -} - -// ListenDeliverTx satisfies the ABCIListener interface. It appends the received -// DeliverTx request and response to a list of DeliverTxs objects. Note, these -// are not written to file until ListenCommit is executed and outputMetadata is -// set, after which it will be reset again on the next block. -func (fss *StreamingService) ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { - fss.blockMetadata.DeliverTxs = append(fss.blockMetadata.DeliverTxs, &types.BlockMetadata_DeliverTx{ - Request: &req, - Response: &res, - }) - - return nil -} - -// ListenEndBlock satisfies the ABCIListener interface. It sets the received -// EndBlock request, response and the current block number. Note, these are -// not written to file until ListenCommit is executed and outputMetadata is set, -// after which it will be reset again on the next block. -func (fss *StreamingService) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { - fss.blockMetadata.RequestEndBlock = &req - fss.blockMetadata.ResponseEndBlock = &res - return nil -} - -// ListenCommit satisfies the ABCIListener interface. It is executed during the -// ABCI Commit request and is responsible for writing all staged data to files. -// It will only return a non-nil error when stopNodeOnErr is set. -func (fss *StreamingService) ListenCommit(ctx context.Context, res abci.ResponseCommit) error { - if err := fss.doListenCommit(ctx, res); err != nil { - if fss.stopNodeOnErr { - return err - } - } - - return nil -} - -func (fss *StreamingService) doListenCommit(ctx context.Context, res abci.ResponseCommit) (err error) { - fss.blockMetadata.ResponseCommit = &res - - // Write to target files, the file size is written at the beginning, which can - // be used to detect completeness. - metaFileName := fmt.Sprintf("block-%d-meta", fss.currentBlockNumber) - dataFileName := fmt.Sprintf("block-%d-data", fss.currentBlockNumber) - - if fss.filePrefix != "" { - metaFileName = fmt.Sprintf("%s-%s", fss.filePrefix, metaFileName) - dataFileName = fmt.Sprintf("%s-%s", fss.filePrefix, dataFileName) - } - - if fss.outputMetadata { - bz, err := fss.codec.Marshal(&fss.blockMetadata) - if err != nil { - return err - } - - if err := writeLengthPrefixedFile(path.Join(fss.writeDir, metaFileName), bz, fss.fsync); err != nil { - return err - } - } - - var buf bytes.Buffer - if err := fss.writeBlockData(&buf); err != nil { - return err - } - - return writeLengthPrefixedFile(path.Join(fss.writeDir, dataFileName), buf.Bytes(), fss.fsync) -} - -func (fss *StreamingService) writeBlockData(writer io.Writer) error { - for _, listener := range fss.storeListeners { - cache := listener.PopStateCache() - - for i := range cache { - bz, err := fss.codec.MarshalLengthPrefixed(&cache[i]) - if err != nil { - return err - } - - if _, err := writer.Write(bz); err != nil { - return err - } - } - } - - return nil -} - -// Stream satisfies the StreamingService interface. It performs a no-op. -func (fss *StreamingService) Stream(wg *sync.WaitGroup) error { return nil } - -// Close satisfies the StreamingService interface. It performs a no-op. -func (fss *StreamingService) Close() error { return nil } - -// isDirWriteable checks if dir is writable by writing and removing a file -// to dir. It returns nil if dir is writable. We have to do this as there is no -// platform-independent way of determining if a directory is writeable. -func isDirWriteable(dir string) error { - f := path.Join(dir, ".touch") - if err := os.WriteFile(f, []byte(""), 0o600); err != nil { - return err - } - - return os.Remove(f) -} - -func writeLengthPrefixedFile(path string, data []byte, fsync bool) (err error) { - var f *os.File - f, err = os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) - if err != nil { - return sdkerrors.Wrapf(err, "open file failed: %s", path) - } - - defer func() { - // avoid overriding the real error with file close error - if err1 := f.Close(); err1 != nil && err == nil { - err = sdkerrors.Wrapf(err, "close file failed: %s", path) - } - }() - - _, err = f.Write(sdk.Uint64ToBigEndian(uint64(len(data)))) - if err != nil { - return sdkerrors.Wrapf(err, "write length prefix failed: %s", path) - } - - _, err = f.Write(data) - if err != nil { - return sdkerrors.Wrapf(err, "write block data failed: %s", path) - } - - if fsync { - err = f.Sync() - if err != nil { - return sdkerrors.Wrapf(err, "fsync failed: %s", path) - } - } - - return err -} diff --git a/store/streaming/file/service_test.go b/store/streaming/file/service_test.go deleted file mode 100644 index fbbb55090167..000000000000 --- a/store/streaming/file/service_test.go +++ /dev/null @@ -1,375 +0,0 @@ -package file - -import ( - "encoding/binary" - "errors" - "fmt" - "os" - "path/filepath" - "sync" - "testing" - - "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" - types1 "github.com/tendermint/tendermint/proto/tendermint/types" - - "github.com/cosmos/cosmos-sdk/codec" - codecTypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - interfaceRegistry = codecTypes.NewInterfaceRegistry() - testMarshaller = codec.NewProtoCodec(interfaceRegistry) - testStreamingService *StreamingService - testListener1, testListener2 types.WriteListener - emptyContext = sdk.Context{} - - // test abci message types - mockHash = []byte{1, 2, 3, 4, 5, 6, 7, 8, 9} - testBeginBlockReq = abci.RequestBeginBlock{ - Header: types1.Header{ - Height: 1, - }, - ByzantineValidators: []abci.Evidence{}, - Hash: mockHash, - LastCommitInfo: abci.LastCommitInfo{ - Round: 1, - Votes: []abci.VoteInfo{}, - }, - } - testBeginBlockRes = abci.ResponseBeginBlock{ - Events: []abci.Event{ - { - Type: "testEventType1", - }, - { - Type: "testEventType2", - }, - }, - } - testEndBlockReq = abci.RequestEndBlock{ - Height: 1, - } - testEndBlockRes = abci.ResponseEndBlock{ - Events: []abci.Event{}, - ConsensusParamUpdates: &abci.ConsensusParams{}, - ValidatorUpdates: []abci.ValidatorUpdate{}, - } - testCommitRes = abci.ResponseCommit{ - Data: []byte{1}, - RetainHeight: 0, - } - mockTxBytes1 = []byte{9, 8, 7, 6, 5, 4, 3, 2, 1} - testDeliverTxReq1 = abci.RequestDeliverTx{ - Tx: mockTxBytes1, - } - mockTxBytes2 = []byte{8, 7, 6, 5, 4, 3, 2} - testDeliverTxReq2 = abci.RequestDeliverTx{ - Tx: mockTxBytes2, - } - mockTxResponseData1 = []byte{1, 3, 5, 7, 9} - testDeliverTxRes1 = abci.ResponseDeliverTx{ - Events: []abci.Event{}, - Code: 1, - Codespace: "mockCodeSpace", - Data: mockTxResponseData1, - GasUsed: 2, - GasWanted: 3, - Info: "mockInfo", - Log: "mockLog", - } - mockTxResponseData2 = []byte{1, 3, 5, 7, 9} - testDeliverTxRes2 = abci.ResponseDeliverTx{ - Events: []abci.Event{}, - Code: 1, - Codespace: "mockCodeSpace", - Data: mockTxResponseData2, - GasUsed: 2, - GasWanted: 3, - Info: "mockInfo", - Log: "mockLog", - } - - // mock store keys - mockStoreKey1 = sdk.NewKVStoreKey("mockStore1") - mockStoreKey2 = sdk.NewKVStoreKey("mockStore2") - - // file stuff - testPrefix = "testPrefix" - testDir = "./.test" - - // mock state changes - mockKey1 = []byte{1, 2, 3} - mockValue1 = []byte{3, 2, 1} - mockKey2 = []byte{2, 3, 4} - mockValue2 = []byte{4, 3, 2} - mockKey3 = []byte{3, 4, 5} - mockValue3 = []byte{5, 4, 3} -) - -func TestFileStreamingService(t *testing.T) { - if os.Getenv("CI") != "" { - t.Skip("Skipping TestFileStreamingService in CI environment") - } - - require.Nil(t, os.Mkdir(testDir, 0o700)) - defer os.RemoveAll(testDir) - - testKeys := []types.StoreKey{mockStoreKey1, mockStoreKey2} - var err error - testStreamingService, err = NewStreamingService(testDir, testPrefix, testKeys, testMarshaller, true, false, false) - require.Nil(t, err) - require.IsType(t, &StreamingService{}, testStreamingService) - require.Equal(t, testPrefix, testStreamingService.filePrefix) - require.Equal(t, testDir, testStreamingService.writeDir) - require.Equal(t, testMarshaller, testStreamingService.codec) - - testListener1 = testStreamingService.storeListeners[0] - testListener2 = testStreamingService.storeListeners[1] - - wg := new(sync.WaitGroup) - - testStreamingService.Stream(wg) - testListenBlock(t) - testStreamingService.Close() - wg.Wait() -} - -func testListenBlock(t *testing.T) { - var ( - expectKVPairsStore1 [][]byte - expectKVPairsStore2 [][]byte - ) - - // write state changes - testListener1.OnWrite(mockStoreKey1, mockKey1, mockValue1, false) - testListener2.OnWrite(mockStoreKey2, mockKey2, mockValue2, false) - testListener1.OnWrite(mockStoreKey1, mockKey3, mockValue3, false) - - // expected KV pairs - expectedKVPair1, err := testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey1.Name(), - Key: mockKey1, - Value: mockValue1, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair2, err := testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey2.Name(), - Key: mockKey2, - Value: mockValue2, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair3, err := testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey1.Name(), - Key: mockKey3, - Value: mockValue3, - Delete: false, - }) - require.Nil(t, err) - - expectKVPairsStore1 = append(expectKVPairsStore1, expectedKVPair1, expectedKVPair3) - expectKVPairsStore2 = append(expectKVPairsStore2, expectedKVPair2) - - // send the ABCI messages - err = testStreamingService.ListenBeginBlock(emptyContext, testBeginBlockReq, testBeginBlockRes) - require.Nil(t, err) - - // write state changes - testListener1.OnWrite(mockStoreKey1, mockKey1, mockValue1, false) - testListener2.OnWrite(mockStoreKey2, mockKey2, mockValue2, false) - testListener2.OnWrite(mockStoreKey2, mockKey3, mockValue3, false) - - // expected KV pairs - expectedKVPair1, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey1.Name(), - Key: mockKey1, - Value: mockValue1, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair2, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey2.Name(), - Key: mockKey2, - Value: mockValue2, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair3, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey2.Name(), - Key: mockKey3, - Value: mockValue3, - Delete: false, - }) - require.Nil(t, err) - - expectKVPairsStore1 = append(expectKVPairsStore1, expectedKVPair1) - expectKVPairsStore2 = append(expectKVPairsStore2, expectedKVPair2, expectedKVPair3) - - // send the ABCI messages - err = testStreamingService.ListenDeliverTx(emptyContext, testDeliverTxReq1, testDeliverTxRes1) - require.Nil(t, err) - - // write state changes - testListener2.OnWrite(mockStoreKey2, mockKey1, mockValue1, false) - testListener1.OnWrite(mockStoreKey1, mockKey2, mockValue2, false) - testListener2.OnWrite(mockStoreKey2, mockKey3, mockValue3, false) - - // expected KV pairs - expectedKVPair1, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey2.Name(), - Key: mockKey1, - Value: mockValue1, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair2, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey1.Name(), - Key: mockKey2, - Value: mockValue2, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair3, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey2.Name(), - Key: mockKey3, - Value: mockValue3, - Delete: false, - }) - require.Nil(t, err) - - expectKVPairsStore1 = append(expectKVPairsStore1, expectedKVPair2) - expectKVPairsStore2 = append(expectKVPairsStore2, expectedKVPair1, expectedKVPair3) - - // send the ABCI messages - err = testStreamingService.ListenDeliverTx(emptyContext, testDeliverTxReq2, testDeliverTxRes2) - require.Nil(t, err) - - // write state changes - testListener1.OnWrite(mockStoreKey1, mockKey1, mockValue1, false) - testListener1.OnWrite(mockStoreKey1, mockKey2, mockValue2, false) - testListener2.OnWrite(mockStoreKey2, mockKey3, mockValue3, false) - - // expected KV pairs - expectedKVPair1, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey1.Name(), - Key: mockKey1, - Value: mockValue1, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair2, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey1.Name(), - Key: mockKey2, - Value: mockValue2, - Delete: false, - }) - require.Nil(t, err) - - expectedKVPair3, err = testMarshaller.Marshal(&types.StoreKVPair{ - StoreKey: mockStoreKey2.Name(), - Key: mockKey3, - Value: mockValue3, - Delete: false, - }) - require.Nil(t, err) - - expectKVPairsStore1 = append(expectKVPairsStore1, expectedKVPair1, expectedKVPair2) - expectKVPairsStore2 = append(expectKVPairsStore2, expectedKVPair3) - - // send the ABCI messages - err = testStreamingService.ListenEndBlock(emptyContext, testEndBlockReq, testEndBlockRes) - require.Nil(t, err) - - err = testStreamingService.ListenCommit(emptyContext, testCommitRes) - require.Nil(t, err) - - // load the file, checking that it was created with the expected name - metaFileName := fmt.Sprintf("%s-block-%d-meta", testPrefix, testBeginBlockReq.GetHeader().Height) - dataFileName := fmt.Sprintf("%s-block-%d-data", testPrefix, testBeginBlockReq.GetHeader().Height) - metaFileBytes, err := readInFile(metaFileName) - dataFileBytes, err := readInFile(dataFileName) - require.Nil(t, err) - - metadata := types.BlockMetadata{ - RequestBeginBlock: &testBeginBlockReq, - ResponseBeginBlock: &testBeginBlockRes, - RequestEndBlock: &testEndBlockReq, - ResponseEndBlock: &testEndBlockRes, - ResponseCommit: &testCommitRes, - DeliverTxs: []*types.BlockMetadata_DeliverTx{ - {Request: &testDeliverTxReq1, Response: &testDeliverTxRes1}, - {Request: &testDeliverTxReq2, Response: &testDeliverTxRes2}, - }, - } - expectedMetadataBytes, err := testMarshaller.Marshal(&metadata) - require.Nil(t, err) - require.Equal(t, expectedMetadataBytes, metaFileBytes) - - // segment the file into the separate gRPC messages and check the correctness of each - segments, err := segmentBytes(dataFileBytes) - require.Nil(t, err) - require.Equal(t, len(expectKVPairsStore1)+len(expectKVPairsStore2), len(segments)) - require.Equal(t, expectKVPairsStore1, segments[:len(expectKVPairsStore1)]) - require.Equal(t, expectKVPairsStore2, segments[len(expectKVPairsStore1):]) -} - -func readInFile(name string) ([]byte, error) { - path := filepath.Join(testDir, name) - bz, err := os.ReadFile(path) - if err != nil { - return nil, err - } - - size := sdk.BigEndianToUint64(bz[:8]) - if len(bz) != int(size)+8 { - return nil, errors.New("incomplete file ") - } - - return bz[8:], nil -} - -// segmentBytes returns all of the protobuf messages contained in the byte array -// as an array of byte arrays. The messages have their length prefix removed. -func segmentBytes(bz []byte) ([][]byte, error) { - var err error - - segments := make([][]byte, 0) - for len(bz) > 0 { - var segment []byte - - segment, bz, err = getHeadSegment(bz) - if err != nil { - return nil, err - } - - segments = append(segments, segment) - } - - return segments, nil -} - -// getHeadSegment returns the bytes for the leading protobuf object in the byte -// array (removing the length prefix) and returns the remainder of the byte array. -func getHeadSegment(bz []byte) ([]byte, []byte, error) { - size, prefixSize := binary.Uvarint(bz) - if prefixSize < 0 { - return nil, nil, fmt.Errorf("invalid number of bytes read from length-prefixed encoding: %d", prefixSize) - } - - if size > uint64(len(bz)-prefixSize) { - return nil, nil, fmt.Errorf("not enough bytes to read; want: %v, got: %v", size, len(bz)-prefixSize) - } - - return bz[prefixSize:(uint64(prefixSize) + size)], bz[uint64(prefixSize)+size:], nil -} diff --git a/store/types/listening.go b/store/types/listening.go index d345e75678c3..dba5aa934a58 100644 --- a/store/types/listening.go +++ b/store/types/listening.go @@ -1,90 +1,28 @@ package types -import ( - "io" - - "github.com/cosmos/cosmos-sdk/codec" -) - -// WriteListener interface for streaming data out from a KVStore -type WriteListener interface { - // if value is nil then it was deleted - // storeKey indicates the source KVStore, to facilitate using the same WriteListener across separate KVStores - // delete bool indicates if it was a delete; true: delete, false: set - OnWrite(storeKey StoreKey, key []byte, value []byte, delete bool) error -} - -// StoreKVPairWriteListener is used to configure listening to a KVStore by -// writing out length-prefixed Protobuf encoded StoreKVPairs to an underlying -// io.Writer object. -type StoreKVPairWriteListener struct { - writer io.Writer - marshaller codec.BinaryCodec -} - -// NewStoreKVPairWriteListener wraps creates a StoreKVPairWriteListener with a -// provided io.Writer and codec.BinaryCodec. -func NewStoreKVPairWriteListener(w io.Writer, m codec.BinaryCodec) *StoreKVPairWriteListener { - return &StoreKVPairWriteListener{ - writer: w, - marshaller: m, - } -} - -// OnWrite satisfies the WriteListener interface by writing length-prefixed -// Protobuf encoded StoreKVPairs. -func (wl *StoreKVPairWriteListener) OnWrite(storeKey StoreKey, key []byte, value []byte, delete bool) error { - kvPair := &StoreKVPair{ - StoreKey: storeKey.Name(), - Key: key, - Value: value, - Delete: delete, - } - - by, err := wl.marshaller.MarshalLengthPrefixed(kvPair) - if err != nil { - return err - } - - if _, err := wl.writer.Write(by); err != nil { - return err - } - - return nil -} - // MemoryListener listens to the state writes and accumulate the records in memory. type MemoryListener struct { - key StoreKey - stateCache []StoreKVPair + stateCache []*StoreKVPair } // NewMemoryListener creates a listener that accumulate the state writes in memory. -func NewMemoryListener(key StoreKey) *MemoryListener { - return &MemoryListener{key: key} +func NewMemoryListener() *MemoryListener { + return &MemoryListener{} } -// OnWrite implements WriteListener interface. -func (fl *MemoryListener) OnWrite(storeKey StoreKey, key []byte, value []byte, delete bool) error { - fl.stateCache = append(fl.stateCache, StoreKVPair{ +// OnWrite implements MemoryListener interface +func (fl *MemoryListener) OnWrite(storeKey StoreKey, key []byte, value []byte, delete bool) { + fl.stateCache = append(fl.stateCache, &StoreKVPair{ StoreKey: storeKey.Name(), Delete: delete, Key: key, Value: value, }) - - return nil } -// PopStateCache returns the current state caches and set to nil. -func (fl *MemoryListener) PopStateCache() []StoreKVPair { +// PopStateCache returns the current state caches and set to nil +func (fl *MemoryListener) PopStateCache() []*StoreKVPair { res := fl.stateCache fl.stateCache = nil - return res } - -// StoreKey returns the storeKey it listens to. -func (fl *MemoryListener) StoreKey() StoreKey { - return fl.key -} diff --git a/store/types/listening_test.go b/store/types/listening_test.go index af1362e4f938..034d2a49601c 100644 --- a/store/types/listening_test.go +++ b/store/types/listening_test.go @@ -1,66 +1,42 @@ package types import ( - "bytes" "testing" "github.com/stretchr/testify/require" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/types" ) func TestNewStoreKVPairWriteListener(t *testing.T) { - testWriter := new(bytes.Buffer) - interfaceRegistry := types.NewInterfaceRegistry() - testMarshaller := codec.NewProtoCodec(interfaceRegistry) - - wl := NewStoreKVPairWriteListener(testWriter, testMarshaller) - - require.IsType(t, &StoreKVPairWriteListener{}, wl) - require.Equal(t, testWriter, wl.writer) - require.Equal(t, testMarshaller, wl.marshaller) + listener := NewMemoryListener() + require.IsType(t, &MemoryListener{}, listener) } func TestOnWrite(t *testing.T) { - testWriter := new(bytes.Buffer) - interfaceRegistry := types.NewInterfaceRegistry() - testMarshaller := codec.NewProtoCodec(interfaceRegistry) - - wl := NewStoreKVPairWriteListener(testWriter, testMarshaller) + listener := NewMemoryListener() testStoreKey := NewKVStoreKey("test_key") testKey := []byte("testing123") testValue := []byte("testing321") // test set - err := wl.OnWrite(testStoreKey, testKey, testValue, false) - require.Nil(t, err) - - outputBytes := testWriter.Bytes() - outputKVPair := new(StoreKVPair) + listener.OnWrite(testStoreKey, testKey, testValue, false) + outputKVPair := listener.PopStateCache()[0] expectedOutputKVPair := &StoreKVPair{ Key: testKey, Value: testValue, StoreKey: testStoreKey.Name(), Delete: false, } - testMarshaller.UnmarshalLengthPrefixed(outputBytes, outputKVPair) require.EqualValues(t, expectedOutputKVPair, outputKVPair) - testWriter.Reset() // test delete - err = wl.OnWrite(testStoreKey, testKey, testValue, true) - require.Nil(t, err) - - outputBytes = testWriter.Bytes() - outputKVPair = new(StoreKVPair) + listener.OnWrite(testStoreKey, testKey, testValue, true) + outputKVPair = listener.PopStateCache()[0] expectedOutputKVPair = &StoreKVPair{ Key: testKey, Value: testValue, StoreKey: testStoreKey.Name(), Delete: true, } - testMarshaller.UnmarshalLengthPrefixed(outputBytes, outputKVPair) require.EqualValues(t, expectedOutputKVPair, outputKVPair) } diff --git a/store/types/store.go b/store/types/store.go index ef5ff36c8c42..5e41854b77ac 100644 --- a/store/types/store.go +++ b/store/types/store.go @@ -194,9 +194,11 @@ type CommitMultiStore interface { // ListeningEnabled returns if listening is enabled for the KVStore belonging the provided StoreKey ListeningEnabled(key StoreKey) bool - // AddListeners adds WriteListeners for the KVStore belonging to the provided StoreKey - // It appends the listeners to a current set, if one already exists - AddListeners(key StoreKey, listeners []WriteListener) + // AddListeners adds a listener for the KVStore belonging to the provided StoreKey + AddListeners(keys []StoreKey) + + // PopStateCache returns the accumulated state change messages from the CommitMultiStore + PopStateCache() []*StoreKVPair } //---------subsp------------------------------- @@ -344,7 +346,7 @@ type StoreKey interface { } // CapabilityKey represent the Cosmos SDK keys for object-capability -// generation in the IBC protocol as defined in https://github.com/cosmos/ibc/tree/master/spec/core/ics-005-port-allocation#data-structures +// generation in the IBC protocol as defined in https://github.com/cosmos/ics/tree/master/spec/ics-005-port-allocation#data-structures type CapabilityKey StoreKey // KVStoreKey is used for accessing substores. diff --git a/store/types/streaming.go b/store/types/streaming.go new file mode 100644 index 000000000000..02bc122b6ddd --- /dev/null +++ b/store/types/streaming.go @@ -0,0 +1,32 @@ +package types + +import ( + "context" + + abci "github.com/tendermint/tendermint/abci/types" +) + +// ABCIListener is the interface that we're exposing as a streaming service. +// It hooks into the ABCI message processing of the BaseApp. +// The error results are propagated to consensus state machine, +// if you don't want to affect consensus, handle the errors internally and always return `nil` in these APIs. +type ABCIListener interface { + // ListenBeginBlock updates the streaming service with the latest BeginBlock messages + ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error + // ListenEndBlock updates the steaming service with the latest EndBlock messages + ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error + // ListenDeliverTx updates the steaming service with the latest DeliverTx messages + ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error + // ListenCommit updates the steaming service with the latest Commit messages and state changes + ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*StoreKVPair) error +} + +// StreamingManager is the struct that maintains a list of AbciListeners and configuration settings. +type StreamingManager struct { + // AbciListeners for hooking into the ABCI message processing of the BaseApp + // and exposing the requests and responses to external consumers + AbciListeners []ABCIListener + + // StopNodeOnErr halts the node when ABCI streaming service listening results in an error. + StopNodeOnErr bool +} diff --git a/store/v2alpha1/dbadapter/store.go b/store/v2alpha1/dbadapter/store.go index 1cbd6c83585b..4222bfb8eae3 100644 --- a/store/v2alpha1/dbadapter/store.go +++ b/store/v2alpha1/dbadapter/store.go @@ -87,6 +87,6 @@ func (dsa Store) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types.Ca } // CacheWrapWithListeners implements the CacheWrapper interface. -func (dsa Store) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types.WriteListener) types.CacheWrap { - return cachekv.NewStore(listenkv.NewStore(dsa, storeKey, listeners)) +func (dsa Store) CacheWrapWithListeners(storeKey types.StoreKey, listener *types.MemoryListener) types.CacheWrap { + return cachekv.NewStore(listenkv.NewStore(dsa, storeKey, listener)) } diff --git a/store/v2alpha1/multi/store.go b/store/v2alpha1/multi/store.go index 4916adea6c81..5343d61ea0c0 100644 --- a/store/v2alpha1/multi/store.go +++ b/store/v2alpha1/multi/store.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "math" + "sort" "strings" "sync" @@ -140,13 +141,14 @@ type prefixRegistry struct { // Mixin type that to compose trace & listen state into each root store variant type type traceListenMixin struct { - listeners map[string][]types.WriteListener + listeners map[string]*types.MemoryListener TraceWriter io.Writer TraceContext types.TraceContext + listenersMx sync.Mutex } func newTraceListenMixin() *traceListenMixin { - return &traceListenMixin{listeners: map[string][]types.WriteListener{}} + return &traceListenMixin{listeners: map[string]*types.MemoryListener{}} } // DefaultStoreConfig returns a MultiStore config with an empty schema, a single backing DB, @@ -876,19 +878,42 @@ func (pr *prefixRegistry) RegisterSubstore(key string, typ types.StoreType) erro return nil } -func (tlm *traceListenMixin) AddListeners(skey types.StoreKey, listeners []types.WriteListener) { - key := skey.Name() - tlm.listeners[key] = append(tlm.listeners[key], listeners...) +// AddListeners adds a listener for the KVStore belonging to the provided StoreKey +func (tlm *traceListenMixin) AddListeners(keys []types.StoreKey) { + tlm.listenersMx.Lock() + defer tlm.listenersMx.Unlock() + for i := range keys { + listener := tlm.listeners[keys[i].Name()] + if listener == nil { + tlm.listeners[keys[i].Name()] = &types.MemoryListener{} + } + } } // ListeningEnabled returns if listening is enabled for a specific KVStore func (tlm *traceListenMixin) ListeningEnabled(key types.StoreKey) bool { if ls, has := tlm.listeners[key.Name()]; has { - return len(ls) != 0 + return ls != nil } return false } +func (tlm *traceListenMixin) PopStateCache() []*types.StoreKVPair { + tlm.listenersMx.Lock() + defer tlm.listenersMx.Unlock() + var cache []*types.StoreKVPair + for key := range tlm.listeners { + ls := tlm.listeners[key] + if ls != nil { + cache = append(cache, ls.PopStateCache()...) + } + } + sort.SliceStable(cache, func(i, j int) bool { + return cache[i].StoreKey < cache[j].StoreKey + }) + return cache +} + func (tlm *traceListenMixin) TracingEnabled() bool { return tlm.TraceWriter != nil } @@ -902,6 +927,8 @@ func (tlm *traceListenMixin) SetTraceContext(tc types.TraceContext) { } func (tlm *traceListenMixin) wrapTraceListen(store types.KVStore, skey types.StoreKey) types.KVStore { + tlm.listenersMx.Lock() + defer tlm.listenersMx.Unlock() if tlm.TracingEnabled() { store = tracekv.NewStore(store, tlm.TraceWriter, tlm.TraceContext) } diff --git a/store/v2alpha1/multi/store_test.go b/store/v2alpha1/multi/store_test.go index de09003518d0..6b46f96868be 100644 --- a/store/v2alpha1/multi/store_test.go +++ b/store/v2alpha1/multi/store_test.go @@ -9,8 +9,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" - "github.com/cosmos/cosmos-sdk/codec" - codecTypes "github.com/cosmos/cosmos-sdk/codec/types" dbm "github.com/cosmos/cosmos-sdk/db" "github.com/cosmos/cosmos-sdk/db/memdb" pruningtypes "github.com/cosmos/cosmos-sdk/pruning/types" @@ -937,9 +935,6 @@ func TestListeners(t *testing.T) { }, } - interfaceRegistry := codecTypes.NewInterfaceRegistry() - marshaller := codec.NewProtoCodec(interfaceRegistry) - db := memdb.NewDB() opts := simpleStoreConfig(t) require.NoError(t, opts.RegisterSubstore(skey_2.Name(), types.StoreTypeMemory)) @@ -949,37 +944,34 @@ func TestListeners(t *testing.T) { require.NoError(t, err) for i, tc := range testCases { - var buf bytes.Buffer - listener := types.NewStoreKVPairWriteListener(&buf, marshaller) - store.AddListeners(tc.skey, []types.WriteListener{listener}) + store.AddListeners([]types.StoreKey{tc.skey}) require.True(t, store.ListeningEnabled(tc.skey)) // Set case - expected := types.StoreKVPair{ + expected := &types.StoreKVPair{ Key: tc.key, Value: tc.value, StoreKey: tc.skey.Name(), Delete: false, } - var kvpair types.StoreKVPair - - buf.Reset() store.GetKVStore(tc.skey).Set(tc.key, tc.value) - require.NoError(t, marshaller.UnmarshalLengthPrefixed(buf.Bytes(), &kvpair)) + cache := store.PopStateCache() + require.Equal(t, 1, len(cache)) + kvpair := cache[0] require.Equal(t, expected, kvpair, i) // Delete case - expected = types.StoreKVPair{ + expected = &types.StoreKVPair{ Key: tc.key, Value: nil, StoreKey: tc.skey.Name(), Delete: true, } - kvpair = types.StoreKVPair{} - buf.Reset() store.GetKVStore(tc.skey).Delete(tc.key) - require.NoError(t, marshaller.UnmarshalLengthPrefixed(buf.Bytes(), &kvpair)) + cache = store.PopStateCache() + require.Equal(t, 1, len(cache)) + kvpair = cache[0] require.Equal(t, expected, kvpair, i) } require.NoError(t, store.Close()) diff --git a/store/v2alpha1/multi/sub_store.go b/store/v2alpha1/multi/sub_store.go index 613b7ac2c412..79cc674dbf22 100644 --- a/store/v2alpha1/multi/sub_store.go +++ b/store/v2alpha1/multi/sub_store.go @@ -112,6 +112,6 @@ func (s *substore) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) types. return cachekv.NewStore(tracekv.NewStore(s, w, tc)) } -func (s *substore) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types.WriteListener) types.CacheWrap { - return cachekv.NewStore(listenkv.NewStore(s, storeKey, listeners)) +func (s *substore) CacheWrapWithListeners(storeKey types.StoreKey, listener *types.MemoryListener) types.CacheWrap { + return cachekv.NewStore(listenkv.NewStore(s, storeKey, listener)) } diff --git a/store/v2alpha1/multi/view_store.go b/store/v2alpha1/multi/view_store.go index b06596c3161b..550919e961fb 100644 --- a/store/v2alpha1/multi/view_store.go +++ b/store/v2alpha1/multi/view_store.go @@ -80,8 +80,8 @@ func (st *viewSubstore) CacheWrapWithTrace(w io.Writer, tc types.TraceContext) t return cachekv.NewStore(tracekv.NewStore(st, w, tc)) } -func (st *viewSubstore) CacheWrapWithListeners(storeKey types.StoreKey, listeners []types.WriteListener) types.CacheWrap { - return cachekv.NewStore(listenkv.NewStore(st, storeKey, listeners)) +func (st *viewSubstore) CacheWrapWithListeners(storeKey types.StoreKey, listener *types.MemoryListener) types.CacheWrap { + return cachekv.NewStore(listenkv.NewStore(st, storeKey, listener)) } func (s *viewStore) getMerkleRoots() (ret map[string][]byte, err error) { diff --git a/store/v2alpha1/types.go b/store/v2alpha1/types.go index 44c97ff4f52d..2c94fcf7a1da 100644 --- a/store/v2alpha1/types.go +++ b/store/v2alpha1/types.go @@ -16,8 +16,8 @@ type ( StoreRename = v1.StoreRename Iterator = v1.Iterator - TraceContext = v1.TraceContext - WriteListener = v1.WriteListener + TraceContext = v1.TraceContext + MemoryListener = v1.MemoryListener BasicKVStore = v1.BasicKVStore KVStore = v1.KVStore @@ -50,8 +50,6 @@ var ( KVStorePrefixIterator = v1.KVStorePrefixIterator KVStoreReversePrefixIterator = v1.KVStoreReversePrefixIterator - NewStoreKVPairWriteListener = v1.NewStoreKVPairWriteListener - ProofOpSMTCommitment = v1.ProofOpSMTCommitment ProofOpSimpleMerkleCommitment = v1.ProofOpSimpleMerkleCommitment @@ -73,7 +71,7 @@ type rootStoreTraceListen interface { SetTracer(w io.Writer) SetTraceContext(TraceContext) ListeningEnabled(key StoreKey) bool - AddListeners(key StoreKey, listeners []WriteListener) + AddListeners(keys []StoreKey) } // CommitMultiStore defines a complete interface for persistent root state, including diff --git a/streaming/README.md b/streaming/README.md new file mode 100644 index 000000000000..3805da6611e5 --- /dev/null +++ b/streaming/README.md @@ -0,0 +1,27 @@ +# Cosmos-SDK Plugins + +This package contains an extensible plugin system for the Cosmos-SDK. The plugin system leverages the [hashicorp/go-plugin](https://github.com/hashicorp/go-plugin) system. This system is designed to work over RCP. + +Although the `go-plugin` is built to work over RCP, it is currently only designed to work over a local network. + +## Pre requisites +For an overview of supported features by the `go-plugin` system, please see https://github.com/hashicorp/go-plugin. The `go-plugin` documentation is located [here](https://github.com/hashicorp/go-plugin/tree/master/docs). You can also directly visit any of the links below: +- [Writing plugins without Go](https://github.com/hashicorp/go-plugin/blob/master/docs/guide-plugin-write-non-go.md) +- [Go Plugin Tutorial](https://github.com/hashicorp/go-plugin/blob/master/docs/extensive-go-plugin-tutorial.md) +- [Plugin Internals](https://github.com/hashicorp/go-plugin/blob/master/docs/internals.md) +- [Plugin Architecture](https://www.youtube.com/watch?v=SRvm3zQQc1Q) (start here) + +## Exposing plugins + +To expose plugins to the plugin system, you will need to: +1. Implement the gRPC message protocol service of the plugin +2. Build the plugin binary +3. Export it + +Read the plugin documentation in the [Streaming Plugins](#streaming-plugins) section for examples on how to build a plugin. + +## Streaming Plugins + +List of support streaming plugins + +- [ABCI State Streaming Plugin](plugins/abci/v1/README.md) diff --git a/streaming/plugins/abci/v1/README.md b/streaming/plugins/abci/v1/README.md new file mode 100644 index 000000000000..980068e439c5 --- /dev/null +++ b/streaming/plugins/abci/v1/README.md @@ -0,0 +1,391 @@ +# ABCI and State Streaming Plugin (gRPC) + +The `BaseApp` package contains the interface for a [ABCIListener](https://github.com/cosmos/cosmos-sdk/blob/main/baseapp/streaming.go) +service used to write state changes out from individual KVStores to external systems, +as described in [ADR-038](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-038-state-listening.md). + +Specific `ABCIListener` service implementations are written and loaded as [hashicorp/go-plugin](https://github.com/hashicorp/go-plugin). + +## Implementation + +In this section we describe the implementation of the `ABCIListener` interface as a gRPC service. + +### Service Protocol + +The companion service protocol for the `ABCIListener` interface is described below. +See [streaming/plugins/proto/abci/v1/grpc.proto](https://github.com/cosmos/cosmos-sdk/blob/main/streaming/plugins/proto/abci/v1/grpc.proto) for full details. + +```protobuf +syntax = "proto3"; + +package cosmos.streaming.abci.v1; + +import "tendermint/abci/types.proto"; +import "cosmos/base/store/v1beta1/listening.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/streaming/plugins/abci/v1"; + +// Empty is the response message for incoming requests +message Empty {} + +// ListenBeginBlockRequest sends BeginBlock requests and responses to server +message ListenBeginBlockRequest { + tendermint.abci.RequestBeginBlock req = 1; + tendermint.abci.ResponseBeginBlock res = 2; +} + +// ListenEndBlockRequest sends EndBlock requests and responses to server +message ListenEndBlockRequest { + tendermint.abci.RequestEndBlock req = 1; + tendermint.abci.ResponseEndBlock res = 2; +} + +// ListenDeliverTxRequest sends DeliverTx requests and responses to server +message ListenDeliverTxRequest { + // explicitly pass in block height as neither RequestDeliverTx or ResponseDeliverTx contain it + int64 block_height = 1; + tendermint.abci.RequestDeliverTx req = 2; + tendermint.abci.ResponseDeliverTx res = 3; +} + +// ListenCommitRequest sends Commit responses and state changes to server +message ListenCommitRequest { + // explicitly pass in block height as ResponseCommit does not contain this info + int64 block_height = 1; + tendermint.abci.ResponseCommit res = 2; + repeated cosmos.base.store.v1beta1.StoreKVPair change_set = 3; +} + +service ABCIListenerService { + rpc ListenBeginBlock(ListenBeginBlockRequest) returns (Empty); + rpc ListenEndBlock(ListenEndBlockRequest) returns (Empty); + rpc ListenDeliverTx(ListenDeliverTxRequest) returns (Empty); + rpc ListenCommit(ListenCommitRequest) returns (Empty); +} +``` + +### Generating the Code + +To generate the stubs the local client implementation can call, run the following command: + +Download required proto files: + +```shell +buf export buf.build/cosmos/cosmos-sdk:${commit} --output streaming/plugins/proto +``` +where `${commit}` is the commit of the buf commit of version of the Cosmos SDK you are using. +That commit can be found [here](https://github.com/cosmos/cosmos-sdk/blob/main/proto/README.md). + +```shell +protoc -I streaming/plugins/proto --go_out=plugins=grpc:. streaming/plugins/proto/abci/v1/grpc.proto \ + && cp -r github.com/cosmos/cosmos-sdk/streaming/* streaming \ + && rm -rf github.com +``` + +For other languages you'll need to [download](https://github.com/cosmos/cosmos-sdk/blob/main/third_party/proto/README.md) +the CosmosSDK protos and the [streaming/plugins/proto/abci/v1/grpc.proto](https://github.com/cosmos/cosmos-sdk/blob/main/streaming/plugins/proto/abci/v1/grpc.proto) +into your project and compile. For language specific compilation instructions visit +[https://github.com/grpc](https://github.com/grpc) and look in the `examples` folder of your +language of choice `https://github.com/grpc/grpc-{language}/tree/master/examples` and [https://grpc.io](https://grpc.io) +for the documentation. + +### gRPC Client and Server + +Implementing the ABCIListener gRPC client and server is a simple and straight forward process. + +To create the client and server we create a `ListenerGRPCPlugin` struct that implements the +`plugin.GRPCPlugin` interface and a `Impl` property that will contain a concrete implementation +of the `ABCIListener` plugin written in Go. + +#### The Interface + +The `BaseApp` `ABCIListener` interface will be what will define the plugins capabilities. + +Boilerplate RPC implementation of the `ABCIListener` interface. ([streaming/plugins/abci/v1/grpc.go](grpc.go)) +```go +... + +var ( + _ baseapp.ABCIListener = (*GRPCClient)(nil) +) + +// GRPCClient is an implementation of the ABCIListener interface that talks over gRPC. +type GRPCClient struct { + client ABCIListenerServiceClient +} + +func (m GRPCClient) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + _, err := m.client.ListenBeginBlock(ctx, &ListenBeginBlockRequest{ + Req: &req, + Res: &res, + }) + return err +} + +func (m GRPCClient) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + _, err := m.client.ListenEndBlock(ctx, &ListenEndBlockRequest{ + Req: &req, + Res: &res, + }) + return err +} + +func (m GRPCClient) ListenDeliverTx(goCtx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + ctx := sdk.UnwrapSDKContext(goCtx) + _, err := m.client.ListenDeliverTx(ctx, &ListenDeliverTxRequest{ + BlockHeight: ctx.BlockHeight(), + Req: &req, + Res: &res, + }) + return err +} + +func (m GRPCClient) ListenCommit(goCtx context.Context, res abci.ResponseCommit, changeSet []*store.StoreKVPair) error { + ctx := sdk.UnwrapSDKContext(goCtx) + _, err := m.client.ListenCommit(ctx, &ListenCommitRequest{ + BlockHeight: ctx.BlockHeight(), + Res: &res, + ChangeSet: changeSet, + }) + return err +} + +// GRPCServer is the gRPC server that GRPCClient talks to. +type GRPCServer struct { + // This is the real implementation + Impl baseapp.ABCIListener +} + +func (m GRPCServer) ListenBeginBlock(ctx context.Context, request *ListenBeginBlockRequest) (*Empty, error) { + if err := m.Impl.ListenBeginBlock(ctx, *request.Req, *request.Res); err != nil { + return nil, err + } + return &Empty{}, nil +} + +func (m GRPCServer) ListenEndBlock(ctx context.Context, request *ListenEndBlockRequest) (*Empty, error) { + if err := m.Impl.ListenEndBlock(ctx, *request.Req, *request.Res); err != nil { + return nil, err + } + return &Empty{}, nil +} + +func (m GRPCServer) ListenDeliverTx(ctx context.Context, request *ListenDeliverTxRequest) (*Empty, error) { + if err := m.Impl.ListenDeliverTx(ctx, *request.Req, *request.Res); err != nil { + return nil, err + } + return &Empty{}, nil +} + +func (m GRPCServer) ListenCommit(ctx context.Context, request *ListenCommitRequest) (*Empty, error) { + if err := m.Impl.ListenCommit(ctx, *request.Res, request.ChangeSet); err != nil { + return nil, err + } + return &Empty{}, nil +} +``` + +Our `ABCIlistener` service plugin. ([streaming/plugins/abci/v1/interface.go](interface.go)) +```go +... + +// Handshake is a common handshake that is shared by streaming and host. +// This prevents users from executing bad plugins or executing a plugin +// directory. It is a UX feature, not a security feature. +var Handshake = plugin.HandshakeConfig{ + // This isn't required when using VersionedPlugins + ProtocolVersion: 1, + MagicCookieKey: "ABCI_LISTENER_PLUGIN", + MagicCookieValue: "ef78114d-7bdf-411c-868f-347c99a78345", +} + +var ( + _ plugin.GRPCPlugin = (*ABCIListenerGRPCPlugin)(nil) +) + +// ListenerGRPCPlugin is the implementation of plugin.Plugin so we can serve/consume this +// +// This has two methods: Server must return an RPC server for this plugin +// type. We construct a GreeterRPCServer for this. +// +// Client must return an implementation of our interface that communicates +// over an RPC client. We return GreeterRPC for this. +// +// Ignore MuxBroker. That is used to create more multiplexed streams on our +// plugin connection and is a more advanced use case. +// +// description: copied from hashicorp plugin documentation. +type ListenerGRPCPlugin struct { + // GRPCPlugin must still implement the Plugin interface + plugin.Plugin + // Concrete implementation, written in Go. This is only used for plugins + // that are written in Go. + Impl baseapp.ABCIListener +} + +func (p *ListenerGRPCPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error { + RegisterABCIListenerServiceServer(s, &GRPCServer{Impl: p.Impl}) + return nil +} + +func (p *ListenerGRPCPlugin) GRPCClient( + _ context.Context, + _ *plugin.GRPCBroker, + c *grpc.ClientConn, +) (interface{}, error) { + return &GRPCClient{client: NewABCIListenerServiceClient(c)}, nil +} +``` + +#### Plugin Implementation + +Plugin implementations can be in a completely separate package but will need access +to the `ABCIListener` interface. One thing to note here is that plugin implementations +defined in the `ListenerGRPCPlugin.Impl` property are **only** required when building +plugins in Go. They are pre compiled into Go modules. The `GRPCServer.Impl` calls methods +on this out-of-process plugin. + +For Go plugins this is all that is required to process data that is sent over gRPC. +This provides the advantage of writing quick plugins that process data to different +external systems (i.e: DB, File, DB, Kafka, etc.) without the need for implementing +the gRPC server endpoints. + +```go +// MyPlugin is the implementation of the baseapp.ABCIListener interface +// For Go plugins this is all that is required to process data sent over gRPC. +type MyPlugin struct { + ... +} + +func (a FilePlugin) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + // process data + return nil +} + +func (a FilePlugin) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + // process data + return nil +} + +func (a FilePlugin) ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + // process data + return nil +} + +func (a FilePlugin) ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*store.StoreKVPair) error { + // process data + return nil +} + +func main() { + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: v1.Handshake, + Plugins: map[string]plugin.Plugin{ + "abci_v1": &v1.ABCIListenerGRPCPlugin{Impl: &MyPlugin{}}, + }, + + // A non-nil value here enables gRPC serving for this streaming... + GRPCServer: plugin.DefaultGRPCServer, + }) +} +``` + +## Plugin Loading System + +A general purpose plugin loading system has been provided by the SDK to be able to load not just +the `ABCIListener` service plugin but other protocol services as well. You can take a look +at how plugins are loaded by the SDK in [streaming/streaming.go](https://github.com/cosmos/cosmos-sdk/blob/main/streaming/streaming.go) + +You'll need to add this in your `app.go` +```go +// app.go + +func NewApp(...) *App { + + ... + + // register streaming services + streamingCfg := cast.ToStringMap(appOpts.Get(baseapp.StreamingTomlKey)) + for service := range streamingCfg { + pluginKey := fmt.Sprintf("%s.%s.%s", baseapp.StreamingTomlKey, service, baseapp.StreamingABCIPluginTomlKey) + pluginName := strings.TrimSpace(cast.ToString(appOpts.Get(pluginKey))) + if len(pluginName) > 0 { + logLevel := cast.ToString(appOpts.Get(flags.FlagLogLevel)) + plugin, err := streaming.NewStreamingPlugin(pluginName, logLevel) + if err != nil { + tmos.Exit(err.Error()) + } + if err := baseapp.RegisterStreamingPlugin(bApp, appOpts, keys, plugin); err != nil { + tmos.Exit(err.Error()) + } + } + } + + ... +} +``` + +## Configuration + +Update the streaming section in `app.toml` +```toml +# Streaming allows nodes to stream state to external systems +[streaming] + +# streaming.abci specifies the configuration for the ABCI Listener streaming service +[streaming.abci] + +# List of kv store keys to stream out via gRPC +# Set to ["*"] to expose all keys. +keys = ["*"] + +# The plugin name used for streaming via gRPC +# Supported plugins: abci_v1 +plugin = "abci_v1" + +# stop-node-on-err specifies whether to stop the node on message deliver error +stop-node-on-err = true +``` + +## Updating the protocol + +If you update the protocol buffers file, you can regenerate the file and plugins using the +following commands from the project root directory. You do not need to run this if you're +just trying the examples, you can skip ahead to the [Testing](#testing) section. + +```shell +make proto-gen +``` + +- stdout plugin +```shell +go build -o streaming/plugins/abci/v1/examples/stdout/stdout streaming/plugins/abci/v1/examples/stdout/stdout.go +``` + +- file plugin (writes to ~/) +```shell +go build -o streaming/plugins/abci/v1/examples/file/file streaming/plugins/abci/v1/examples/file/file.go +``` + +### Testing + +Export a plugin from one of the Go or Python examples. + +- stdout plugin +```shell +export COSMOS_SDK_ABCI_V1="{path to}/cosmos-sdk/streaming/plugins/abci/v1/examples/stdout/stdout" +``` +- file plugin (writes to ~/) +```shell +export COSMOS_SDK_ABCI_V1="{path to}/cosmos-sdk/streaming/plugins/abci/v1/examples/file/file" +``` +where `{path to}` is the parent path to the `cosmos-sdk` repo on you system. + +Test: +```shell +make test-sim-nondeterminism-streaming +``` + +The plugin system will look for the plugin binary in the `env` variable `COSMOS_SDK_{PLUGIN_NAME}` above +and if it does not find it, it will error out. The plugin UPPERCASE name is that of the +`streaming.abci.plugin` TOML configuration setting. diff --git a/streaming/plugins/abci/v1/examples/file/file b/streaming/plugins/abci/v1/examples/file/file new file mode 100755 index 000000000000..b9779a0f312f Binary files /dev/null and b/streaming/plugins/abci/v1/examples/file/file differ diff --git a/streaming/plugins/abci/v1/examples/file/file.go b/streaming/plugins/abci/v1/examples/file/file.go new file mode 100644 index 000000000000..aaf638b75c8d --- /dev/null +++ b/streaming/plugins/abci/v1/examples/file/file.go @@ -0,0 +1,109 @@ +package main + +import ( + "context" + "fmt" + "os" + "path/filepath" + + "github.com/hashicorp/go-plugin" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/streaming/plugins/abci/v1" + abci "github.com/tendermint/tendermint/abci/types" +) + +// FilePlugin is the implementation of the ABCIListener interface +// For Go plugins this is all that is required to process data sent over gRPC. +type FilePlugin struct { + BlockHeight int64 + fileDict map[string]*os.File +} + +func (a *FilePlugin) writeToFile(file string, data []byte) error { + if f, ok := a.fileDict[file]; ok { + _, err := f.Write(data) + return err + } + a.fileDict = make(map[string]*os.File, 0) + + home, err := os.UserHomeDir() + if err != nil { + return err + } + + filename := fmt.Sprintf("%s/%s.txt", home, file) + f, err := os.OpenFile(filepath.Clean(filename), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0600) + if err != nil { + return err + } + a.fileDict[file] = f + + if _, err := f.Write(data); err != nil { + return err + } + + return nil +} + +func (a *FilePlugin) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + a.BlockHeight = req.Header.Height + d1 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, req)) + d2 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, res)) + if err := a.writeToFile("begin-block-req", d1); err != nil { + return err + } + if err := a.writeToFile("begin-block-res", d2); err != nil { + return err + } + return nil +} + +func (a *FilePlugin) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + d1 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, req)) + d2 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, req)) + if err := a.writeToFile("end-block-req", d1); err != nil { + return err + } + if err := a.writeToFile("end-block-res", d2); err != nil { + return err + } + return nil +} + +func (a *FilePlugin) ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + d1 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, req)) + d2 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, res)) + if err := a.writeToFile("deliver-tx-req", d1); err != nil { + return err + } + if err := a.writeToFile("deliver-tx-res", d2); err != nil { + return err + } + return nil +} + +func (a *FilePlugin) ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*storetypes.StoreKVPair) error { + fmt.Printf("listen-commit: block_height=%d data=%v", res.RetainHeight, changeSet) + d1 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, res)) + d2 := []byte(fmt.Sprintf("%d:::%v\n", a.BlockHeight, changeSet)) + if err := a.writeToFile("commit-res", d1); err != nil { + return err + } + if err := a.writeToFile("state-change", d2); err != nil { + return err + } + return nil +} + +func main() { + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: v1.Handshake, + Plugins: map[string]plugin.Plugin{ + "abci_v1": &v1.ABCIListenerGRPCPlugin{Impl: &FilePlugin{}}, + }, + + // A non-nil value here enables gRPC serving for this streaming... + GRPCServer: plugin.DefaultGRPCServer, + }) +} diff --git a/streaming/plugins/abci/v1/examples/stdout/stdout b/streaming/plugins/abci/v1/examples/stdout/stdout new file mode 100755 index 000000000000..0621daec27f5 Binary files /dev/null and b/streaming/plugins/abci/v1/examples/stdout/stdout differ diff --git a/streaming/plugins/abci/v1/examples/stdout/stdout.go b/streaming/plugins/abci/v1/examples/stdout/stdout.go new file mode 100644 index 000000000000..8fb99deb7aff --- /dev/null +++ b/streaming/plugins/abci/v1/examples/stdout/stdout.go @@ -0,0 +1,55 @@ +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-plugin" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/streaming/plugins/abci/v1" + abci "github.com/tendermint/tendermint/abci/types" +) + +// StdoutPlugin is the implementation of the ABCIListener interface +// For Go plugins this is all that is required to process data sent over gRPC. +type StdoutPlugin struct { + BlockHeight int64 +} + +func (a StdoutPlugin) ListenBeginBlock(ctx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + a.BlockHeight = req.Header.Height + // process tx messages (i.e: sent to external system) + fmt.Printf("listen-begin-block: block-height=%d req=%v res=%v", a.BlockHeight, req, res) + return nil +} + +func (a StdoutPlugin) ListenEndBlock(ctx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + // process end block messages (i.e: sent to external system) + fmt.Printf("listen-end-block: block-height=%d req=%v res=%v", a.BlockHeight, req, res) + return nil +} + +func (a StdoutPlugin) ListenDeliverTx(ctx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + // process tx messages (i.e: sent to external system) + fmt.Printf("listen-deliver-tx: block-height=%d req=%v res=%v", a.BlockHeight, req, res) + return nil +} + +func (a StdoutPlugin) ListenCommit(ctx context.Context, res abci.ResponseCommit, changeSet []*storetypes.StoreKVPair) error { + // process block commit messages (i.e: sent to external system) + fmt.Printf("listen-commit: block_height=%d res=%v data=%v", a.BlockHeight, res, changeSet) + return nil +} + +func main() { + plugin.Serve(&plugin.ServeConfig{ + HandshakeConfig: v1.Handshake, + Plugins: map[string]plugin.Plugin{ + "abci_v1": &v1.ABCIListenerGRPCPlugin{Impl: &StdoutPlugin{}}, + }, + + // A non-nil value here enables gRPC serving for this streaming... + GRPCServer: plugin.DefaultGRPCServer, + }) +} diff --git a/streaming/plugins/abci/v1/grpc.go b/streaming/plugins/abci/v1/grpc.go new file mode 100644 index 000000000000..8e5bda08ae3f --- /dev/null +++ b/streaming/plugins/abci/v1/grpc.go @@ -0,0 +1,108 @@ +package v1 + +import ( + "context" + "os" + + "github.com/hashicorp/go-plugin" + abci "github.com/tendermint/tendermint/abci/types" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ storetypes.ABCIListener = (*GRPCClient)(nil) + +// GRPCClient is an implementation of the ABCIListener interface that talks over RPC. +type GRPCClient struct { + client ABCIListenerServiceClient +} + +func (m *GRPCClient) ListenBeginBlock(goCtx context.Context, req abci.RequestBeginBlock, res abci.ResponseBeginBlock) error { + ctx := sdk.UnwrapSDKContext(goCtx) + sm := ctx.StreamingManager() + request := &ListenBeginBlockRequest{Req: &req, Res: &res} + _, err := m.client.ListenBeginBlock(ctx, request) + if err != nil && sm.StopNodeOnErr { + ctx.Logger().Error("BeginBlock listening hook failed", "height", ctx.BlockHeight(), "err", err) + cleanupAndExit() + } + return err +} + +func (m *GRPCClient) ListenEndBlock(goCtx context.Context, req abci.RequestEndBlock, res abci.ResponseEndBlock) error { + ctx := sdk.UnwrapSDKContext(goCtx) + sm := ctx.StreamingManager() + request := &ListenEndBlockRequest{Req: &req, Res: &res} + _, err := m.client.ListenEndBlock(ctx, request) + if err != nil && sm.StopNodeOnErr { + ctx.Logger().Error("EndBlock listening hook failed", "height", ctx.BlockHeight(), "err", err) + cleanupAndExit() + } + return err +} + +func (m *GRPCClient) ListenDeliverTx(goCtx context.Context, req abci.RequestDeliverTx, res abci.ResponseDeliverTx) error { + ctx := sdk.UnwrapSDKContext(goCtx) + sm := ctx.StreamingManager() + request := &ListenDeliverTxRequest{BlockHeight: ctx.BlockHeight(), Req: &req, Res: &res} + _, err := m.client.ListenDeliverTx(ctx, request) + if err != nil && sm.StopNodeOnErr { + ctx.Logger().Error("DeliverTx listening hook failed", "height", ctx.BlockHeight(), "err", err) + cleanupAndExit() + } + return err +} + +func (m *GRPCClient) ListenCommit(goCtx context.Context, res abci.ResponseCommit, changeSet []*storetypes.StoreKVPair) error { + ctx := sdk.UnwrapSDKContext(goCtx) + sm := ctx.StreamingManager() + request := &ListenCommitRequest{BlockHeight: ctx.BlockHeight(), Res: &res, ChangeSet: changeSet} + _, err := m.client.ListenCommit(ctx, request) + if err != nil && sm.StopNodeOnErr { + ctx.Logger().Error("Commit listening hook failed", "height", ctx.BlockHeight(), "err", err) + cleanupAndExit() + } + return err +} + +func cleanupAndExit() { + plugin.CleanupClients() + os.Exit(1) +} + +var _ ABCIListenerServiceServer = (*GRPCServer)(nil) + +// GRPCServer is the gRPC server that GRPCClient talks to. +type GRPCServer struct { + // This is the real implementation + Impl storetypes.ABCIListener +} + +func (m GRPCServer) ListenBeginBlock(ctx context.Context, request *ListenBeginBlockRequest) (*ListenBeginBlockResponse, error) { + if err := m.Impl.ListenBeginBlock(ctx, *request.Req, *request.Res); err != nil { + return nil, err + } + return &ListenBeginBlockResponse{}, nil +} + +func (m GRPCServer) ListenEndBlock(ctx context.Context, request *ListenEndBlockRequest) (*ListenEndBlockResponse, error) { + if err := m.Impl.ListenEndBlock(ctx, *request.Req, *request.Res); err != nil { + return nil, err + } + return &ListenEndBlockResponse{}, nil +} + +func (m GRPCServer) ListenDeliverTx(ctx context.Context, request *ListenDeliverTxRequest) (*ListenDeliverTxResponse, error) { + if err := m.Impl.ListenDeliverTx(ctx, *request.Req, *request.Res); err != nil { + return nil, err + } + return &ListenDeliverTxResponse{}, nil +} + +func (m GRPCServer) ListenCommit(ctx context.Context, request *ListenCommitRequest) (*ListenCommitResponse, error) { + if err := m.Impl.ListenCommit(ctx, *request.Res, request.ChangeSet); err != nil { + return nil, err + } + return &ListenCommitResponse{}, nil +} diff --git a/streaming/plugins/abci/v1/grpc.pb.go b/streaming/plugins/abci/v1/grpc.pb.go new file mode 100644 index 000000000000..d0e21723d5e1 --- /dev/null +++ b/streaming/plugins/abci/v1/grpc.pb.go @@ -0,0 +1,1888 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: cosmos/streaming/abci/v1/grpc.proto + +package v1 + +import ( + context "context" + fmt "fmt" + types1 "github.com/cosmos/cosmos-sdk/store/types" + grpc1 "github.com/gogo/protobuf/grpc" + proto "github.com/gogo/protobuf/proto" + types "github.com/tendermint/tendermint/abci/types" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ListenBeginBlockRequest is the request type for the ListenBeginBlock RPC method +type ListenBeginBlockRequest struct { + Req *types.RequestBeginBlock `protobuf:"bytes,1,opt,name=req,proto3" json:"req,omitempty"` + Res *types.ResponseBeginBlock `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` +} + +func (m *ListenBeginBlockRequest) Reset() { *m = ListenBeginBlockRequest{} } +func (m *ListenBeginBlockRequest) String() string { return proto.CompactTextString(m) } +func (*ListenBeginBlockRequest) ProtoMessage() {} +func (*ListenBeginBlockRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{0} +} +func (m *ListenBeginBlockRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenBeginBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenBeginBlockRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenBeginBlockRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenBeginBlockRequest.Merge(m, src) +} +func (m *ListenBeginBlockRequest) XXX_Size() int { + return m.Size() +} +func (m *ListenBeginBlockRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListenBeginBlockRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenBeginBlockRequest proto.InternalMessageInfo + +func (m *ListenBeginBlockRequest) GetReq() *types.RequestBeginBlock { + if m != nil { + return m.Req + } + return nil +} + +func (m *ListenBeginBlockRequest) GetRes() *types.ResponseBeginBlock { + if m != nil { + return m.Res + } + return nil +} + +// ListenBeginBlockResponse is the response type for the ListenBeginBlock RPC method +type ListenBeginBlockResponse struct { +} + +func (m *ListenBeginBlockResponse) Reset() { *m = ListenBeginBlockResponse{} } +func (m *ListenBeginBlockResponse) String() string { return proto.CompactTextString(m) } +func (*ListenBeginBlockResponse) ProtoMessage() {} +func (*ListenBeginBlockResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{1} +} +func (m *ListenBeginBlockResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenBeginBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenBeginBlockResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenBeginBlockResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenBeginBlockResponse.Merge(m, src) +} +func (m *ListenBeginBlockResponse) XXX_Size() int { + return m.Size() +} +func (m *ListenBeginBlockResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListenBeginBlockResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenBeginBlockResponse proto.InternalMessageInfo + +// ListenEndBlockRequest is the request type for the ListenEndBlock RPC method +type ListenEndBlockRequest struct { + Req *types.RequestEndBlock `protobuf:"bytes,1,opt,name=req,proto3" json:"req,omitempty"` + Res *types.ResponseEndBlock `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` +} + +func (m *ListenEndBlockRequest) Reset() { *m = ListenEndBlockRequest{} } +func (m *ListenEndBlockRequest) String() string { return proto.CompactTextString(m) } +func (*ListenEndBlockRequest) ProtoMessage() {} +func (*ListenEndBlockRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{2} +} +func (m *ListenEndBlockRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenEndBlockRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenEndBlockRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenEndBlockRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenEndBlockRequest.Merge(m, src) +} +func (m *ListenEndBlockRequest) XXX_Size() int { + return m.Size() +} +func (m *ListenEndBlockRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListenEndBlockRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenEndBlockRequest proto.InternalMessageInfo + +func (m *ListenEndBlockRequest) GetReq() *types.RequestEndBlock { + if m != nil { + return m.Req + } + return nil +} + +func (m *ListenEndBlockRequest) GetRes() *types.ResponseEndBlock { + if m != nil { + return m.Res + } + return nil +} + +// ListenBeginBlockResponse is the response type for the ListenEndBlock RPC method +type ListenEndBlockResponse struct { +} + +func (m *ListenEndBlockResponse) Reset() { *m = ListenEndBlockResponse{} } +func (m *ListenEndBlockResponse) String() string { return proto.CompactTextString(m) } +func (*ListenEndBlockResponse) ProtoMessage() {} +func (*ListenEndBlockResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{3} +} +func (m *ListenEndBlockResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenEndBlockResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenEndBlockResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenEndBlockResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenEndBlockResponse.Merge(m, src) +} +func (m *ListenEndBlockResponse) XXX_Size() int { + return m.Size() +} +func (m *ListenEndBlockResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListenEndBlockResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenEndBlockResponse proto.InternalMessageInfo + +// ListenDeliverTxRequest is the request type for the ListenDeliverTx RPC method +type ListenDeliverTxRequest struct { + // explicitly pass in block height as neither RequestDeliverTx or ResponseDeliverTx contain it + BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + Req *types.RequestDeliverTx `protobuf:"bytes,2,opt,name=req,proto3" json:"req,omitempty"` + Res *types.ResponseDeliverTx `protobuf:"bytes,3,opt,name=res,proto3" json:"res,omitempty"` +} + +func (m *ListenDeliverTxRequest) Reset() { *m = ListenDeliverTxRequest{} } +func (m *ListenDeliverTxRequest) String() string { return proto.CompactTextString(m) } +func (*ListenDeliverTxRequest) ProtoMessage() {} +func (*ListenDeliverTxRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{4} +} +func (m *ListenDeliverTxRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenDeliverTxRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenDeliverTxRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenDeliverTxRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenDeliverTxRequest.Merge(m, src) +} +func (m *ListenDeliverTxRequest) XXX_Size() int { + return m.Size() +} +func (m *ListenDeliverTxRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListenDeliverTxRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenDeliverTxRequest proto.InternalMessageInfo + +func (m *ListenDeliverTxRequest) GetBlockHeight() int64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *ListenDeliverTxRequest) GetReq() *types.RequestDeliverTx { + if m != nil { + return m.Req + } + return nil +} + +func (m *ListenDeliverTxRequest) GetRes() *types.ResponseDeliverTx { + if m != nil { + return m.Res + } + return nil +} + +// ListenBeginBlockResponse is the response type for the ListenDeliverTx RPC method +type ListenDeliverTxResponse struct { +} + +func (m *ListenDeliverTxResponse) Reset() { *m = ListenDeliverTxResponse{} } +func (m *ListenDeliverTxResponse) String() string { return proto.CompactTextString(m) } +func (*ListenDeliverTxResponse) ProtoMessage() {} +func (*ListenDeliverTxResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{5} +} +func (m *ListenDeliverTxResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenDeliverTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenDeliverTxResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenDeliverTxResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenDeliverTxResponse.Merge(m, src) +} +func (m *ListenDeliverTxResponse) XXX_Size() int { + return m.Size() +} +func (m *ListenDeliverTxResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListenDeliverTxResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenDeliverTxResponse proto.InternalMessageInfo + +// ListenCommitRequest is the request type for the ListenCommit RPC method +type ListenCommitRequest struct { + // explicitly pass in block height as ResponseCommit does not contain this info + BlockHeight int64 `protobuf:"varint,1,opt,name=block_height,json=blockHeight,proto3" json:"block_height,omitempty"` + Res *types.ResponseCommit `protobuf:"bytes,2,opt,name=res,proto3" json:"res,omitempty"` + ChangeSet []*types1.StoreKVPair `protobuf:"bytes,3,rep,name=change_set,json=changeSet,proto3" json:"change_set,omitempty"` +} + +func (m *ListenCommitRequest) Reset() { *m = ListenCommitRequest{} } +func (m *ListenCommitRequest) String() string { return proto.CompactTextString(m) } +func (*ListenCommitRequest) ProtoMessage() {} +func (*ListenCommitRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{6} +} +func (m *ListenCommitRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenCommitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenCommitRequest.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenCommitRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenCommitRequest.Merge(m, src) +} +func (m *ListenCommitRequest) XXX_Size() int { + return m.Size() +} +func (m *ListenCommitRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ListenCommitRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenCommitRequest proto.InternalMessageInfo + +func (m *ListenCommitRequest) GetBlockHeight() int64 { + if m != nil { + return m.BlockHeight + } + return 0 +} + +func (m *ListenCommitRequest) GetRes() *types.ResponseCommit { + if m != nil { + return m.Res + } + return nil +} + +func (m *ListenCommitRequest) GetChangeSet() []*types1.StoreKVPair { + if m != nil { + return m.ChangeSet + } + return nil +} + +// ListenBeginBlockResponse is the response type for the ListenCommit RPC method +type ListenCommitResponse struct { +} + +func (m *ListenCommitResponse) Reset() { *m = ListenCommitResponse{} } +func (m *ListenCommitResponse) String() string { return proto.CompactTextString(m) } +func (*ListenCommitResponse) ProtoMessage() {} +func (*ListenCommitResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_801bd9edb3c0cbfd, []int{7} +} +func (m *ListenCommitResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ListenCommitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ListenCommitResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ListenCommitResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ListenCommitResponse.Merge(m, src) +} +func (m *ListenCommitResponse) XXX_Size() int { + return m.Size() +} +func (m *ListenCommitResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ListenCommitResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ListenCommitResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*ListenBeginBlockRequest)(nil), "cosmos.streaming.abci.v1.ListenBeginBlockRequest") + proto.RegisterType((*ListenBeginBlockResponse)(nil), "cosmos.streaming.abci.v1.ListenBeginBlockResponse") + proto.RegisterType((*ListenEndBlockRequest)(nil), "cosmos.streaming.abci.v1.ListenEndBlockRequest") + proto.RegisterType((*ListenEndBlockResponse)(nil), "cosmos.streaming.abci.v1.ListenEndBlockResponse") + proto.RegisterType((*ListenDeliverTxRequest)(nil), "cosmos.streaming.abci.v1.ListenDeliverTxRequest") + proto.RegisterType((*ListenDeliverTxResponse)(nil), "cosmos.streaming.abci.v1.ListenDeliverTxResponse") + proto.RegisterType((*ListenCommitRequest)(nil), "cosmos.streaming.abci.v1.ListenCommitRequest") + proto.RegisterType((*ListenCommitResponse)(nil), "cosmos.streaming.abci.v1.ListenCommitResponse") +} + +func init() { + proto.RegisterFile("cosmos/streaming/abci/v1/grpc.proto", fileDescriptor_801bd9edb3c0cbfd) +} + +var fileDescriptor_801bd9edb3c0cbfd = []byte{ + // 547 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0x17, 0x22, 0x21, 0xe1, 0x4e, 0x80, 0x3c, 0x18, 0x21, 0x48, 0xa1, 0xcb, 0x24, 0x34, + 0x0e, 0x73, 0x48, 0x37, 0xb8, 0xd3, 0x31, 0x09, 0x04, 0x87, 0xa9, 0x45, 0x1c, 0xb8, 0x4c, 0x49, + 0xfa, 0x2a, 0xb5, 0xd6, 0xfc, 0xa9, 0xed, 0x46, 0xec, 0xc6, 0x89, 0x33, 0x9f, 0x82, 0x0f, 0xc0, + 0xa7, 0xe0, 0xb8, 0x23, 0x47, 0xd4, 0x5e, 0xf9, 0x10, 0x28, 0xb6, 0xbb, 0x25, 0x81, 0xd0, 0xf5, + 0x54, 0xd5, 0x7e, 0x9e, 0xd7, 0x3f, 0xe7, 0x7d, 0xfc, 0xa2, 0xdd, 0x28, 0xe3, 0x49, 0xc6, 0x3d, + 0x2e, 0x18, 0x04, 0x09, 0x4d, 0x63, 0x2f, 0x08, 0x23, 0xea, 0x15, 0xbe, 0x17, 0xb3, 0x3c, 0x22, + 0x39, 0xcb, 0x44, 0x86, 0x2d, 0x25, 0x22, 0x97, 0x22, 0x52, 0x8a, 0x48, 0xe1, 0xdb, 0x8f, 0x04, + 0xa4, 0x23, 0x60, 0x09, 0x4d, 0x85, 0x32, 0x8a, 0xf3, 0x1c, 0xb8, 0xb2, 0xd9, 0x4f, 0x75, 0xed, + 0x30, 0xe0, 0xe0, 0x71, 0x91, 0x31, 0xf0, 0x0a, 0x3f, 0x04, 0x11, 0xf8, 0xde, 0x84, 0x72, 0x01, + 0x69, 0x59, 0x49, 0x4a, 0xdd, 0x2f, 0x06, 0x7a, 0xf0, 0x4e, 0xae, 0xf5, 0x21, 0xa6, 0x69, 0x7f, + 0x92, 0x45, 0x67, 0x03, 0x98, 0xce, 0x80, 0x0b, 0x7c, 0x88, 0x4c, 0x06, 0x53, 0xcb, 0xe8, 0x1a, + 0x7b, 0x9d, 0x9e, 0x4b, 0xae, 0x4e, 0x54, 0x14, 0x5a, 0x56, 0xf1, 0x95, 0x72, 0xfc, 0xbc, 0x74, + 0x71, 0xeb, 0x86, 0x74, 0xed, 0xfe, 0xc3, 0xc5, 0xf3, 0x2c, 0xe5, 0x50, 0xb7, 0x71, 0xd7, 0x46, + 0xd6, 0xdf, 0x1c, 0x4a, 0xea, 0x7e, 0x36, 0xd0, 0x7d, 0xb5, 0x79, 0x9c, 0x8e, 0x6a, 0x88, 0xbd, + 0x2a, 0x62, 0xb7, 0x0d, 0xf1, 0xd2, 0x25, 0x01, 0x0f, 0xaa, 0x80, 0x3b, 0xad, 0x80, 0x55, 0x13, + 0x77, 0x2d, 0xb4, 0xdd, 0x24, 0xd0, 0x70, 0xdf, 0x8c, 0xe5, 0xd6, 0x2b, 0x98, 0xd0, 0x02, 0xd8, + 0xfb, 0x4f, 0x4b, 0xba, 0x1d, 0xb4, 0x19, 0x96, 0xda, 0xd3, 0x31, 0xd0, 0x78, 0x2c, 0x24, 0xa6, + 0x39, 0xe8, 0xc8, 0xb5, 0xd7, 0x72, 0x49, 0xc1, 0x4c, 0xff, 0x03, 0x23, 0x2b, 0x5d, 0x55, 0x96, + 0x37, 0x38, 0x54, 0x37, 0x30, 0x5b, 0x1b, 0xa3, 0xd0, 0x6a, 0x2e, 0xee, 0x3e, 0x5c, 0x76, 0xba, + 0xc2, 0xa9, 0xef, 0xf0, 0xdd, 0x40, 0x5b, 0x6a, 0xef, 0x28, 0x4b, 0x12, 0x2a, 0xd6, 0xb8, 0x80, + 0x5f, 0xfd, 0x9a, 0x8f, 0x5b, 0x59, 0x74, 0xdd, 0x52, 0x8b, 0x8f, 0x11, 0x8a, 0xc6, 0x41, 0x1a, + 0xc3, 0x29, 0x07, 0x61, 0x99, 0x5d, 0x73, 0xaf, 0xd3, 0x7b, 0x42, 0x74, 0xd4, 0xcb, 0xcc, 0x12, + 0x99, 0x59, 0xa2, 0x33, 0x4b, 0x86, 0xe5, 0xbf, 0xb7, 0x1f, 0x4e, 0x02, 0xca, 0x06, 0xb7, 0x94, + 0x73, 0x08, 0xc2, 0xdd, 0x46, 0xf7, 0xea, 0xcc, 0xea, 0xa4, 0xde, 0x6f, 0x13, 0x6d, 0xbd, 0xec, + 0x1f, 0xbd, 0x51, 0x9b, 0xc0, 0x86, 0xc0, 0x0a, 0x1a, 0x01, 0x3e, 0x47, 0x77, 0x9b, 0x09, 0xc3, + 0x3e, 0x69, 0x7b, 0x61, 0xa4, 0xe5, 0x55, 0xd8, 0xbd, 0x75, 0x2c, 0x0a, 0x09, 0x73, 0x74, 0xbb, + 0x9e, 0x1e, 0xec, 0xad, 0xaa, 0xd2, 0x48, 0xba, 0xfd, 0xec, 0xfa, 0x06, 0x7d, 0x68, 0x81, 0xee, + 0x34, 0xfa, 0x8d, 0x57, 0x16, 0x69, 0x46, 0xd8, 0xf6, 0xd7, 0x70, 0xe8, 0x73, 0x13, 0xb4, 0x59, + 0xed, 0x0b, 0xde, 0x5f, 0x55, 0xa2, 0x96, 0x39, 0x9b, 0x5c, 0x57, 0xae, 0xe7, 0xc8, 0xc9, 0x8f, + 0xb9, 0x63, 0x5c, 0xcc, 0x1d, 0xe3, 0xd7, 0xdc, 0x31, 0xbe, 0x2e, 0x9c, 0x8d, 0x8b, 0x85, 0xb3, + 0xf1, 0x73, 0xe1, 0x6c, 0x7c, 0x7c, 0x11, 0x53, 0x31, 0x9e, 0x85, 0x24, 0xca, 0x12, 0x4f, 0x4f, + 0x44, 0xf5, 0xb3, 0xcf, 0x47, 0x67, 0x95, 0xc1, 0x9b, 0x4f, 0x66, 0x31, 0x4d, 0xf9, 0x72, 0x00, + 0x87, 0x37, 0xe5, 0x68, 0x3c, 0xf8, 0x13, 0x00, 0x00, 0xff, 0xff, 0xe5, 0x11, 0xd7, 0x0c, 0xa3, + 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// ABCIListenerServiceClient is the client API for ABCIListenerService service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type ABCIListenerServiceClient interface { + // ListenBeginBlock is the corresponding endpoint for ABCIListener.ListenBeginBlock + ListenBeginBlock(ctx context.Context, in *ListenBeginBlockRequest, opts ...grpc.CallOption) (*ListenBeginBlockResponse, error) + // ListenEndBlock is the corresponding endpoint for ABCIListener.ListenEndBlock + ListenEndBlock(ctx context.Context, in *ListenEndBlockRequest, opts ...grpc.CallOption) (*ListenEndBlockResponse, error) + // ListenDeliverTx is the corresponding endpoint for ABCIListener.ListenDeliverTx + ListenDeliverTx(ctx context.Context, in *ListenDeliverTxRequest, opts ...grpc.CallOption) (*ListenDeliverTxResponse, error) + // ListenCommit is the corresponding endpoint for ABCIListener.ListenCommit + ListenCommit(ctx context.Context, in *ListenCommitRequest, opts ...grpc.CallOption) (*ListenCommitResponse, error) +} + +type aBCIListenerServiceClient struct { + cc grpc1.ClientConn +} + +func NewABCIListenerServiceClient(cc grpc1.ClientConn) ABCIListenerServiceClient { + return &aBCIListenerServiceClient{cc} +} + +func (c *aBCIListenerServiceClient) ListenBeginBlock(ctx context.Context, in *ListenBeginBlockRequest, opts ...grpc.CallOption) (*ListenBeginBlockResponse, error) { + out := new(ListenBeginBlockResponse) + err := c.cc.Invoke(ctx, "/cosmos.streaming.abci.v1.ABCIListenerService/ListenBeginBlock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aBCIListenerServiceClient) ListenEndBlock(ctx context.Context, in *ListenEndBlockRequest, opts ...grpc.CallOption) (*ListenEndBlockResponse, error) { + out := new(ListenEndBlockResponse) + err := c.cc.Invoke(ctx, "/cosmos.streaming.abci.v1.ABCIListenerService/ListenEndBlock", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aBCIListenerServiceClient) ListenDeliverTx(ctx context.Context, in *ListenDeliverTxRequest, opts ...grpc.CallOption) (*ListenDeliverTxResponse, error) { + out := new(ListenDeliverTxResponse) + err := c.cc.Invoke(ctx, "/cosmos.streaming.abci.v1.ABCIListenerService/ListenDeliverTx", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *aBCIListenerServiceClient) ListenCommit(ctx context.Context, in *ListenCommitRequest, opts ...grpc.CallOption) (*ListenCommitResponse, error) { + out := new(ListenCommitResponse) + err := c.cc.Invoke(ctx, "/cosmos.streaming.abci.v1.ABCIListenerService/ListenCommit", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ABCIListenerServiceServer is the server API for ABCIListenerService service. +type ABCIListenerServiceServer interface { + // ListenBeginBlock is the corresponding endpoint for ABCIListener.ListenBeginBlock + ListenBeginBlock(context.Context, *ListenBeginBlockRequest) (*ListenBeginBlockResponse, error) + // ListenEndBlock is the corresponding endpoint for ABCIListener.ListenEndBlock + ListenEndBlock(context.Context, *ListenEndBlockRequest) (*ListenEndBlockResponse, error) + // ListenDeliverTx is the corresponding endpoint for ABCIListener.ListenDeliverTx + ListenDeliverTx(context.Context, *ListenDeliverTxRequest) (*ListenDeliverTxResponse, error) + // ListenCommit is the corresponding endpoint for ABCIListener.ListenCommit + ListenCommit(context.Context, *ListenCommitRequest) (*ListenCommitResponse, error) +} + +// UnimplementedABCIListenerServiceServer can be embedded to have forward compatible implementations. +type UnimplementedABCIListenerServiceServer struct { +} + +func (*UnimplementedABCIListenerServiceServer) ListenBeginBlock(ctx context.Context, req *ListenBeginBlockRequest) (*ListenBeginBlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListenBeginBlock not implemented") +} +func (*UnimplementedABCIListenerServiceServer) ListenEndBlock(ctx context.Context, req *ListenEndBlockRequest) (*ListenEndBlockResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListenEndBlock not implemented") +} +func (*UnimplementedABCIListenerServiceServer) ListenDeliverTx(ctx context.Context, req *ListenDeliverTxRequest) (*ListenDeliverTxResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListenDeliverTx not implemented") +} +func (*UnimplementedABCIListenerServiceServer) ListenCommit(ctx context.Context, req *ListenCommitRequest) (*ListenCommitResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ListenCommit not implemented") +} + +func RegisterABCIListenerServiceServer(s grpc1.Server, srv ABCIListenerServiceServer) { + s.RegisterService(&_ABCIListenerService_serviceDesc, srv) +} + +func _ABCIListenerService_ListenBeginBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListenBeginBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ABCIListenerServiceServer).ListenBeginBlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.streaming.abci.v1.ABCIListenerService/ListenBeginBlock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ABCIListenerServiceServer).ListenBeginBlock(ctx, req.(*ListenBeginBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ABCIListenerService_ListenEndBlock_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListenEndBlockRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ABCIListenerServiceServer).ListenEndBlock(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.streaming.abci.v1.ABCIListenerService/ListenEndBlock", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ABCIListenerServiceServer).ListenEndBlock(ctx, req.(*ListenEndBlockRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ABCIListenerService_ListenDeliverTx_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListenDeliverTxRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ABCIListenerServiceServer).ListenDeliverTx(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.streaming.abci.v1.ABCIListenerService/ListenDeliverTx", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ABCIListenerServiceServer).ListenDeliverTx(ctx, req.(*ListenDeliverTxRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _ABCIListenerService_ListenCommit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ListenCommitRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ABCIListenerServiceServer).ListenCommit(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/cosmos.streaming.abci.v1.ABCIListenerService/ListenCommit", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ABCIListenerServiceServer).ListenCommit(ctx, req.(*ListenCommitRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _ABCIListenerService_serviceDesc = grpc.ServiceDesc{ + ServiceName: "cosmos.streaming.abci.v1.ABCIListenerService", + HandlerType: (*ABCIListenerServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ListenBeginBlock", + Handler: _ABCIListenerService_ListenBeginBlock_Handler, + }, + { + MethodName: "ListenEndBlock", + Handler: _ABCIListenerService_ListenEndBlock_Handler, + }, + { + MethodName: "ListenDeliverTx", + Handler: _ABCIListenerService_ListenDeliverTx_Handler, + }, + { + MethodName: "ListenCommit", + Handler: _ABCIListenerService_ListenCommit_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "cosmos/streaming/abci/v1/grpc.proto", +} + +func (m *ListenBeginBlockRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenBeginBlockRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenBeginBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Req != nil { + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ListenBeginBlockResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenBeginBlockResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenBeginBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ListenEndBlockRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenEndBlockRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenEndBlockRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Req != nil { + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ListenEndBlockResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenEndBlockResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenEndBlockResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ListenDeliverTxRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenDeliverTxRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenDeliverTxRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Req != nil { + { + size, err := m.Req.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockHeight != 0 { + i = encodeVarintGrpc(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ListenDeliverTxResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenDeliverTxResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenDeliverTxResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ListenCommitRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenCommitRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenCommitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ChangeSet) > 0 { + for iNdEx := len(m.ChangeSet) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ChangeSet[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if m.Res != nil { + { + size, err := m.Res.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGrpc(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.BlockHeight != 0 { + i = encodeVarintGrpc(dAtA, i, uint64(m.BlockHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ListenCommitResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ListenCommitResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ListenCommitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintGrpc(dAtA []byte, offset int, v uint64) int { + offset -= sovGrpc(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ListenBeginBlockRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + return n +} + +func (m *ListenBeginBlockResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ListenEndBlockRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + return n +} + +func (m *ListenEndBlockResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ListenDeliverTxRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovGrpc(uint64(m.BlockHeight)) + } + if m.Req != nil { + l = m.Req.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + return n +} + +func (m *ListenDeliverTxResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ListenCommitRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeight != 0 { + n += 1 + sovGrpc(uint64(m.BlockHeight)) + } + if m.Res != nil { + l = m.Res.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + if len(m.ChangeSet) > 0 { + for _, e := range m.ChangeSet { + l = e.Size() + n += 1 + l + sovGrpc(uint64(l)) + } + } + return n +} + +func (m *ListenCommitResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovGrpc(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGrpc(x uint64) (n int) { + return sovGrpc(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ListenBeginBlockRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenBeginBlockRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenBeginBlockRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Req == nil { + m.Req = &types.RequestBeginBlock{} + } + if err := m.Req.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Res", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Res == nil { + m.Res = &types.ResponseBeginBlock{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenBeginBlockResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenBeginBlockResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenBeginBlockResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenEndBlockRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenEndBlockRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenEndBlockRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Req == nil { + m.Req = &types.RequestEndBlock{} + } + if err := m.Req.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Res", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Res == nil { + m.Res = &types.ResponseEndBlock{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenEndBlockResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenEndBlockResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenEndBlockResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenDeliverTxRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenDeliverTxRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenDeliverTxRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Req", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Req == nil { + m.Req = &types.RequestDeliverTx{} + } + if err := m.Req.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Res", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Res == nil { + m.Res = &types.ResponseDeliverTx{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenDeliverTxResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenDeliverTxResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenDeliverTxResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenCommitRequest) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenCommitRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenCommitRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeight", wireType) + } + m.BlockHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlockHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Res", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Res == nil { + m.Res = &types.ResponseCommit{} + } + if err := m.Res.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChangeSet", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGrpc + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGrpc + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChangeSet = append(m.ChangeSet, &types1.StoreKVPair{}) + if err := m.ChangeSet[len(m.ChangeSet)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ListenCommitResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGrpc + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ListenCommitResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ListenCommitResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipGrpc(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGrpc + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGrpc(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGrpc + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGrpc + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGrpc + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGrpc + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGrpc + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGrpc + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGrpc = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGrpc = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGrpc = fmt.Errorf("proto: unexpected end of group") +) diff --git a/streaming/plugins/abci/v1/interface.go b/streaming/plugins/abci/v1/interface.go new file mode 100644 index 000000000000..1a05ec778c64 --- /dev/null +++ b/streaming/plugins/abci/v1/interface.go @@ -0,0 +1,45 @@ +// Package v1 contains shared data between the host and plugins. +package v1 + +import ( + "context" + + "github.com/hashicorp/go-plugin" + "google.golang.org/grpc" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" +) + +// Handshake is a common handshake that is shared by streaming and host. +// This prevents users from executing bad plugins or executing a plugin +// directory. It is a UX feature, not a security feature. +var Handshake = plugin.HandshakeConfig{ + // This isn't required when using VersionedPlugins + ProtocolVersion: 1, + MagicCookieKey: "ABCI_LISTENER_PLUGIN", + MagicCookieValue: "ef78114d-7bdf-411c-868f-347c99a78345", +} + +var _ plugin.GRPCPlugin = (*ABCIListenerGRPCPlugin)(nil) + +// ABCIListenerGRPCPlugin is the implementation of plugin.GRPCPlugin, so we can serve/consume this. +type ABCIListenerGRPCPlugin struct { + // GRPCPlugin must still implement the Plugin interface + plugin.Plugin + // Concrete implementation, written in Go. This is only used for plugins + // that are written in Go. + Impl storetypes.ABCIListener +} + +func (p *ABCIListenerGRPCPlugin) GRPCServer(_ *plugin.GRPCBroker, s *grpc.Server) error { + RegisterABCIListenerServiceServer(s, &GRPCServer{Impl: p.Impl}) + return nil +} + +func (p *ABCIListenerGRPCPlugin) GRPCClient( + _ context.Context, + _ *plugin.GRPCBroker, + c *grpc.ClientConn, +) (interface{}, error) { + return &GRPCClient{client: NewABCIListenerServiceClient(c)}, nil +} diff --git a/streaming/streaming.go b/streaming/streaming.go new file mode 100644 index 000000000000..39aa22e3821f --- /dev/null +++ b/streaming/streaming.go @@ -0,0 +1,79 @@ +package streaming + +import ( + "fmt" + "os" + "os/exec" + "strings" + + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/go-plugin" + + "github.com/cosmos/cosmos-sdk/streaming/plugins/abci/v1" +) + +const pluginEnvKeyPrefix = "COSMOS_SDK" + +// HandshakeMap contains a map of each supported streaming's handshake config +var HandshakeMap = map[string]plugin.HandshakeConfig{ + "abci_v1": v1.Handshake, +} + +// PluginMap contains a map of supported gRPC plugins +var PluginMap = map[string]plugin.Plugin{ + "abci_v1": &v1.ABCIListenerGRPCPlugin{}, +} + +func GetPluginEnvKey(name string) string { + return fmt.Sprintf("%s_%s", pluginEnvKeyPrefix, strings.ToUpper(name)) +} + +func NewStreamingPlugin(name string, logLevel string) (interface{}, error) { + logger := hclog.New(&hclog.LoggerOptions{ + Output: hclog.DefaultOutput, + Level: toHclogLevel(logLevel), + Name: fmt.Sprintf("plugin.%s", name), + }) + + // We're a host. Start by launching the streaming process. + env := os.Getenv(GetPluginEnvKey(name)) + client := plugin.NewClient(&plugin.ClientConfig{ + HandshakeConfig: HandshakeMap[name], + Managed: true, + Plugins: PluginMap, + // For verifying the integrity of executables see SecureConfig documentation + // https://pkg.go.dev/github.com/hashicorp/go-plugin#SecureConfig + //#nosec G204 -- Required to load plugins + Cmd: exec.Command("sh", "-c", env), + Logger: logger, + AllowedProtocols: []plugin.Protocol{ + plugin.ProtocolNetRPC, plugin.ProtocolGRPC, + }, + }) + + // Connect via RPC + rpcClient, err := client.Client() + if err != nil { + return nil, err + } + + // Request streaming plugin + return rpcClient.Dispense(name) +} + +func toHclogLevel(s string) hclog.Level { + switch s { + case "trace": + return hclog.Trace + case "debug": + return hclog.Debug + case "info": + return hclog.Info + case "warn": + return hclog.Warn + case "error": + return hclog.Error + default: + return hclog.DefaultLevel + } +} diff --git a/streaming/streaming_test.go b/streaming/streaming_test.go new file mode 100644 index 000000000000..f2dde2933549 --- /dev/null +++ b/streaming/streaming_test.go @@ -0,0 +1,143 @@ +package streaming + +import ( + "fmt" + "os" + "testing" + "time" + + abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" +) + +type PluginTestSuite struct { + suite.Suite + + loggerCtx sdk.Context + + workDir string + + beginBlockReq abci.RequestBeginBlock + beginBlockRes abci.ResponseBeginBlock + endBlockReq abci.RequestEndBlock + endBlockRes abci.ResponseEndBlock + deliverTxReq abci.RequestDeliverTx + deliverTxRes abci.ResponseDeliverTx + commitRes abci.ResponseCommit + + changeSet []*storetypes.StoreKVPair +} + +func (s *PluginTestSuite) SetupTest() { + s.loggerCtx = sdk.NewContext( + nil, + tmproto.Header{Height: 1, Time: time.Now()}, + false, + log.TestingLogger(), + ) + + path, err := os.Getwd() + if err != nil { + s.T().Fail() + } + s.workDir = path + + // test abci message types + s.beginBlockReq = abci.RequestBeginBlock{ + Header: tmproto.Header{Height: 1, Time: time.Now()}, + ByzantineValidators: []abci.Evidence{}, + Hash: []byte{1, 2, 3, 4, 5, 6, 7, 8, 9}, + LastCommitInfo: abci.LastCommitInfo{Round: 1, Votes: []abci.VoteInfo{}}, + } + s.beginBlockRes = abci.ResponseBeginBlock{ + Events: []abci.Event{{Type: "testEventType1"}}, + } + s.endBlockReq = abci.RequestEndBlock{Height: 1} + s.endBlockRes = abci.ResponseEndBlock{ + Events: []abci.Event{}, + ConsensusParamUpdates: &abci.ConsensusParams{}, + ValidatorUpdates: []abci.ValidatorUpdate{}, + } + s.deliverTxReq = abci.RequestDeliverTx{ + Tx: []byte{9, 8, 7, 6, 5, 4, 3, 2, 1}, + } + s.deliverTxRes = abci.ResponseDeliverTx{ + Events: []abci.Event{}, + Code: 1, + Codespace: "mockCodeSpace", + Data: []byte{5, 6, 7, 8}, + GasUsed: 2, + GasWanted: 3, + Info: "mockInfo", + Log: "mockLog", + } + s.commitRes = abci.ResponseCommit{} + + // test storetypes kv pair types + for range [2000]int{} { + s.changeSet = append(s.changeSet, &storetypes.StoreKVPair{ + StoreKey: "mockStore", + Delete: false, + Key: []byte{1, 2, 3}, + Value: []byte{3, 2, 1}, + }) + } +} + +func TestPluginTestSuite(t *testing.T) { + suite.Run(t, new(PluginTestSuite)) +} + +func (s *PluginTestSuite) TestABCIGRPCPlugin() { + s.T().Run("Should successfully load streaming", func(t *testing.T) { + pluginVersion := "abci_v1" + // to write data to files, replace stdout/stdout => file/file + pluginPath := fmt.Sprintf("%s/plugins/abci/v1/examples/stdout/stdout", s.workDir) + if err := os.Setenv(GetPluginEnvKey(pluginVersion), pluginPath); err != nil { + t.Fail() + } + + raw, err := NewStreamingPlugin(pluginVersion, "trace") + require.NoError(t, err, "load", "streaming", "unexpected error") + + abciListener, ok := raw.(storetypes.ABCIListener) + require.True(t, ok, "should pass type check") + + s.loggerCtx = s.loggerCtx.WithStreamingManager(storetypes.StreamingManager{ + AbciListeners: []storetypes.ABCIListener{abciListener}, + StopNodeOnErr: true, + }) + + for i := range [50]int{} { + s.updateHeight(int64(i)) + + err = abciListener.ListenBeginBlock(s.loggerCtx, s.beginBlockReq, s.beginBlockRes) + assert.NoError(t, err, "ListenBeginBlock") + + err = abciListener.ListenEndBlock(s.loggerCtx, s.endBlockReq, s.endBlockRes) + assert.NoError(t, err, "ListenEndBlock") + + for range [50]int{} { + err = abciListener.ListenDeliverTx(s.loggerCtx, s.deliverTxReq, s.deliverTxRes) + assert.NoError(t, err, "ListenDeliverTx") + } + + err = abciListener.ListenCommit(s.loggerCtx, s.commitRes, s.changeSet) + assert.NoError(t, err, "ListenCommit") + } + }) +} + +func (s *PluginTestSuite) updateHeight(n int64) { + s.beginBlockReq.Header.Height = n + s.endBlockReq.Height = n + s.loggerCtx = s.loggerCtx.WithBlockHeight(n) +} diff --git a/types/context.go b/types/context.go index da86a8c089fd..74e8de6713e3 100644 --- a/types/context.go +++ b/types/context.go @@ -41,29 +41,31 @@ type Context struct { priority int64 // The tx priority, only relevant in CheckTx kvGasConfig storetypes.GasConfig transientKVGasConfig storetypes.GasConfig + streamingManager storetypes.StreamingManager } // Proposed rename, not done to avoid API breakage type Request = Context // Read-only accessors -func (c Context) Context() context.Context { return c.baseCtx } -func (c Context) MultiStore() MultiStore { return c.ms } -func (c Context) BlockHeight() int64 { return c.header.Height } -func (c Context) BlockTime() time.Time { return c.header.Time } -func (c Context) ChainID() string { return c.chainID } -func (c Context) TxBytes() []byte { return c.txBytes } -func (c Context) Logger() log.Logger { return c.logger } -func (c Context) VoteInfos() []abci.VoteInfo { return c.voteInfo } -func (c Context) GasMeter() GasMeter { return c.gasMeter } -func (c Context) BlockGasMeter() GasMeter { return c.blockGasMeter } -func (c Context) IsCheckTx() bool { return c.checkTx } -func (c Context) IsReCheckTx() bool { return c.recheckTx } -func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } -func (c Context) EventManager() *EventManager { return c.eventManager } -func (c Context) Priority() int64 { return c.priority } -func (c Context) KVGasConfig() storetypes.GasConfig { return c.kvGasConfig } -func (c Context) TransientKVGasConfig() storetypes.GasConfig { return c.transientKVGasConfig } +func (c Context) Context() context.Context { return c.baseCtx } +func (c Context) MultiStore() MultiStore { return c.ms } +func (c Context) BlockHeight() int64 { return c.header.Height } +func (c Context) BlockTime() time.Time { return c.header.Time } +func (c Context) ChainID() string { return c.chainID } +func (c Context) TxBytes() []byte { return c.txBytes } +func (c Context) Logger() log.Logger { return c.logger } +func (c Context) VoteInfos() []abci.VoteInfo { return c.voteInfo } +func (c Context) GasMeter() GasMeter { return c.gasMeter } +func (c Context) BlockGasMeter() GasMeter { return c.blockGasMeter } +func (c Context) IsCheckTx() bool { return c.checkTx } +func (c Context) IsReCheckTx() bool { return c.recheckTx } +func (c Context) MinGasPrices() DecCoins { return c.minGasPrice } +func (c Context) EventManager() *EventManager { return c.eventManager } +func (c Context) Priority() int64 { return c.priority } +func (c Context) KVGasConfig() storetypes.GasConfig { return c.kvGasConfig } +func (c Context) TransientKVGasConfig() storetypes.GasConfig { return c.transientKVGasConfig } +func (c Context) StreamingManager() storetypes.StreamingManager { return c.streamingManager } // clone the header before returning func (c Context) BlockHeader() tmproto.Header { @@ -254,6 +256,12 @@ func (c Context) WithPriority(p int64) Context { return c } +// WithStreamingManager returns a Context with an updated streaming manager +func (c Context) WithStreamingManager(s storetypes.StreamingManager) Context { + c.streamingManager = s + return c +} + // TODO: remove??? func (c Context) IsZero() bool { return c.ms == nil diff --git a/x/group/internal/math/dec_test.go b/x/group/internal/math/dec_test.go index 22bca12d1669..c524716934ca 100644 --- a/x/group/internal/math/dec_test.go +++ b/x/group/internal/math/dec_test.go @@ -95,8 +95,8 @@ func TestDec(t *testing.T) { require.True(t, minusOne.IsNegative()) } -var genDec *rapid.Generator = rapid.Custom(func(t *rapid.T) Dec { - f := rapid.Float64().Draw(t, "f").(float64) +var genDec *rapid.Generator[Dec] = rapid.Custom(func(t *rapid.T) Dec { + f := rapid.Float64().Draw(t, "f") dec, err := NewDecFromString(fmt.Sprintf("%g", f)) require.NoError(t, err) return dec @@ -109,8 +109,8 @@ type floatAndDec struct { } // Generate a Dec value along with the float used to create it -var genFloatAndDec *rapid.Generator = rapid.Custom(func(t *rapid.T) floatAndDec { - f := rapid.Float64().Draw(t, "f").(float64) +var genFloatAndDec *rapid.Generator[floatAndDec] = rapid.Custom(func(t *rapid.T) floatAndDec { + f := rapid.Float64().Draw(t, "f") dec, err := NewDecFromString(fmt.Sprintf("%g", f)) require.NoError(t, err) return floatAndDec{f, dec} @@ -118,7 +118,7 @@ var genFloatAndDec *rapid.Generator = rapid.Custom(func(t *rapid.T) floatAndDec // Property: n == NewDecFromInt64(n).Int64() func testDecInt64(t *rapid.T) { - nIn := rapid.Int64().Draw(t, "n").(int64) + nIn := rapid.Int64().Draw(t, "n") nOut, err := NewDecFromInt64(nIn).Int64() require.NoError(t, err) @@ -127,7 +127,7 @@ func testDecInt64(t *rapid.T) { // Property: 0 + a == a func testAddLeftIdentity(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) + a := genDec.Draw(t, "a") zero := NewDecFromInt64(0) b, err := zero.Add(a) @@ -138,7 +138,7 @@ func testAddLeftIdentity(t *rapid.T) { // Property: a + 0 == a func testAddRightIdentity(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) + a := genDec.Draw(t, "a") zero := NewDecFromInt64(0) b, err := a.Add(zero) @@ -149,8 +149,8 @@ func testAddRightIdentity(t *rapid.T) { // Property: a + b == b + a func testAddCommutative(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) - b := genDec.Draw(t, "b").(Dec) + a := genDec.Draw(t, "a") + b := genDec.Draw(t, "b") c, err := a.Add(b) require.NoError(t, err) @@ -163,9 +163,9 @@ func testAddCommutative(t *rapid.T) { // Property: (a + b) + c == a + (b + c) func testAddAssociative(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) - b := genDec.Draw(t, "b").(Dec) - c := genDec.Draw(t, "c").(Dec) + a := genDec.Draw(t, "a") + b := genDec.Draw(t, "b") + c := genDec.Draw(t, "c") // (a + b) + c d, err := a.Add(b) @@ -186,7 +186,7 @@ func testAddAssociative(t *rapid.T) { // Property: a - 0 == a func testSubRightIdentity(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) + a := genDec.Draw(t, "a") zero := NewDecFromInt64(0) b, err := a.Sub(zero) @@ -197,7 +197,7 @@ func testSubRightIdentity(t *rapid.T) { // Property: a - a == 0 func testSubZero(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) + a := genDec.Draw(t, "a") zero := NewDecFromInt64(0) b, err := a.Sub(a) @@ -208,8 +208,8 @@ func testSubZero(t *rapid.T) { // Property: (a - b) + b == a func testSubAdd(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) - b := genDec.Draw(t, "b").(Dec) + a := genDec.Draw(t, "a") + b := genDec.Draw(t, "b") c, err := a.Sub(b) require.NoError(t, err) @@ -222,8 +222,8 @@ func testSubAdd(t *rapid.T) { // Property: (a + b) - b == a func testAddSub(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) - b := genDec.Draw(t, "b").(Dec) + a := genDec.Draw(t, "a") + b := genDec.Draw(t, "b") c, err := a.Add(b) require.NoError(t, err) @@ -236,23 +236,23 @@ func testAddSub(t *rapid.T) { // Property: Cmp(a, b) == -Cmp(b, a) func testCmpInverse(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) - b := genDec.Draw(t, "b").(Dec) + a := genDec.Draw(t, "a") + b := genDec.Draw(t, "b") require.Equal(t, a.Cmp(b), -b.Cmp(a)) } // Property: IsEqual(a, b) == IsEqual(b, a) func testEqualCommutative(t *rapid.T) { - a := genDec.Draw(t, "a").(Dec) - b := genDec.Draw(t, "b").(Dec) + a := genDec.Draw(t, "a") + b := genDec.Draw(t, "b") require.Equal(t, a.IsEqual(b), b.IsEqual(a)) } // Property: isNegative(f) == isNegative(NewDecFromString(f.String())) func testIsNegative(t *rapid.T) { - floatAndDec := genFloatAndDec.Draw(t, "floatAndDec").(floatAndDec) + floatAndDec := genFloatAndDec.Draw(t, "floatAndDec") f, dec := floatAndDec.float, floatAndDec.dec require.Equal(t, f < 0, dec.IsNegative()) diff --git a/x/group/internal/orm/generators_test.go b/x/group/internal/orm/generators_test.go index 0cc95eedaae0..3ad52df15daf 100644 --- a/x/group/internal/orm/generators_test.go +++ b/x/group/internal/orm/generators_test.go @@ -10,9 +10,9 @@ import ( // generate empty strings for Name. var genTableModel = rapid.Custom(func(t *rapid.T) *testdata.TableModel { return &testdata.TableModel{ - Id: rapid.Uint64().Draw(t, "id").(uint64), - Name: rapid.StringN(1, 100, 150).Draw(t, "name").(string), - Number: rapid.Uint64().Draw(t, "number ").(uint64), - Metadata: []byte(rapid.StringN(1, 100, 150).Draw(t, "metadata").(string)), + Id: rapid.Uint64().Draw(t, "id"), + Name: rapid.StringN(1, 100, 150).Draw(t, "name"), + Number: rapid.Uint64().Draw(t, "number "), + Metadata: []byte(rapid.StringN(1, 100, 150).Draw(t, "metadata")), } }) diff --git a/x/group/internal/orm/index_property_test.go b/x/group/internal/orm/index_property_test.go index 48b2cc02ef66..e48de3c12240 100644 --- a/x/group/internal/orm/index_property_test.go +++ b/x/group/internal/orm/index_property_test.go @@ -10,7 +10,7 @@ import ( func TestPrefixRangeProperty(t *testing.T) { t.Run("TestPrefixRange", rapid.MakeCheck(func(t *rapid.T) { - prefix := rapid.SliceOf(rapid.Byte()).Draw(t, "prefix").([]byte) + prefix := rapid.SliceOf(rapid.Byte()).Draw(t, "prefix") start, end := PrefixRange(prefix) diff --git a/x/group/internal/orm/iterator_property_test.go b/x/group/internal/orm/iterator_property_test.go index 1f30fcb2278a..c1e5eaec8b90 100644 --- a/x/group/internal/orm/iterator_property_test.go +++ b/x/group/internal/orm/iterator_property_test.go @@ -15,14 +15,14 @@ import ( func TestPaginationProperty(t *testing.T) { t.Run("TestPagination", rapid.MakeCheck(func(t *rapid.T) { // Create a slice of group members - tableModels := rapid.SliceOf(genTableModel).Draw(t, "tableModels").([]*testdata.TableModel) + tableModels := rapid.SliceOf(genTableModel).Draw(t, "tableModels") // Choose a random limit for paging upperLimit := uint64(len(tableModels)) if upperLimit == 0 { upperLimit = 1 } - limit := rapid.Uint64Range(1, upperLimit).Draw(t, "limit").(uint64) + limit := rapid.Uint64Range(1, upperLimit).Draw(t, "limit") // Reconstruct the slice from offset pages reconstructedTableModels := make([]*testdata.TableModel, 0, len(tableModels)) diff --git a/x/group/internal/orm/primary_key_property_test.go b/x/group/internal/orm/primary_key_property_test.go index 083fd2c2944b..3b7f371053cc 100644 --- a/x/group/internal/orm/primary_key_property_test.go +++ b/x/group/internal/orm/primary_key_property_test.go @@ -13,7 +13,7 @@ import ( ) func TestPrimaryKeyTable(t *testing.T) { - rapid.Check(t, rapid.Run(&primaryKeyMachine{})) + rapid.Check(t, rapid.Run[*primaryKeyMachine]()) } // primaryKeyMachine is a state machine model of the PrimaryKeyTable. The state @@ -39,9 +39,9 @@ func (m *primaryKeyMachine) stateKeys() []string { // Generate a TableModel that has a 50% chance of being a part of the existing // state -func (m *primaryKeyMachine) genTableModel() *rapid.Generator { +func (m *primaryKeyMachine) genTableModel() *rapid.Generator[*testdata.TableModel] { genStateTableModel := rapid.Custom(func(t *rapid.T) *testdata.TableModel { - pk := rapid.SampledFrom(m.stateKeys()).Draw(t, "key").(string) + pk := rapid.SampledFrom(m.stateKeys()).Draw(t, "key") return m.state[pk] }) @@ -86,7 +86,7 @@ func (m *primaryKeyMachine) Check(t *rapid.T) { // Create is one of the model commands. It adds an object to the table, creating // an error if it already exists. func (m *primaryKeyMachine) Create(t *rapid.T) { - g := genTableModel.Draw(t, "g").(*testdata.TableModel) + g := genTableModel.Draw(t, "g") pk := string(PrimaryKey(g)) t.Logf("pk: %v", pk) @@ -105,9 +105,9 @@ func (m *primaryKeyMachine) Create(t *rapid.T) { // Update is one of the model commands. It updates the value at a given primary // key and fails if that primary key doesn't already exist in the table. func (m *primaryKeyMachine) Update(t *rapid.T) { - tm := m.genTableModel().Draw(t, "tm").(*testdata.TableModel) + tm := m.genTableModel().Draw(t, "tm") - newName := rapid.StringN(1, 100, 150).Draw(t, "newName").(string) + newName := rapid.StringN(1, 100, 150).Draw(t, "newName") tm.Name = newName // Perform the real Update @@ -128,7 +128,7 @@ func (m *primaryKeyMachine) Update(t *rapid.T) { // Set is one of the model commands. It sets the value at a key in the table // whether it exists or not. func (m *primaryKeyMachine) Set(t *rapid.T) { - g := genTableModel.Draw(t, "g").(*testdata.TableModel) + g := genTableModel.Draw(t, "g") pk := string(PrimaryKey(g)) err := m.table.Set(m.store, g) @@ -141,7 +141,7 @@ func (m *primaryKeyMachine) Set(t *rapid.T) { // primary key from the table and returns an error if that primary key doesn't // already exist in the table. func (m *primaryKeyMachine) Delete(t *rapid.T) { - tm := m.genTableModel().Draw(t, "tm").(*testdata.TableModel) + tm := m.genTableModel().Draw(t, "tm") // Perform the real Delete err := m.table.Delete(m.store, tm) @@ -161,7 +161,7 @@ func (m *primaryKeyMachine) Delete(t *rapid.T) { // Has is one of the model commands. It checks whether a key already exists in // the table. func (m *primaryKeyMachine) Has(t *rapid.T) { - pk := PrimaryKey(m.genTableModel().Draw(t, "g").(*testdata.TableModel)) + pk := PrimaryKey(m.genTableModel().Draw(t, "g")) realHas := m.table.Has(m.store, pk) modelHas := m.state[string(pk)] != nil @@ -172,7 +172,7 @@ func (m *primaryKeyMachine) Has(t *rapid.T) { // GetOne is one of the model commands. It fetches an object from the table by // its primary key and returns an error if that primary key isn't in the table. func (m *primaryKeyMachine) GetOne(t *rapid.T) { - pk := PrimaryKey(m.genTableModel().Draw(t, "tm").(*testdata.TableModel)) + pk := PrimaryKey(m.genTableModel().Draw(t, "tm")) var tm testdata.TableModel diff --git a/x/group/internal/orm/sequence_property_test.go b/x/group/internal/orm/sequence_property_test.go index 2d3d9c10a2fd..0872e429a07e 100644 --- a/x/group/internal/orm/sequence_property_test.go +++ b/x/group/internal/orm/sequence_property_test.go @@ -9,7 +9,7 @@ import ( ) func TestSequence(t *testing.T) { - rapid.Check(t, rapid.Run(&sequenceMachine{})) + rapid.Check(t, rapid.Run[*sequenceMachine]()) } // sequenceMachine is a state machine model of Sequence. It simply uses a uint64 @@ -32,7 +32,7 @@ func (m *sequenceMachine) Init(t *rapid.T) { m.seq = &seq // Choose initial sequence value - initSeqVal := rapid.Uint64().Draw(t, "initSeqVal").(uint64) + initSeqVal := rapid.Uint64().Draw(t, "initSeqVal") err := m.seq.InitVal(m.store, initSeqVal) require.NoError(t, err)