params

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionMajor = 1          // Major version component of the current release
	VersionMinor = 0          // Minor version component of the current release
	VersionPatch = 0          // Patch version component of the current release
	VersionMeta  = "unstable" // Version metadata to append to the version string. Set to "" for stable release.
)
View Source
const (
	MainNetId = 1
	TestNetId = 2

	// NetworkIdForTestCase is used for test case so to use a different suite of parameters.
	// This value is within the range of int8, so it can acts like the MainNetId.
	NetworkIdForTestCase = 99
)
View Source
const (
	Lu  = 1
	GLu = 1e9
	YOU = 1e18
)

These are the multipliers for ether denominations. Example: To get the lu value of an amount in 'glu', use

new(big.Int).Mul(value, big.NewInt(params.GLu))
View Source
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 = 8888888 // Gas limit of the Genesis block.

	MaximumExtraDataSize  uint64 = 32    // Maximum size extra data may be after Genesis.
	SloadGas              uint64 = 800   // 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.
	LogDataGas            uint64 = 8     // Per byte in a LOG* operation's data.
	CallStipend           uint64 = 2300  // Free gas given at beginning of call.

	SstoreSentryGas   uint64 = 2300  // Minimum gas required to be present for an SSTORE call, not consumed
	SstoreNoopGas     uint64 = 800   // Once per SSTORE operation if the value doesn't change.
	SstoreDirtyGas    uint64 = 800   // Once per SSTORE operation if a dirty value is changed.
	SstoreInitGas     uint64 = 20000 // Once per SSTORE operation from clean zero to non-zero
	SstoreInitRefund  uint64 = 19200 // Once per SSTORE operation for resetting to the original zero value
	SstoreCleanGas    uint64 = 5000  // Once per SSTORE operation from clean non-zero to something else
	SstoreCleanRefund uint64 = 4200  // Once per SSTORE operation for resetting to the original non-zero value
	SstoreClearRefund uint64 = 15000 // Once per SSTORE operation for clearing an originally existing storage slot

	TxValidatorGas   uint64 = 100000
	TxValCreationGas uint64 = 900000 // more gas for creates validator

	Sha3Gas          uint64 = 30    // Once per SHA3 operation.
	Sha3WordGas      uint64 = 6     // Once per word of the SHA3 operation's data.
	SstoreSetGas     uint64 = 20000 // Once per SLOAD operation.
	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.
	CallGas          uint64 = 700   // 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
	ExpByte          uint64 = 50    // EXP has a dynamic portion depending on the size of the exponent
	LogGas           uint64 = 375   // Per LOG* operation.
	CopyGas          uint64 = 3     //
	StackLimit       uint64 = 1024  // Maximum size of VM stack allowed.
	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
	SuicideRefundGas uint64 = 24000 // Refunded following a suicide operation.
	SelfdestructGas  uint64 = 5000  // Cost of SELFDESTRUCT
	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 = 16    // Per byte of data attached to a transaction that is not equal to zero. NOTE: Not payable on data of calls between transactions.

	BalanceGas     uint64 = 700 // The cost of a BALANCE operation
	ExtcodeSizeGas uint64 = 700 // Cost of EXTCODESIZE
	// Extcodecopy has a dynamic AND a static cost. This represents only the
	// static portion of the gas.
	ExtcodeCopyBase uint64 = 700

	ExtcodeHashGas uint64 = 400 // Cost of EXTCODEHASH (introduced in Constantinople)

	// CreateBySelfdestructGas is used when the refunded account is one that does
	// not exist. This logic is similar to call.
	// Introduced in Tangerine Whistle (Eip 150)
	CreateBySelfdestructGas uint64 = 25000

	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
)
View Source
const (
	DefaultIPCPath = "youchain.ipc"

	DefaultHTTPHost = "localhost" // Default host interface for the HTTP RPC server
	DefaultHTTPPort = 8283

	DefaultWSHost = "localhost" // Default host interface for the websocket RPC server
	DefaultWSPort = 8284

	DefaultP2PListenPort = 9283 // Default port for the P2P RUDP transport

	DefaultP2PDiscoverPort = 9284 // Default port for the P2P Discover transport

	DefaultPProfHost = "0.0.0.0" //port for PProf metrics
	DefaultPProfPort = 7283      //port for PProf metrics
)
View Source
const (
	// YouV1 is a baseline version of the YOUChain consensus protocol.
	YouV1 = YouVersion(1)
	// YouV2 adds the parameter `AllowedFutureBlockTime`
	YouV2 = YouVersion(2)
	// YouV3 adjust `SubsidyThreshold` and `UpgradeThreshold`, and tune txs-broadcast strategy
	YouV3 = YouVersion(3)
	// YouV4 fixes a bug on gas used for a failed staking-transaction.
	YouV4 = YouVersion(4)
	// YouV5 is the first permission-less version for validators of Chamber.
	YouV5 = YouVersion(5)
)
View Source
const (
	// validator kinds
	KindValidator ValidatorKind = 0 // 全体验证人集合的统计
	KindChamber   ValidatorKind = 1 // 全体议员(全体议长+全体议员)
	KindHouse     ValidatorKind = 2 // 众议节点

	// validator roles
	RoleChancellor ValidatorRole = 1 // 议长
	RoleSenator    ValidatorRole = 2 // 议员
	RoleHouse      ValidatorRole = 3 // 众议

	KindNameValidator = "validator"
	KindNameChamber   = "chamber"
	KindNameHouse     = "house"

	RoleNameChancellor = "chancellor"
	RoleNameSenator    = "senator"
	RoleNameHouse      = "house"

	ValidatorOffline uint8 = 0
	ValidatorOnline  uint8 = 1

	// CommissionRateBase is the denominator of commission rate
	CommissionRateBase = 10000

	NotAcceptDelegation uint16 = 0
	AcceptDelegation    uint16 = 1
)
View Source
const (
	LookBackNone LookBackType = iota
	LookBackPos
	LookBackSeed
	LookBackStake
	LookBackCert
	LookBackCertSeed
	LookBackCertStake

	MaxVoteCacheCount int = 4
)
View Source
const (
	// ACoCHTFrequency is the block frequency for creating CHTs and BloomTries,
	// and also the number of blocks a single bloom bit section vector contains.
	ACoCHTFrequency uint64 = 32768
)

