diff --git a/app/app.go b/app/app.go index fccbf32a..b86350ce 100644 --- a/app/app.go +++ b/app/app.go @@ -21,6 +21,7 @@ import ( "github.com/line/lbm-sdk/baseapp" "github.com/line/lbm-sdk/client" + nodeservice "github.com/line/lbm-sdk/client/grpc/node" "github.com/line/lbm-sdk/client/grpc/tmservice" "github.com/line/lbm-sdk/client/rpc" "github.com/line/lbm-sdk/codec" @@ -29,6 +30,7 @@ import ( "github.com/line/lbm-sdk/server/config" servertypes "github.com/line/lbm-sdk/server/types" "github.com/line/lbm-sdk/simapp" + "github.com/line/lbm-sdk/store/streaming" sdk "github.com/line/lbm-sdk/types" "github.com/line/lbm-sdk/types/module" "github.com/line/lbm-sdk/version" @@ -253,6 +255,12 @@ func NewLinkApp( // not include this key. memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) + // configure state listening capabilities using AppOptions + // we are doing nothing with the returned streamingServices and waitGroup in this case + if _, _, err := streaming.LoadStreamingServices(bApp, appOpts, appCodec, keys); err != nil { + ostos.Exit(err.Error()) + } + app := &LinkApp{ BaseApp: bApp, legacyAmino: legacyAmino, @@ -672,6 +680,9 @@ func (app *LinkApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APICo // Register new tendermint queries routes from grpc-gateway. tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register node gRPC service for grpc-gateway. + nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) + // Register legacy and grpc-gateway routes for all modules. ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router) ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) @@ -692,6 +703,10 @@ func (app *LinkApp) RegisterTendermintService(clientCtx client.Context) { tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) } +func (app *LinkApp) RegisterNodeService(clientCtx client.Context) { + nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter()) +} + // RegisterSwaggerAPI registers swagger route with API Server func RegisterSwaggerAPI(rtr *mux.Router) { statikFS, err := fs.New() diff --git a/cli_test/cli_test.go b/cli_test/cli_test.go index e7824714..1dc49ab5 100644 --- a/cli_test/cli_test.go +++ b/cli_test/cli_test.go @@ -171,12 +171,15 @@ func TestLBMFeesDeduction(t *testing.T) { keyFoo, barAddr, sdk.NewCoin(fooDenom, largeCoins), fmt.Sprintf("--fees=%s", sdk.NewInt64Coin(feeDenom, 2)), "-y") require.NoError(t, err) - require.Contains(t, out.String(), "insufficient funds") // Wait for a block err = n.WaitForNextBlock() require.NoError(t, err) + resp := UnmarshalTxResponse(t, out.Bytes()) + out2 := f.QueryTx(resp.TxHash) + require.Contains(t, out2.String(), "insufficient funds") + // ensure state didn't change fooBal = f.QueryBalances(fooAddr) require.Equal(t, fooAmt.Int64(), fooBal.GetBalances().AmountOf(fooDenom).Int64()) @@ -743,6 +746,8 @@ func TestLBMQueryTxPagination(t *testing.T) { require.NoError(t, err) seq++ } + err := n.WaitForNextBlock() + require.NoError(t, err) // perPage = 15, 2 pages txsPage1 := f.QueryTxs(1, 2, fmt.Sprintf("--events='message.sender=%s'", fooAddr)) diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 631a2030..6c2b1ea0 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -1429,7 +1429,7 @@ func newValidator(f *Fixtures, cfg testnet.Config, appCfg *srvconfig.Config, ctx ctx.Logger = logger - require.NoError(f.T, os.MkdirAll(filepath.Join(f.Home, "config"), 0755)) + require.NoError(f.T, os.MkdirAll(filepath.Join(f.Home, "config"), 0o755)) tmCfg.SetRoot(f.Home) tmCfg.Moniker = f.Moniker diff --git a/cmd/lbm/cmd/root.go b/cmd/lbm/cmd/root.go index 13f17c0b..34f48978 100644 --- a/cmd/lbm/cmd/root.go +++ b/cmd/lbm/cmd/root.go @@ -13,6 +13,7 @@ import ( "github.com/line/lbm-sdk/client/debug" "github.com/line/lbm-sdk/client/flags" "github.com/line/lbm-sdk/client/keys" + "github.com/line/lbm-sdk/client/pruning" "github.com/line/lbm-sdk/client/rpc" "github.com/line/lbm-sdk/codec" "github.com/line/lbm-sdk/server" @@ -163,6 +164,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { testnetCmd(app.ModuleBasics, banktypes.GenesisBalancesIterator{}), debug.Cmd(), config.Cmd(), + pruning.PruningCmd(newApp), ) server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, createSimappAndExport, addModuleInitFlags) @@ -256,7 +258,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty } snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots") - if err := os.MkdirAll(snapshotDir, 0755); err != nil { + if err := os.MkdirAll(snapshotDir, 0o755); err != nil { panic(err) } snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir) @@ -286,10 +288,11 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty baseapp.SetMinRetainBlocks(cast.ToUint64(appOpts.Get(server.FlagMinRetainBlocks))), baseapp.SetInterBlockCache(cache), baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))), - baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), baseapp.SetSnapshotStore(snapshotStore), baseapp.SetSnapshotInterval(cast.ToUint64(appOpts.Get(server.FlagStateSyncSnapshotInterval))), baseapp.SetSnapshotKeepRecent(cast.ToUint32(appOpts.Get(server.FlagStateSyncSnapshotKeepRecent))), + baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))), + baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagIAVLFastNode))), baseapp.SetChanCheckTxSize(cast.ToUint(appOpts.Get(server.FlagChanCheckTxSize))), ) } diff --git a/cmd/lbm/cmd/testnet.go b/cmd/lbm/cmd/testnet.go index 5607c75a..b947732a 100644 --- a/cmd/lbm/cmd/testnet.go +++ b/cmd/lbm/cmd/testnet.go @@ -94,7 +94,7 @@ Example: return cmd } -const nodeDirPerm = 0755 +const nodeDirPerm = 0o755 // Initialize the testnet func InitTestnet( diff --git a/go.mod b/go.mod index a7b49b35..d174eef4 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.18 require ( github.com/golang/mock v1.6.0 github.com/gorilla/mux v1.8.0 - github.com/line/lbm-sdk v0.46.0-rc9 + github.com/line/lbm-sdk v0.46.0-rc10 github.com/line/ostracon v1.0.7-0.20220906074149-e6ecd80874f8 github.com/prometheus/client_golang v1.13.0 github.com/rakyll/statik v0.1.7 @@ -105,7 +105,7 @@ require ( github.com/regen-network/cosmos-proto v0.3.1 // indirect github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.28.0 // indirect - github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect + github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.8.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -118,6 +118,7 @@ require ( github.com/zondax/hid v0.9.0 // indirect go.etcd.io/bbolt v1.3.6 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect golang.org/x/net v0.0.0-20220617184016-355a448f1bc9 // indirect golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect diff --git a/go.sum b/go.sum index b796f728..6adcbc1b 100644 --- a/go.sum +++ b/go.sum @@ -734,8 +734,8 @@ github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QT github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/line/gorocksdb v0.0.0-20210406043732-d4bea34b6d55/go.mod h1:DHRJroSL7NaRkpvocRx3OtRsleXVsYSxBI9SfHFlTQ0= -github.com/line/lbm-sdk v0.46.0-rc9 h1:DntTpRixOHhAHDLcaPBtPXJm1nS2Jg+LEGDtfwFYeic= -github.com/line/lbm-sdk v0.46.0-rc9/go.mod h1:WRGlX57Np2OUqp+F2LRVDBENGdZWIthNGiKufwkdFbQ= +github.com/line/lbm-sdk v0.46.0-rc10 h1:MzSIWJQbWFaheoRaq2egHTiT24mH8PxmfJUWMBP+98Q= +github.com/line/lbm-sdk v0.46.0-rc10/go.mod h1:EcflA9fjgm8tjuRtr/m5IRagu2p9MynZ3yDKAGCcL/4= github.com/line/ostracon v1.0.7-0.20220906074149-e6ecd80874f8 h1:f4qs+qoF28n+bezpZIPAtbdl36l6hwm7EbrZeOGQZhI= github.com/line/ostracon v1.0.7-0.20220906074149-e6ecd80874f8/go.mod h1:fZk18b2be10fRB4qGM2IyvMIGKuPtBVa8xnPxDg9LRI= github.com/line/tm-db/v2 v2.0.0-init.1.0.20220121012851-61d2bc1d9486 h1:uvXQdcWaUyNsgkXBz375FpQ285WEJaLXhQ5HtoNK/GU= @@ -1047,8 +1047,9 @@ github.com/sagikazarmark/crypt v0.5.0/go.mod h1:l+nzl7KWh51rpzp2h7t4MZWyiEWdhNpO github.com/sagikazarmark/crypt v0.6.0/go.mod h1:U8+INwJo3nBv1m6A/8OBXAq7Jnpspk5AxSgDyEQcea8= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= -github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= +github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0= +github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/seccomp/libseccomp-golang v0.9.2-0.20210429002308-3879420cc921/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg= @@ -1308,8 +1309,9 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5 h1:FR+oGxGfbQu1d+jglI3rCkjAjUnhRSZcUxr+DqlDLNo= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=