Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: Latest consensus active from simnet genesis. #1482

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions blockchain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1766,8 +1766,8 @@ 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 only enabled on testnet v1 (removed
// from code), simnet, and regnet.
if b.chainParams.Net != wire.SimNet && b.chainParams.Net != wire.RegNet {
// from code) and regnet.
if b.chainParams.Net != wire.RegNet {
return int64(b.chainParams.MaximumBlockSizes[0]), nil
}

Expand Down
10 changes: 4 additions & 6 deletions blockchain/difficulty.go
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,9 @@ func sdiffAlgoDeploymentVersion(network wire.CurrencyNet) uint32 {
// This function MUST be called with the chain state lock held (for writes).
func (b *BlockChain) calcNextRequiredStakeDifficulty(curNode *blockNode) (int64, error) {
// Consensus voting on the new stake difficulty algorithm is only
// enabled on mainnet, testnet v2 (removed from code), simnet, and
// regnet.
// enabled on mainnet, testnet v2 (removed from code), and regnet.
net := b.chainParams.Net
if net != wire.MainNet && net != wire.SimNet && net != wire.RegNet {
if net != wire.MainNet && net != wire.RegNet {
return b.calcNextRequiredStakeDifficultyV2(curNode)
}

Expand Down Expand Up @@ -1374,10 +1373,9 @@ func (b *BlockChain) estimateNextStakeDifficultyV2(curNode *blockNode, newTicket
// This function MUST be called with the chain state lock held (for writes).
func (b *BlockChain) estimateNextStakeDifficulty(curNode *blockNode, newTickets int64, useMaxTickets bool) (int64, error) {
// Consensus voting on the new stake difficulty algorithm is only
// enabled on mainnet, testnet v2 (removed from code), simnet, and
// regnet.
// enabled on mainnet, testnet v2 (removed from code), and regnet.
net := b.chainParams.Net
if net != wire.MainNet && net != wire.SimNet && net != wire.RegNet {
if net != wire.MainNet && net != wire.RegNet {
return b.calcNextRequiredStakeDifficultyV2(curNode)
}

Expand Down
4 changes: 2 additions & 2 deletions blockchain/thresholdstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ func (b *BlockChain) ThresholdState(hash *chainhash.Hash, version uint32, deploy
// This function MUST be called with the chain state lock held (for writes).
func (b *BlockChain) isLNFeaturesAgendaActive(prevNode *blockNode) (bool, error) {
// Consensus voting on LN features is only enabled on mainnet, testnet
// v2 (removed from code), simnet, and regnet.
// v2 (removed from code), and regnet.
net := b.chainParams.Net
if net != wire.MainNet && net != wire.SimNet && net != wire.RegNet {
if net != wire.MainNet && net != wire.RegNet {
return true, nil
}

Expand Down
3 changes: 1 addition & 2 deletions blockchain/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,7 @@ func (b *BlockChain) checkBlockHeaderContext(header *wire.BlockHeader, prevNode
// Reject version 5 blocks for networks other than the main
// network once a majority of the network has upgraded.
if b.chainParams.Net != wire.MainNet && header.Version < 6 &&
b.isMajorityVersion(6, prevNode,
b.chainParams.BlockRejectNumRequired) {
b.isMajorityVersion(6, prevNode, b.chainParams.BlockRejectNumRequired) {

str := "new blocks with version %d are no longer valid"
str = fmt.Sprintf(str, header.Version)
Expand Down
89 changes: 1 addition & 88 deletions chaincfg/simnetparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package chaincfg

import (
"math"
"time"

"github.com/decred/dcrd/wire"
Expand Down Expand Up @@ -37,7 +36,7 @@ var SimNetParams = Params{
ReduceMinDifficulty: false,
MinDiffReductionTime: 0, // Does not apply since ReduceMinDifficulty false
GenerateSupported: true,
MaximumBlockSizes: []int{1000000, 1310720},
MaximumBlockSizes: []int{1310720},
MaxTxSize: 1000000,
TargetTimePerBlock: time.Second,
WorkDiffAlpha: 1,
Expand Down Expand Up @@ -66,92 +65,6 @@ var SimNetParams = Params{
RuleChangeActivationMultiplier: 3, // 75%
RuleChangeActivationDivisor: 4,
RuleChangeActivationInterval: 320, // 320 seconds
Deployments: map[uint32][]ConsensusDeployment{
4: {{
Vote: Vote{
Id: VoteIDMaxBlockSize,
Description: "Change maximum allowed block size from 1MiB to 1.25MB",
Mask: 0x0006, // Bits 1 and 2
Choices: []Choice{{
Id: "abstain",
Description: "abstain voting for change",
Bits: 0x0000,
IsAbstain: true,
IsNo: false,
}, {
Id: "no",
Description: "reject changing max allowed block size",
Bits: 0x0002, // Bit 1
IsAbstain: false,
IsNo: true,
}, {
Id: "yes",
Description: "accept changing max allowed block size",
Bits: 0x0004, // Bit 2
IsAbstain: false,
IsNo: false,
}},
},
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires
}},
5: {{
Vote: Vote{
Id: VoteIDSDiffAlgorithm,
Description: "Change stake difficulty algorithm as defined in DCP0001",
Mask: 0x0006, // Bits 1 and 2
Choices: []Choice{{
Id: "abstain",
Description: "abstain voting for change",
Bits: 0x0000,
IsAbstain: true,
IsNo: false,
}, {
Id: "no",
Description: "keep the existing algorithm",
Bits: 0x0002, // Bit 1
IsAbstain: false,
IsNo: true,
}, {
Id: "yes",
Description: "change to the new algorithm",
Bits: 0x0004, // Bit 2
IsAbstain: false,
IsNo: false,
}},
},
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires
}},
6: {{
Vote: Vote{
Id: VoteIDLNFeatures,
Description: "Enable features defined in DCP0002 and DCP0003 necessary to support Lightning Network (LN)",
Mask: 0x0006, // Bits 1 and 2
Choices: []Choice{{
Id: "abstain",
Description: "abstain voting for change",
Bits: 0x0000,
IsAbstain: true,
IsNo: false,
}, {
Id: "no",
Description: "keep the existing consensus rules",
Bits: 0x0002, // Bit 1
IsAbstain: false,
IsNo: true,
}, {
Id: "yes",
Description: "change to the new consensus rules",
Bits: 0x0004, // Bit 2
IsAbstain: false,
IsNo: false,
}},
},
StartTime: 0, // Always available for vote
ExpireTime: math.MaxInt64, // Never expires
}},
},

// Enforce current block version once majority of the network has
// upgraded.
Expand Down
4 changes: 2 additions & 2 deletions mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
generatedBlockVersion = 5

// generatedBlockVersionTest is the version of the block being generated
// for networks other than the main network.
// for networks other than the main and simulation networks.
generatedBlockVersionTest = 6

// blockHeaderOverhead is the max number of bytes it takes to serialize
Expand Down Expand Up @@ -1950,7 +1950,7 @@ mempoolLoop:

// Choose the block version to generate based on the network.
blockVersion := int32(generatedBlockVersion)
if g.chainParams.Net != wire.MainNet {
if g.chainParams.Net != wire.MainNet && g.chainParams.Net != wire.SimNet {
blockVersion = generatedBlockVersionTest
}

Expand Down