user19338: I have two bitcoind regtest processes; v0.16.3 and v0.14.3. I got "unexpected witness data found (code 16)" when v0.14.3 node try to received a block from the peer (v0.16.3)
How can I fix it? (I'm tring to reproduce CVE-2018-17144 error, the DoS issue, for learning. I think I reproduced the another issue, inflation bug. reproduce CVE-2018-17144 (inflation bug) on regtest for learning)
This is what I did:
// start bitcoindA (v0.16.3)
$ /home/zono/bitcoinA/src/bitcoind -server -listen -port=17591 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -datadir=$HOME/regtest/A/ -connect=localhost:17592 -regtest -pid=$HOME/regtest/A/.pid -daemon -debug

// start bitcoindB (v0.14.3)
$ /home/zono/bitcoinB/src/bitcoind -server -listen -port=17592 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -datadir=$HOME/regtest/B/ -connect=localhost:17591 -regtest -pid=$HOME/regtest/B/.pid -daemon -debug

// generate a block on bitcoindA
$ ./bitcoin/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 1

// check log on bitcoindB
$ tail -f /home/zono/regtest/B/regtest/debug.log

2019-01-27 03:36:27 Requesting block 086e6b0cdb854c4ffa08033af35a0a5866aebf1fe72195805401c4e7692861cb (1) peer=0
2019-01-27 03:36:27 sending getdata (37 bytes) peer=0
2019-01-27 03:36:27 received: block (262 bytes) peer=0
2019-01-27 03:36:27 received block 086e6b0cdb854c4ffa08033af35a0a5866aebf1fe72195805401c4e7692861cb peer=0
2019-01-27 03:36:27 ERROR: AcceptBlock: unexpected-witness, ContextualCheckBlock : unexpected witness data found (code 16)
2019-01-27 03:36:27 Misbehaving: 127.0.0.1:52872 peer=0 (0 -> 100) BAN THRESHOLD EXCEEDED
2019-01-27 03:36:27 ERROR: ProcessNewBlock: AcceptBlock FAILED
2019-01-27 03:36:27 sending reject (58 bytes) peer=0
2019-01-27 03:36:27 Warning: not banning local peer 127.0.0.1:52872!


Update 1
I found the segwit status of the v0.14.3 is "defined"
// bitcoindA (v0.16.3)
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 1,
  "bestblockhash": "4c5dab9fb090b4eec3d248a1531abf0e02f6f8d4f6331cefe574477c38a93c0d",
  "bip9_softforks": {
    "segwit": {
      "status": "active",
      "startTime": -1,
      "timeout": 9223372036854775807,
      "since": 0
    }
  }
}

// bitcoindB (v0.14.3)
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 0,
  "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
  "difficulty": 4.656542373906925e-10,
  "bip9_softforks": {
    "segwit": {
      "status": "defined",
      "startTime": 0,
      "timeout": 999999999999,
      "since": 0
    }
  }
}

I added "-prematurewitness" and "-walletprematurewitness" option but the result is same. (unexpected witness data found (code 16))
/home/zono/bitcoinB/src/bitcoind -server -listen -port=17592 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -datadir=$HOME/regtest/B/ -connect=localhost:17591 -regtest -pid=$HOME/regtest/B/.pid -daemon -debug -prematurewitness -walletprematurewitness

Then, I tried to mine in bitcoindB (v0.14.3) but I got another error like following. (16: bad-witness-nonce-size)
2019-01-27 04:59:13 received: getdata (37 bytes) peer=0
2019-01-27 04:59:13 received getdata (1 invsz) peer=0
2019-01-27 04:59:13 received getdata for: witness-block 593a4919ae144569e83a6145e717b920fdd2a4267b427bdfd38c265d6bc5e1ea peer=0
2019-01-27 04:59:13 sending block (226 bytes) peer=0
2019-01-27 04:59:13 received: reject (62 bytes) peer=0
2019-01-27 04:59:13 Reject block code 16: bad-witness-nonce-size: hash 593a4919ae144569e83a6145e717b920fdd2a4267b427bdfd38c265d6bc5e1ea
2019-01-27 04:59:13 Unknown command "reject" from peer=0

seems I need to mine up to the certain block to active segwit.

Did you activate segwit yet? Have you mined 288 blocks (IIRC that's the threshold for regtest) to activate segwit?

https://bitcointalk.org/index.php?topic=1800935.0

Update 2
Segwit activated after generating 432 blocks based on this page. https://gist.github.com/t4sk/0bc6b35a26998b9007d68f376a852636
However, bitcoindA (v0.16.3) rejected the block due to "16: bad-witness-nonce-size"
// generate 432 blocks on bitcoindB (v0.14.3)
$ ./bitcoinB/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 432

// check segwit status on bitcoindB (v0.14.3)
$ ./bitcoinB/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 432,
  "headers": 432,
  "bestblockhash": "04488f65623bf43557e7874e5d576addf5b4f43bcd44821ba90876274de74347",
  "bip9_softforks": {
    "segwit": {
      "status": "active",
      "startTime": 0,
      "timeout": 999999999999,
      "since": 432
    }
  }
}

