Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultLogLevel() string
- func DefaultPackageLogLevels() string
- func DefaultRotateConfig() *log.RotateConfig
- func EnsureRoot(rootDir string, config *Config)
- func TestRotateConfig() *log.RotateConfig
- func WriteConfigFile(configFilePath string, config *Config)
- type BaseConfig
- type BootNodeConfig
- type Config
- type ConsensusConfig
- func (cfg *ConsensusConfig) Commit(t time.Time) time.Time
- func (cfg *ConsensusConfig) EmptyBlocksInterval() time.Duration
- func (cfg *ConsensusConfig) PeerGossipSleep() time.Duration
- func (cfg *ConsensusConfig) PeerQueryMaj23Sleep() time.Duration
- func (cfg *ConsensusConfig) Precommit(round int) time.Duration
- func (cfg *ConsensusConfig) Prevote(round int) time.Duration
- func (cfg *ConsensusConfig) Propose(round int) time.Duration
- func (cfg *ConsensusConfig) SetWalFile(walFile string)
- func (cfg *ConsensusConfig) WaitForTxs() bool
- func (cfg *ConsensusConfig) WalFile() string
- type FuzzConnConfig
- type GasTable
- type InstrumentationConfig
- type MempoolConfig
- type P2PConfig
- type RPCConfig
Constants ¶
const ( // FuzzModeDrop is a mode in which we randomly drop reads/writes, connections or sleep FuzzModeDrop = iota // FuzzModeDelay is a mode in which we randomly sleep FuzzModeDelay )
const ( Wei = 1 Ada = 1e3 Babbage = 1e6 Shannon = 1e9 Szabo = 1e12 Finney = 1e15 Ether = 1e18 Einstein = 1e21 Douglas = 1e42 )
These are the multipliers for ether denominations. Example: To get the wei value of an amount in 'douglas', use
new(big.Int).Mul(value, big.NewInt(params.Douglas))
const ( GasLimitBoundDivisor uint64 = 1024 // The bound divisor of the gas limit, used in update calculations. MinGasLimit uint64 = 5000 // Minimum the gas limit may ever be. GenesisGasLimit uint64 = 4712388 // Gas limit of the Genesis block. MaximumExtraDataSize uint64 = 32 // Maximum size extra data may be after Genesis. ExpByteGas uint64 = 10 // Times ceil(log256(exponent)) for the EXP instruction. SloadGas uint64 = 50 // Multiplied by the number of 32-byte words that are copied (round up) for any *COPY operation and added. CallValueTransferGas uint64 = 9000 // Paid for CALL when the value transfer is non-zero. CallNewAccountGas uint64 = 25000 // Paid for CALL when the destination address didn't exist prior. TxGas uint64 = 21000 // Per transaction not creating a contract. NOTE: Not payable on data of calls between transactions. TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract. NOTE: Not payable on data of calls between transactions. TxDataZeroGas uint64 = 4 // Per byte of data attached to a transaction that equals zero. NOTE: Not payable on data of calls between transactions. QuadCoeffDiv uint64 = 512 // Divisor for the quadratic particle of the memory cost equation. SstoreSetGas uint64 = 20000 // Once per SLOAD operation. LogDataGas uint64 = 8 // Per byte in a LOG* operation's data. CallStipend uint64 = 2300 // Free gas given at beginning of call. Sha3Gas uint64 = 30 // Once per SHA3 operation. Sha3WordGas uint64 = 6 // Once per word of the SHA3 operation's data. SstoreResetGas uint64 = 5000 // Once per SSTORE operation if the zeroness changes from zero. SstoreClearGas uint64 = 5000 // Once per SSTORE operation if the zeroness doesn't change. SstoreRefundGas uint64 = 15000 // Once per SSTORE operation if the zeroness changes to zero. JumpdestGas uint64 = 1 // Refunded gas, once per SSTORE operation if the zeroness changes to zero. EpochDuration uint64 = 30000 // Duration between proof-of-work epochs. CallGas uint64 = 40 // Once per CALL operation & message call transaction. CreateDataGas uint64 = 200 // CallCreateDepth uint64 = 1024 // Maximum depth of call/create stack. ExpGas uint64 = 10 // Once per EXP instruction LogGas uint64 = 375 // Per LOG* operation. CopyGas uint64 = 3 // StackLimit uint64 = 1024 // Maximum size of VM stack allowed. TierStepGas uint64 = 0 // Once per operation, for a selection of them. LogTopicGas uint64 = 375 // Multiplied by the * of the LOG*, per LOG transaction. e.g. LOG0 incurs 0 * c_txLogTopicGas, LOG4 incurs 4 * c_txLogTopicGas. CreateGas uint64 = 32000 // Once per CREATE operation & contract-creation transaction. Create2Gas uint64 = 32000 // Once per CREATE2 operation & contract-creation transaction. SuicideRefundGas uint64 = 24000 // Refunded following a suicide operation. MemoryGas uint64 = 3 // Times the address of the (highest referenced byte in memory + 1). NOTE: referencing happens on read, write and in instructions such as RETURN and CALL. TxDataNonZeroGas uint64 = 68 // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions. MaxCodeSize = 24576 // Maximum bytecode to permit for a contract EcrecoverGas uint64 = 3000 // Elliptic curve sender recovery gas price Sha256BaseGas uint64 = 60 // Base price for a SHA256 operation Sha256PerWordGas uint64 = 12 // Per-word price for a SHA256 operation Ripemd160BaseGas uint64 = 600 // Base price for a RIPEMD160 operation Ripemd160PerWordGas uint64 = 120 // Per-word price for a RIPEMD160 operation IdentityBaseGas uint64 = 15 // Base price for a data copy operation IdentityPerWordGas uint64 = 3 // Per-work price for a data copy operation ModExpQuadCoeffDiv uint64 = 20 // Divisor for the quadratic particle of the big int modular exponentiation Bn256AddGas uint64 = 500 // Gas needed for an elliptic curve addition Bn256ScalarMulGas uint64 = 40000 // Gas needed for an elliptic curve scalar multiplication Bn256PairingBaseGas uint64 = 100000 // Base price for an elliptic curve pairing check Bn256PairingPerPointGas uint64 = 80000 // Per-point price for an elliptic curve pairing check IssueGsa uint64 = 25000 //Gas needed for issue tokens in contract account )
Variables ¶
var ( DefaultChainDir = "linkchain" WasmGasRate = uint64(1) EvmGasRate = uint64(1) )
NOTE: Most of the structs & relevant comments + the default configuration options were used to manually generate the config.toml. Please reflect any changes made here in the defaultConfigTemplate constant in config/toml.go NOTE: tmlibs/cli must know to look in the config dir!
var ( // GasTableHomestead contain the gas prices for // the homestead phase. GasTableHomestead = GasTable{ ExtcodeSize: 20, ExtcodeCopy: 20, Balance: 20, SLoad: 50, Calls: 40, Suicide: 0, ExpByte: 10, } // GasTableEIP150 contain the gas re-prices for // the EIP150 phase. GasTableEIP150 = GasTable{ ExtcodeSize: 700, ExtcodeCopy: 700, Balance: 400, SLoad: 200, Calls: 700, Suicide: 5000, ExpByte: 10, CreateBySuicide: 25000, } // GasTableEIP158 contain the gas re-prices for // the EIP15* phase. GasTableEIP158 = GasTable{ ExtcodeSize: 700, ExtcodeCopy: 700, ExtcodeHash: 400, Balance: 400, SLoad: 200, Calls: 700, Suicide: 5000, ExpByte: 50, CreateBySuicide: 25000, } )
Variables containing gas prices for different phases.
var ( DifficultyBoundDivisor = big.NewInt(2048) // The bound divisor of the difficulty, used in the update calculations. GenesisDifficulty = big.NewInt(131072) // Difficulty of the Genesis block. MinimumDifficulty = big.NewInt(131072) // The minimum that the difficulty may ever be. DurationLimit = big.NewInt(13) // The decision boundary on the blocktime duration used to determine whether difficulty should go up or not. )
var ( //ContractCandidatesAddr 0x0000000000000000000043616e64696461746573 ContractCandidatesAddr = common.BytesToAddress([]byte("Candidates")) //ContractCoefficientAddr 0x000000000000000000436f656666696369656e74 ContractCoefficientAddr = common.BytesToAddress([]byte("Coefficient")) //ContractCommitteeAddr 0x0000000000000000000000436f6d6d6974746565 ContractCommitteeAddr = common.BytesToAddress([]byte("Committee")) //ContractFoundationAddr 0x00000000000000000000466f756e646174696f6e ContractFoundationAddr = common.BytesToAddress([]byte("Foundation")) //ContractPledgeAddr 0x0000000000000000000000000000506c65646765 ContractPledgeAddr = common.BytesToAddress([]byte("Pledge")) //ContractValidatorsAddr 0x0000000000000000000056616c696461746f7273 ContractValidatorsAddr = common.BytesToAddress([]byte("Validators")) //ContractBlacklistAddr 0x0000000000000000000000426c61636b6c697374 ContractBlacklistAddr = common.BytesToAddress([]byte("Blacklist")) //ContractConsCommitteeAddr = 0x00000000000000436f6e73436f6d6d6974746565 ContractConsCommitteeAddr = common.BytesToAddress([]byte("ConsCommittee")) )
var ( //TwoConsecutive Two Consecutive times TwoConsecutive = 2 //Threshold indicates the threshold of increase or decrease score in proposalBlock Threshold = 3 //PunishThreshold indicates the threshold of clear score PunishThreshold = -10 )
var InnerContracts = map[common.Address]struct{}{ ContractCandidatesAddr: struct{}{}, ContractCoefficientAddr: struct{}{}, ContractCommitteeAddr: struct{}{}, ContractFoundationAddr: struct{}{}, ContractPledgeAddr: struct{}{}, ContractValidatorsAddr: struct{}{}, ContractBlacklistAddr: struct{}{}, ContractConsCommitteeAddr: struct{}{}, }
InnerContracts indicates all of inner contracts above
var (
TargetGasLimit = GenesisGasLimit // The artificial target
)
Functions ¶
func DefaultLogLevel ¶
func DefaultLogLevel() string
DefaultLogLevel returns a default log level of "info"
func DefaultPackageLogLevels ¶
func DefaultPackageLogLevels() string
DefaultPackageLogLevels returns a default log level setting so all packages log at "error", while the `state` and `main` packages log at "info"
func DefaultRotateConfig ¶
func DefaultRotateConfig() *log.RotateConfig
RotateConfig defines the configuration options for the Log -----------------------------------------------------------------------------
func EnsureRoot ¶
EnsureRoot creates the root, config, and data directories if they don't exist, and panics if it fails.
func TestRotateConfig ¶
func TestRotateConfig() *log.RotateConfig
func WriteConfigFile ¶
WriteConfigFile renders config using the template and writes it to configFilePath.
Types ¶
type BaseConfig ¶
type BaseConfig struct { // The ID of the chain to join (should be signed with every transaction and vote) ChainID string `mapstructure:"chain_id"` // The chain initial height InitHeight uint64 `mapstructure:"init_height"` // The root directory for all data. // This should be set in viper so it can unmarshal into this struct RootDir string `mapstructure:"home"` // Path to the JSON file containing the initial validator set and other meta data Genesis string `mapstructure:"genesis_file"` // Path to the JSON file containing the private key to use as a validator in the consensus protocol PrivValidator string `mapstructure:"priv_validator_file"` // A custom human readable name for this node Moniker string `mapstructure:"moniker"` //nodetype_hostname // Output level for logging LogLevel string `mapstructure:"log_level"` // Output file for rotate logging LogFile string `mapstructure:"log_file"` // TCP or UNIX socket address for the profiling server to listen on ProfListenAddress string `mapstructure:"pprof"` // If this node is many blocks behind the tip of the chain, FastSync // allows them to catchup quickly by downloading blocks in parallel // and verifying their commits FastSync bool `mapstructure:"fast_sync"` // If true, the app can decide a new peer if we should keep the connection or not FilterPeers bool `mapstructure:"filter_peers"` // false // Database backend: leveldb | memdb DBBackend string `mapstructure:"db_backend"` // Database directory DBPath string `mapstructure:"db_path"` // Database split counts DBCounts uint64 `mapstructure:"db_counts"` // LogPath directory LogPath string `mapstructure:"log_dir"` // KeyStore directory KeyStorePath string `mapstructure:"keystore_dir"` // if false, the node init with default account's state OnLine bool `mapstructure:"on_line"` InfoAddr string `mapstructure:"info_addr"` InfoPrefix string `mapstructure:"info_prefix"` // jspath ExecFlag string `mapstructure:"exec"` // wasm gas rate WasmGasRate uint64 `mapstructure:"wasm_gas_rate"` RollBack bool `mapstructure:"roll_back"` FullNode bool `mapstructure:"full_node"` InitStateRoot string `mapstructure:"init_state_root"` KeepLatestBlocks uint64 `mapstructure:"keep_latest_blocks"` ClearDataInterval uint64 `mapstructure:"clear_data_interval"` SaveBalanceRecord bool `mapstructure:"save_balance_record"` IsTestMode bool `mapstructure:"is_test_mode"` TestNet bool `mapstructure:"test_net"` }
BaseConfig defines the base configuration for a node
func DefaultBaseConfig ¶
func DefaultBaseConfig() BaseConfig
DefaultBaseConfig returns a default base configuration for a node
func TestBaseConfig ¶
func TestBaseConfig() BaseConfig
TestBaseConfig returns a base configuration for testing a node
func (BaseConfig) DBDir ¶
func (cfg BaseConfig) DBDir() string
DBDir returns the full path to the database directory
func (BaseConfig) GenesisFile ¶
func (cfg BaseConfig) GenesisFile() string
GenesisFile returns the full path to the genesis.json file
func (BaseConfig) KeyStoreDir ¶
func (cfg BaseConfig) KeyStoreDir() string
KeyStoreDir returns the full path to the keystore directory
func (BaseConfig) LogDir ¶
func (cfg BaseConfig) LogDir() string
LogDir returns the full path to the log directory
func (BaseConfig) PrivValidatorFile ¶
func (cfg BaseConfig) PrivValidatorFile() string
PrivValidatorFile returns the full path to the priv_validator.json file
type BootNodeConfig ¶
type BootNodeConfig struct {
Addrs []string `mapstructure:"addrs"` //https://ip1:port1,https://ip2:port2
}
BootNodeConfig defines the configuration of bootnode
type Config ¶
type Config struct { // Top level options use an anonymous struct BaseConfig `mapstructure:",squash"` // Options for services Log *log.RotateConfig `mapstructure:"log"` RPC *RPCConfig `mapstructure:"rpc"` P2P *P2PConfig `mapstructure:"p2p"` Mempool *MempoolConfig `mapstructure:"mempool"` Consensus *ConsensusConfig `mapstructure:"consensus"` Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"` BootNodeSvr *BootNodeConfig `mapstructure:"bootnode"` }
Config defines the top level configuration for a node
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a default configuration for a node
func ResetTestRoot ¶
func TestConfig ¶
func TestConfig() *Config
TestConfig returns a configuration that can be used for testing
type ConsensusConfig ¶
type ConsensusConfig struct { RootDir string `mapstructure:"home"` WalPath string `mapstructure:"wal_file"` // All timeouts are in milliseconds TimeoutPropose int `mapstructure:"timeout_propose"` TimeoutProposeDelta int `mapstructure:"timeout_propose_delta"` TimeoutPrevote int `mapstructure:"timeout_prevote"` TimeoutPrevoteDelta int `mapstructure:"timeout_prevote_delta"` TimeoutPrecommit int `mapstructure:"timeout_precommit"` TimeoutPrecommitDelta int `mapstructure:"timeout_precommit_delta"` TimeoutCommit int `mapstructure:"timeout_commit"` // rewardChain CurrentTimeoutCommit int // Make progress as soon as we have all the precommits (as if TimeoutCommit = 0) SkipTimeoutCommit bool `mapstructure:"skip_timeout_commit"` // EmptyBlocks mode and possible interval between empty blocks in seconds CreateEmptyBlocks bool `mapstructure:"create_empty_blocks"` CreateEmptyBlocksInterval int `mapstructure:"create_empty_blocks_interval"` // Reactor sleep duration parameters are in milliseconds PeerGossipSleepDuration int `mapstructure:"peer_gossip_sleep_duration"` PeerQueryMaj23SleepDuration int `mapstructure:"peer_query_maj23_sleep_duration"` // contains filtered or unexported fields }
ConsensusConfig defines the configuration for the consensus service, including timeouts and details about the WAL and the block structure.
func DefaultConsensusConfig ¶
func DefaultConsensusConfig() *ConsensusConfig
DefaultConsensusConfig returns a default configuration for the consensus service
func TestConsensusConfig ¶
func TestConsensusConfig() *ConsensusConfig
TestConsensusConfig returns a configuration for testing the consensus service
func (*ConsensusConfig) Commit ¶
func (cfg *ConsensusConfig) Commit(t time.Time) time.Time
Commit returns the amount of time to wait for straggler votes after receiving +2/3 precommits for a single block (ie. a commit).
func (*ConsensusConfig) EmptyBlocksInterval ¶
func (cfg *ConsensusConfig) EmptyBlocksInterval() time.Duration
EmptyBlocks returns the amount of time to wait before proposing an empty block or starting the propose timer if there are no txs available
func (*ConsensusConfig) PeerGossipSleep ¶
func (cfg *ConsensusConfig) PeerGossipSleep() time.Duration
PeerGossipSleep returns the amount of time to sleep if there is nothing to send from the ConsensusReactor
func (*ConsensusConfig) PeerQueryMaj23Sleep ¶
func (cfg *ConsensusConfig) PeerQueryMaj23Sleep() time.Duration
PeerQueryMaj23Sleep returns the amount of time to sleep after each VoteSetMaj23Message is sent in the ConsensusReactor
func (*ConsensusConfig) Precommit ¶
func (cfg *ConsensusConfig) Precommit(round int) time.Duration
Precommit returns the amount of time to wait for straggler votes after receiving any +2/3 precommits
func (*ConsensusConfig) Prevote ¶
func (cfg *ConsensusConfig) Prevote(round int) time.Duration
Prevote returns the amount of time to wait for straggler votes after receiving any +2/3 prevotes
func (*ConsensusConfig) Propose ¶
func (cfg *ConsensusConfig) Propose(round int) time.Duration
Propose returns the amount of time to wait for a proposal
func (*ConsensusConfig) SetWalFile ¶
func (cfg *ConsensusConfig) SetWalFile(walFile string)
SetWalFile sets the path to the write-ahead log file
func (*ConsensusConfig) WaitForTxs ¶
func (cfg *ConsensusConfig) WaitForTxs() bool
WaitForTxs returns true if the consensus should wait for transactions before entering the propose step
func (*ConsensusConfig) WalFile ¶
func (cfg *ConsensusConfig) WalFile() string
WalFile returns the full path to the write-ahead log file
type FuzzConnConfig ¶
type FuzzConnConfig struct { Mode int MaxDelay time.Duration ProbDropRW float64 ProbDropConn float64 ProbSleep float64 }
FuzzConnConfig is a FuzzedConnection configuration.
func DefaultFuzzConnConfig ¶
func DefaultFuzzConnConfig() *FuzzConnConfig
DefaultFuzzConnConfig returns the default config.
type GasTable ¶
type GasTable struct { ExtcodeSize uint64 ExtcodeCopy uint64 ExtcodeHash uint64 Balance uint64 SLoad uint64 Calls uint64 Suicide uint64 ExpByte uint64 // CreateBySuicide occurs when the // refunded account is one that does // not exist. This logic is similar // to call. May be left nil. Nil means // not charged. CreateBySuicide uint64 }
GasTable organizes gas prices for different phases.
type InstrumentationConfig ¶
type InstrumentationConfig struct { // When true, Prometheus metrics are served under /metrics on // PrometheusListenAddr. // Check out the documentation for the list of available metrics. Prometheus bool `mapstructure:"prometheus"` // Address to listen for Prometheus collector(s) connections. PrometheusListenAddr string `mapstructure:"prometheus_listen_addr"` // Maximum number of simultaneous connections. // If you want to accept more significant number than the default, make sure // you increase your OS limits. // 0 - unlimited. MaxOpenConnections int `mapstructure:"max_open_connections"` }
InstrumentationConfig defines the configuration for metrics reporting.
func DefaultInstrumentationConfig ¶
func DefaultInstrumentationConfig() *InstrumentationConfig
DefaultInstrumentationConfig returns a default configuration for metrics reporting.
func TestInstrumentationConfig ¶
func TestInstrumentationConfig() *InstrumentationConfig
TestInstrumentationConfig returns a default configuration for metrics reporting.
type MempoolConfig ¶
type MempoolConfig struct { RootDir string `mapstructure:"home"` Recheck bool `mapstructure:"recheck"` RecheckEmpty bool `mapstructure:"recheck_empty"` Broadcast bool `mapstructure:"broadcast"` BroadcastChanSize int `mapstructure:"broadcast_size"` WalPath string `mapstructure:"wal_dir"` Size int `mapstructure:"size"` MaxReapSize int `mapstructure:"max_reapSize"` SpecSize int `mapstructure:"specialTxsSize"` UTXOSize int `mapstructure:"UTXOSize"` FutureSize int `mapstructure:"future_size"` // Maximum number of non-executable transaction slots for all accounts CacheSize int `mapstructure:"cache_size"` AccountQueue int `mapstructure:"account_queue"` // Maximum number of non-executable transaction slots permitted per account Lifetime time.Duration `mapstructure:"life_time"` // Maximum amount of time non-executable transaction are queued RemoveFutureTx bool `mapstructure:"removeFutureTx"` ReceiveP2pTx bool `mapstructure:"receive_p2pTx"` }
MempoolConfig defines the configuration options for the mempool
func DefaultMempoolConfig ¶
func DefaultMempoolConfig() *MempoolConfig
DefaultMempoolConfig returns a default configuration for the mempool
func TestMempoolConfig ¶
func TestMempoolConfig() *MempoolConfig
TestMempoolConfig returns a configuration for testing the mempool
func (*MempoolConfig) WalDir ¶
func (cfg *MempoolConfig) WalDir() string
WalDir returns the full path to the mempool's write-ahead log
type P2PConfig ¶
type P2PConfig struct { // Address to listen for incoming connections ListenAddress string `mapstructure:"laddr"` //ip:port // Address to advertise to peers for them to dial ExternalAddress string `mapstructure:"external_address"` //ip // Maximum number of peers to connect to MaxNumPeers int `mapstructure:"max_num_peers"` // Minimum number of outbound peers MinOutboundPeers int `mapstructure:"min_outbound_peers"` // Maximum size of a message packet payload, in bytes MaxPacketMsgPayloadSize int `mapstructure:"max_packet_msg_payload_size"` // Peer connection configuration. HandshakeTimeout time.Duration `mapstructure:"handshake_timeout"` DialTimeout time.Duration `mapstructure:"dial_timeout"` }
----------------------------------------------------------------------------- P2PConfig defines the configuration options for the peer-to-peer networking layer
func DefaultP2PConfig ¶
func DefaultP2PConfig() *P2PConfig
DefaultP2PConfig returns a default configuration for the peer-to-peer layer
func TestP2PConfig ¶
func TestP2PConfig() *P2PConfig
TestP2PConfig returns a configuration for testing the peer-to-peer layer
type RPCConfig ¶
type RPCConfig struct { RootDir string `mapstructure:"home"` IpcEndpoint string `mapstructure:"ipc_endpoint"` HTTPEndpoint string `mapstructure:"http_endpoint"` HTTPModules []string `mapstructure:"http_modules"` HTTPCores []string `mapstructure:"http_cores"` VHosts []string `mapstructure:"vhosts"` WSEndpoint string `mapstructure:"ws_endpoint"` WSModules []string `mapstructure:"ws_modules"` WSOrigins []string `mapsturcture:"ws_origins"` WSExposeAll bool `mapstructure:"ws_expose_all"` EVMInterval time.Duration `mapstructure:"evm_interval"` EVMMax int `mapstructure:"evm_max"` }
RPCConfig defines the configuration options for the RPC server
func DefaultRPCConfig ¶
func DefaultRPCConfig() *RPCConfig
DefaultRPCConfig returns a default configuration for the RPC server
func TestRPCConfig ¶
func TestRPCConfig() *RPCConfig
TestRPCConfig returns a configuration for testing the RPC server