forked from cerc-io/laconicd-deprecated
update from fork
This commit is contained in:
+18
-3
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package config
|
||||
|
||||
import (
|
||||
@@ -20,13 +35,13 @@ const (
|
||||
DefaultGRPCAddress = "0.0.0.0:9900"
|
||||
|
||||
// DefaultJSONRPCAddress is the default address the JSON-RPC server binds to.
|
||||
DefaultJSONRPCAddress = "0.0.0.0:8545"
|
||||
DefaultJSONRPCAddress = "127.0.0.1:8545"
|
||||
|
||||
// DefaultJSONRPCWsAddress is the default address the JSON-RPC WebSocket server binds to.
|
||||
DefaultJSONRPCWsAddress = "0.0.0.0:8546"
|
||||
DefaultJSONRPCWsAddress = "127.0.0.1:8546"
|
||||
|
||||
// DefaultJsonRPCMetricsAddress is the default address the JSON-RPC Metrics server binds to.
|
||||
DefaultJSONRPCMetricsAddress = "0.0.0.0:6065"
|
||||
DefaultJSONRPCMetricsAddress = "127.0.0.1:6065"
|
||||
|
||||
// DefaultEVMTracer is the default vm.Tracer type
|
||||
DefaultEVMTracer = ""
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package config
|
||||
|
||||
// DefaultConfigTemplate defines the configuration template for the EVM RPC configuration
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package flags
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package server
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package server
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package server
|
||||
|
||||
import (
|
||||
|
||||
+45
-12
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package server
|
||||
|
||||
import (
|
||||
@@ -47,7 +62,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/cerc-io/laconicd/gql"
|
||||
|
||||
"github.com/cerc-io/laconicd/indexer"
|
||||
ethdebug "github.com/cerc-io/laconicd/rpc/namespaces/ethereum/debug"
|
||||
"github.com/cerc-io/laconicd/server/config"
|
||||
@@ -55,9 +69,28 @@ import (
|
||||
ethermint "github.com/cerc-io/laconicd/types"
|
||||
)
|
||||
|
||||
// DBOpener is a function to open `application.db`, potentially with customized options.
|
||||
type DBOpener func(opts types.AppOptions, rootDir string, backend dbm.BackendType) (dbm.DB, error)
|
||||
|
||||
// StartOptions defines options that can be customized in `StartCmd`
|
||||
type StartOptions struct {
|
||||
AppCreator types.AppCreator
|
||||
DefaultNodeHome string
|
||||
DBOpener DBOpener
|
||||
}
|
||||
|
||||
// NewDefaultStartOptions use the default db opener provided in tm-db.
|
||||
func NewDefaultStartOptions(appCreator types.AppCreator, defaultNodeHome string) StartOptions {
|
||||
return StartOptions{
|
||||
AppCreator: appCreator,
|
||||
DefaultNodeHome: defaultNodeHome,
|
||||
DBOpener: openDB,
|
||||
}
|
||||
}
|
||||
|
||||
// StartCmd runs the service passed in, either stand-alone or in-process with
|
||||
// Tendermint.
|
||||
func StartCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command {
|
||||
func StartCmd(opts StartOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Run the full node",
|
||||
@@ -106,7 +139,7 @@ which accepts a path for the resulting pprof file.
|
||||
withTM, _ := cmd.Flags().GetBool(srvflags.WithTendermint)
|
||||
if !withTM {
|
||||
serverCtx.Logger.Info("starting ABCI without Tendermint")
|
||||
return startStandAlone(serverCtx, appCreator)
|
||||
return startStandAlone(serverCtx, opts)
|
||||
}
|
||||
|
||||
serverCtx.Logger.Info("Unlocking keyring")
|
||||
@@ -123,7 +156,7 @@ which accepts a path for the resulting pprof file.
|
||||
serverCtx.Logger.Info("starting ABCI with Tendermint")
|
||||
|
||||
// amino is needed here for backwards compatibility of REST routes
|
||||
err = startInProcess(serverCtx, clientCtx, appCreator)
|
||||
err = startInProcess(serverCtx, clientCtx, opts)
|
||||
errCode, ok := err.(server.ErrorCode)
|
||||
if !ok {
|
||||
return err
|
||||
@@ -134,7 +167,7 @@ which accepts a path for the resulting pprof file.
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().String(flags.FlagHome, defaultNodeHome, "The application home directory")
|
||||
cmd.Flags().String(flags.FlagHome, opts.DefaultNodeHome, "The application home directory")
|
||||
cmd.Flags().Bool(srvflags.WithTendermint, true, "Run abci app embedded in-process with tendermint")
|
||||
cmd.Flags().String(srvflags.Address, "tcp://0.0.0.0:26658", "Listen address")
|
||||
cmd.Flags().String(srvflags.Transport, "socket", "Transport protocol: socket, grpc")
|
||||
@@ -193,12 +226,12 @@ which accepts a path for the resulting pprof file.
|
||||
return cmd
|
||||
}
|
||||
|
||||
func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
|
||||
func startStandAlone(ctx *server.Context, opts StartOptions) error {
|
||||
addr := ctx.Viper.GetString(srvflags.Address)
|
||||
transport := ctx.Viper.GetString(srvflags.Transport)
|
||||
home := ctx.Viper.GetString(flags.FlagHome)
|
||||
|
||||
db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
|
||||
db, err := opts.DBOpener(ctx.Viper, home, server.GetAppDBBackend(ctx.Viper))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -215,7 +248,7 @@ func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
|
||||
return err
|
||||
}
|
||||
|
||||
app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
|
||||
app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper)
|
||||
|
||||
config, err := config.GetConfig(ctx.Viper)
|
||||
if err != nil {
|
||||
@@ -256,7 +289,7 @@ func startStandAlone(ctx *server.Context, appCreator types.AppCreator) error {
|
||||
}
|
||||
|
||||
// legacyAminoCdc is used for the legacy REST API
|
||||
func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator types.AppCreator) (err error) {
|
||||
func startInProcess(ctx *server.Context, clientCtx client.Context, opts StartOptions) (err error) {
|
||||
cfg := ctx.Config
|
||||
home := cfg.RootDir
|
||||
logger := ctx.Logger
|
||||
@@ -287,7 +320,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
|
||||
}()
|
||||
}
|
||||
|
||||
db, err := openDB(home, server.GetAppDBBackend(ctx.Viper))
|
||||
db, err := opts.DBOpener(ctx.Viper, home, server.GetAppDBBackend(ctx.Viper))
|
||||
if err != nil {
|
||||
logger.Error("failed to open DB", "error", err.Error())
|
||||
return err
|
||||
@@ -317,7 +350,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
|
||||
return err
|
||||
}
|
||||
|
||||
app := appCreator(ctx.Logger, db, traceWriter, ctx.Viper)
|
||||
app := opts.AppCreator(ctx.Logger, db, traceWriter, ctx.Viper)
|
||||
|
||||
nodeKey, err := p2p.LoadOrGenNodeKey(cfg.NodeKeyFile())
|
||||
if err != nil {
|
||||
@@ -615,7 +648,7 @@ func startInProcess(ctx *server.Context, clientCtx client.Context, appCreator ty
|
||||
return server.WaitForQuitSignals()
|
||||
}
|
||||
|
||||
func openDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error) {
|
||||
func openDB(_ types.AppOptions, rootDir string, backendType dbm.BackendType) (dbm.DB, error) {
|
||||
dataDir := filepath.Join(rootDir, "data")
|
||||
return dbm.NewDB("application", backendType, dataDir)
|
||||
}
|
||||
|
||||
+19
-5
@@ -1,3 +1,18 @@
|
||||
// Copyright 2021 Evmos Foundation
|
||||
// This file is part of Evmos' Ethermint library.
|
||||
//
|
||||
// The Ethermint library is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// The Ethermint library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with the Ethermint library. If not, see https://github.com/evmos/ethermint/blob/main/LICENSE
|
||||
package server
|
||||
|
||||
import (
|
||||
@@ -23,8 +38,7 @@ import (
|
||||
// AddCommands adds server commands
|
||||
func AddCommands(
|
||||
rootCmd *cobra.Command,
|
||||
defaultNodeHome string,
|
||||
appCreator types.AppCreator,
|
||||
opts StartOptions,
|
||||
appExport types.AppExporter,
|
||||
addStartFlags types.ModuleInitFlags,
|
||||
) {
|
||||
@@ -42,15 +56,15 @@ func AddCommands(
|
||||
tmcmd.ResetStateCmd,
|
||||
)
|
||||
|
||||
startCmd := StartCmd(appCreator, defaultNodeHome)
|
||||
startCmd := StartCmd(opts)
|
||||
addStartFlags(startCmd)
|
||||
|
||||
rootCmd.AddCommand(
|
||||
startCmd,
|
||||
tendermintCmd,
|
||||
sdkserver.ExportCmd(appExport, defaultNodeHome),
|
||||
sdkserver.ExportCmd(appExport, opts.DefaultNodeHome),
|
||||
version.NewVersionCommand(),
|
||||
sdkserver.NewRollbackCmd(appCreator, defaultNodeHome),
|
||||
sdkserver.NewRollbackCmd(opts.AppCreator, opts.DefaultNodeHome),
|
||||
|
||||
// custom tx indexer command
|
||||
NewIndexTxCmd(),
|
||||
|
||||
Reference in New Issue
Block a user