github.com/fozzysec/SiaPrime@v0.0.0-20190612043147-66c8e8d11fe3/types/constants.go (about)

     1  package types
     2  
     3  // constants.go contains the Sia constants. Depending on which build tags are
     4  // used, the constants will be initialized to different values.
     5  //
     6  // CONTRIBUTE: We don't have way to check that the non-test constants are all
     7  // sane, plus we have no coverage for them.
     8  
     9  import (
    10  	"math"
    11  	"math/big"
    12  	"time"
    13  
    14  	"SiaPrime/build"
    15  )
    16  
    17  var (
    18  	// ASICHardforkHeight is the height at which the hardfork targeting
    19  	// selected ASICs was activated.
    20  	ASICHardforkHeight BlockHeight
    21  
    22  	// ASICHardforkTotalTarget is the initial target after the ASIC hardfork.
    23  	// The actual target at ASICHardforkHeight is replaced with this value in
    24  	// order to prevent intolerably slow block times post-fork.
    25  	ASICHardforkTotalTarget Target
    26  
    27  	// ASICHardforkTotalTime is the initial total time after the ASIC
    28  	// hardfork. The actual total time at ASICHardforkHeight is replaced with
    29  	// this value in order to prevent intolerably slow block times post-fork.
    30  	ASICHardforkTotalTime int64
    31  
    32  	// ASICHardforkFactor is the factor by which the hashrate of targeted
    33  	// ASICs will be reduced.
    34  	ASICHardforkFactor = uint64(1)
    35  
    36  	// ASICHardforkReplayProtectionPrefix is a byte that prefixes
    37  	// SiacoinInputs and SiafundInputs when calculating SigHashes to protect
    38  	// against replay attacks.
    39  	ASICHardforkReplayProtectionPrefix = []byte(nil)
    40  
    41  	// BlockFrequency is the desired number of seconds that
    42  	// should elapse, on average, between successive Blocks.
    43  	BlockFrequency BlockHeight
    44  	// BlockSizeLimit is the maximum size of a binary-encoded Block
    45  	// that is permitted by the consensus rules.
    46  	BlockSizeLimit = uint64(2e6)
    47  	// BurnAddressBlockHeight is the height at which the dev fund will be burnt
    48  	// instead of being claimed by the dev fund. Setting this value to 0 will
    49  	// prevent the dev fund from being burnt at any height.
    50  	BurnAddressBlockHeight = BlockHeight(105000)
    51  	// BurnAddressUnlockHash is the unlock hash for where to send coins to burn.
    52  	BurnAddressUnlockHash = UnlockHashFromAddrStr("000000000000000000000000000000000000000000000000000000000000000089eb0d6a8a69")
    53  	// DevFundEnabled is a boolean that when set to true will enable the ability to
    54  	// configure a dev fund
    55  	DevFundEnabled = true
    56  	// DevFundInitialBlockHeight is the height at which the dev fund became mandatory
    57  	DevFundInitialBlockHeight = BlockHeight(1)
    58  	// DevFundDecayStartBlockHeight is the height at which the DevFundInitialPercentage
    59  	// begins to linearly decay to the DevFundFinalPercentage
    60  	DevFundDecayStartBlockHeight = BlockHeight(30000)
    61  	// DevFundDecayEndBlockHeight is the height at which the DevFundInitialPercentage
    62  	// has fully decayed to the DevFundFinalPercentage
    63  	DevFundDecayEndBlockHeight = BlockHeight(105000)
    64  	// DevFundInitialPercentage is the initial percentage of the block reward that is
    65  	// sent to the DevFundUnlockHash before any dev fund percentage decay happens
    66  	DevFundInitialPercentage = uint64(20)
    67  	// DevFundFinalPercentage is the final percentage of the block reward that is sent
    68  	//  to the DevFundUnlockHash after the dev fund percentage is fully decayed
    69  	DevFundFinalPercentage = uint64(10)
    70  	// DevFundUnlockHash is the unlock hash for the dev fund subsidy
    71  	// Do not set this to the Zero address as doing so will cause the test that
    72  	// verifies that a dev fee is set to fail
    73  	DevFundUnlockHash = UnlockHashFromAddrStr("aefe0af2713c112ba4d10dee7753726e5c4de3f237ea455151342615c95d0e797d7a8cce7b05")
    74  
    75  	// EndOfTime is value to be used when a date in the future is needed for
    76  	// validation
    77  	EndOfTime = time.Unix(0, math.MaxInt64)
    78  
    79  	// ExtremeFutureThreshold is a temporal limit beyond which Blocks are
    80  	// discarded by the consensus rules. When incoming Blocks are processed, their
    81  	// Timestamp is allowed to exceed the processor's current time by a small amount.
    82  	// But if the Timestamp is further into the future than ExtremeFutureThreshold,
    83  	// the Block is immediately discarded.
    84  	ExtremeFutureThreshold Timestamp
    85  	// FutureThreshold is a temporal limit beyond which Blocks are
    86  	// discarded by the consensus rules. When incoming Blocks are processed, their
    87  	// Timestamp is allowed to exceed the processor's current time by no more than
    88  	// FutureThreshold. If the excess duration is larger than FutureThreshold, but
    89  	// smaller than ExtremeFutureThreshold, the Block may be held in memory until
    90  	// the Block's Timestamp exceeds the current time by less than FutureThreshold.
    91  	FutureThreshold Timestamp
    92  	// GenesisBlock is the first block of the block chain
    93  	GenesisBlock Block
    94  
    95  	// GenesisID is used in many places. Calculating it once saves lots of
    96  	// redundant computation.
    97  	GenesisID BlockID
    98  
    99  	// GenesisAirdropAllocation is the output creating the initial coins allocated
   100  	// for the airdrop at network launch
   101  	GenesisAirdropAllocation []SiacoinOutput
   102  	// GenesisSiafundAllocation is the set of SiafundOutputs created in the Genesis
   103  	// block.
   104  	GenesisSiafundAllocation []SiafundOutput
   105  	// ForkedGenesisSiafundAllocation is the set of SiafundOutputs created in the Genesis
   106  	// block.
   107  	ForkedGenesisSiafundAllocation []SiafundOutput
   108  	// GenesisTimestamp is the timestamp when genesis block was mined
   109  	GenesisTimestamp Timestamp
   110  	// InitialCoinbase is the coinbase reward of the Genesis block.
   111  	InitialCoinbase = uint64(300e3)
   112  	// AirdropCommunityValue is the total amount of coins the community members will split
   113  	// from the genesis block airdrop.
   114  	AirdropCommunityValue = NewCurrency64(10000000000).Mul(SiacoinPrecision)
   115  	// AirdropPoolValue is the total amount of coins the pools get
   116  	// airdrop so that they can pay out miners in the first 144 blocks
   117  	AirdropPoolValue = NewCurrency64(51840000).Mul(SiacoinPrecision)
   118  	// AirdropNebulousLabsValue is a gift to the NebulousLabs Team to acknowledge all their
   119  	// effort and hard work. THANK YOU!
   120  	AirdropNebulousLabsValue = NewCurrency64(300000000).Mul(SiacoinPrecision)
   121  	// AirdropSiaPrimeValue is the total amount of coins SiaPrime gets to help bootstrap
   122  	// expenses
   123  	AirdropSiaPrimeValue = NewCurrency64(200000000).Mul(SiacoinPrecision)
   124  	// MaturityDelay specifies the number of blocks that a maturity-required output
   125  	// is required to be on hold before it can be spent on the blockchain.
   126  	// Outputs are maturity-required if they are highly likely to be altered or
   127  	// invalidated in the event of a small reorg. One example is the block reward,
   128  	// as a small reorg may invalidate the block reward. Another example is a siafund
   129  	// payout, as a tiny reorg may change the value of the payout, and thus invalidate
   130  	// any transactions spending the payout. File contract payouts also are subject to
   131  	// a maturity delay.
   132  	MaturityDelay BlockHeight
   133  	// MaxTargetAdjustmentDown restrict how much the block difficulty is allowed to
   134  	// change in a single step, which is important to limit the effect of difficulty
   135  	// raising and lowering attacks.
   136  	MaxTargetAdjustmentDown *big.Rat
   137  	// MaxTargetAdjustmentUp restrict how much the block difficulty is allowed to
   138  	// change in a single step, which is important to limit the effect of difficulty
   139  	// raising and lowering attacks.
   140  	MaxTargetAdjustmentUp *big.Rat
   141  	// MedianTimestampWindow tells us how many blocks to look back when calculating
   142  	// the median timestamp over the previous n blocks. The timestamp of a block is
   143  	// not allowed to be less than or equal to the median timestamp of the previous n
   144  	// blocks, where for Sia this number is typically 11.
   145  	MedianTimestampWindow = uint64(11)
   146  	// MinimumCoinbase is the minimum coinbase reward for a block.
   147  	// The coinbase decreases in each block after the Genesis block,
   148  	// but it will not decrease past MinimumCoinbase.
   149  	MinimumCoinbase uint64
   150  
   151  	// Oak hardfork constants. Oak is the name of the difficulty algorithm for
   152  	// Sia following a hardfork at block 135e3.
   153  
   154  	// OakDecayDenom is the denominator for how much the total timestamp is decayed
   155  	// each step.
   156  	OakDecayDenom int64
   157  	// OakDecayNum is the numerator for how much the total timestamp is decayed each
   158  	// step.
   159  	OakDecayNum int64
   160  	// OakHardforkBlock is the height at which the hardfork to switch to the oak
   161  	// difficulty adjustment algorithm is triggered.
   162  	OakHardforkBlock BlockHeight
   163  	// OakHardforkFixBlock is the height at which the hardfork to switch from the broken
   164  	// oak difficulty adjustment algorithm to the fixed oak difficulty adjustment
   165  	// algorithm is triggered.
   166  	OakHardforkFixBlock BlockHeight
   167  	// OakHardforkTxnSizeLimit is the maximum size allowed for a transaction, a change
   168  	// which I believe was implemented simultaneously with the oak hardfork.
   169  	OakHardforkTxnSizeLimit = uint64(64e3) // 64 KB
   170  	// OakMaxBlockShift is the maximum number of seconds that the oak algorithm will shift
   171  	// the difficulty.
   172  	OakMaxBlockShift int64
   173  	// OakMaxDrop is the drop is the maximum amount that the difficulty will drop each block.
   174  	OakMaxDrop *big.Rat
   175  	// OakMaxRise is the maximum amount that the difficulty will rise each block.
   176  	OakMaxRise *big.Rat
   177  
   178  	// RootDepth is the cumulative target of all blocks. The root depth is essentially
   179  	// the maximum possible target, there have been no blocks yet, so there is no
   180  	// cumulated difficulty yet.
   181  	RootDepth = Target{255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255}
   182  	// RootTarget is the target for the genesis block - basically how much work needs
   183  	// to be done in order to mine the first block. The difficulty adjustment algorithm
   184  	// takes over from there.
   185  	RootTarget Target
   186  	// SiacoinPrecision is the number of base units in a siacoin. The Sia network has a very
   187  	// large number of base units. We call 10^24 of these a siacoin.
   188  	//
   189  	// The base unit for Bitcoin is called a satoshi. We call 10^8 satoshis a bitcoin,
   190  	// even though the code itself only ever works with satoshis.
   191  	SiacoinPrecision = NewCurrency(new(big.Int).Exp(big.NewInt(10), big.NewInt(24), nil))
   192  	// SiafundCount is the total number of Siafunds in existence.
   193  	SiafundCount = NewCurrency64(10000)
   194  	// SiafundPortion is the percentage of siacoins that is taxed from FileContracts.
   195  	SiafundPortion = big.NewRat(39, 1000)
   196  	// TargetWindow is the number of blocks to look backwards when determining how much
   197  	// time has passed vs. how many blocks have been created. It's only used in the old,
   198  	// broken difficulty adjustment algorithm.
   199  	TargetWindow BlockHeight
   200  )
   201  
   202  var (
   203  	// TaxHardforkHeight is the height at which the tax hardfork occurred.
   204  	TaxHardforkHeight = build.Select(build.Var{
   205  		Dev:      BlockHeight(10),
   206  		Standard: BlockHeight(21e3),
   207  		Testing:  BlockHeight(10),
   208  	}).(BlockHeight)
   209  )
   210  
   211  // scanAddress scans a types.UnlockHash from a string.
   212  func scanAddress(addrStr string) (addr UnlockHash, err error) {
   213  	err = addr.LoadString(addrStr)
   214  	if err != nil {
   215  		return UnlockHash{}, err
   216  	}
   217  	return addr, nil
   218  }
   219  
   220  // UnlockHashFromAddrStr convert string address to UnlockHash
   221  func UnlockHashFromAddrStr(addrStr string) (addr UnlockHash) {
   222  	dest, err := scanAddress(addrStr)
   223  	if err != nil {
   224  		return UnlockHash{}
   225  	}
   226  	return dest
   227  }
   228  
   229  // init checks which build constant is in place and initializes the variables
   230  // accordingly.
   231  func init() {
   232  	if build.Release == "dev" {
   233  		// 'dev' settings are for small developer testnets, usually on the same
   234  		// computer. Settings are slow enough that a small team of developers
   235  		// can coordinate their actions over a the developer testnets, but fast
   236  		// enough that there isn't much time wasted on waiting for things to
   237  		// happen.
   238  		ASICHardforkHeight = math.MaxInt64
   239  		ASICHardforkTotalTarget = Target{0, 0, 0, 8}
   240  		ASICHardforkTotalTime = 800
   241  
   242  		BlockFrequency = 12                      // 12 seconds: slow enough for developers to see ~each block, fast enough that blocks don't waste time.
   243  		MaturityDelay = 10                       // 60 seconds before a delayed output matures.
   244  		GenesisTimestamp = Timestamp(1528293910) // Change as necessary.
   245  		RootTarget = Target{0, 0, 2}             // Standard developer CPUs will be able to mine blocks with the race library activated.
   246  
   247  		TargetWindow = 20                              // Difficulty is adjusted based on prior 20 blocks.
   248  		MaxTargetAdjustmentUp = big.NewRat(120, 100)   // Difficulty adjusts quickly.
   249  		MaxTargetAdjustmentDown = big.NewRat(100, 120) // Difficulty adjusts quickly.
   250  		FutureThreshold = 2 * 60                       // 2 minutes.
   251  		ExtremeFutureThreshold = 4 * 60                // 4 minutes.
   252  
   253  		MinimumCoinbase = 30e3
   254  
   255  		OakHardforkBlock = 100
   256  		OakHardforkFixBlock = 105
   257  		OakDecayNum = 985
   258  		OakDecayDenom = 1000
   259  		OakMaxBlockShift = 3
   260  		OakMaxRise = big.NewRat(102, 100)
   261  		OakMaxDrop = big.NewRat(100, 102)
   262  
   263  		GenesisAirdropAllocation = []SiacoinOutput{
   264  			{
   265  				Value:      AirdropCommunityValue,
   266  				UnlockHash: UnlockHashFromAddrStr("436890aacc53f93f9cc4538d9b4abba27dd5be6ff8a064fae7b78a67809db5e210819ffc4a21"),
   267  			},
   268  			{
   269  				Value:      AirdropPoolValue,
   270  				UnlockHash: UnlockHashFromAddrStr("78054218b7d0bc04929e5a3e6a2ac5fed29b98898cba3d740dd31a1aae6e8c8b3ce7467d4e8f"),
   271  			},
   272  			{
   273  				Value:      AirdropNebulousLabsValue,
   274  				UnlockHash: UnlockHashFromAddrStr("7d0c44f7664e2d34e53efde0661a6f628ec9264785ae8e3cd7c973e8d190c3c97b5e3ecbc567"),
   275  			},
   276  			{
   277  				Value:      AirdropSiaPrimeValue,
   278  				UnlockHash: UnlockHashFromAddrStr("aefe0af2713c112ba4d10dee7753726e5c4de3f237ea455151342615c95d0e797d7a8cce7b05"),
   279  			},
   280  		}
   281  
   282  		GenesisSiafundAllocation = []SiafundOutput{
   283  			{
   284  				Value:      NewCurrency64(2000),
   285  				UnlockHash: UnlockHash{214, 166, 197, 164, 29, 201, 53, 236, 106, 239, 10, 158, 127, 131, 20, 138, 63, 221, 230, 16, 98, 247, 32, 77, 210, 68, 116, 12, 241, 89, 27, 223},
   286  			},
   287  			{
   288  				Value:      NewCurrency64(7000),
   289  				UnlockHash: UnlockHash{209, 246, 228, 60, 248, 78, 242, 110, 9, 8, 227, 248, 225, 216, 163, 52, 142, 93, 47, 176, 103, 41, 137, 80, 212, 8, 132, 58, 241, 189, 2, 17},
   290  			},
   291  			{
   292  				Value:      NewCurrency64(1000),
   293  				UnlockHash: UnlockConditions{}.UnlockHash(),
   294  			},
   295  		}
   296  
   297  		ForkedGenesisSiafundAllocation = GenesisSiafundAllocation
   298  	} else if build.Release == "testing" {
   299  		// 'testing' settings are for automatic testing, and create much faster
   300  		// environments than a human can interact with.
   301  		ASICHardforkHeight = math.MaxInt64
   302  		ASICHardforkTotalTarget = Target{255, 255}
   303  		ASICHardforkTotalTime = 10e3
   304  
   305  		BlockFrequency = 1 // As fast as possible
   306  		MaturityDelay = 3
   307  		GenesisTimestamp = CurrentTimestamp() - 1e6
   308  		RootTarget = Target{128} // Takes an expected 2 hashes; very fast for testing but still probes 'bad hash' code.
   309  
   310  		// A restrictive difficulty clamp prevents the difficulty from climbing
   311  		// during testing, as the resolution on the difficulty adjustment is
   312  		// only 1 second and testing mining should be happening substantially
   313  		// faster than that.
   314  		TargetWindow = 200
   315  		MaxTargetAdjustmentUp = big.NewRat(10001, 10000)
   316  		MaxTargetAdjustmentDown = big.NewRat(9999, 10000)
   317  		FutureThreshold = 3        // 3 seconds
   318  		ExtremeFutureThreshold = 6 // 6 seconds
   319  
   320  		MinimumCoinbase = 299990 // Minimum coinbase is hit after 10 blocks to make testing minimum-coinbase code easier.
   321  
   322  		// Do not let the difficulty change rapidly - blocks will be getting
   323  		// mined far faster than the difficulty can adjust to.
   324  		OakHardforkBlock = 20
   325  		OakHardforkFixBlock = 23
   326  		OakDecayNum = 9999
   327  		OakDecayDenom = 10e3
   328  		OakMaxBlockShift = 3
   329  		OakMaxRise = big.NewRat(10001, 10e3)
   330  		OakMaxDrop = big.NewRat(10e3, 10001)
   331  
   332  		GenesisAirdropAllocation = []SiacoinOutput{
   333  			{
   334  				Value:      AirdropCommunityValue,
   335  				UnlockHash: UnlockHashFromAddrStr("436890aacc53f93f9cc4538d9b4abba27dd5be6ff8a064fae7b78a67809db5e210819ffc4a21"),
   336  			},
   337  			{
   338  				Value:      AirdropPoolValue,
   339  				UnlockHash: UnlockHashFromAddrStr("78054218b7d0bc04929e5a3e6a2ac5fed29b98898cba3d740dd31a1aae6e8c8b3ce7467d4e8f"),
   340  			},
   341  			{
   342  				Value:      AirdropNebulousLabsValue,
   343  				UnlockHash: UnlockHashFromAddrStr("7d0c44f7664e2d34e53efde0661a6f628ec9264785ae8e3cd7c973e8d190c3c97b5e3ecbc567"),
   344  			},
   345  			{
   346  				Value:      AirdropSiaPrimeValue,
   347  				UnlockHash: UnlockHashFromAddrStr("aefe0af2713c112ba4d10dee7753726e5c4de3f237ea455151342615c95d0e797d7a8cce7b05"),
   348  			},
   349  		}
   350  
   351  		GenesisSiafundAllocation = []SiafundOutput{
   352  			{
   353  				Value:      NewCurrency64(2000),
   354  				UnlockHash: UnlockHash{214, 166, 197, 164, 29, 201, 53, 236, 106, 239, 10, 158, 127, 131, 20, 138, 63, 221, 230, 16, 98, 247, 32, 77, 210, 68, 116, 12, 241, 89, 27, 223},
   355  			},
   356  			{
   357  				Value:      NewCurrency64(7000),
   358  				UnlockHash: UnlockHash{209, 246, 228, 60, 248, 78, 242, 110, 9, 8, 227, 248, 225, 216, 163, 52, 142, 93, 47, 176, 103, 41, 137, 80, 212, 8, 132, 58, 241, 189, 2, 17},
   359  			},
   360  			{
   361  				Value:      NewCurrency64(1000),
   362  				UnlockHash: UnlockConditions{}.UnlockHash(),
   363  			},
   364  		}
   365  
   366  		ForkedGenesisSiafundAllocation = GenesisSiafundAllocation
   367  	} else if build.Release == "standard" {
   368  		// 'standard' settings are for the full network. They are slow enough
   369  		// that the network is secure in a real-world byzantine environment.
   370  
   371  		// A hardfork height of max int64 was chosen to clarify that the we
   372  		// expect the hardfork to never happen on the SiaPrime blockchain.
   373  		// A total time of 120,000 is chosen because that represents the total
   374  		// time elapsed at a perfect equilibrium, indicating a visible average
   375  		// block time that perfectly aligns with what is expected. A total
   376  		// target of 67 leading zeroes is chosen because that aligns with the
   377  		// amount of hashrate that we expect to be on the network after the
   378  		// hardfork.
   379  		ASICHardforkHeight = math.MaxInt64
   380  		ASICHardforkTotalTarget = Target{0, 0, 0, 0, 0, 0, 0, 0, 32}
   381  		ASICHardforkTotalTime = 120e3
   382  
   383  		// A block time of 1 block per 10 minutes is chosen to follow Bitcoin's
   384  		// example. The security lost by lowering the block time is not
   385  		// insignificant, and the convenience gained by lowering the blocktime
   386  		// even down to 90 seconds is not significant. I do feel that 10
   387  		// minutes could even be too short, but it has worked well for Bitcoin.
   388  		BlockFrequency = 600
   389  
   390  		// Payouts take 1 day to mature. This is to prevent a class of double
   391  		// spending attacks parties unintentionally spend coins that will stop
   392  		// existing after a blockchain reorganization. There are multiple
   393  		// classes of payouts in Sia that depend on a previous block - if that
   394  		// block changes, then the output changes and the previously existing
   395  		// output ceases to exist. This delay stops both unintentional double
   396  		// spending and stops a small set of long-range mining attacks.
   397  		MaturityDelay = 144
   398  
   399  		// The genesis timestamp is set to June 6th, because that is when the
   400  		// 100-block developer premine started. The trailing zeroes are a
   401  		// bonus, and make the timestamp easier to memorize.
   402  		GenesisTimestamp = Timestamp(1540955779)
   403  
   404  		// The RootTarget was set such that the developers could reasonable
   405  		// premine 100 blocks in a day. It was known to the developers at launch
   406  		// this this was at least one and perhaps two orders of magnitude too
   407  		// small.
   408  		RootTarget = Target{0, 0, 0, 0, 0, 0, 2}
   409  
   410  		// When the difficulty is adjusted, it is adjusted by looking at the
   411  		// timestamp of the 1000th previous block. This minimizes the abilities
   412  		// of miners to attack the network using rogue timestamps.
   413  		TargetWindow = 1e3
   414  
   415  		// The difficulty adjustment is clamped to 2.5x every 500 blocks. This
   416  		// corresponds to 6.25x every 2 weeks, which can be compared to
   417  		// Bitcoin's clamp of 4x every 2 weeks. The difficulty clamp is
   418  		// primarily to stop difficulty raising attacks. Sia's safety margin is
   419  		// similar to Bitcoin's despite the looser clamp because Sia's
   420  		// difficulty is adjusted four times as often. This does result in
   421  		// greater difficulty oscillation, a tradeoff that was chosen to be
   422  		// acceptable due to Sia's more vulnerable position as an altcoin.
   423  		MaxTargetAdjustmentUp = big.NewRat(25, 10)
   424  		MaxTargetAdjustmentDown = big.NewRat(10, 25)
   425  
   426  		// Blocks will not be accepted if their timestamp is more than 3 hours
   427  		// into the future, but will be accepted as soon as they are no longer
   428  		// 3 hours into the future. Blocks that are greater than 5 hours into
   429  		// the future are rejected outright, as it is assumed that by the time
   430  		// 2 hours have passed, those blocks will no longer be on the longest
   431  		// chain. Blocks cannot be kept forever because this opens a DoS
   432  		// vector.
   433  		FutureThreshold = 3 * 60 * 60        // 3 hours.
   434  		ExtremeFutureThreshold = 5 * 60 * 60 // 5 hours.
   435  
   436  		// The minimum coinbase is set to 10,000. Because the coinbase
   437  		// decreases by 1 every time, it means that Sia's coinbase will have an
   438  		// increasingly potent dropoff for about 5 years, until inflation more
   439  		// or less permanently settles around 2%.
   440  		MinimumCoinbase = 10e3
   441  
   442  		// The oak difficulty adjustment hardfork is set to trigger at block
   443  		// 135,000, which is just under 6 months after the hardfork was first
   444  		// released as beta software to the network. This hopefully gives
   445  		// everyone plenty of time to upgrade and adopt the hardfork, while also
   446  		// being earlier than the most optimistic shipping dates for the miners
   447  		// that would otherwise be very disruptive to the network.
   448  		//
   449  		// There was a bug in the original Oak hardfork that had to be quickly
   450  		// followed up with another fix. The height of that fix is the
   451  		// OakHardforkFixBlock.
   452  		OakHardforkBlock = 1500
   453  		OakHardforkFixBlock = 1500
   454  
   455  		// The decay is kept at 995/1000, or a decay of about 0.5% each block.
   456  		// This puts the halflife of a block's relevance at about 1 day. This
   457  		// allows the difficulty to adjust rapidly if the hashrate is adjusting
   458  		// rapidly, while still keeping a relatively strong insulation against
   459  		// random variance.
   460  		OakDecayNum = 995
   461  		OakDecayDenom = 1e3
   462  
   463  		// The block shift determines the most that the difficulty adjustment
   464  		// algorithm is allowed to shift the target block time. With a block
   465  		// frequency of 600 seconds, the min target block time is 200 seconds,
   466  		// and the max target block time is 1800 seconds.
   467  		OakMaxBlockShift = 3
   468  
   469  		// The max rise and max drop for the difficulty is kept at 0.4% per
   470  		// block, which means that in 1008 blocks the difficulty can move a
   471  		// maximum of about 55x. This is significant, and means that dramatic
   472  		// hashrate changes can be responded to quickly, while still forcing an
   473  		// attacker to do a significant amount of work in order to execute a
   474  		// difficulty raising attack, and minimizing the chance that an attacker
   475  		// can get lucky and fake a ton of work.
   476  		OakMaxRise = big.NewRat(1004, 1e3)
   477  		OakMaxDrop = big.NewRat(1e3, 1004)
   478  
   479  		GenesisAirdropAllocation = []SiacoinOutput{
   480  			{
   481  				Value:      AirdropCommunityValue,
   482  				UnlockHash: UnlockHashFromAddrStr("436890aacc53f93f9cc4538d9b4abba27dd5be6ff8a064fae7b78a67809db5e210819ffc4a21"),
   483  			},
   484  			{
   485  				Value:      AirdropPoolValue,
   486  				UnlockHash: UnlockHashFromAddrStr("78054218b7d0bc04929e5a3e6a2ac5fed29b98898cba3d740dd31a1aae6e8c8b3ce7467d4e8f"),
   487  			},
   488  			{
   489  				Value:      AirdropNebulousLabsValue,
   490  				UnlockHash: UnlockHashFromAddrStr("7d0c44f7664e2d34e53efde0661a6f628ec9264785ae8e3cd7c973e8d190c3c97b5e3ecbc567"),
   491  			},
   492  			{
   493  				Value:      AirdropSiaPrimeValue,
   494  				UnlockHash: UnlockHashFromAddrStr("aefe0af2713c112ba4d10dee7753726e5c4de3f237ea455151342615c95d0e797d7a8cce7b05"),
   495  			},
   496  		}
   497  
   498  		ForkedGenesisSiafundAllocation = []SiafundOutput{
   499  			{
   500  				Value:      NewCurrency64(10000),
   501  				UnlockHash: UnlockHashFromAddrStr("436890aacc53f93f9cc4538d9b4abba27dd5be6ff8a064fae7b78a67809db5e210819ffc4a21"),
   502  			},
   503  		}
   504  
   505  		GenesisSiafundAllocation = []SiafundOutput{
   506  			{
   507  				Value:      NewCurrency64(2),
   508  				UnlockHash: UnlockHash{4, 57, 229, 188, 127, 20, 204, 245, 211, 167, 232, 130, 208, 64, 146, 62, 69, 98, 81, 102, 221, 7, 123, 100, 70, 107, 199, 113, 121, 26, 198, 252},
   509  			},
   510  			{
   511  				Value:      NewCurrency64(6),
   512  				UnlockHash: UnlockHash{4, 158, 29, 42, 105, 119, 43, 5, 138, 72, 190, 190, 101, 114, 79, 243, 189, 248, 208, 151, 30, 187, 233, 148, 225, 233, 28, 159, 19, 232, 75, 244},
   513  			},
   514  			{
   515  				Value:      NewCurrency64(7),
   516  				UnlockHash: UnlockHash{8, 7, 66, 250, 25, 74, 247, 108, 162, 79, 220, 151, 202, 228, 241, 11, 130, 138, 13, 248, 193, 167, 136, 197, 65, 63, 234, 174, 205, 216, 71, 230},
   517  			},
   518  			{
   519  				Value:      NewCurrency64(8),
   520  				UnlockHash: UnlockHash{44, 106, 239, 51, 138, 102, 242, 19, 204, 197, 248, 178, 219, 122, 152, 251, 19, 20, 52, 32, 175, 32, 4, 156, 73, 33, 163, 165, 222, 184, 217, 218},
   521  			},
   522  			{
   523  				Value:      NewCurrency64(3),
   524  				UnlockHash: UnlockHash{44, 163, 31, 233, 74, 103, 55, 132, 230, 159, 97, 78, 149, 147, 65, 110, 164, 211, 105, 173, 158, 29, 202, 43, 85, 217, 85, 75, 83, 37, 205, 223},
   525  			},
   526  			{
   527  				Value:      NewCurrency64(1),
   528  				UnlockHash: UnlockHash{51, 151, 146, 84, 199, 7, 59, 89, 111, 172, 227, 200, 62, 55, 165, 253, 238, 186, 28, 145, 47, 137, 200, 15, 70, 199, 187, 125, 243, 104, 179, 240},
   529  			},
   530  			{
   531  				Value:      NewCurrency64(10),
   532  				UnlockHash: UnlockHash{53, 118, 253, 229, 254, 229, 28, 131, 233, 156, 108, 58, 197, 152, 17, 160, 74, 252, 11, 49, 112, 240, 66, 119, 40, 98, 114, 251, 5, 86, 233, 117},
   533  			},
   534  			{
   535  				Value:      NewCurrency64(50),
   536  				UnlockHash: UnlockHash{56, 219, 3, 50, 28, 3, 166, 95, 141, 163, 202, 35, 60, 199, 219, 10, 151, 176, 228, 97, 176, 133, 189, 33, 211, 202, 83, 197, 31, 208, 254, 193},
   537  			},
   538  			{
   539  				Value:      NewCurrency64(75),
   540  				UnlockHash: UnlockHash{68, 190, 140, 87, 96, 232, 150, 32, 161, 177, 204, 65, 228, 223, 87, 217, 134, 90, 25, 56, 51, 45, 72, 107, 129, 12, 29, 202, 6, 7, 50, 13},
   541  			},
   542  			{
   543  				Value:      NewCurrency64(10),
   544  				UnlockHash: UnlockHash{69, 14, 201, 200, 90, 73, 245, 45, 154, 94, 161, 19, 199, 241, 203, 56, 13, 63, 5, 220, 121, 245, 247, 52, 194, 181, 252, 76, 130, 6, 114, 36},
   545  			},
   546  			{
   547  				Value:      NewCurrency64(10),
   548  				UnlockHash: UnlockHash{72, 128, 253, 207, 169, 48, 1, 26, 237, 205, 169, 102, 196, 224, 42, 186, 95, 151, 59, 226, 203, 136, 251, 223, 165, 38, 88, 110, 47, 213, 121, 224},
   549  			},
   550  			{
   551  				Value:      NewCurrency64(50),
   552  				UnlockHash: UnlockHash{72, 130, 164, 227, 218, 28, 60, 15, 56, 151, 212, 242, 77, 131, 232, 131, 42, 57, 132, 173, 113, 118, 66, 183, 38, 79, 96, 178, 105, 108, 26, 247},
   553  			},
   554  			{
   555  				Value:      NewCurrency64(10),
   556  				UnlockHash: UnlockHash{74, 210, 58, 228, 111, 69, 253, 120, 53, 195, 110, 26, 115, 76, 211, 202, 199, 159, 204, 14, 78, 92, 14, 131, 250, 22, 141, 236, 154, 44, 39, 135},
   557  			},
   558  			{
   559  				Value:      NewCurrency64(15),
   560  				UnlockHash: UnlockHash{85, 198, 154, 41, 196, 116, 226, 114, 202, 94, 214, 147, 87, 84, 247, 164, 195, 79, 58, 123, 26, 33, 68, 65, 116, 79, 181, 241, 241, 208, 215, 184},
   561  			},
   562  			{
   563  				Value:      NewCurrency64(121),
   564  				UnlockHash: UnlockHash{87, 239, 83, 125, 152, 14, 19, 22, 203, 136, 46, 192, 203, 87, 224, 190, 77, 236, 125, 18, 142, 223, 146, 70, 16, 23, 252, 19, 100, 69, 91, 111},
   565  			},
   566  			{
   567  				Value:      NewCurrency64(222),
   568  				UnlockHash: UnlockHash{91, 201, 101, 11, 188, 40, 35, 111, 236, 133, 31, 124, 97, 246, 140, 136, 143, 245, 152, 174, 111, 245, 188, 124, 21, 125, 187, 192, 203, 92, 253, 57},
   569  			},
   570  			{
   571  				Value:      NewCurrency64(10),
   572  				UnlockHash: UnlockHash{110, 240, 238, 173, 78, 138, 185, 138, 179, 227, 135, 153, 54, 132, 46, 62, 226, 206, 204, 35, 174, 107, 156, 15, 142, 2, 93, 132, 163, 60, 50, 89},
   573  			},
   574  			{
   575  				Value:      NewCurrency64(3),
   576  				UnlockHash: UnlockHash{114, 58, 147, 44, 64, 69, 72, 184, 65, 178, 213, 94, 157, 44, 88, 106, 92, 31, 145, 193, 215, 200, 215, 233, 99, 116, 36, 197, 160, 70, 79, 153},
   577  			},
   578  			{
   579  				Value:      NewCurrency64(1),
   580  				UnlockHash: UnlockHash{123, 106, 229, 101, 220, 252, 50, 203, 38, 183, 133, 152, 250, 167, 210, 155, 252, 102, 150, 29, 187, 3, 178, 53, 11, 145, 143, 33, 166, 115, 250, 40},
   581  			},
   582  			{
   583  				Value:      NewCurrency64(5),
   584  				UnlockHash: UnlockHash{124, 101, 207, 175, 50, 119, 207, 26, 62, 15, 247, 141, 150, 174, 73, 247, 238, 28, 77, 255, 222, 104, 166, 244, 112, 86, 227, 80, 215, 45, 69, 143},
   585  			},
   586  			{
   587  				Value:      NewCurrency64(10),
   588  				UnlockHash: UnlockHash{130, 184, 72, 15, 227, 79, 217, 205, 120, 254, 67, 69, 10, 49, 76, 194, 222, 30, 242, 62, 88, 179, 51, 117, 27, 166, 140, 6, 7, 22, 222, 185},
   589  			},
   590  			{
   591  				Value:      NewCurrency64(25),
   592  				UnlockHash: UnlockHash{134, 137, 198, 172, 96, 54, 45, 10, 100, 128, 91, 225, 226, 134, 143, 108, 31, 70, 187, 228, 54, 212, 70, 229, 149, 57, 64, 166, 153, 123, 238, 180},
   593  			},
   594  			{
   595  				Value:      NewCurrency64(1),
   596  				UnlockHash: UnlockHash{143, 253, 118, 229, 109, 181, 141, 224, 91, 144, 123, 160, 203, 221, 119, 104, 172, 13, 105, 77, 171, 185, 122, 54, 229, 168, 6, 130, 160, 130, 182, 151},
   597  			},
   598  			{
   599  				Value:      NewCurrency64(8),
   600  				UnlockHash: UnlockHash{147, 108, 249, 16, 36, 249, 108, 184, 196, 212, 241, 120, 219, 63, 45, 184, 86, 53, 96, 207, 130, 96, 210, 251, 136, 9, 193, 160, 131, 198, 221, 185},
   601  			},
   602  			{
   603  				Value:      NewCurrency64(58),
   604  				UnlockHash: UnlockHash{155, 79, 89, 28, 69, 71, 239, 198, 246, 2, 198, 254, 92, 59, 192, 205, 229, 152, 36, 186, 110, 122, 233, 221, 76, 143, 3, 238, 89, 231, 192, 23},
   605  			},
   606  			{
   607  				Value:      NewCurrency64(2),
   608  				UnlockHash: UnlockHash{156, 32, 76, 105, 213, 46, 66, 50, 27, 85, 56, 9, 106, 193, 80, 145, 19, 101, 84, 177, 145, 4, 125, 28, 79, 252, 43, 83, 118, 110, 206, 247},
   609  			},
   610  			{
   611  				Value:      NewCurrency64(23),
   612  				UnlockHash: UnlockHash{157, 169, 134, 24, 254, 22, 58, 188, 119, 87, 201, 238, 55, 168, 194, 131, 88, 18, 39, 168, 37, 2, 198, 194, 93, 202, 116, 146, 189, 17, 108, 44},
   613  			},
   614  			{
   615  				Value:      NewCurrency64(10),
   616  				UnlockHash: UnlockHash{158, 51, 104, 36, 242, 114, 67, 16, 168, 230, 4, 111, 241, 72, 5, 14, 182, 102, 169, 156, 144, 220, 103, 117, 223, 8, 58, 187, 124, 102, 80, 44},
   617  			},
   618  			{
   619  				Value:      NewCurrency64(1),
   620  				UnlockHash: UnlockHash{160, 175, 59, 33, 223, 30, 82, 60, 34, 110, 28, 203, 249, 93, 3, 16, 218, 12, 250, 206, 138, 231, 85, 67, 69, 191, 68, 198, 160, 87, 154, 68},
   621  			},
   622  			{
   623  				Value:      NewCurrency64(75),
   624  				UnlockHash: UnlockHash{163, 94, 51, 220, 14, 144, 83, 112, 62, 10, 0, 173, 161, 234, 211, 176, 186, 84, 9, 189, 250, 111, 33, 231, 114, 87, 100, 75, 72, 217, 11, 26},
   625  			},
   626  			{
   627  				Value:      NewCurrency64(3),
   628  				UnlockHash: UnlockHash{170, 7, 138, 116, 205, 20, 132, 197, 166, 251, 75, 93, 69, 6, 109, 244, 212, 119, 173, 114, 34, 18, 25, 21, 111, 203, 203, 253, 138, 104, 27, 36},
   629  			},
   630  			{
   631  				Value:      NewCurrency64(90),
   632  				UnlockHash: UnlockHash{173, 120, 128, 104, 186, 86, 151, 140, 191, 23, 231, 193, 77, 245, 243, 104, 196, 55, 155, 243, 111, 15, 84, 139, 148, 187, 173, 47, 104, 69, 141, 39},
   633  			},
   634  			{
   635  				Value:      NewCurrency64(20),
   636  				UnlockHash: UnlockHash{179, 185, 228, 166, 139, 94, 13, 193, 255, 227, 174, 99, 120, 105, 109, 221, 247, 4, 155, 243, 229, 37, 26, 98, 222, 12, 91, 80, 223, 33, 61, 56},
   637  			},
   638  			{
   639  				Value:      NewCurrency64(5),
   640  				UnlockHash: UnlockHash{193, 49, 103, 20, 170, 135, 182, 85, 149, 18, 159, 194, 152, 120, 162, 208, 49, 158, 220, 188, 114, 79, 1, 131, 62, 27, 86, 57, 244, 46, 64, 66},
   641  			},
   642  			{
   643  				Value:      NewCurrency64(1),
   644  				UnlockHash: UnlockHash{196, 71, 45, 222, 0, 21, 12, 121, 197, 224, 101, 65, 40, 57, 19, 119, 112, 205, 166, 23, 2, 91, 75, 231, 69, 143, 221, 68, 245, 75, 7, 52},
   645  			},
   646  			{
   647  				Value:      NewCurrency64(44),
   648  				UnlockHash: UnlockHash{196, 214, 236, 211, 227, 216, 152, 127, 164, 2, 235, 14, 235, 46, 142, 231, 83, 38, 7, 131, 208, 29, 179, 189, 62, 88, 129, 180, 119, 158, 214, 97},
   649  			},
   650  			{
   651  				Value:      NewCurrency64(23),
   652  				UnlockHash: UnlockHash{206, 58, 114, 148, 131, 49, 87, 197, 86, 18, 216, 26, 62, 79, 152, 175, 33, 4, 132, 160, 108, 231, 53, 200, 48, 76, 125, 94, 156, 85, 32, 130},
   653  			},
   654  			{
   655  				Value:      NewCurrency64(80),
   656  				UnlockHash: UnlockHash{200, 103, 135, 126, 197, 2, 203, 63, 241, 6, 245, 195, 220, 102, 27, 74, 232, 249, 201, 86, 207, 34, 51, 26, 180, 151, 136, 108, 112, 56, 132, 72},
   657  			},
   658  			{
   659  				Value:      NewCurrency64(2),
   660  				UnlockHash: UnlockHash{200, 249, 245, 218, 58, 253, 76, 250, 88, 114, 70, 239, 14, 2, 250, 123, 10, 192, 198, 61, 187, 155, 247, 152, 165, 174, 198, 24, 142, 39, 177, 119},
   661  			},
   662  			{
   663  				Value:      NewCurrency64(1),
   664  				UnlockHash: UnlockHash{209, 1, 199, 184, 186, 57, 21, 137, 33, 252, 219, 184, 130, 38, 32, 98, 63, 252, 250, 79, 70, 146, 169, 78, 180, 161, 29, 93, 38, 45, 175, 176},
   665  			},
   666  			{
   667  				Value:      NewCurrency64(2),
   668  				UnlockHash: UnlockHash{212, 107, 233, 43, 185, 138, 79, 253, 12, 237, 214, 17, 219, 198, 151, 92, 81, 129, 17, 120, 139, 58, 66, 119, 126, 220, 132, 136, 3, 108, 57, 58},
   669  			},
   670  			{
   671  				Value:      NewCurrency64(3),
   672  				UnlockHash: UnlockHash{214, 244, 146, 173, 173, 80, 33, 185, 29, 133, 77, 167, 185, 1, 38, 23, 111, 179, 104, 150, 105, 162, 120, 26, 245, 63, 114, 119, 52, 1, 44, 222},
   673  			},
   674  			{
   675  				Value:      NewCurrency64(1),
   676  				UnlockHash: UnlockHash{217, 218, 172, 16, 53, 134, 160, 226, 44, 138, 93, 53, 181, 62, 4, 209, 190, 27, 0, 93, 105, 17, 169, 61, 98, 145, 131, 112, 121, 55, 97, 184},
   677  			},
   678  			{
   679  				Value:      NewCurrency64(1),
   680  				UnlockHash: UnlockHash{223, 162, 172, 55, 54, 193, 37, 142, 200, 213, 230, 48, 186, 145, 184, 206, 15, 225, 167, 19, 37, 70, 38, 48, 135, 87, 205, 81, 187, 237, 181, 180},
   681  			},
   682  			{
   683  				Value:      NewCurrency64(1),
   684  				UnlockHash: UnlockHash{241, 46, 139, 41, 40, 63, 47, 169, 131, 173, 124, 246, 228, 213, 102, 44, 100, 217, 62, 237, 133, 154, 248, 69, 228, 2, 36, 206, 47, 250, 249, 170},
   685  			},
   686  			{
   687  				Value:      NewCurrency64(50),
   688  				UnlockHash: UnlockHash{241, 50, 229, 211, 66, 32, 115, 241, 117, 87, 180, 239, 76, 246, 14, 129, 105, 181, 153, 105, 105, 203, 229, 237, 23, 130, 193, 170, 100, 201, 38, 71},
   689  			},
   690  			{
   691  				Value:      NewCurrency64(8841),
   692  				UnlockHash: UnlockHash{125, 12, 68, 247, 102, 78, 45, 52, 229, 62, 253, 224, 102, 26, 111, 98, 142, 201, 38, 71, 133, 174, 142, 60, 215, 201, 115, 232, 209, 144, 195, 201},
   693  			},
   694  		}
   695  	}
   696  
   697  	// Create the genesis block.
   698  	GenesisBlock = Block{
   699  		Timestamp: GenesisTimestamp,
   700  		Transactions: []Transaction{
   701  			{SiacoinOutputs: GenesisAirdropAllocation},
   702  			{SiafundOutputs: GenesisSiafundAllocation},
   703  		},
   704  	}
   705  	// Calculate the genesis ID.
   706  	GenesisID = GenesisBlock.ID()
   707  }