Bitcoin-Core

regtest:錯誤:ProcessNewBlock:AcceptBlock FAILED:在 v0.14.3 上發現意外見證數據(程式碼 16)

  • January 29, 2019

我有兩個 bitcoind regtest 程序;v0.16.3 和 v0.14.3。當 v0.14.3 節點嘗試從對等方(v0.16.3)接收塊時,我得到“發現意外的見證數據(程式碼 16)”

我該如何解決?(我試圖重現 CVE-2018-17144 錯誤,DoS 問題,用於學習。我想我重現了另一個問題,通貨膨脹錯誤。在 regtest 上重現 CVE-2018-17144(通貨膨脹錯誤)以進行學習

這就是我所做的:

// 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!

更新 1

我發現 v0.14.3 的 segwit 狀態是“已定義”

// 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
   }
 }
}

我添加了“-prematurewitness”和“-walletprematurewitness”選項,但結果是一樣的。(發現意外的見證數據(程式碼 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

然後,我嘗試在 bitcoindB (v0.14.3) 中進行探勘,但我遇到了另一個錯誤,如下所示。(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

看來我需要探勘到某個區塊才能啟動隔離見證。

你啟動segwit了嗎?你挖了 288 個區塊(IIRC 是 regtest 的門檻)來啟動 segwit 嗎?

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


更新 2

基於此頁面生成 432 個區塊後,Segwit 被啟動。<https://gist.github.com/t4sk/0bc6b35a26998b9007d68f376a852636>

但是,bitcoindA (v0.16.3) 由於“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

更新 3

我為 bitcoind 添加了“-vbparams=segwit:0:999999999999”參數,但仍然出現錯誤。“發現意外的證人數據”

// 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
 }

由於兩個節點在 regtest 上的 segwit 啟動方案不一致,解決方案是為它們設置一個共同的version bits參數。例如,添加vbparams=segwit:0:99999999999兩個節點的.conf文件將起作用。

引用自:https://bitcoin.stackexchange.com/questions/84022