Have SegWit active by default
This commit is contained in:
parent
4bd89210a1
commit
d618458184
11 changed files with 30 additions and 16 deletions
|
@ -291,7 +291,7 @@ public:
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 0;
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
|
||||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
||||||
|
|
||||||
// The best chain should have at least this much work.
|
// The best chain should have at least this much work.
|
||||||
|
|
|
@ -106,6 +106,9 @@ TestingSetup::~TestingSetup()
|
||||||
|
|
||||||
TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
|
TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
|
||||||
{
|
{
|
||||||
|
// CreateAndProcessBlock() does not support building SegWit blocks, so don't activate in these tests.
|
||||||
|
// TODO: fix the code to support SegWit blocks.
|
||||||
|
UpdateVersionBitsParameters(Consensus::DEPLOYMENT_SEGWIT, 0, Consensus::BIP9Deployment::NO_TIMEOUT);
|
||||||
// Generate a 100-block chain:
|
// Generate a 100-block chain:
|
||||||
coinbaseKey.MakeNewKey(true);
|
coinbaseKey.MakeNewKey(true);
|
||||||
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
|
||||||
|
|
|
@ -40,7 +40,9 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness']]
|
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
|
||||||
|
# normal segwit activation here (and don't use the default always-on behaviour).
|
||||||
|
self.extra_args = [['-whitelist=127.0.0.1', '-walletprematurewitness', '-vbparams=segwit:0:999999999999']]
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.address = self.nodes[0].getnewaddress()
|
self.address = self.nodes[0].getnewaddress()
|
||||||
|
|
|
@ -93,7 +93,9 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
# Node0 = pre-segwit, node1 = segwit-aware
|
# Node0 = pre-segwit, node1 = segwit-aware
|
||||||
self.num_nodes = 2
|
self.num_nodes = 2
|
||||||
self.extra_args = [["-vbparams=segwit:0:0"], ["-txindex"]]
|
# This test was written assuming SegWit is activated using BIP9 at height 432 (3x confirmation window).
|
||||||
|
# TODO: Rewrite this test to support SegWit being always active.
|
||||||
|
self.extra_args = [["-vbparams=segwit:0:0"], ["-vbparams=segwit:0:999999999999", "-txindex"]]
|
||||||
self.utxos = []
|
self.utxos = []
|
||||||
|
|
||||||
def build_block_on_tip(self, node, segwit=False):
|
def build_block_on_tip(self, node, segwit=False):
|
||||||
|
|
|
@ -111,7 +111,8 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.num_nodes = 3
|
self.num_nodes = 3
|
||||||
self.extra_args = [["-whitelist=127.0.0.1"], ["-whitelist=127.0.0.1", "-acceptnonstdtxn=0"], ["-whitelist=127.0.0.1", "-vbparams=segwit:0:0"]]
|
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
|
||||||
|
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"]]
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
self.setup_nodes()
|
self.setup_nodes()
|
||||||
|
@ -1493,7 +1494,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Restart with the new binary
|
# Restart with the new binary
|
||||||
self.stop_node(node_id)
|
self.stop_node(node_id)
|
||||||
self.start_node(node_id, extra_args=[])
|
self.start_node(node_id, extra_args=["-vbparams=segwit:0:999999999999"])
|
||||||
connect_nodes(self.nodes[0], node_id)
|
connect_nodes(self.nodes[0], node_id)
|
||||||
|
|
||||||
sync_blocks(self.nodes)
|
sync_blocks(self.nodes)
|
||||||
|
|
|
@ -77,9 +77,10 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
self.num_nodes = 3
|
self.num_nodes = 3
|
||||||
self.extra_args = [["-walletprematurewitness", "-rpcserialversion=0"],
|
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
|
||||||
["-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=1"],
|
self.extra_args = [["-walletprematurewitness", "-rpcserialversion=0", "-vbparams=segwit:0:999999999999"],
|
||||||
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness"]]
|
["-blockversion=4", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-rpcserialversion=1", "-vbparams=segwit:0:999999999999"],
|
||||||
|
["-blockversion=536870915", "-promiscuousmempoolflags=517", "-prematurewitness", "-walletprematurewitness", "-vbparams=segwit:0:999999999999"]]
|
||||||
|
|
||||||
def setup_network(self):
|
def setup_network(self):
|
||||||
super().setup_network()
|
super().setup_network()
|
||||||
|
|
|
@ -215,7 +215,7 @@ class SendHeadersTest(BitcoinTestFramework):
|
||||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], inv_node))
|
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], inv_node))
|
||||||
# Set nServices to 0 for test_node, so no block download will occur outside of
|
# Set nServices to 0 for test_node, so no block download will occur outside of
|
||||||
# direct fetching
|
# direct fetching
|
||||||
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_node, services=0))
|
connections.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test_node, services=NODE_WITNESS))
|
||||||
inv_node.add_connection(connections[0])
|
inv_node.add_connection(connections[0])
|
||||||
test_node.add_connection(connections[1])
|
test_node.add_connection(connections[1])
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ class BlockStore():
|
||||||
def get_blocks(self, inv):
|
def get_blocks(self, inv):
|
||||||
responses = []
|
responses = []
|
||||||
for i in inv:
|
for i in inv:
|
||||||
if (i.type == 2): # MSG_BLOCK
|
if (i.type == 2 or i.type == (2 | (1 << 30))): # MSG_BLOCK or MSG_WITNESS_BLOCK
|
||||||
data = self.get(i.hash)
|
data = self.get(i.hash)
|
||||||
if data is not None:
|
if data is not None:
|
||||||
# Use msg_generic to avoid re-serialization
|
# Use msg_generic to avoid re-serialization
|
||||||
|
@ -153,7 +153,7 @@ class TxStore():
|
||||||
def get_transactions(self, inv):
|
def get_transactions(self, inv):
|
||||||
responses = []
|
responses = []
|
||||||
for i in inv:
|
for i in inv:
|
||||||
if (i.type == 1): # MSG_TX
|
if (i.type == 1 or i.type == (1 | (1 << 30))): # MSG_TX or MSG_WITNESS_TX
|
||||||
tx = self.get(i.hash)
|
tx = self.get(i.hash)
|
||||||
if tx is not None:
|
if tx is not None:
|
||||||
responses.append(msg_generic(b"tx", tx))
|
responses.append(msg_generic(b"tx", tx))
|
||||||
|
|
|
@ -80,9 +80,9 @@ class TestNode(NodeConnCB):
|
||||||
[conn.send_message(r) for r in self.tx_store.get_transactions(message.inv)]
|
[conn.send_message(r) for r in self.tx_store.get_transactions(message.inv)]
|
||||||
|
|
||||||
for i in message.inv:
|
for i in message.inv:
|
||||||
if i.type == 1:
|
if i.type == 1 or i.type == 1 | (1 << 30): # MSG_TX or MSG_WITNESS_TX
|
||||||
self.tx_request_map[i.hash] = True
|
self.tx_request_map[i.hash] = True
|
||||||
elif i.type == 2:
|
elif i.type == 2 or i.type == 2 | (1 << 30): # MSG_BLOCK or MSG_WITNESS_BLOCK
|
||||||
self.block_request_map[i.hash] = True
|
self.block_request_map[i.hash] = True
|
||||||
|
|
||||||
def on_inv(self, conn, message):
|
def on_inv(self, conn, message):
|
||||||
|
|
|
@ -949,7 +949,7 @@ class msg_version():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.nVersion = MY_VERSION
|
self.nVersion = MY_VERSION
|
||||||
self.nServices = 1
|
self.nServices = NODE_NETWORK | NODE_WITNESS
|
||||||
self.nTime = int(time.time())
|
self.nTime = int(time.time())
|
||||||
self.addrTo = CAddress()
|
self.addrTo = CAddress()
|
||||||
self.addrFrom = CAddress()
|
self.addrFrom = CAddress()
|
||||||
|
@ -1649,7 +1649,7 @@ class NodeConn(asyncore.dispatcher):
|
||||||
"regtest": b"\xfa\xbf\xb5\xda", # regtest
|
"regtest": b"\xfa\xbf\xb5\xda", # regtest
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", services=NODE_NETWORK, send_version=True):
|
def __init__(self, dstaddr, dstport, rpc, callback, net="regtest", services=NODE_NETWORK|NODE_WITNESS, send_version=True):
|
||||||
asyncore.dispatcher.__init__(self, map=mininode_socket_map)
|
asyncore.dispatcher.__init__(self, map=mininode_socket_map)
|
||||||
self.dstaddr = dstaddr
|
self.dstaddr = dstaddr
|
||||||
self.dstport = dstport
|
self.dstport = dstport
|
||||||
|
|
|
@ -8,10 +8,12 @@ import os
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from test_framework.test_framework import BitcoinTestFramework, SkipTest
|
from test_framework.test_framework import BitcoinTestFramework, SkipTest
|
||||||
|
from test_framework.mininode import CTransaction
|
||||||
from test_framework.util import (assert_equal,
|
from test_framework.util import (assert_equal,
|
||||||
bytes_to_hex_str,
|
bytes_to_hex_str,
|
||||||
hash256,
|
hash256,
|
||||||
)
|
)
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
class ZMQSubscriber:
|
class ZMQSubscriber:
|
||||||
def __init__(self, socket, topic):
|
def __init__(self, socket, topic):
|
||||||
|
@ -93,7 +95,10 @@ class ZMQTest (BitcoinTestFramework):
|
||||||
|
|
||||||
# Should receive the coinbase raw transaction.
|
# Should receive the coinbase raw transaction.
|
||||||
hex = self.rawtx.receive()
|
hex = self.rawtx.receive()
|
||||||
assert_equal(hash256(hex), txid)
|
tx = CTransaction()
|
||||||
|
tx.deserialize(BytesIO(hex))
|
||||||
|
tx.calc_sha256()
|
||||||
|
assert_equal(tx.hash, bytes_to_hex_str(txid))
|
||||||
|
|
||||||
# Should receive the generated block hash.
|
# Should receive the generated block hash.
|
||||||
hash = bytes_to_hex_str(self.hashblock.receive())
|
hash = bytes_to_hex_str(self.hashblock.receive())
|
||||||
|
|
Loading…
Reference in a new issue