github.com/decred/dcrd/blockchain@v1.2.1/fullblocktests/params.go (about) 1 // Copyright (c) 2016-2019 The Decred developers 2 // Use of this source code is governed by an ISC 3 // license that can be found in the LICENSE file. 4 5 package fullblocktests 6 7 import ( 8 "encoding/hex" 9 "math" 10 "math/big" 11 "time" 12 13 "github.com/decred/dcrd/chaincfg" 14 "github.com/decred/dcrd/chaincfg/chainhash" 15 "github.com/decred/dcrd/wire" 16 ) 17 18 // newHashFromStr converts the passed big-endian hex string into a 19 // wire.Hash. It only differs from the one available in chainhash in that 20 // it panics on an error since it will only (and must only) be called with 21 // hard-coded, and therefore known good, hashes. 22 func newHashFromStr(hexStr string) *chainhash.Hash { 23 hash, err := chainhash.NewHashFromStr(hexStr) 24 if err != nil { 25 panic(err) 26 } 27 return hash 28 } 29 30 // fromHex converts the passed hex string into a byte slice and will panic if 31 // there is an error. This is only provided for the hard-coded constants so 32 // errors in the source code can be detected. It will only (and must only) be 33 // called for initialization purposes. 34 func fromHex(s string) []byte { 35 r, err := hex.DecodeString(s) 36 if err != nil { 37 panic("invalid hex in source file: " + s) 38 } 39 return r 40 } 41 42 var ( 43 // bigOne is 1 represented as a big.Int. It is defined here to avoid 44 // the overhead of creating it multiple times. 45 bigOne = big.NewInt(1) 46 47 // regNetPowLimit is the highest proof of work value a Decred block 48 // can have for the regression test network. It is the value 2^255 - 1. 49 regNetPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne) 50 51 // regNetGenesisBlock defines the genesis block of the block chain which 52 // serves as the public transaction ledger for the regression test network. 53 regNetGenesisBlock = wire.MsgBlock{ 54 Header: wire.BlockHeader{ 55 Version: 1, 56 PrevBlock: *newHashFromStr("0000000000000000000000000000000000000000000000000000000000000000"), 57 MerkleRoot: *newHashFromStr("66aa7491b9adce110585ccab7e3fb5fe280de174530cca10eba2c6c3df01c10d"), 58 StakeRoot: *newHashFromStr("0000000000000000000000000000000000000000000000000000000000000000"), 59 VoteBits: uint16(0x0000), 60 FinalState: [6]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 61 Voters: uint16(0x0000), 62 FreshStake: uint8(0x00), 63 Revocations: uint8(0x00), 64 Timestamp: time.Unix(1538524800, 0), // 2018-10-03 00:00:00 +0000 UTC 65 PoolSize: uint32(0), 66 Bits: 0x207fffff, // 545259519 67 SBits: int64(0x0000000000000000), 68 Nonce: 0x00000000, 69 Height: uint32(0), 70 }, 71 Transactions: []*wire.MsgTx{{ 72 SerType: wire.TxSerializeFull, 73 Version: 1, 74 TxIn: []*wire.TxIn{{ 75 PreviousOutPoint: wire.OutPoint{ 76 Hash: chainhash.Hash{}, 77 Index: 0xffffffff, 78 }, 79 SignatureScript: fromHex("0000"), 80 Sequence: 0xffffffff, 81 BlockIndex: 0xffffffff, 82 ValueIn: -1, 83 }}, 84 TxOut: []*wire.TxOut{{ 85 Value: 0, 86 PkScript: fromHex("801679e98561ada96caec2949a" + 87 "5d41c4cab3851eb740d951c10ecbcf265c1fd9"), 88 }}, 89 LockTime: 0, 90 Expiry: 0, 91 }}, 92 STransactions: nil, 93 } 94 ) 95 96 // regNetParams defines the network parameters for the regression test network. 97 // 98 // NOTE: The test generator intentionally does not use the existing definitions 99 // in the chaincfg package since the intent is to be able to generate known 100 // good tests which exercise that code. Using the chaincfg parameters would 101 // allow them to change without the tests failing as desired. 102 var regNetParams = &chaincfg.Params{ 103 Name: "regnet", 104 Net: wire.RegNet, 105 DefaultPort: "18655", 106 DNSSeeds: nil, // NOTE: There must NOT be any seeds. 107 108 // Chain parameters 109 GenesisBlock: ®NetGenesisBlock, 110 GenesisHash: newHashFromStr("2ced94b4ae95bba344cfa043268732d230649c640f92dce2d9518823d3057cb0"), 111 PowLimit: regNetPowLimit, 112 PowLimitBits: 0x207fffff, 113 ReduceMinDifficulty: false, 114 MinDiffReductionTime: 0, // Does not apply since ReduceMinDifficulty false 115 GenerateSupported: true, 116 MaximumBlockSizes: []int{1000000, 1310720}, 117 MaxTxSize: 1000000, 118 TargetTimePerBlock: time.Second, 119 WorkDiffAlpha: 1, 120 WorkDiffWindowSize: 8, 121 WorkDiffWindows: 4, 122 TargetTimespan: time.Second * 8, // TimePerBlock * WindowSize 123 RetargetAdjustmentFactor: 4, 124 125 // Subsidy parameters. 126 BaseSubsidy: 50000000000, 127 MulSubsidy: 100, 128 DivSubsidy: 101, 129 SubsidyReductionInterval: 128, 130 WorkRewardProportion: 6, 131 StakeRewardProportion: 3, 132 BlockTaxProportion: 1, 133 134 // Checkpoints ordered from oldest to newest. 135 Checkpoints: nil, 136 137 // Consensus rule change deployments. 138 // 139 // The miner confirmation window is defined as: 140 // target proof of work timespan / target proof of work spacing 141 RuleChangeActivationQuorum: 160, // 10 % of RuleChangeActivationInterval * TicketsPerBlock 142 RuleChangeActivationMultiplier: 3, // 75% 143 RuleChangeActivationDivisor: 4, 144 RuleChangeActivationInterval: 320, // 320 seconds 145 Deployments: map[uint32][]chaincfg.ConsensusDeployment{ 146 4: {{ 147 Vote: chaincfg.Vote{ 148 Id: chaincfg.VoteIDMaxBlockSize, 149 Description: "Change maximum allowed block size from 1MiB to 1.25MB", 150 Mask: 0x0006, // Bits 1 and 2 151 Choices: []chaincfg.Choice{{ 152 Id: "abstain", 153 Description: "abstain voting for change", 154 Bits: 0x0000, 155 IsAbstain: true, 156 IsNo: false, 157 }, { 158 Id: "no", 159 Description: "reject changing max allowed block size", 160 Bits: 0x0002, // Bit 1 161 IsAbstain: false, 162 IsNo: true, 163 }, { 164 Id: "yes", 165 Description: "accept changing max allowed block size", 166 Bits: 0x0004, // Bit 2 167 IsAbstain: false, 168 IsNo: false, 169 }}, 170 }, 171 StartTime: 0, // Always available for vote 172 ExpireTime: math.MaxInt64, // Never expires 173 }}, 174 5: {{ 175 Vote: chaincfg.Vote{ 176 Id: chaincfg.VoteIDSDiffAlgorithm, 177 Description: "Change stake difficulty algorithm as defined in DCP0001", 178 Mask: 0x0006, // Bits 1 and 2 179 Choices: []chaincfg.Choice{{ 180 Id: "abstain", 181 Description: "abstain voting for change", 182 Bits: 0x0000, 183 IsAbstain: true, 184 IsNo: false, 185 }, { 186 Id: "no", 187 Description: "keep the existing algorithm", 188 Bits: 0x0002, // Bit 1 189 IsAbstain: false, 190 IsNo: true, 191 }, { 192 Id: "yes", 193 Description: "change to the new algorithm", 194 Bits: 0x0004, // Bit 2 195 IsAbstain: false, 196 IsNo: false, 197 }}, 198 }, 199 StartTime: 0, // Always available for vote 200 ExpireTime: math.MaxInt64, // Never expires 201 }}, 202 6: {{ 203 Vote: chaincfg.Vote{ 204 Id: chaincfg.VoteIDLNFeatures, 205 Description: "Enable features defined in DCP0002 and DCP0003 necessary to support Lightning Network (LN)", 206 Mask: 0x0006, // Bits 1 and 2 207 Choices: []chaincfg.Choice{{ 208 Id: "abstain", 209 Description: "abstain voting for change", 210 Bits: 0x0000, 211 IsAbstain: true, 212 IsNo: false, 213 }, { 214 Id: "no", 215 Description: "keep the existing consensus rules", 216 Bits: 0x0002, // Bit 1 217 IsAbstain: false, 218 IsNo: true, 219 }, { 220 Id: "yes", 221 Description: "change to the new consensus rules", 222 Bits: 0x0004, // Bit 2 223 IsAbstain: false, 224 IsNo: false, 225 }}, 226 }, 227 StartTime: 0, // Always available for vote 228 ExpireTime: math.MaxInt64, // Never expires 229 }}, 230 7: {{ 231 Vote: chaincfg.Vote{ 232 Id: chaincfg.VoteIDFixLNSeqLocks, 233 Description: "Modify sequence lock handling as defined in DCP0004", 234 Mask: 0x0006, // Bits 1 and 2 235 Choices: []chaincfg.Choice{{ 236 Id: "abstain", 237 Description: "abstain voting for change", 238 Bits: 0x0000, 239 IsAbstain: true, 240 IsNo: false, 241 }, { 242 Id: "no", 243 Description: "keep the existing consensus rules", 244 Bits: 0x0002, // Bit 1 245 IsAbstain: false, 246 IsNo: true, 247 }, { 248 Id: "yes", 249 Description: "change to the new consensus rules", 250 Bits: 0x0004, // Bit 2 251 IsAbstain: false, 252 IsNo: false, 253 }}, 254 }, 255 StartTime: 0, // Always available for vote 256 ExpireTime: math.MaxInt64, // Never expires 257 }}, 258 }, 259 260 // Enforce current block version once majority of the network has 261 // upgraded. 262 // 51% (51 / 100) 263 // Reject previous block versions once a majority of the network has 264 // upgraded. 265 // 75% (75 / 100) 266 BlockEnforceNumRequired: 51, 267 BlockRejectNumRequired: 75, 268 BlockUpgradeNumToCheck: 100, 269 270 // AcceptNonStdTxs is a Mempool param to accept and relay non standard 271 // txs to the network or reject them 272 AcceptNonStdTxs: true, 273 274 // Address encoding magics 275 NetworkAddressPrefix: "R", 276 PubKeyAddrID: [2]byte{0x25, 0xe5}, // starts with Rk 277 PubKeyHashAddrID: [2]byte{0x0e, 0x00}, // starts with Rs 278 PKHEdwardsAddrID: [2]byte{0x0d, 0xe0}, // starts with Re 279 PKHSchnorrAddrID: [2]byte{0x0d, 0xc2}, // starts with RS 280 ScriptHashAddrID: [2]byte{0x0d, 0xdb}, // starts with Rc 281 PrivateKeyID: [2]byte{0x22, 0xfe}, // starts with Pr 282 283 // BIP32 hierarchical deterministic extended key magics 284 HDPrivateKeyID: [4]byte{0xea, 0xb4, 0x04, 0x48}, // starts with rprv 285 HDPublicKeyID: [4]byte{0xea, 0xb4, 0xf9, 0x87}, // starts with rpub 286 287 // BIP44 coin type used in the hierarchical deterministic path for 288 // address generation. 289 SLIP0044CoinType: 1, // SLIP0044, Testnet (all coins) 290 LegacyCoinType: 1, 291 292 // Decred PoS parameters 293 MinimumStakeDiff: 20000, 294 TicketPoolSize: 64, 295 TicketsPerBlock: 5, 296 TicketMaturity: 16, 297 TicketExpiry: 384, // 6*TicketPoolSize 298 CoinbaseMaturity: 16, 299 SStxChangeMaturity: 1, 300 TicketPoolSizeWeight: 4, 301 StakeDiffAlpha: 1, 302 StakeDiffWindowSize: 8, 303 StakeDiffWindows: 8, 304 StakeVersionInterval: 8 * 2 * 7, 305 MaxFreshStakePerBlock: 20, // 4*TicketsPerBlock 306 StakeEnabledHeight: 16 + 16, // CoinbaseMaturity + TicketMaturity 307 StakeValidationHeight: 16 + (64 * 2), // CoinbaseMaturity + TicketPoolSize*2 308 StakeBaseSigScript: []byte{0x73, 0x57}, 309 StakeMajorityMultiplier: 3, 310 StakeMajorityDivisor: 4, 311 312 // Decred organization related parameters 313 OrganizationPkScript: fromHex("a9146913bcc838bd0087fb3f6b3c868423d5e300078d87"), 314 OrganizationPkScriptVersion: 0, 315 BlockOneLedger: []*chaincfg.TokenPayout{ 316 {Address: "RsKrWb7Vny1jnzL1sDLgKTAteh9RZcRr5g6", Amount: 100000 * 1e8}, 317 {Address: "Rs8ca5cDALtsMVD4PV3xvFTC7dmuU1juvLv", Amount: 100000 * 1e8}, 318 {Address: "RsHzbGt6YajuHpurtpqXXHz57LmYZK8w9tX", Amount: 100000 * 1e8}, 319 }, 320 }