server

package
v0.0.0-...-bf46863 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 72 Imported by: 0

Documentation

Overview

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

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

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

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

Index

Constants

View Source
const (
	FlagHeight           = "height"
	FlagForZeroHeight    = "for-zero-height"
	FlagJailAllowedAddrs = "jail-allowed-addrs"
)
View Source
const (
	ServiceName = "EVMIndexerService"

	NewBlockWaitTimeout = 60 * time.Second
)
View Source
const (
	FlagMinGasPrices       = "minimum-gas-prices"
	FlagHaltHeight         = "halt-height"
	FlagHaltTime           = "halt-time"
	FlagInterBlockCache    = "inter-block-cache"
	FlagUnsafeSkipUpgrades = "unsafe-skip-upgrades"
	FlagTrace              = "trace"
	FlagProfile            = "profile"
	FlagInvCheckPeriod     = "inv-check-period"

	FlagPruning            = "pruning"
	FlagPruningKeepRecent  = "pruning-keep-recent"
	FlagPruningKeepEvery   = "pruning-keep-every"
	FlagPruningInterval    = "pruning-interval"
	FlagIndexEvents        = "index-events"
	FlagMinRetainBlocks    = "min-retain-blocks"
	FlagIAVLCacheSize      = "iavl-cache-size"
	FlagIAVLFastNode       = "iavl-disable-fastnode"
	FlagCompactionInterval = "compaction-interval"
	FlagNoVersioning       = "no-versioning"

	// state sync-related flags
	FlagStateSyncSnapshotInterval   = "state-sync.snapshot-interval"
	FlagStateSyncSnapshotKeepRecent = "state-sync.snapshot-keep-recent"

	// archival related flags
	FlagArchivalVersion                = "archival-version"
	FlagArchivalDBType                 = "archival-db-type"
	FlagArchivalArweaveIndexDBFullPath = "archival-arweave-index-db-full-path"
	FlagArchivalArweaveNodeURL         = "archival-arweave-node-url"

	// chain info
	FlagChainID = "chain-id"
)
View Source
const RestartErrorCode = 100

Error code reserved for signalled

View Source
const ServerContextKey = sdk.ContextKey("server.context")

ServerContextKey defines the context key used to retrieve a server.Context from a command's Context.

Variables

This section is empty.

Functions

func AddCommands

func AddCommands(
	rootCmd *cobra.Command,
	defaultNodeHome string,
	appCreator types.AppCreator,
	appExport types.AppExporter,
	addStartFlags types.ModuleInitFlags,
	tracerProviderOptions []trace.TracerProviderOption,
)

add server commands

func ConnectTmWS

func ConnectTmWS(tmRPCAddr, tmEndpoint string, logger tmlog.Logger) *rpcclient.WSClient

func DefaultDBProvider

func DefaultDBProvider(ctx *DBContext) (dbm.DB, error)

DefaultDBProvider returns a database using the DBBackend and DBDir specified in the ctx.Config.

func ExportCmd

func ExportCmd(appExporter types.AppExporter, defaultNodeHome string) *cobra.Command

ExportCmd dumps app state to JSON.

func ExternalIP

func ExternalIP() (string, error)

https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go TODO there must be a better way to get external IP

func GetAppDBBackend

func GetAppDBBackend(opts types.AppOptions) dbm.BackendType

GetAppDBBackend gets the backend type to use for the application DBs.

func GetPruningOptionsFromFlags

func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOptions, error)

GetPruningOptionsFromFlags parses command flags and returns the correct PruningOptions. If a pruning strategy is provided, that will be parsed and returned, otherwise, it is assumed custom pruning options are provided.

func GetServerContextFromCmd

func GetServerContextFromCmd(cmd *cobra.Command) *server.Context

GetServerContextFromCmd returns a Context from a command or an empty Context if it has not been set.

func InterceptConfigs

func InterceptConfigs(cmd *cobra.Command) (*tmcfg.Config, error)

func InterceptConfigsPreRunHandler

func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate string, customAppConfig interface{}) error

InterceptConfigsPreRunHandler performs a pre-run function for the root daemon application command. It will create a Viper literal and a default server Context. The server Tendermint configuration will either be read and parsed or created and saved to disk, where the server Context is updated to reflect the Tendermint configuration. It takes custom app config template and config settings to create a custom Tendermint configuration. If the custom template is empty, it uses default-template provided by the server. The Viper literal is used to read and parse the application configuration. Command handlers can fetch the server Context to get the Tendermint configuration or to get access to Viper.

func LatestVersionCmd

func LatestVersionCmd(defaultNodeHome string) *cobra.Command

LatestVersionCmd returns the latest version of the application DB

func Listen

func Listen(addr string, config *config.Config) (net.Listener, error)

Listen starts a net.Listener on the tcp network on the given address. If there is a specified MaxOpenConnections in the config, it will also set the limitListener.

func MountGRPCWebServices

func MountGRPCWebServices(
	router *mux.Router,
	grpcWeb *grpcweb.WrappedGrpcServer,
	grpcResources []string,
	logger tmlog.Logger,
)

func NewContext

func NewContext(v *viper.Viper, config *tmcfg.Config, logger tmlog.Logger) *server.Context

func NewDefaultContext

func NewDefaultContext() *server.Context

func NewIndexTxCmd

func NewIndexTxCmd() *cobra.Command

func NewRollbackCmd