These are network parameters that need to be constant. There constants are also consensus related, so it can't be changed once it was set.

View Source
const (
	EvmIstanbul = "Istanbul"
)
View Source
const YouCurrentVersion = YouV5

YouCurrentVersion is the latest version and should be used when a specific version is not provided.

Variables

View Source
var (
	//StakeUint = new(big.Int).Mul(big.NewInt(1000), big.NewInt(YOU))
	StakeUint = new(big.Int).Mul(big.NewInt(1), big.NewInt(YOU))

	StakingModuleAddress = common.BytesToAddress([]byte(`ValidatorsManager`)) //0x00000056616C696461746f72734D616E61676572

)
View Source
var DefaultMinGasPrice uint64 = 100 * GLu // 1GLu
View Source
var MainnetBootnodes = []string{
	"enode://9af98f9bb26530b7cd7449a580c7f0b10457b9404810ad93651edd9061245e981dde2244acaf122843bce3e513756c2455c8cadc420305515be7ee942e549b6d@47.114.151.44:9283?discport=9284&nat=2&nodetype=2",
	"enode://9ca4777fc642ccbb5e2cf120dae8c05b4dc827390daa82442a5cbbcf4944e995089b96d2f6a479847376d5ecc0f6fa25e42309975e6d50952a61231a3b0df517@47.111.249.64:9283?discport=9284&nat=2&nodetype=2",
	"enode://7eb533b94f5e28cfd2bdb198a494f2ce50464ee4246f0fcf05839fcb55631e9331170b6513ff98930d210a2a017d34f953d3637df0b8b798f7bc42dbccad9355@47.93.225.217:9283?discport=9284&nat=2&nodetype=2",
}
View Source
var (
	TargetGasLimit = GenesisGasLimit // The artificial target
)
View Source
var TestnetBootnodes = []string{
	"enode://f3a5c1189b007add14afba2aba41e4258842da3fa6baa00458bfc9b7ad3aa72117276dfcc2c94cff8a534282a9c644c8f370d045cc57786f517a48cb5a0dab61@42.62.25.72:9283?discport=9284&nat=1&nodetype=1",
}

Functions

func CheckRole

func CheckRole(role ValidatorRole) bool

func ClientVersion

func ClientVersion() string

func InitNetworkId

func InitNetworkId(id uint64)

InitNetworkId initialize the networkId for once. It should be set according the stored genesis information or by user specified on the first time the client was ran.

func LoadBootstrapNodes

func LoadBootstrapNodes() []string

func MinStakeLookBack

func MinStakeLookBack() int

MinStakeLookBack returns a minimal stakeLookBack value, It can be used for concurrency control when batch handling headers or blocks.

func NetworkId

func NetworkId() uint64

NetworkId return the current networkId. if the networkId is not set, it panic.

func ValidatorKindToString

func ValidatorKindToString(kind ValidatorKind) string

只返回大类

func YOUToStake

func YOUToStake(token *big.Int) *big.Int

Types

type CaravelParams

type CaravelParams struct {
	ProposerThreshold     uint64 // can use a fixed value, such as 26
	ValidatorThreshold    uint64
	CertValThreshold      uint64
	ConsensusTimeout      time.Duration
	ConsensusStepInterval time.Duration
	StakeLookBack         uint64 // look-back parameter for seed, a security parameter. can use a fixed value
	SeedLookBack          uint64
	EnableBls             bool // enable bls signature. may be deprecated due to performance or security reason.
	EnableInactivity      bool
	// Max time from current time allowed for blocks, before they're considered future blocks
	AllowedFutureBlockTime time.Duration
}

