Documentation
¶
Index ¶
Constants ¶
const ( DefaultHTTPHost = "localhost" // Default host interface for the HTTP RPC server DefaultHTTPPort = 8545 // Default TCP port for the HTTP RPC server DefaultWSHost = "localhost" // Default host interface for the websocket RPC server DefaultWSPort = 8546 // Default TCP port for the websocket RPC server )
Variables ¶
var (
DefaultDataDir = defaultHomeDir()
)
var DefaultRpcConfig = RpcConfig{ DataDir: DefaultDataDir, HTTPHost: "localhost", HTTPPort: DefaultHTTPPort, HTTPModules: []string{"net", "web3"}, HTTPVirtualHosts: []string{"localhost"}, HTTPTimeouts: rpc.DefaultHTTPTimeouts, WSHost: "localhost", WSPort: DefaultWSPort, WSModules: []string{"net", "web3"}, }
DefaultRpcConfig contains reasonable default settings.
Functions ¶
func DefaultHTTPEndpoint ¶
func DefaultHTTPEndpoint() string
DefaultHTTPEndpoint returns the HTTP endpoint used by default.
func DefaultIPCEndpoint ¶
DefaultIPCEndpoint returns the IPC path used by default.
func DefaultWSEndpoint ¶
func DefaultWSEndpoint() string
DefaultWSEndpoint returns the websocket endpoint used by default.
Types ¶
type BaseConfig ¶
type BaseConfig struct {
// Top-level directory of evm-lachesis data
DataDir string `mapstructure:"datadir"`
// Debug, info, warn, error, fatal, panic
LogLevel string `mapstructure:"log"`
}
BaseConfig contains the top level configuration for an EVM-Lachesis node
func DefaultBaseConfig ¶
func DefaultBaseConfig() BaseConfig
DefaultBaseConfig returns the default top-level configuration for EVM-Lachesis
type Config ¶
type Config struct {
// Top level options use an anonymous struct
BaseConfig `mapstructure:",squash"`
// Options for EVM and State
Eth *EthConfig `mapstructure:"eth"`
// Options for Lachesis consensus
Lachesis *LachesisConfig `mapstructure:"lachesis"`
// Options for Raft consensus
Raft *RaftConfig `mapstructure:"raft"`
ProxyAddr string `mapstructure:"proxy"`
ClientAddr string `mapstructure:"client-connect"`
Standalone bool `mapstructure:"standalone"`
}
Config contains de configuration for an EVM-Lite node
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default configuration for an EVM-Lite node
func (*Config) SetDataDir ¶
SetDataDir updates the root data directory as well as the various lower config for eth and consensus
type EthConfig ¶
type EthConfig struct {
// Genesis file
Genesis string `mapstructure:"genesis"`
// Location of ethereum account keys
Keystore string `mapstructure:"keystore"`
// File containing passwords to unlock ethereum accounts
PwdFile string `mapstructure:"pwd"`
// File containing the levelDB database
DbFile string `mapstructure:"db"`
// Address of HTTP API Service
EthAPIAddr string `mapstructure:"listen"`
// Megabytes of memory allocated to internal caching (min 16MB / database forced)
Cache int `mapstructure:"cache"`
}
EthConfig contains the configuration relative to the accounts, EVM, trie/db, and service API
func DefaultEthConfig ¶
func DefaultEthConfig() *EthConfig
DefaultEthConfig return the default configuration for Eth services
func (*EthConfig) SetDataDir ¶
SetDataDir updates the eth configuration directories if they were set to default values.
type LachesisConfig ¶
type LachesisConfig struct {
// Directory containing priv_key.pem and peers.json files
DataDir string `mapstructure:"datadir"`
// Address of Lachesis node (where it talks to other Lachesis nodes)
BindAddr string `mapstructure:"listen"`
// Lachesis HTTP API address
ServiceAddr string `mapstructure:"service-listen"`
// Gossip heartbeat
Heartbeat time.Duration `mapstructure:"heartbeat"`
// TCP timeout
TCPTimeout time.Duration `mapstructure:"timeout"`
// Max number of items in caches
CacheSize int `mapstructure:"cache-size"`
// Max number of Event in SyncResponse
SyncLimit int64 `mapstructure:"sync-limit"`
// Max number of connections in net pool
MaxPool int `mapstructure:"max-pool"`
// Database type; badger or inmeum
Store bool `mapstructure:"store"`
}
LachesisConfig contains the configuration of a Lachesis node
func DefaultLachesisConfig ¶
func DefaultLachesisConfig() *LachesisConfig
DefaultLachesisConfig returns the default configuration for a Lachesis node
func (*LachesisConfig) SetDataDir ¶
func (c *LachesisConfig) SetDataDir(datadir string)
SetDataDir updates the lachesis configuration directories if they were set to to default values.
func (*LachesisConfig) ToRealLachesisConfig ¶
func (c *LachesisConfig) ToRealLachesisConfig(logger *logrus.Logger) *_lachesis.LachesisConfig
ToRealLachesisConfig converts an evm/src/config.LachesisConfig to a lachesis/src/lachesis.LachesisConfig as used by Lachesis
type RaftConfig ¶
type RaftConfig struct {
// ProtocolVersion allows a Raft server to inter-operate with older
// Raft servers running an older version of the code. This is used to
// version the wire protocol as well as Raft-specific log entries that
// the server uses when _speaking_ to other servers. There is currently
// no auto-negotiation of versions so all servers must be manually
// configured with compatible versions. See ProtocolVersionMin and
// ProtocolVersionMax for the versions of the protocol that this server
// can _understand_.
ProtocolVersion _raft.ProtocolVersion `mapstructure:"protocol_version"`
// HeartbeatTimeout specifies the time in follower state without
// a leader before we attempt an election.
HeartbeatTimeout time.Duration `mapstructure:"heartbeat"`
// ElectionTimeout specifies the time in candidate state without
// a leader before we attempt an election.
ElectionTimeout time.Duration `mapstructure:"election_timeout"`
// CommitTimeout controls the time without an Apply() operation
// before we heartbeat to ensure a timely commit. Due to random
// staggering, may be delayed as much as 2x this value.
CommitTimeout time.Duration `mapstructure:"commit_timeout"`
// MaxAppendEntries controls the maximum number of append entries
// to send at once. We want to strike a balance between efficiency
// and avoiding waste if the follower is going to reject because of
// an inconsistent log.
MaxAppendEntries int `mapstructure:"max_append_entries"`
// If we are a member of a cluster, and RemovePeer is invoked for the
// local node, then we forget all peers and transition into the follower state.
// If ShutdownOnRemove is is set, we additional shutdown Raft. Otherwise,
// we can become a leader of a cluster containing only this node.
ShutdownOnRemove bool `mapstructure:"shutdown_on_remove"`
// TrailingLogs controls how many logs we leave after a snapshot. This is
// used so that we can quickly replay logs on a follower instead of being
// forced to send an entire snapshot.
TrailingLogs uint64 `mapstructure:"trailing_logs"`
// SnapshotInterval controls how often we check if we should perform a snapshot.
// We randomly stagger between this value and 2x this value to avoid the entire
// cluster from performing a snapshot at once.
SnapshotInterval time.Duration `mapstructure:"snapshot_interval"`
// SnapshotThreshold controls how many outstanding logs there must be before
// we perform a snapshot. This is to prevent excessive snapshots when we can
// just replay a small set of logs.
SnapshotThreshold uint64 `mapstructure:"snapshot_threshold"`
// LeaderLeaseTimeout is used to control how long the "lease" lasts
// for being the leader without being able to contact a quorum
// of nodes. If we reach this interval without contact, we will
// step down as leader.
LeaderLeaseTimeout time.Duration `mapstructure:"leader_lease_timeout"`
// StartAsLeader forces Raft to start in the leader state. This should
// never be used except for testing purposes, as it can cause a split-brain.
StartAsLeader bool `mapstructure:"start_as_leader"`
// The unique ID for this server across all time. When running with
// ProtocolVersion < 3, you must set this to be the same as the network
// address of your transport.
LocalID _raft.ServerID `mapstructure:"server-id"`
RaftDir string `mapstructure:"dir"`
SnapshotDir string `mapstructure:"snapshot-dir"`
NodeAddr string `mapstructure:"node-addr"`
}
RaftConfig contains the configuration of a Raft node
func DefaultRaftConfig ¶
func DefaultRaftConfig() *RaftConfig
DefaultRaftConfig returns the default configuration for a Raft node
func (*RaftConfig) SetDataDir ¶
func (c *RaftConfig) SetDataDir(datadir string)
SetDataDir updates the raft configuration directories if they were set to default values
type RpcConfig ¶
type RpcConfig struct {
// Name sets the instance name of the node. It must not contain the / character and is
// used in the devp2p node identifier. The instance name of geth is "geth". If no
// value is specified, the basename of the current executable is used.
Name string `toml:"-"`
// UserIdent, if set, is used as an additional component in the devp2p node identifier.
UserIdent string `toml:",omitempty"`
// Version should be set to the version number of the program. It is used
// in the devp2p node identifier.
Version string `toml:"-"`
// DataDir is the file system folder the node should use for any data storage
// requirements. The configured data directory will not be directly shared with
// registered services, instead those can use utility methods to create/access
// databases or flat files. This enables ephemeral nodes which can fully reside
// in memory.
DataDir string
// IPCPath is the requested location to place the IPC endpoint. If the path is
// a simple file name, it is placed inside the data directory (or on the root
// pipe path on Windows), whereas if it's a resolvable path name (absolute or
// relative), then that specific path is enforced. An empty path disables IPC.
IPCPath string `toml:",omitempty"`
// HTTPHost is the host interface on which to start the HTTP RPC server. If this
// field is empty, no HTTP API endpoint will be started.
HTTPHost string `toml:",omitempty"`
// HTTPPort is the TCP port number on which to start the HTTP RPC server. The
// default zero value is/ valid and will pick a port number randomly (useful
// for ephemeral nodes).
HTTPPort int `toml:",omitempty"`
// HTTPCors is the Cross-Origin Resource Sharing header to send to requesting
// clients. Please be aware that CORS is a browser enforced security, it's fully
// useless for custom HTTP clients.
HTTPCors []string `toml:",omitempty"`
// HTTPVirtualHosts is the list of virtual hostnames which are allowed on incoming requests.
// This is by default {'localhost'}. Using this prevents attacks like
// DNS rebinding, which bypasses SOP by simply masquerading as being within the same
// origin. These attacks do not utilize CORS, since they are not cross-domain.
// By explicitly checking the Host-header, the server will not allow requests
// made against the server with a malicious host domain.
// Requests using ip address directly are not affected
HTTPVirtualHosts []string `toml:",omitempty"`
// HTTPModules is a list of API modules to expose via the HTTP RPC interface.
// If the module list is empty, all RPC API endpoints designated public will be
// exposed.
HTTPModules []string `toml:",omitempty"`
// HTTPTimeouts allows for customization of the timeout values used by the HTTP RPC
// interface.
HTTPTimeouts rpc.HTTPTimeouts
// WSHost is the host interface on which to start the websocket RPC server. If
// this field is empty, no websocket API endpoint will be started.
WSHost string `toml:",omitempty"`
// WSPort is the TCP port number on which to start the websocket RPC server. The
// default zero value is/ valid and will pick a port number randomly (useful for
// ephemeral nodes).
WSPort int `toml:",omitempty"`
// WSOrigins is the list of domain to accept websocket requests from. Please be
// aware that the server can only act upon the HTTP request the client sends and
// cannot verify the validity of the request header.
WSOrigins []string `toml:",omitempty"`
// WSModules is a list of API modules to expose via the websocket RPC interface.
// If the module list is empty, all RPC API endpoints designated public will be
// exposed.
WSModules []string `toml:",omitempty"`
// WSExposeAll exposes all API modules via the WebSocket RPC interface rather
// than just the public ones.
//
// *WARNING* Only set this if the node is running in a trusted network, exposing
// private APIs to untrusted users is a major security risk.
WSExposeAll bool `toml:",omitempty"`
}
RpcConfig represents a small collection of configuration values to fine tune RPC TODO: change toml to mapstructure like congig.Config, apply main config policy
func (*RpcConfig) HTTPEndpoint ¶
HTTPEndpoint resolves an HTTP endpoint based on the configured host interface and port parameters.
func (*RpcConfig) IPCEndpoint ¶
IPCEndpoint resolves an IPC endpoint based on a configured value, taking into account the set data folders as well as the designated platform we're currently running on.
func (*RpcConfig) ResolvePath ¶
ResolvePath resolves path in the instance directory.
func (*RpcConfig) WSEndpoint ¶
WSEndpoint resolves a websocket endpoint based on the configured host interface and port parameters.