config

package
v0.106.1 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: MIT Imports: 17 Imported by: 4

Documentation

Overview

Package config contains NeoGo node configuration definition.

Index

Constants

View Source
const (
	// UserAgentWrapper is a string that user agent string should be wrapped into.
	UserAgentWrapper = "/"
	// UserAgentPrefix is a prefix used to generate user agent string.
	UserAgentPrefix = "NEO-GO:"
	// UserAgentFormat is a formatted string used to generate user agent string.
	UserAgentFormat = UserAgentWrapper + UserAgentPrefix + "%s" + UserAgentWrapper
	// DefaultMaxIteratorResultItems is the default upper bound of traversed
	// iterator items per JSON-RPC response. It covers both session-based and
	// naive iterators.
	DefaultMaxIteratorResultItems = 100
	// DefaultMaxFindResultItems is the default maximum number of resulting
	// contract states items that can be retrieved by `findstates` JSON-RPC handler.
	DefaultMaxFindResultItems = 100
	// DefaultMaxFindStorageResultItems is the default maximum number of resulting
	// contract storage items that can be retrieved by `findstorge` JSON-RPC handler.
	DefaultMaxFindStorageResultItems = 50
	// DefaultMaxNEP11Tokens is the default maximum number of resulting NEP11 tokens
	// that can be traversed by `getnep11balances` JSON-RPC handler.
	DefaultMaxNEP11Tokens = 100
	// DefaultMaxRequestBodyBytes is the default maximum allowed size of HTTP
	// request body in bytes.
	DefaultMaxRequestBodyBytes = 5 * 1024 * 1024
	// DefaultMaxRequestHeaderBytes is the maximum permitted size of the headers
	// in an HTTP request.
	DefaultMaxRequestHeaderBytes = http.DefaultMaxHeaderBytes
)

Variables

View Source
var Hardforks []Hardfork

Hardforks represents the ordered slice of all possible hardforks.

View Source
var Version string

Version is the version of the node, set at the build time.

Functions

func IsHardforkValid added in v0.99.0

func IsHardforkValid(s string) bool

IsHardforkValid denotes whether the provided string represents a valid Hardfork name.

Types

type AnnounceableAddress added in v0.100.0

type AnnounceableAddress struct {
	Address       string
	AnnouncedPort uint16
}

AnnounceableAddress is a pair of node address in the form of "[host]:[port]" with optional corresponding announced port to be used in version exchange.

type ApplicationConfiguration

type ApplicationConfiguration struct {
	Ledger `yaml:",inline"`

	DBConfiguration dbconfig.DBConfiguration `yaml:"DBConfiguration"`

	LogLevel string `yaml:"LogLevel"`
	LogPath  string `yaml:"LogPath"`

	P2P P2P `yaml:"P2P"`

	Pprof      BasicService `yaml:"Pprof"`
	Prometheus BasicService `yaml:"Prometheus"`

	Relay     bool                `yaml:"Relay"`
	Consensus Consensus           `yaml:"Consensus"`
	RPC       RPC                 `yaml:"RPC"`
	Oracle    OracleConfiguration `yaml:"Oracle"`
	P2PNotary P2PNotary           `yaml:"P2PNotary"`
	StateRoot StateRoot           `yaml:"StateRoot"`
}

ApplicationConfiguration config specific to the node.

func (*ApplicationConfiguration) EqualsButServices added in v0.99.2

func (a *ApplicationConfiguration) EqualsButServices(o *ApplicationConfiguration) bool

EqualsButServices returns true when the o is the same as a except for services (Oracle, P2PNotary, Pprof, Prometheus, RPC and StateRoot sections) and LogLevel field.

func (*ApplicationConfiguration) GetAddresses added in v0.100.0

func (a *ApplicationConfiguration) GetAddresses() ([]AnnounceableAddress, error)

GetAddresses parses returns the list of AnnounceableAddress containing information gathered from Addresses.

type BasicService added in v0.99.1