CaravelParams contains parameters of the Caravel consensus

type CurdFlag

type CurdFlag uint8
const (
	Noop   CurdFlag = iota
	Create          // create, new inserted, new added
	Update
	Delete
)

type LookBackType

type LookBackType uint8

func TurnToSeedType

func TurnToSeedType(backType LookBackType) LookBackType

func TurnToStakeType

func TurnToStakeType(backType LookBackType) LookBackType

type NodeType

type NodeType uint16
const (
	UnknownNodeType NodeType = iota
	ArchiveNode
	FullNode
	LightNode
	UltraLightNode
)

func ParseNodeType

func ParseNodeType(text string) NodeType

func (NodeType) IsValid

func (t NodeType) IsValid() bool

func (NodeType) String

func (t NodeType) String() string

type StakingParams

type StakingParams struct {
	MinStakes map[ValidatorRole]uint64
	MaxStakes map[ValidatorRole]uint64
	// MinSelfStake is the minimum stake that a validator should afford by it self.
	MinSelfStakes      map[ValidatorRole]uint64
	RewardsPoolAddress common.Address
	SubsidyThreshold   uint64 // max subsidy, should less than 18*YOU, otherwise we must change the type and the related logic.
	SubsidyCoeff       uint8  // the coefficient for calculating subsidy, must between 1 and 9.
	RewardsDistRatio   map[ValidatorRole]uint64
	SignatureRequired  map[ValidatorRole]bool

	MaxRewardsPeriod     uint64
	MaxEvidenceExpiredIn uint64

	WithdrawDelay                uint64 // MUST be larger then CaravelParams.StakeLookBack
	WithdrawRecordRetention      uint64
	ExpelledRoundForDoubleSign   uint64
	ExpelledRoundForInactive     uint64
	PenaltyTo                    common.Address
	PenaltyFractionForDoubleSign uint64
	PenaltyFractionForInactive   uint64
	// InactivityPenaltyWaitRounds, valid starting from YouV5, for Chamber only.
	InactivityPenaltyWaitRounds uint64

	// StakingTrieFrequency represents how many round a staking trie remains
	StakingTrieFrequency uint64
	// MaxDelegationForValidator represents how many delegations a validator can hold
	MaxDelegationForValidator int
	// MaxDelegationForDelegator represents how many delegations a delegator can send
	MaxDelegationForDelegator int
	// MinDelegationTokens is the minimum tokens(in LU) for a single delegation
	MinDelegationTokens *big.Int

	// address of staking module master
	MasterAddress common.Address
}

StakingParams contains parameters of the staking module

type ValidatorKind

type ValidatorKind uint8

func KindOfRole

func KindOfRole(role ValidatorRole) (ValidatorKind, bool)

type ValidatorRole

type ValidatorRole uint8

type VersionsMap

type VersionsMap map[YouVersion]YouParams
var Versions VersionsMap

Versions contains all YOUChain protocol version and it's parameters

type YouParams

type YouParams struct {
	// YOUChain protocol version
	Version YouVersion
	// EVM version.
	EVMVersion string

	CaravelParams
	StakingParams

	// YOUChain protocol upgrades.  Votes for upgrades are collected for
	// UpgradeVoteRounds.  If the number of positive votes is over
	// UpgradeThreshold, the proposal is accepted.
	//
	// UpgradeVoteRounds needs to be long enough to collect an
	// accurate sample of participants, and UpgradeThreshold needs
	// to be high enough to ensure that there are sufficient participants
	// after the upgrade.
	//
	// A consensus protocol upgrade may specify the delay between its
	// acceptance and its execution.  This gives clients time to notify
	// users.  This delay is specified by the upgrade proposer and must
	// be between MinUpgradeWaitRounds and MaxUpgradeWaitRounds (inclusive)
	// in the old protocol's parameters.  Note that these parameters refer
	// to the representation of the delay in a block rather than the actual
	// delay: if the specified delay is zero, it is equivalent to
	// MinUpgradeWaitRounds in the old protocol's parameters.
	ApprovedUpgradeVersion YouVersion //target version that should upgrade to
	UpgradeWaitRounds      uint64     //wait until execution after approve
	UpgradeVoteRounds      uint64     //voting rounds
	UpgradeThreshold       uint64     //voting threshold
	MinUpgradeWaitRounds   uint64
	MaxUpgradeWaitRounds   uint64
}

YouParams contains YOUChain protocol related parameters. And these parameters can be block height related.

func (YouParams) DeepCopy

func (p YouParams) DeepCopy() YouParams

type YouVersion

type YouVersion uint64

YouVersion is an integer that identifies a version of the consensus protocol.

Jump to

Keyboard shortcuts

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