func NewRollbackCmd(appCreator types.AppCreator, defaultNodeHome string) *cobra.Command

NewRollbackCmd creates a command to rollback tendermint and multistore state by one height.

func OpenDB

func OpenDB(rootDir string) (dbm.DB, error)

func OpenIndexerDB

func OpenIndexerDB(rootDir string, backendType dbm.BackendType) (dbm.DB, error)

OpenIndexerDB opens the custom eth indexer db, using the same db backend as the main app

func SetCmdServerContext

func SetCmdServerContext(cmd *cobra.Command, serverCtx *server.Context) error

SetCmdServerContext sets a command's Context value to the provided argument.

func ShowAddressCmd

func ShowAddressCmd() *cobra.Command

ShowAddressCmd - show this node's validator address

func ShowNodeIDCmd

func ShowNodeIDCmd() *cobra.Command

ShowNodeIDCmd - ported from Tendermint, dump node ID to stdout

func ShowValidatorCmd

func ShowValidatorCmd() *cobra.Command

ShowValidatorCmd - ported from Tendermint, show this node's validator info

func StartCmd

func StartCmd(appCreator types.AppCreator, defaultNodeHome string, tracerProviderOptions []trace.TracerProviderOption) *cobra.Command

StartCmd runs the service passed in, either stand-alone or in-process with Tendermint.

func StartJSONRPC

func StartJSONRPC(ctx *servercosmos.Context,
	clientCtx client.Context,
	tmRPCAddr,
	tmEndpoint string,
	config *config.Config,
	indexer ethermint.EVMTxIndexer,
) (*http.Server, chan struct{}, error)

StartJSONRPC starts the JSON-RPC server

func StartJSONRPCInProcess

func StartJSONRPCInProcess(ctx *servercosmos.Context,
	clientCtx client.Context) (err error)

StartJSONRPCInProcess 添加 JSON-RPC 接口

func TrapSignal

func TrapSignal(cleanupFunc func())

TrapSignal traps SIGINT and SIGTERM and terminates the server correctly.

func VersionCmd

func VersionCmd() *cobra.Command

VersionCmd prints tendermint and ABCI version numbers.

Types

type DBContext

type DBContext struct {
	ID     string
	Config *tmcfg.Config
}

DBContext specifies config information for loading a new DB.

type EVMIndexerService

type EVMIndexerService struct {
	service.BaseService

	Logger log.Logger
	// contains filtered or unexported fields
}

EVMIndexerService indexes transactions for json-rpc service.

func NewEVMIndexerService

func NewEVMIndexerService(
	txIdxr ethermint.EVMTxIndexer,
	client rpcclient.Client,
) *EVMIndexerService

NewEVMIndexerService returns a new service instance.

func (*EVMIndexerService) OnStart

func (eis *EVMIndexerService) OnStart(ctx context.Context) error

OnStart implements service.Service by subscribing for new blocks and indexing them by events.

func (*EVMIndexerService) OnStop

func (eis *EVMIndexerService) OnStop()

func (*EVMIndexerService) SetLogger

func (eis *EVMIndexerService) SetLogger(l log.Logger)

SetLogger implements Service by setting a logger.

type ErrorCode

type ErrorCode struct {
	Code int
}

ErrorCode contains the exit code for server exit.

func WaitForQuitSignals

func WaitForQuitSignals(ctx *server.Context, restartCh chan struct{}, canRestartAfter time.Time) ErrorCode

WaitForQuitSignals waits for SIGINT and SIGTERM and returns.

func (ErrorCode) Error

func (e ErrorCode) Error() string

type GenesisDocProvider

type GenesisDocProvider func() (*tmtypes.GenesisDoc, error)

GenesisDocProvider returns a GenesisDoc. It allows the GenesisDoc to be pulled from sources other than the filesystem, for instance from a distributed key-value store cluster.

func DefaultGenesisDocProviderFunc

func DefaultGenesisDocProviderFunc(config *tmcfg.Config) GenesisDocProvider

DefaultGenesisDocProviderFunc returns a GenesisDocProvider that loads the GenesisDoc from the config.GenesisFile() on the filesystem.

type ZeroLogWrapper

type ZeroLogWrapper struct {
	zerolog.Logger
}

ZeroLogWrapper provides a wrapper around a zerolog.Logger instance. It implements Tendermint's Logger interface.

func (ZeroLogWrapper) Debug

func (z ZeroLogWrapper) Debug(msg string, keyVals ...interface{})

Debug implements Tendermint's Logger interface and logs with level DEBUG. A set of key/value tuples may be provided to add context to the log. The number of tuples must be even and the key of the tuple must be a string.

func (ZeroLogWrapper) Error

func (z ZeroLogWrapper) Error(msg string, keyVals ...interface{})

Error implements Tendermint's Logger interface and logs with level ERR. A set of key/value tuples may be provided to add context to the log. The number of tuples must be even and the key of the tuple must be a string.

func (ZeroLogWrapper) Info

func (z ZeroLogWrapper) Info(msg string, keyVals ...interface{})

Info implements Tendermint's Logger interface and logs with level INFO. A set of key/value tuples may be provided to add context to the log. The number of tuples must be even and the key of the tuple must be a string.

func (ZeroLogWrapper) With

func (z ZeroLogWrapper) With(keyVals ...interface{}) tmlog.Logger

With returns a new wrapped logger with additional context provided by a set of key/value tuples. The number of tuples must be even and the key of the tuple must be a string.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL