From b2648cf1fd82f694f492213814c28d478a6e796a Mon Sep 17 00:00:00 2001 From: Ori Newman Date: Sun, 30 Sep 2018 12:34:08 +0300 Subject: [PATCH] [DEV-132] change TargetTimePerBlock to 10 seconds (#66) * [DEV-132] change TargetTimePerBlock to 10 seconds * [DEV-132] change pow limits to regtest limits in all networks, enable cpu mining in testnet, and get rid of dns seeds in testnet --- blockdag/fullblocktests/params.go | 5 +++-- connmgr/seed.go | 6 +++--- dagconfig/params.go | 34 ++++++++++++++----------------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/blockdag/fullblocktests/params.go b/blockdag/fullblocktests/params.go index 579b9bf31..1c12fde72 100644 --- a/blockdag/fullblocktests/params.go +++ b/blockdag/fullblocktests/params.go @@ -6,11 +6,12 @@ package fullblocktests import ( "encoding/hex" - "github.com/daglabs/btcd/util/hdkeychain" "math" "math/big" "time" + "github.com/daglabs/btcd/util/hdkeychain" + "github.com/daglabs/btcd/dagconfig" "github.com/daglabs/btcd/dagconfig/daghash" "github.com/daglabs/btcd/wire" @@ -108,7 +109,7 @@ var regressionNetParams = &dagconfig.Params{ CoinbaseMaturity: 100, SubsidyReductionInterval: 150, TargetTimespan: time.Hour * 24 * 14, // 14 days - TargetTimePerBlock: time.Minute * 10, // 10 minutes + TargetTimePerBlock: time.Second * 10, // 10 seconds RetargetAdjustmentFactor: 4, // 25% less, 400% more ReduceMinDifficulty: true, MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2 diff --git a/connmgr/seed.go b/connmgr/seed.go index d743ee743..3b44120db 100644 --- a/connmgr/seed.go +++ b/connmgr/seed.go @@ -30,10 +30,10 @@ type OnSeed func(addrs []*wire.NetAddress) type LookupFunc func(string) ([]net.IP, error) // SeedFromDNS uses DNS seeding to populate the address manager with peers. -func SeedFromDNS(chainParams *dagconfig.Params, reqServices wire.ServiceFlag, +func SeedFromDNS(dagParams *dagconfig.Params, reqServices wire.ServiceFlag, lookupFn LookupFunc, seedFn OnSeed) { - for _, dnsseed := range chainParams.DNSSeeds { + for _, dnsseed := range dagParams.DNSSeeds { var host string if !dnsseed.HasFiltering || reqServices == wire.SFNodeNetwork { host = dnsseed.Host @@ -58,7 +58,7 @@ func SeedFromDNS(chainParams *dagconfig.Params, reqServices wire.ServiceFlag, } addresses := make([]*wire.NetAddress, len(seedpeers)) // if this errors then we have *real* problems - intPort, _ := strconv.Atoi(chainParams.DefaultPort) + intPort, _ := strconv.Atoi(dagParams.DefaultPort) for i, peer := range seedpeers { addresses[i] = wire.NewNetAddressTimestamp( // bitcoind seeds with addresses from diff --git a/dagconfig/params.go b/dagconfig/params.go index 82294ab0f..40a3e815b 100644 --- a/dagconfig/params.go +++ b/dagconfig/params.go @@ -6,12 +6,13 @@ package dagconfig import ( "errors" - "github.com/daglabs/btcd/util" - "github.com/daglabs/btcd/util/hdkeychain" "math" "math/big" "time" + "github.com/daglabs/btcd/util" + "github.com/daglabs/btcd/util/hdkeychain" + "github.com/daglabs/btcd/dagconfig/daghash" "github.com/daglabs/btcd/wire" ) @@ -24,8 +25,8 @@ var ( bigOne = big.NewInt(1) // mainPowLimit is the highest proof of work value a Bitcoin block can - // have for the main network. It is the value 2^232 - 1. - mainPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 232), bigOne) + // have for the main network. It is the value 2^255 - 1. + mainPowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne) // regressionPowLimit is the highest proof of work value a Bitcoin block // can have for the regression test network. It is the value 2^255 - 1. @@ -33,8 +34,8 @@ var ( // testNet3PowLimit is the highest proof of work value a Bitcoin block // can have for the test network (version 3). It is the value - // 2^232 - 1. - testNet3PowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 232), bigOne) + // 2^255 - 1. + testNet3PowLimit = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne) // simNetPowLimit is the highest proof of work value a Bitcoin block // can have for the simulation test network. It is the value 2^255 - 1. @@ -227,11 +228,11 @@ var MainNetParams = Params{ GenesisBlock: &genesisBlock, GenesisHash: &genesisHash, PowLimit: mainPowLimit, - PowLimitBits: 0x1d00ffff, + PowLimitBits: 0x207fffff, CoinbaseMaturity: 100, SubsidyReductionInterval: 210000, TargetTimespan: time.Hour * 24 * 14, // 14 days - TargetTimePerBlock: time.Minute * 10, // 10 minutes + TargetTimePerBlock: time.Second * 10, // 10 seconds RetargetAdjustmentFactor: 4, // 25% less, 400% more ReduceMinDifficulty: false, MinDiffReductionTime: 0, @@ -309,7 +310,7 @@ var RegressionNetParams = Params{ CoinbaseMaturity: 100, SubsidyReductionInterval: 150, TargetTimespan: time.Hour * 24 * 14, // 14 days - TargetTimePerBlock: time.Minute * 10, // 10 minutes + TargetTimePerBlock: time.Second * 10, // 10 seconds RetargetAdjustmentFactor: 4, // 25% less, 400% more ReduceMinDifficulty: true, MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2 @@ -358,26 +359,21 @@ var TestNet3Params = Params{ Net: wire.TestNet3, RPCPort: "18334", DefaultPort: "18333", - DNSSeeds: []DNSSeed{ - {"testnet-seed.bitcoin.jonasschnelli.ch", true}, - {"testnet-seed.bitcoin.schildbach.de", false}, - {"seed.tbtc.petertodd.org", true}, - {"testnet-seed.bluematt.me", false}, - }, + DNSSeeds: []DNSSeed{}, // Chain parameters GenesisBlock: &testNet3GenesisBlock, GenesisHash: &testNet3GenesisHash, PowLimit: testNet3PowLimit, - PowLimitBits: 0x1d00ffff, + PowLimitBits: 0x207fffff, CoinbaseMaturity: 100, SubsidyReductionInterval: 210000, TargetTimespan: time.Hour * 24 * 14, // 14 days - TargetTimePerBlock: time.Minute * 10, // 10 minutes + TargetTimePerBlock: time.Second * 10, // 10 seconds RetargetAdjustmentFactor: 4, // 25% less, 400% more ReduceMinDifficulty: true, MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2 - GenerateSupported: false, + GenerateSupported: true, // Checkpoints ordered from oldest to newest. Checkpoints: []Checkpoint{ @@ -448,7 +444,7 @@ var SimNetParams = Params{ CoinbaseMaturity: 100, SubsidyReductionInterval: 210000, TargetTimespan: time.Hour * 24 * 14, // 14 days - TargetTimePerBlock: time.Minute * 10, // 10 minutes + TargetTimePerBlock: time.Second * 10, // 10 seconds RetargetAdjustmentFactor: 4, // 25% less, 400% more ReduceMinDifficulty: true, MinDiffReductionTime: time.Minute * 20, // TargetTimePerBlock * 2