consensus

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: Apache-2.0 Imports: 1 Imported by: 3

Documentation

Index

Constants

View Source
const ARScaleDampFactor uint64 = 13

ARScaleDampFactor is the dampening factor to use for AR scale calculation.

View Source
const AutomatedTestingCoinbaseMaturity uint64 = 3

AutomatedTestingCoinbaseMaturity is the automated testing coinbase maturity

View Source
const AutomatedTestingMinEdgeBits uint8 = 9

AutomatedTestingMinEdgeBits is the automated testing edgebits

View Source
const AutomatedTestingProofSize int = 4

AutomatedTestingProofSize is the automated testing proof size

View Source
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

View Source
const BlockInputWeight int = 1

BlockInputWeight is the weight of an input when counted against the max block weight capacity

View Source
const BlockKernelWeight int = 3

BlockKernelWeight is the weight of a kernel when counted against the max block weight capacity

View Source
const BlockOutputWeight int = 21

BlockOutputWeight is the weight of an output when counted against the max block weight capacity

View Source
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).

BlockTimeWindow is the average time span of the difficulty adjustment window

View Source
const ClampFactor uint64 = 2

ClampFactor is the clamp factor to use for difficulty adjustment Limit value to within this factor of goal

View Source
const CoinbaseMaturity uint64 = DayHeight

CoinbaseMaturity is the number of blocks before a coinbase matures and can be spent

View Source
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.

View Source
const DayHeight uint64 = 24 * HourHeight

DayHeight is 1440 blocks

View Source
const DefaultMinEdgeBits uint8 = 31

DefaultMinEdgeBits is the default Cuckatoo Cycle edge_bits, used for mining and validating.

View Source
const DifficultyAdjustWindow uint64 = HourHeight

DifficultyAdjustWindow is the number of blocks used to calculate difficulty adjustments

View Source
const DifficultyDampFactor uint64 = 3

DifficultyDampFactor is the Dampening factor to use for difficulty adjustment

View Source
const FloonetFirstHardFork uint64 = 185040

FloonetFirstHardFork is the Floonet first hard fork height, set to happen around 2019-06-23

View Source
const GrinBase uint64 = 1000000000

GrinBase is the grin base. A grin is divisible to 10^9, following the SI prefixes

View Source
const HardForkInterval uint64 = YearHeight / 2

HardForkInterval every 6 months.

View Source
const HourHeight uint64 = 3600 / BlockTimeSec

HourHeight is the nominal height for standard time intervals, hour is 60 blocks

View Source
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)

View Source
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)

View Source
const MicroGrin uint64 = MilliGrin / 1000

MicroGrin is a thousand of a milligrin

View Source
const MilliGrin uint64 = GrinBase / 1000

MilliGrin is a thousand of a grin

View Source
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

View Source
const MinDifficulty uint64 = DifficultyDampFactor

MinDifficulty is the minimum difficulty, enforced in diff retargetting avoids getting stuck when trying to increase difficulty subject to dampening

View Source
const NanoGrin uint64 = 1

NanoGrin is the smallest unit, takes a billion to make a grin

View Source
const ProofSize int = 42

ProofSize is the Cuckoo-cycle proof size (cycle length)

Reward is the block subsidy amount, one grin per second on average

View Source
const SecondPoWEdgeBits uint8 = 29

SecondPoWEdgeBits is the Cuckaroo proof-of-work edge_bits, meant to be ASIC resistant.

View Source
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.

View Source
const TestingCutThroughHorizon uint32 = 70

TestingCutThroughHorizon is the testing cut through horizon in blocks

View Source
const TestingInitialDifficulty uint64 = 1

TestingInitialDifficulty is the testing initial block difficulty

View Source
const TestingInitialGraphWeight uint32 = 1

TestingInitialGraphWeight is the testing initial graph weight

View Source
const TestingMaxBlockWeight int = 150

TestingMaxBlockWeight is the testing maxblockweight (artificially low, just enough to support a few txs).

View Source
const TestingStateSyncThreshold uint32 = 20

TestingStateSyncThreshold is the testing state sync threshold in blocks

UnitDifficulty is the unit difficulty, equal to graph_weight(SECOND_POW_EDGE_BITS)

View Source
const UserTestingCoinbaseMaturity uint64 = 3

UserTestingCoinbaseMaturity is the user testing coinbase maturity

View Source
const UserTestingMinEdgeBits uint8 = 15

UserTestingMinEdgeBits is the user testing edgebits

View Source
const UserTestingProofSize int = 42

UserTestingProofSize is theuser testing proof size

View Source
const WeekHeight uint64 = 7 * DayHeight

WeekHeight is 10 080 blocks

View Source
const YearHeight uint64 = 52 * WeekHeight

YearHeight is 524 160 blocks

Variables

This section is empty.

Functions

func ChainTypeProofSize

func ChainTypeProofSize(chainType ChainType) int

ChainTypeProofSize return the proof size based on the proofsize

func GraphWeight

func GraphWeight(chainType ChainType, height uint64, edgeBits uint8) uint64

GraphWeight is a weight of a graph as number of siphash bits defining the graph Must be made dependent on height to phase out smaller size over the years This can wait until end of 2019 at latest

func SecondaryPoWRatio

func SecondaryPoWRatio(height uint64) uint64

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.

func ValidHeaderVersion

func ValidHeaderVersion(chainType ChainType, height uint64, version uint16) bool

Check whether the block version is valid at a given height, implements 6 months interval scheduled hard forks for the first 2 years.

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.

const (
	// AutomatedTesting is for CI testing
	AutomatedTesting ChainType = iota
	// UserTesting is for User testing
	UserTesting
	// Floonet is the protocol testing network
	Floonet
	// Mainnet is the main production network
	Mainnet
)

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

Jump to

Keyboard shortcuts

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