type BasicService struct {
	Enabled bool `yaml:"Enabled"`
	// Addresses holds the list of bind addresses in the form of "address:port".
	Addresses []string `yaml:"Addresses"`
}

BasicService is used as a simple base for node services like Pprof, RPC or Prometheus monitoring.

type Blockchain added in v0.100.0

type Blockchain struct {
	ProtocolConfiguration
	Ledger
}

Blockchain is a set of settings for core.Blockchain to use, it includes protocol settings and local node-specific ones.

type Config

type Config struct {
	ProtocolConfiguration    ProtocolConfiguration    `yaml:"ProtocolConfiguration"`
	ApplicationConfiguration ApplicationConfiguration `yaml:"ApplicationConfiguration"`
}

Config top level struct representing the config for the node.

func Load

func Load(path string, netMode netmode.Magic, relativePath ...string) (Config, error)

Load attempts to load the config from the given path for the given netMode. If relativePath is not empty, relative paths in the config will be updated based on the provided relative path.

func LoadFile added in v0.90.0

func LoadFile(configPath string, relativePath ...string) (Config, error)

LoadFile loads config from the provided path. It also applies backwards compatibility fixups if necessary. If relativePath is not empty, relative paths in the config will be updated based on the provided relative path.

func (Config) Blockchain added in v0.100.0

func (c Config) Blockchain() Blockchain

Blockchain generates a Blockchain configuration based on Protocol and Application settings.

func (Config) GenerateUserAgent

func (c Config) GenerateUserAgent() string

GenerateUserAgent creates a user agent string based on the build time environment.

type Consensus added in v0.100.0

type Consensus InternalService

Consensus contains consensus service configuration.

type Genesis added in v0.103.0

type Genesis struct {
	// Roles contains the set of roles that should be designated during native
	// Designation contract initialization. It is NeoGo extension and must be
	// disabled on the public Neo N3 networks.
	Roles map[noderoles.Role]keys.PublicKeys
	// Transaction contains transaction script that should be deployed in the
	// genesis block. It is NeoGo extension and must be disabled on the public
	// Neo N3 networks.
	Transaction *GenesisTransaction
}

Genesis represents a set of genesis block settings including the extensions enabled in the genesis block or during native contracts initialization.

func (Genesis) MarshalYAML added in v0.103.0

func (e Genesis) MarshalYAML() (any, error)

MarshalYAML implements the YAML marshaler interface.

func (*Genesis) UnmarshalYAML added in v0.103.0

func (e *Genesis) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements the YAML unmarshaler interface.

type GenesisTransaction added in v0.103.0

type GenesisTransaction struct {
	Script    []byte
	SystemFee int64
}

GenesisTransaction is a placeholder for script that should be included into genesis block as a transaction script with the given system fee. Provided system fee value will be taken from the standby validators account which is added to the list of Signers as a sender with CalledByEntry scope.

type Hardfork added in v0.99.0

type Hardfork byte

Hardfork represents the application hard-fork identifier.

const (
	// HFAspidochelone represents hard-fork introduced in #2469 (ported from
	// https://github.com/neo-project/neo/pull/2712) and #2519 (ported from
	// https://github.com/neo-project/neo/pull/2749).
	HFAspidochelone Hardfork = 1 << iota // Aspidochelone
	// HFBasilisk represents hard-fork introduced in #3056 (ported from
	// https://github.com/neo-project/neo/pull/2881), #3080 (ported from
	// https://github.com/neo-project/neo/pull/2883) and #3085 (ported from
	// https://github.com/neo-project/neo/pull/2810).
	HFBasilisk // Basilisk
	// HFCockatrice represents hard-fork introduced in #3402 (ported from
	// https://github.com/neo-project/neo/pull/2942), #3301 (ported from
	// https://github.com/neo-project/neo/pull/2925) and #3362 (ported from
	// https://github.com/neo-project/neo/pull/3154).
	HFCockatrice // Cockatrice

)
const HFDefault Hardfork = 0 // Default

