From 9f58376efca89bb164e684933076ad93bfa6f536 Mon Sep 17 00:00:00 2001 From: "John C. Vernaleo" Date: Tue, 14 Mar 2017 08:34:50 -0400 Subject: [PATCH] Testnet Reset This adds a new testnet2 network with new genesis block, premine address, magic number, etc. Corrected some testnet related comments while there. --- blockchain/chain.go | 5 +- chaincfg/genesis.go | 26 +++++++++++ chaincfg/params.go | 110 ++++++++++++++++++++++++++++++++++++++++++++ chaincfg/premine.go | 6 +++ config.go | 2 +- params.go | 10 +++- wire/protocol.go | 16 ++++--- 7 files changed, 164 insertions(+), 11 deletions(-) diff --git a/blockchain/chain.go b/blockchain/chain.go index bb36f7be..7077e3e9 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -2193,8 +2193,9 @@ func (b *BlockChain) BestSnapshot() *BestState { // // This function MUST be called with the chain state lock held (for reads). func (b *BlockChain) maxBlockSize(prevNode *blockNode) (int64, error) { - // Hard fork voting on block size is not enabled on mainnet. - if b.chainParams.Net == wire.MainNet { + // Hard fork voting on block size is only enabled on testnet v1 and + // simnet. + if b.chainParams.Net != wire.TestNet && b.chainParams.Net != wire.SimNet { return int64(b.chainParams.MaximumBlockSizes[0]), nil } diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index 6c42dab6..dbaa3b2b 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -159,6 +159,32 @@ var testNetGenesisBlock = wire.MsgBlock{ // test network. var testNetGenesisHash = testNetGenesisBlock.BlockHash() +// TestNet2 ------------------------------------------------------------------------ + +// testNetGenesisMerkleRoot is the hash of the first transaction in the genesis block +// for the test network. +var testNet2GenesisMerkleRoot = genesisCoinbaseTxLegacy.TxHash() + +// testNetGenesisBlock defines the genesis block of the block chain which +// serves as the public transaction ledger for the test network (version 3). +var testNet2GenesisBlock = wire.MsgBlock{ + Header: wire.BlockHeader{ + Version: 4, + PrevBlock: chainhash.Hash{}, + MerkleRoot: testNetGenesisMerkleRoot, + Timestamp: time.Unix(1489550400, 0), // 2017-03-15 TestNet10 + Bits: 0x1e00ffff, + SBits: 20000000, + Nonce: 0x18aea41a, + StakeVersion: 0, + }, + Transactions: []*wire.MsgTx{&genesisCoinbaseTxLegacy}, +} + +// testNetGenesisHash is the hash of the first block in the block chain for the +// test network. +var testNet2GenesisHash = testNet2GenesisBlock.BlockHash() + // SimNet ------------------------------------------------------------------------- var regTestGenesisCoinbaseTx = wire.MsgTx{ diff --git a/chaincfg/params.go b/chaincfg/params.go index 86279834..d8a8d585 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -709,6 +709,115 @@ var TestNetParams = Params{ BlockOneLedger: BlockOneLedgerTestNet, } +// Test2NetParams defines the network parameters for the test currency network. +// This network is sometimes simply called "testnet". +// This is the second public iteration of testnet. +var TestNet2Params = Params{ + Name: "testnet2", + Net: wire.TestNet2, + DefaultPort: "19108", + DNSSeeds: []string{ + "testnet-seed.decred.mindcry.org", + "testnet-seed.decred.netpurgatory.org", + "testnet.decredseed.org", + "testnet-seed.decred.org", + }, + + // Chain parameters + GenesisBlock: &testNet2GenesisBlock, + GenesisHash: &testNet2GenesisHash, + PowLimit: testNetPowLimit, + PowLimitBits: 0x1e00ffff, + ReduceMinDifficulty: false, + MinDiffReductionTime: 0, // Does not apply since ReduceMinDifficulty false + GenerateSupported: true, + MaximumBlockSizes: []int{1310720}, + MaxTxSize: 1000000, + TargetTimePerBlock: time.Minute * 2, + WorkDiffAlpha: 1, + WorkDiffWindowSize: 144, + WorkDiffWindows: 20, + TargetTimespan: time.Minute * 2 * 144, // TimePerBlock * WindowSize + RetargetAdjustmentFactor: 4, + + // Subsidy parameters. + BaseSubsidy: 2500000000, // 25 Coin + MulSubsidy: 100, + DivSubsidy: 101, + SubsidyReductionInterval: 2048, + WorkRewardProportion: 6, + StakeRewardProportion: 3, + BlockTaxProportion: 1, + + // Checkpoints ordered from oldest to newest. + Checkpoints: []Checkpoint{}, + + // Consensus rule change deployments. + // + // The miner confirmation window is defined as: + // target proof of work timespan / target proof of work spacing + RuleChangeActivationQuorum: 2520, // 10 % of RuleChangeActivationInterval * TicketsPerBlock + RuleChangeActivationMultiplier: 3, // 75% + RuleChangeActivationDivisor: 4, + RuleChangeActivationInterval: 5040, // 1 week + + // Enforce current block version once majority of the network has + // upgraded. + // 51% (51 / 100) + // Reject previous block versions once a majority of the network has + // upgraded. + // 75% (75 / 100) + BlockEnforceNumRequired: 51, + BlockRejectNumRequired: 75, + BlockUpgradeNumToCheck: 100, + + // Mempool parameters + RelayNonStdTxs: false, + + // Address encoding magics + NetworkAddressPrefix: "T", + PubKeyAddrID: [2]byte{0x28, 0xf7}, // starts with Tk + PubKeyHashAddrID: [2]byte{0x0f, 0x21}, // starts with Ts + PKHEdwardsAddrID: [2]byte{0x0f, 0x01}, // starts with Te + PKHSchnorrAddrID: [2]byte{0x0e, 0xe3}, // starts with TS + ScriptHashAddrID: [2]byte{0x0e, 0xfc}, // starts with Tc + PrivateKeyID: [2]byte{0x23, 0x0e}, // starts with Pt + + // BIP32 hierarchical deterministic extended key magics + HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x97}, // starts with tprv + HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xd1}, // starts with tpub + + // BIP44 coin type used in the hierarchical deterministic path for + // address generation. + HDCoinType: 11, + + // Decred PoS parameters + MinimumStakeDiff: 20000000, // 0.2 Coin + TicketPoolSize: 1024, + TicketsPerBlock: 5, + TicketMaturity: 16, + TicketExpiry: 6144, // 6*TicketPoolSize + CoinbaseMaturity: 16, + SStxChangeMaturity: 1, + TicketPoolSizeWeight: 4, + StakeDiffAlpha: 1, + StakeDiffWindowSize: 144, + StakeDiffWindows: 20, + StakeVersionInterval: 144 * 2 * 7, // ~1 week + MaxFreshStakePerBlock: 20, // 4*TicketsPerBlock + StakeEnabledHeight: 16 + 16, // CoinbaseMaturity + TicketMaturity + StakeValidationHeight: 768, // Arbitrary + StakeBaseSigScript: []byte{0xDE, 0xAD, 0xBE, 0xEF}, + StakeMajorityMultiplier: 3, + StakeMajorityDivisor: 4, + + // Decred organization related parameters. + // Organization address is TccTkqj8wFqrUemmHMRSx8SYEueQYLmuuFk + OrganizationPkScript: hexDecode("4fa6cbd0dbe5ec407fe4c8ad374e667771fa0d44"), + OrganizationPkScriptVersion: 0, + BlockOneLedger: BlockOneLedgerTestNet2, +} + // SimNetParams defines the network parameters for the simulation test Decred // network. This network is similar to the normal test network except it is // intended for private use within a group of individuals doing simulation @@ -1048,5 +1157,6 @@ func init() { // Register all default networks when the package is initialized. mustRegister(&MainNetParams) mustRegister(&TestNetParams) + mustRegister(&TestNet2Params) mustRegister(&SimNetParams) } diff --git a/chaincfg/premine.go b/chaincfg/premine.go index 98017e69..1e516152 100644 --- a/chaincfg/premine.go +++ b/chaincfg/premine.go @@ -3162,6 +3162,12 @@ var BlockOneLedgerTestNet = []*TokenPayout{ {"TsmWaPM77WSyA3aiQ2Q1KnwGDVWvEkhipBc", 100000 * 1e8}, } +// BlockOneLedgerTestNet2 is the block one output ledger for the 2nd test +// network. +var BlockOneLedgerTestNet2 = []*TokenPayout{ + {"TsT5rhHYqJF7sXouh9jHtwQEn5YJ9KKc5L9", 100000 * 1e8}, +} + // BlockOneLedgerSimNet is the block one output ledger for the simulation // network. See under "Decred organization related parameters" in params.go // for information on how to spend these outputs. diff --git a/config.go b/config.go index cc880d56..f00c0909 100644 --- a/config.go +++ b/config.go @@ -511,7 +511,7 @@ func loadConfig() (*config, []string, error) { // while we're at it if cfg.TestNet { numNets++ - activeNetParams = &testNetParams + activeNetParams = &testNet2Params } if cfg.SimNet { numNets++ diff --git a/params.go b/params.go index 92207d84..5e9e9c44 100644 --- a/params.go +++ b/params.go @@ -33,13 +33,19 @@ var mainNetParams = params{ } // testNetParams contains parameters specific to the test network (version 0) -// (wire.TestNet). NOTE: The RPC port is intentionally different than the -// reference implementation - see the mainNetParams comment for details. +// (wire.TestNet). var testNetParams = params{ Params: &chaincfg.TestNetParams, rpcPort: "19109", } +// testNetParams contains parameters specific to the test network (version 2) +// (wire.TestNet2). +var testNet2Params = params{ + Params: &chaincfg.TestNet2Params, + rpcPort: "19109", +} + // simNetParams contains parameters specific to the simulation test network // (wire.SimNet). var simNetParams = params{ diff --git a/wire/protocol.go b/wire/protocol.go index b5aa1953..f380ef11 100644 --- a/wire/protocol.go +++ b/wire/protocol.go @@ -89,12 +89,15 @@ const ( // MainNet represents the main decred network. MainNet CurrencyNet = 0xd9b400f9 - // TestNet represents the regression test network. + // RegTest represents the regression test network. RegTest CurrencyNet = 0xdab500fa - // TestNet represents the test network (version 3). + // TestNet represents the test network. TestNet CurrencyNet = 0x0709000b + // TestNet2 represents the 2nd test network. + TestNet2 CurrencyNet = 0x48e7a065 + // SimNet represents the simulation test network. SimNet CurrencyNet = 0x12141c16 ) @@ -102,10 +105,11 @@ const ( // bnStrings is a map of decred networks back to their constant names for // pretty printing. var bnStrings = map[CurrencyNet]string{ - MainNet: "MainNet", - TestNet: "TestNet", - RegTest: "RegNet", - SimNet: "SimNet", + MainNet: "MainNet", + TestNet: "TestNet", + TestNet2: "TestNet2", + RegTest: "RegNet", + SimNet: "SimNet", } // String returns the CurrencyNet in human-readable form.