Testnet Reset

This adds a new testnet2 network with new genesis block, premine
address, magic number, etc.

Corrected some testnet related comments while there.
This commit is contained in:
John C. Vernaleo 2017-03-14 08:34:50 -04:00
parent 98af7c78ce
commit 9f58376efc
7 changed files with 164 additions and 11 deletions

View File

@ -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
}

View File

@ -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{

View File

@ -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)
}

View File

@ -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.

View File

@ -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++

View File

@ -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{

View File

@ -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.