HFDefault is a default value of Hardfork enum. It's a special constant aimed to denote the node code enabled by default starting from the genesis block. HFDefault is not a hard-fork, but this constant can be used for convenient hard-forks comparison and to refer to the default hard-fork-less node behaviour.

func LatestHardfork added in v0.106.0

func LatestHardfork() Hardfork

LatestHardfork returns latest known hardfork.

func (Hardfork) Cmp added in v0.106.0

func (hf Hardfork) Cmp(other Hardfork) int

Cmp returns the result of hardforks comparison. It returns:

-1 if hf <  other
 0 if hf == other
+1 if hf >  other

func (Hardfork) Prev added in v0.106.0

func (hf Hardfork) Prev() Hardfork

Prev returns the previous hardfork for the given one. Calling Prev for the default hardfork is a no-op.

func (Hardfork) String added in v0.99.0

func (i Hardfork) String() string

type InternalService added in v0.100.0

type InternalService struct {
	Enabled      bool   `yaml:"Enabled"`
	UnlockWallet Wallet `yaml:"UnlockWallet"`
}

InternalService stores configuration for internal services that don't have any network configuration, but use a wallet and can be enabled/disabled.

type Ledger added in v0.100.0

type Ledger struct {
	// GarbageCollectionPeriod sets the number of blocks to wait before
	// starting the next MPT garbage collection cycle when RemoveUntraceableBlocks
	// option is used.
	GarbageCollectionPeriod uint32 `yaml:"GarbageCollectionPeriod"`
	// KeepOnlyLatestState specifies if MPT should only store the latest state.
	// If true, DB size will be smaller, but older roots won't be accessible.
	// This value should remain the same for the same database.
	KeepOnlyLatestState bool `yaml:"KeepOnlyLatestState"`
	// RemoveUntraceableBlocks specifies if old data should be removed.
	RemoveUntraceableBlocks bool `yaml:"RemoveUntraceableBlocks"`
	// SaveStorageBatch enables storage batch saving before every persist.
	SaveStorageBatch bool `yaml:"SaveStorageBatch"`
	// SkipBlockVerification allows to disable verification of received
	// blocks (including cryptographic checks).
	SkipBlockVerification bool `yaml:"SkipBlockVerification"`
}

Ledger contains core node-specific settings that are not a part of the ProtocolConfiguration (which is common for every node on the network).

type NeoFSConfiguration added in v0.94.0

type NeoFSConfiguration struct {
	Nodes   []string      `yaml:"Nodes"`
	Timeout time.Duration `yaml:"Timeout"`
}

NeoFSConfiguration is a config for the NeoFS service.

type OracleConfiguration added in v0.93.0

type OracleConfiguration struct {
	Enabled               bool               `yaml:"Enabled"`
	AllowPrivateHost      bool               `yaml:"AllowPrivateHost"`
	AllowedContentTypes   []string           `yaml:"AllowedContentTypes"`
	Nodes                 []string           `yaml:"Nodes"`
	NeoFS                 NeoFSConfiguration `yaml:"NeoFS"`
	MaxTaskTimeout        time.Duration      `yaml:"MaxTaskTimeout"`
	RefreshInterval       time.Duration      `yaml:"RefreshInterval"`
	MaxConcurrentRequests int                `yaml:"MaxConcurrentRequests"`
	RequestTimeout        time.Duration      `yaml:"RequestTimeout"`
	ResponseTimeout       time.Duration      `yaml:"ResponseTimeout"`
	UnlockWallet          Wallet             `yaml:"UnlockWallet"`
}

OracleConfiguration is a config for the oracle module.

type P2P added in v0.100.0

