Skip to content

Commit d618458

Browse files
committed
Have SegWit active by default
1 parent 4bd8921 commit d618458

File tree

11 files changed

+30
-16
lines changed

11 files changed

+30
-16
lines changed

src/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ class CRegTestParams : public CChainParams {
291291
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
292292
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
293293
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
294-
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 0;
294+
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
295295
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
296296

297297
// The best chain should have at least this much work.

src/test/test_bitcoin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ TestingSetup::~TestingSetup()
106106

107107
TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
108108
{
109+
// CreateAndProcessBlock() does not support building SegWit blocks, so don't activate in these tests.
110+
// TODO: fix the code to support SegWit blocks.
111+
UpdateVersionBitsParameters(Consensus::DEPLOYMENT_SEGWIT, 0, Consensus::BIP9Deployment::NO_TIMEOUT);
109112
// Generate a 100-block chain:
110113
coinbaseKey.MakeNewKey(true);
111114
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;

test/functional/nulldummy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ class NULLDUMMYTest(BitcoinTestFramework):
4040
def set_test_params(self):
4141
self.num_nodes = 1
4242
self.setup_clean_chain = True
43-
self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness']]
43+
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
44+
# normal segwit activation here (and don't use the default always-on behaviour).
45+
self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness', '-vbparams=segwit:0:999999999999']]
4446

4547
def run_test(self):
4648
self.address = self.nodes[0].getnewaddress()

test/functional/p2p-compactblocks.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ def set_test_params(self):
9393
self.setup_clean_chain = True
9494
# Node0 = pre-segwit, node1 = segwit-aware
9595
self.num_nodes = 2
96-
self.extra_args = [["-vbparams=segwit:0:0"], ["-txindex"]]
96+
# This test was written assuming SegWit is activated using BIP9 at height 432 (3x confirmation window).
97+
# TODO: Rewrite this test to support SegWit being always active.
98+
self.extra_args = [["-vbparams=segwit:0:0"], ["-vbparams=segwit:0:999999999999", "-txindex"]]
9799
self.utxos = []
98100

99101
def build_block_on_tip(self, node, segwit=False):

test/functional/p2p-segwit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ class SegWitTest(BitcoinTestFramework):
111111
def set_test_params(self):
112112
self.setup_clean_chain = True
113113
self.num_nodes = 3
114-
self.extra_args = [["-whitelist=127.0.0.1"], ["-whitelist=127.0.0.1", "-acceptnonstdtxn=0"], ["-whitelist=127.0.0.1", "-vbparams=segwit:0:0"]]
114+
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
115+
self.extra_args = [["-whitelist=127.0.0.1", "-vbparams=segwit:0:999999999999"], ["-whitelist=127.0.0.1", "-acceptnonstdtxn=0", "-vbparams=segwit:0:999999999999"], ["-whitelist=127.0.0.1", "-vbparams=segwit:0:0"]]
115116

116117
def setup_network(self):
117118
self.setup_nodes()
@@ -1493,7 +1494,7 @@ def test_upgrade_after_activation(self, node_id):
14931494

14941495
# Restart with the new binary
14951496
self.stop_node(node_id)
1496-
self.start_node(node_id, extra_args=[])
1497+
self.start_node(node_id, extra_args=["-vbparams=segwit:0:999999999999"])
14971498
connect_nodes(self.nodes[0], node_id)
14981499

14991500
sync_blocks(self.nodes)

test/functional/segwit.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ class SegWitTest(BitcoinTestFramework):
7777
def set_test_params(self):
7878
self.setup_clean_chain = True
7979
self.num_nodes = 3
80-
self.extra_args = [["-walletprematurewitness", "-rpcserialversion=0"],
81-
["-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=1"],
82-
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"]]
80+
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
81+
self.extra_args = [["-walletprematurewitness", "-rpcserialversion=0", "-vbparams=segwit:0:999999999999"],
82+
["-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999"],
83+
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-vbparams=segwit:0:999999999999"]]
8384

8485
def setup_network(self):
8586
super().setup_network()

test/functional/sendheaders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def run_test(self):
215215
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], inv_node))
216216
# Set nServices to 0 for test_node, so no block download will occur outside of
217217
# direct fetching
218-
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_node, services=0))
218+
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_node, services=NODE_WITNESS))
219219
inv_node.add_connection(connections[0])
220220
test_node.add_connection(connections[1])
221221

test/functional/test_framework/blockstore.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def add_header(self, header):
100100
def get_blocks(self, inv):
101101
responses = []
102102
for i in inv:
103-
if (i.type == 2): # MSG_BLOCK
103+
if (i.type == 2 or i.type == (2 | (1 << 30))): # MSG_BLOCK or MSG_WITNESS_BLOCK
104104
data = self.get(i.hash)
105105
if data is not None:
106106
# Use msg_generic to avoid re-serialization
@@ -153,7 +153,7 @@ def add_transaction(self, tx):
153153
def get_transactions(self, inv):
154154
responses = []
155155
for i in inv:
156-
if (i.type == 1): # MSG_TX
156+
if (i.type == 1 or i.type == (1 | (1 << 30))): # MSG_TX or MSG_WITNESS_TX
157157
tx = self.get(i.hash)
158158
if tx is not None:
159159
responses.append(msg_generic(b"tx", tx))

test/functional/test_framework/comptool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def on_getdata(self, conn, message):
8080
[conn.send_message(r) for r in self.tx_store.get_transactions(message.inv)]
8181

8282
for i in message.inv:
83-
if i.type == 1:
83+
if i.type == 1 or i.type == 1 | (1 << 30): # MSG_TX or MSG_WITNESS_TX
8484
self.tx_request_map[i.hash] = True
85-
elif i.type == 2:
85+
elif i.type == 2 or i.type == 2 | (1 << 30): # MSG_BLOCK or MSG_WITNESS_BLOCK
8686
self.block_request_map[i.hash] = True
8787

8888
def on_inv(self, conn, message):

test/functional/test_framework/mininode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ class msg_version():
949949

950950
def __init__(self):
951951
self.nVersion = MY_VERSION
952-
self.nServices = 1
952+
self.nServices = NODE_NETWORK | NODE_WITNESS
953953
self.nTime = int(time.time())
954954
self.addrTo = CAddress()
955955
self.addrFrom = CAddress()
@@ -1649,7 +1649,7 @@ class NodeConn(asyncore.dispatcher):
16491649
"regtest": b"\xfa\xbf\xb5\xda", # regtest
16501650
}
16511651

1652-
def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", services=NODE_NETWORK, send_version=True):
1652+
def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", services=NODE_NETWORK|NODE_WITNESS, send_version=True):
16531653
asyncore.dispatcher.__init__(self, map=mininode_socket_map)
16541654
self.dstaddr = dstaddr
16551655
self.dstport = dstport

0 commit comments

Comments
 (0)