This implements a new voting agenda for the testnet and simnet networks for increasing the maximum block size from 1MiB to 1.25MB. The following is an overview of the changes: - Bump the maximum protocol block size limit to 1.25MB - Bump the protocol version to 4 - Add wire tests for v3 protocol sizes and update tests for latest - Update all wire values that are defined in terms of the max block size to respect the protocol version - Update the MaxSigOpsPerBlock constant to maintain existing value regardless of the raised max protocol block size - Decouple the maximum tx size from the block size by creating a chain parameter for it with the current sizes so it is not a part of the hard fork vote - Add definition for new version 4 stake vote along with agenda to vote on block size to the testnet and simnet networks - Convert the MaximumBlockSize chain parameter to a slice in order to hold the different possible sizes - Adds a new function that returns the maximum block size based upon the result of the vote - Change the existing context-free block size check to enforce the max protocol size and introduce a context-specific check which enforces a restricted size based upon the network consensus parameters and the result of the vote - Set the max allowed size in generated block templates based upon the network params and result of the vote - Generate version 4 blocks and reject version 3 blocks after a super majority has been reached
119 lines
3.0 KiB
Go
119 lines
3.0 KiB
Go
// Copyright (c) 2013-2016 The btcsuite developers
|
|
// Copyright (c) 2015-2016 The Decred developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package wire
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
const (
|
|
// InitialProcotolVersion is the initial protocol version for the
|
|
// network.
|
|
InitialProcotolVersion uint32 = 1
|
|
|
|
// ProtocolVersion is the latest protocol version this package supports.
|
|
ProtocolVersion uint32 = 4
|
|
|
|
// BIP0111Version is the protocol version which added the SFNodeBloom
|
|
// service flag.
|
|
BIP0111Version uint32 = 2
|
|
|
|
// SendHeadersVersion is the protocol version which added a new
|
|
// sendheaders message.
|
|
SendHeadersVersion uint32 = 3
|
|
)
|
|
|
|
// ServiceFlag identifies services supported by a decred peer.
|
|
type ServiceFlag uint64
|
|
|
|
const (
|
|
// SFNodeNetwork is a flag used to indicate a peer is a full node.
|
|
SFNodeNetwork ServiceFlag = 1 << iota
|
|
|
|
// SFNodeBloom is a flag used to indiciate a peer supports bloom
|
|
// filtering.
|
|
SFNodeBloom
|
|
)
|
|
|
|
// Map of service flags back to their constant names for pretty printing.
|
|
var sfStrings = map[ServiceFlag]string{
|
|
SFNodeNetwork: "SFNodeNetwork",
|
|
SFNodeBloom: "SFNodeBloom",
|
|
}
|
|
|
|
// orderedSFStrings is an ordered list of service flags from highest to
|
|
// lowest.
|
|
var orderedSFStrings = []ServiceFlag{
|
|
SFNodeNetwork,
|
|
SFNodeBloom,
|
|
}
|
|
|
|
// String returns the ServiceFlag in human-readable form.
|
|
func (f ServiceFlag) String() string {
|
|
// No flags are set.
|
|
if f == 0 {
|
|
return "0x0"
|
|
}
|
|
|
|
// Add individual bit flags.
|
|
s := ""
|
|
for _, flag := range orderedSFStrings {
|
|
if f&flag == flag {
|
|
s += sfStrings[flag] + "|"
|
|
f -= flag
|
|
}
|
|
}
|
|
|
|
// Add any remaining flags which aren't accounted for as hex.
|
|
s = strings.TrimRight(s, "|")
|
|
if f != 0 {
|
|
s += "|0x" + strconv.FormatUint(uint64(f), 16)
|
|
}
|
|
s = strings.TrimLeft(s, "|")
|
|
return s
|
|
}
|
|
|
|
// CurrencyNet represents which decred network a message belongs to.
|
|
type CurrencyNet uint32
|
|
|
|
// Constants used to indicate the message decred network. They can also be
|
|
// used to seek to the next message when a stream's state is unknown, but
|
|
// this package does not provide that functionality since it's generally a
|
|
// better idea to simply disconnect clients that are misbehaving over TCP.
|
|
const (
|
|
// MainNet represents the main decred network.
|
|
MainNet CurrencyNet = 0xd9b400f9
|
|
|
|
// TestNet represents the regression test network.
|
|
RegTest CurrencyNet = 0xdab500fa
|
|
|
|
// TestNet represents the test network (version 3).
|
|
TestNet CurrencyNet = 0x0709000b
|
|
|
|
// SimNet represents the simulation test network.
|
|
SimNet CurrencyNet = 0x12141c16
|
|
)
|
|
|
|
// 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",
|
|
}
|
|
|
|
// String returns the CurrencyNet in human-readable form.
|
|
func (n CurrencyNet) String() string {
|
|
if s, ok := bnStrings[n]; ok {
|
|
return s
|
|
}
|
|
|
|
return fmt.Sprintf("Unknown CurrencyNet (%d)", uint32(n))
|
|
}
|