type P2P struct {
	// Addresses stores the node address list in the form of "[host]:[port][:announcedPort]".
	Addresses        []string `yaml:"Addresses"`
	AttemptConnPeers int      `yaml:"AttemptConnPeers"`
	// BroadcastFactor is the factor (0-100) controlling gossip fan-out number optimization.
	BroadcastFactor    int           `yaml:"BroadcastFactor"`
	DialTimeout        time.Duration `yaml:"DialTimeout"`
	ExtensiblePoolSize int           `yaml:"ExtensiblePoolSize"`
	MaxPeers           int           `yaml:"MaxPeers"`
	MinPeers           int           `yaml:"MinPeers"`
	PingInterval       time.Duration `yaml:"PingInterval"`
	PingTimeout        time.Duration `yaml:"PingTimeout"`
	ProtoTickInterval  time.Duration `yaml:"ProtoTickInterval"`
}

P2P holds P2P node settings.

type P2PNotary added in v0.93.0

type P2PNotary InternalService

P2PNotary stores configuration for Notary node service.

type ProtocolConfiguration

type ProtocolConfiguration struct {
	// CommitteeHistory stores committee size change history (height: size).
	CommitteeHistory map[uint32]uint32 `yaml:"CommitteeHistory"`
	// Genesis stores genesis-related settings including a set of NeoGo
	// extensions that should be included into genesis block or be enabled
	// at the moment of native contracts initialization.
	Genesis Genesis `yaml:"Genesis"`

	Magic       netmode.Magic `yaml:"Magic"`
	MemPoolSize int           `yaml:"MemPoolSize"`

	// Hardforks is a map of hardfork names that enables version-specific application
	// logic dependent on the specified height.
	Hardforks map[string]uint32 `yaml:"Hardforks"`
	// InitialGASSupply is the amount of GAS generated in the genesis block.
	InitialGASSupply fixedn.Fixed8 `yaml:"InitialGASSupply"`
	// P2PNotaryRequestPayloadPoolSize specifies the memory pool size for P2PNotaryRequestPayloads.
	// It is valid only if P2PSigExtensions are enabled.
	P2PNotaryRequestPayloadPoolSize int `yaml:"P2PNotaryRequestPayloadPoolSize"`
	// MaxBlockSize is the maximum block size in bytes.
	MaxBlockSize uint32 `yaml:"MaxBlockSize"`
	// MaxBlockSystemFee is the maximum overall system fee per block.
	MaxBlockSystemFee int64 `yaml:"MaxBlockSystemFee"`
	// MaxTraceableBlocks is the length of the chain accessible to smart contracts.
	MaxTraceableBlocks uint32 `yaml:"MaxTraceableBlocks"`
	// MaxTransactionsPerBlock is the maximum amount of transactions per block.
	MaxTransactionsPerBlock uint16 `yaml:"MaxTransactionsPerBlock"`
	// MaxValidUntilBlockIncrement is the upper increment size of blockchain height in blocks
	// exceeding that a transaction should fail validation. It is set to estimated daily number
	// of blocks with 15s interval.
	MaxValidUntilBlockIncrement uint32 `yaml:"MaxValidUntilBlockIncrement"`
	// P2PSigExtensions enables additional signature-related logic.
	P2PSigExtensions bool `yaml:"P2PSigExtensions"`
	// P2PStateExchangeExtensions enables additional P2P MPT state data exchange logic.
	P2PStateExchangeExtensions bool `yaml:"P2PStateExchangeExtensions"`
	// ReservedAttributes allows to have reserved attributes range for experimental or private purposes.
	ReservedAttributes bool `yaml:"ReservedAttributes"`

	SeedList         []string `yaml:"SeedList"`
	StandbyCommittee []string `yaml:"StandbyCommittee"`
	// StateRooInHeader enables storing state root in block header.
	StateRootInHeader bool `yaml:"StateRootInHeader"`
	// StateSyncInterval is the number of blocks between state heights available for MPT state data synchronization.
	// It is valid only if P2PStateExchangeExtensions are enabled.
	StateSyncInterval int `yaml:"StateSyncInterval"`
	// TimePerBlock is the time interval between blocks that consensus nodes work with.
	// It must be an integer number of milliseconds.
	TimePerBlock    time.Duration `yaml:"TimePerBlock"`
	ValidatorsCount uint32        `yaml:"ValidatorsCount"`
	// Validators stores history of changes to consensus node number (height: number).
	ValidatorsHistory map[uint32]uint32 `yaml:"ValidatorsHistory"`
	// Whether to verify transactions in the received blocks.
	VerifyTransactions bool `yaml:"VerifyTransactions"`
}