// check sync status on bitcoindA (v0.16.3)
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 0,
  "headers": 432,
  "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
}

// check log on bitcoindB (v0.14.3)
$ tail -f /home/zono/regtest/B/regtest/debug.log
2019-01-27 05:20:29 Reject block code 16: bad-witness-nonce-size: hash 0a11f9ae506ba184eef4a70e59e41599311c060c3466772bc632507cec973889


Update 3
I added "-vbparams=segwit:0:999999999999" param for bitcoind but still I get the error. "unexpected witness data found"
// bitcoindB (v0.14.3)
/home/zono/bitcoinB/src/bitcoind -server -listen -port=17592 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -datadir=$HOME/regtest/B/ -connect=localhost:17591 -regtest -pid=$HOME/regtest/B/.pid -daemon -debug -vbparams=segwit:0:999999999999

// The error message on bitcoindB (v0.14.3) after generating 1 block on bitcoindA (v0.16.3)
2019-01-28 08:37:29 ERROR: AcceptBlock: unexpected-witness, ContextualCheckBlock : unexpected witness data found (code 16)

// The result of getblockchaininfo on bitcoindB (v0.14.3). Still the status is "defined"
"bip9_softforks": {
  "segwit": {
    "status": "defined",
    "startTime": 0,
    "timeout": 999999999999,
    "since": 0
  }


user64730: As the two nodes do not agree on segwit's activation scheme on regtest, the solution is to set a common version bits parameter to both of them.
For example, adding vbparams=segwit:0:99999999999 in the two nodes' .conf files will work.

19338: <p>I have two bitcoind regtest processes; v0.16.3 and v0.14.3. I got "unexpected witness data found (code 16)" when v0.14.3 node try to received a block from the peer (v0.16.3)</p>

<p>How can I fix it? (I'm tring to reproduce CVE-2018-17144 error, the DoS issue, for learning. I think I reproduced the another issue, inflation bug. <a href="https://bitcoin.stackexchange.com/questions/84026/reproduce-cve-2018-17144-inflation-bug-on-regtest-for-learning">reproduce CVE-2018-17144 (inflation bug) on regtest for learning</a>)</p>

<p>This is what I did:</p>

<pre><code>// start bitcoindA (v0.16.3)
$ /home/zono/bitcoinA/src/bitcoind -server -listen -port=17591 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -datadir=$HOME/regtest/A/ -connect=localhost:17592 -regtest -pid=$HOME/regtest/A/.pid -daemon -debug

// start bitcoindB (v0.14.3)
$ /home/zono/bitcoinB/src/bitcoind -server -listen -port=17592 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -datadir=$HOME/regtest/B/ -connect=localhost:17591 -regtest -pid=$HOME/regtest/B/.pid -daemon -debug

// generate a block on bitcoindA
$ ./bitcoin/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 1

// check log on bitcoindB
$ tail -f /home/zono/regtest/B/regtest/debug.log

2019-01-27 03:36:27 Requesting block 086e6b0cdb854c4ffa08033af35a0a5866aebf1fe72195805401c4e7692861cb (1) peer=0
2019-01-27 03:36:27 sending getdata (37 bytes) peer=0
2019-01-27 03:36:27 received: block (262 bytes) peer=0
2019-01-27 03:36:27 received block 086e6b0cdb854c4ffa08033af35a0a5866aebf1fe72195805401c4e7692861cb peer=0
2019-01-27 03:36:27 ERROR: AcceptBlock: unexpected-witness, ContextualCheckBlock : unexpected witness data found (code 16)
2019-01-27 03:36:27 Misbehaving: 127.0.0.1:52872 peer=0 (0 -&gt; 100) BAN THRESHOLD EXCEEDED
2019-01-27 03:36:27 ERROR: ProcessNewBlock: AcceptBlock FAILED
2019-01-27 03:36:27 sending reject (58 bytes) peer=0
2019-01-27 03:36:27 Warning: not banning local peer 127.0.0.1:52872!
</code></pre>

<hr>

<p>Update 1</p>

<p>I found the segwit status of the v0.14.3 is "defined"</p>

<pre><code>// bitcoindA (v0.16.3)
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 1,
  "bestblockhash": "4c5dab9fb090b4eec3d248a1531abf0e02f6f8d4f6331cefe574477c38a93c0d",
  "bip9_softforks": {
    "segwit": {
      "status": "active",
      "startTime": -1,
      "timeout": 9223372036854775807,
      "since": 0
    }
  }
}

// bitcoindB (v0.14.3)
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 0,
  "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
  "difficulty": 4.656542373906925e-10,
  "bip9_softforks": {
    "segwit": {
      "status": "defined",
      "startTime": 0,
      "timeout": 999999999999,
      "since": 0
    }
  }
}
</code></pre>

