Documentation
¶
Index ¶
- Constants
- func ChainTypeProofSize(chainType ChainType) int
- func GraphWeight(chainType ChainType, height uint64, edgeBits uint8) uint64
- func HeaderVersion(chainType ChainType, height uint64) uint16
- func SecondaryPoWRatio(height uint64) uint64
- func ValidHeaderVersion(chainType ChainType, height uint64, version uint16) bool
- type ChainType
- type Difficulty
- type HeaderInfo
Constants ¶
const ARScaleDampFactor uint64 = 13
ARScaleDampFactor is the dampening factor to use for AR scale calculation.
const AutomatedTestingCoinbaseMaturity uint64 = 3
AutomatedTestingCoinbaseMaturity is the automated testing coinbase maturity
const AutomatedTestingMinEdgeBits uint8 = 9
AutomatedTestingMinEdgeBits is the automated testing edgebits
const AutomatedTestingProofSize int = 4
AutomatedTestingProofSize is the automated testing proof size
const BaseEdgeBits uint8 = 24
BaseEdgeBits is the original reference edge_bits to compute difficulty factors for higher Cuckoo graph sizes, changing this would hard fork
const BlockInputWeight int = 1
BlockInputWeight is the weight of an input when counted against the max block weight capacity
const BlockKernelWeight int = 3
BlockKernelWeight is the weight of a kernel when counted against the max block weight capacity
const BlockOutputWeight int = 21
BlockOutputWeight is the weight of an output when counted against the max block weight capacity
const BlockTimeSec uint64 = 60
BlockTimeSec is the block interval, in seconds, the network will tune its next_target for. Note that we may reduce this value in the future as we get more data on mining with Cuckoo Cycle, networks improve and block propagation is optimized (adjusting the reward accordingly).
const BlockTimeWindow uint64 = DifficultyAdjustWindow * BlockTimeSec
BlockTimeWindow is the average time span of the difficulty adjustment window
const ClampFactor uint64 = 2
ClampFactor is the clamp factor to use for difficulty adjustment Limit value to within this factor of goal
const CoinbaseMaturity uint64 = DayHeight
CoinbaseMaturity is the number of blocks before a coinbase matures and can be spent
const CutThroughHorizon uint32 = uint32(WeekHeight)
CutThroughHorizon is the Default number of blocks in the past when cross-block cut-through will start happening. Needs to be long enough to not overlap with a long reorg. Rational behind the value is the longest bitcoin fork was about 30 blocks, so 5h. We add an order of magnitude to be safe and round to 7x24h of blocks to make it easier to reason about.
const DayHeight uint64 = 24 * HourHeight
DayHeight is 1440 blocks
const DefaultMinEdgeBits uint8 = 31
DefaultMinEdgeBits is the default Cuckatoo Cycle edge_bits, used for mining and validating.
const DifficultyAdjustWindow uint64 = HourHeight
DifficultyAdjustWindow is the number of blocks used to calculate difficulty adjustments
const DifficultyDampFactor uint64 = 3
DifficultyDampFactor is the Dampening factor to use for difficulty adjustment
const GrinBase uint64 = 1000000000
GrinBase is the grin base. A grin is divisible to 10^9, following the SI prefixes
const HardForkInterval uint64 = YearHeight / 2
HardForkInterval every 6 months.
const HourHeight uint64 = 3600 / BlockTimeSec
HourHeight is the nominal height for standard time intervals, hour is 60 blocks
const InitialDifficulty uint64 = 1000000 * UnitDifficulty
InitialDifficulty is the initial difficulty at launch. This should be over-estimated and difficulty should come down at launch rather than up Currently grossly over-estimated at 10% of current ethereum GPUs (assuming 1GPU can solve a block at diff 1 in one block interval)
const MaxBlockWeight int = 40000
MaxBlockWeight is the total maximum block weight. At current sizes, this means a maximum theoretical size of: * `(674 + 33 + 1) * (40_000 / 21) = 1_348_571` for a block with only outputs * `(1 + 8 + 8 + 33 + 64) * (40_000 / 3) = 1_520_000` for a block with only kernels * `(1 + 33) * 40_000 = 1_360_000` for a block with only inputs
Regardless of the relative numbers of inputs/outputs/kernels in a block the maximum block size is around 1.5MB For a block full of "average" txs (2 inputs, 2 outputs, 1 kernel) we have - `(1 * 2) + (21 * 2) + (3 * 1) = 47` (weight per tx) `40_000 / 47 = 851` (txs per block)
const MicroGrin uint64 = MilliGrin / 1000
MicroGrin is a thousand of a milligrin
const MilliGrin uint64 = GrinBase / 1000
MilliGrin is a thousand of a grin
const MinArScale uint64 = ARScaleDampFactor
MinArScale is the minimum scaling factor for AR pow, enforced in diff retargetting avoids getting stuck when trying to increase ar_scale subject to dampening
const MinDifficulty uint64 = DifficultyDampFactor
MinDifficulty is the minimum difficulty, enforced in diff retargetting avoids getting stuck when trying to increase difficulty subject to dampening
const NanoGrin uint64 = 1
NanoGrin is the smallest unit, takes a billion to make a grin
const ProofSize int = 42
ProofSize is the Cuckoo-cycle proof size (cycle length)
const Reward uint64 = BlockTimeSec * GrinBase
Reward is the block subsidy amount, one grin per second on average
const SecondPoWEdgeBits uint8 = 29
SecondPoWEdgeBits is the Cuckaroo proof-of-work edge_bits, meant to be ASIC resistant.
const StateSyncThreshold uint32 = 2 * uint32(DayHeight)
StateSyncThreshold is the default number of blocks in the past to determine the height where we request a txhashset (and full blocks from). Needs to be long enough to not overlap with a long reorg. Rational behind the value is the longest bitcoin fork was about 30 blocks, so 5h. We add an order of magnitude to be safe and round to 2x24h of blocks to make it easier to reason about.
const TestingCutThroughHorizon uint32 = 70
TestingCutThroughHorizon is the testing cut through horizon in blocks
const TestingHardForkInterval uint64 = 9
TestingHardForkInterval is the AutomatedTesting and UserTesting hard fork interval Fork every 3 blocks
const TestingInitialDifficulty uint64 = 1
TestingInitialDifficulty is the testing initial block difficulty
const TestingInitialGraphWeight uint32 = 1
TestingInitialGraphWeight is the testing initial graph weight
const TestingMaxBlockWeight int = 150
TestingMaxBlockWeight is the testing maxblockweight (artificially low, just enough to support a few txs).
const TestingStateSyncThreshold uint32 = 20
TestingStateSyncThreshold is the testing state sync threshold in blocks
const TestnetFirstHardFork uint64 = 185040
TestnetFirstHardFork is the Testnet first hard fork height, set to happen around 2019-06-23
const TestnetFourthHardFork uint64 = 642240
TestnetFourthHardFork is the Testnet fourth hard fork height, set to happen around 2020-12-08
const TestnetSecondHardFork uint64 = 298080
TestnetSecondHardFork is the Testnet second hard fork height, set to happen around 2019-12-19
const TestnetThirdHardFork uint64 = 552960
TestnetThirdHardFork is the Testnet third hard fork height, set to happen around 2020-06-20
const UnitDifficulty uint64 = (uint64(2) << (SecondPoWEdgeBits - BaseEdgeBits)) * uint64(SecondPoWEdgeBits)
UnitDifficulty is the unit difficulty, equal to graph_weight(SECOND_POW_EDGE_BITS)
const UserTestingCoinbaseMaturity uint64 = 3
UserTestingCoinbaseMaturity is the user testing coinbase maturity
const UserTestingMinEdgeBits uint8 = 15
UserTestingMinEdgeBits is the user testing edgebits
const UserTestingProofSize int = 42
UserTestingProofSize is theuser testing proof size
const WeekHeight uint64 = 7 * DayHeight
WeekHeight is 10 080 blocks
const YearHeight uint64 = 52 * WeekHeight
YearHeight is 524 160 blocks
Variables ¶
This section is empty.
Functions ¶
func ChainTypeProofSize ¶
ChainTypeProofSize return the proof size based on the proofsize
func GraphWeight ¶
GraphWeight compute weight of a graph as number of siphash bits defining the graph The height dependence allows a 30-week linear transition from C31+ to C32+ starting after 1 year
func HeaderVersion ¶
HeaderVersion compute possible block version at a given height, implements 6 months interval scheduled hard forks for the first 2 years.
func SecondaryPoWRatio ¶
SecondaryPoWRatio is the ratio the secondary proof of work should take over the primary, as a function of block height (time). Starts at 90% losing a percent approximately every week. Represented as an integer between 0 and 100.
Types ¶
type ChainType ¶
type ChainType int
ChainType is the type of chain a server can run with, dictates the genesis block and / and mining parameters used.
type Difficulty ¶
type Difficulty struct {
// contains filtered or unexported fields
}
The Difficulty is defined as the maximum target divided by the block hash.
func (*Difficulty) FromNum ¶
func (p *Difficulty) FromNum(num uint64) Difficulty
FromNum converts a `uint64` into a `Difficulty`
func (*Difficulty) Unit ¶
func (p *Difficulty) Unit(chainType ChainType) Difficulty
Unit is a difficulty unit, which is the graph weight of minimal graph
type HeaderInfo ¶
type HeaderInfo struct {
// contains filtered or unexported fields
}
HeaderInfo is a header info and contains the minimal header information required for the Difficulty calculation to take place
func HeaderInfoFromDiffScaling ¶
func HeaderInfoFromDiffScaling(difficulty Difficulty, secondaryScaling uint32) HeaderInfo
HeaderInfoFromDiffScaling is a constructor from a difficulty and secondary factor, setting a default timestamp
func HeaderInfoFromTsDiff ¶
func HeaderInfoFromTsDiff(chainType ChainType, timestamp uint64, difficulty Difficulty) HeaderInfo
HeaderInfoFromTsDiff is a constructor from a timestamp and difficulty, setting a default secondary PoW factor