ProtocolConfiguration represents the protocol config.

func (*ProtocolConfiguration) Equals added in v0.99.2

Equals allows to compare two ProtocolConfiguration instances, returns true if they're equal.

func (*ProtocolConfiguration) GetCommitteeSize added in v0.98.2

func (p *ProtocolConfiguration) GetCommitteeSize(height uint32) int

GetCommitteeSize returns the committee size for the given height. It implies valid configuration file.

func (*ProtocolConfiguration) GetNumOfCNs added in v0.98.2

func (p *ProtocolConfiguration) GetNumOfCNs(height uint32) int

GetNumOfCNs returns the number of validators for the given height. It implies valid configuration file.

func (*ProtocolConfiguration) ShouldUpdateCommitteeAt added in v0.98.2

func (p *ProtocolConfiguration) ShouldUpdateCommitteeAt(height uint32) bool

ShouldUpdateCommitteeAt answers the question of whether the committee should be updated at the given height.

func (*ProtocolConfiguration) Validate added in v0.98.2

func (p *ProtocolConfiguration) Validate() error

Validate checks ProtocolConfiguration for internal consistency and returns an error if anything inappropriate found. Other methods can rely on protocol validity after this.

type RPC added in v0.99.1

type RPC struct {
	BasicService         `yaml:",inline"`
	EnableCORSWorkaround bool `yaml:"EnableCORSWorkaround"`
	// MaxGasInvoke is the maximum amount of GAS which
	// can be spent during an RPC call.
	MaxGasInvoke              fixedn.Fixed8 `yaml:"MaxGasInvoke"`
	MaxIteratorResultItems    int           `yaml:"MaxIteratorResultItems"`
	MaxFindResultItems        int           `yaml:"MaxFindResultItems"`
	MaxFindStorageResultItems int           `yaml:"MaxFindStoragePageSize"`
	MaxNEP11Tokens            int           `yaml:"MaxNEP11Tokens"`
	MaxRequestBodyBytes       int           `yaml:"MaxRequestBodyBytes"`
	MaxRequestHeaderBytes     int           `yaml:"MaxRequestHeaderBytes"`
	MaxWebSocketClients       int           `yaml:"MaxWebSocketClients"`
	SessionEnabled            bool          `yaml:"SessionEnabled"`
	SessionExpirationTime     int           `yaml:"SessionExpirationTime"`
	SessionBackedByMPT        bool          `yaml:"SessionBackedByMPT"`
	SessionPoolSize           int           `yaml:"SessionPoolSize"`
	StartWhenSynchronized     bool          `yaml:"StartWhenSynchronized"`
	TLSConfig                 TLS           `yaml:"TLSConfig"`
}

RPC is an RPC service configuration information.

type StateRoot added in v0.94.0

type StateRoot InternalService

StateRoot contains state root service configuration.

type TLS added in v0.99.1

type TLS struct {
	BasicService `yaml:",inline"`
	CertFile     string `yaml:"CertFile"`
	KeyFile      string `yaml:"KeyFile"`
}

TLS describes SSL/TLS configuration.

type Wallet added in v0.90.0

type Wallet struct {
	Path     string `yaml:"Path"`
	Password string `yaml:"Password"`
}

Wallet is a wallet info.

Directories

Path Synopsis
Package limits contains a number of system-wide hardcoded constants.
Package limits contains a number of system-wide hardcoded constants.
Package netmode contains well-known network magic numbers.
Package netmode contains well-known network magic numbers.

Jump to

Keyboard shortcuts

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