<p>I added "-prematurewitness" and "-walletprematurewitness" option but the result is same. (unexpected witness data found (code 16))</p>

<pre><code>/home/zono/bitcoinB/src/bitcoind -server -listen -port=17592 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -datadir=$HOME/regtest/B/ -connect=localhost:17591 -regtest -pid=$HOME/regtest/B/.pid -daemon -debug -prematurewitness -walletprematurewitness
</code></pre>

<p>Then, I tried to mine in bitcoindB (v0.14.3) but I got another error like following. (16: bad-witness-nonce-size)</p>

<pre><code>2019-01-27 04:59:13 received: getdata (37 bytes) peer=0
2019-01-27 04:59:13 received getdata (1 invsz) peer=0
2019-01-27 04:59:13 received getdata for: witness-block 593a4919ae144569e83a6145e717b920fdd2a4267b427bdfd38c265d6bc5e1ea peer=0
2019-01-27 04:59:13 sending block (226 bytes) peer=0
2019-01-27 04:59:13 received: reject (62 bytes) peer=0
2019-01-27 04:59:13 Reject block code 16: bad-witness-nonce-size: hash 593a4919ae144569e83a6145e717b920fdd2a4267b427bdfd38c265d6bc5e1ea
2019-01-27 04:59:13 Unknown command "reject" from peer=0
</code></pre>

<p>seems I need to mine up to the certain block to active segwit.</p>

<blockquote>
  <p>Did you activate segwit yet? Have you mined 288 blocks (IIRC that's the threshold for regtest) to activate segwit?</p>
</blockquote>

<p><a href="https://bitcointalk.org/index.php?topic=1800935.0" rel="nofollow noreferrer">https://bitcointalk.org/index.php?topic=1800935.0</a></p>

<hr>

<p>Update 2</p>

<p>Segwit activated after generating 432 blocks based on this page. <a href="https://gist.github.com/t4sk/0bc6b35a26998b9007d68f376a852636" rel="nofollow noreferrer">https://gist.github.com/t4sk/0bc6b35a26998b9007d68f376a852636</a></p>

<p>However, bitcoindA (v0.16.3) rejected the block due to "16: bad-witness-nonce-size"</p>

<pre><code>// generate 432 blocks on bitcoindB (v0.14.3)
$ ./bitcoinB/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 432

// check segwit status on bitcoindB (v0.14.3)
$ ./bitcoinB/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 432,
  "headers": 432,
  "bestblockhash": "04488f65623bf43557e7874e5d576addf5b4f43bcd44821ba90876274de74347",
  "bip9_softforks": {
    "segwit": {
      "status": "active",
      "startTime": 0,
      "timeout": 999999999999,
      "since": 432
    }
  }
}

// check sync status on bitcoindA (v0.16.3)
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 getblockchaininfo
{
  "chain": "regtest",
  "blocks": 0,
  "headers": 432,
  "bestblockhash": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
}

// check log on bitcoindB (v0.14.3)
$ tail -f /home/zono/regtest/B/regtest/debug.log
2019-01-27 05:20:29 Reject block code 16: bad-witness-nonce-size: hash 0a11f9ae506ba184eef4a70e59e41599311c060c3466772bc632507cec973889
</code></pre>

<hr>

<p>Update 3</p>

<p>I added "-vbparams=segwit:0:999999999999" param for bitcoind but still I get the error. "unexpected witness data found"</p>

<pre><code>// bitcoindB (v0.14.3)
/home/zono/bitcoinB/src/bitcoind -server -listen -port=17592 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -datadir=$HOME/regtest/B/ -connect=localhost:17591 -regtest -pid=$HOME/regtest/B/.pid -daemon -debug -vbparams=segwit:0:999999999999

// The error message on bitcoindB (v0.14.3) after generating 1 block on bitcoindA (v0.16.3)
2019-01-28 08:37:29 ERROR: AcceptBlock: unexpected-witness, ContextualCheckBlock : unexpected witness data found (code 16)

// The result of getblockchaininfo on bitcoindB (v0.14.3). Still the status is "defined"
"bip9_softforks": {
  "segwit": {
    "status": "defined",
    "startTime": 0,
    "timeout": 999999999999,
    "since": 0
  }
</code></pre>
 64730: <p>As the two nodes do not agree on segwit's activation scheme on regtest, the solution is to set a common <code>version bits</code> parameter to both of them.
For example, adding <code>vbparams=segwit:0:99999999999</code> in the two nodes' <code>.conf</code> files will work.</p>
