Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testnet - SegWit bech32 address transaction - Assertion `tx.wit.vtxinwit.size() <= tx.vin.size()' failed #109

Open
tohsnoom opened this issue Oct 22, 2018 · 6 comments
Assignees

Comments

@tohsnoom
Copy link
Member

tohsnoom commented Oct 22, 2018

On testnet with SegWit activated, sending to a bech32 address from phored caused an assertion error.

bash command: phore-cli sendtoaddress tp1qwsmxln4glureju35drulnjrrfduyvu6t6z4nx6 1000000

phored: ./primitives/transaction.h:348: void SerializeTransaction(TxType&, Stream&, Operation, int, int) [with Stream = CHashWriter; Operation = CSerActionSerialize; TxType = CTransaction]: Assertion `tx.wit.vtxinwit.size() <= tx.vin.size()' failed.

Previous to this, I successfully sent to a bech32 address within that same wallet, so it does not appear to be universal to bech32 address transactions.

The one that failed has this in the log until it crashed:
2018-10-21 21:53:38 CWallet::SelectCoinsMinConf best subset: 46881.88 46881.75 46880.83 46879.52 46879.13 46878.08 46877.6899408 46877.5599408 46875.4698816 46874.9398816 46874.5498224 46874.2898224 46874.0297632 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 12505.24 2503.49 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 0.0162573 - total 1000000.0148109
2018-10-21 21:53:38 keypool added key 2286, size=1001
2018-10-21 21:53:38 init message: Loading wallet... (228.37 %)
2018-10-21 21:53:38 keypool reserve 1286
2018-10-21 21:53:38 CWallet::SelectCoinsMinConf best subset: 46881.35 46880.44 46879.52 46879.13 46878.74 46875.7299408 46874.9398816 46874.2898224 46874.0297632 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 24999.3099408 2503.49 501.0499408 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 7.00 7.00 0.0162573 - total 1000000.0147469
2018-10-21 22:09:53

The log stops there until the node is restarted, following the assertion error above.

The earlier, successful transaction to a bech32 address shows this:

2018-10-21 21:52:47 CWallet::SelectCoinsMinConf best subset: 46880.18 46879.78 46879.13 46878.74 46878.61 46878.08 46877.4299408 46876.6399408 46876.1199408 46874.5498224 46874.4198224 46874.2898224 46874.1598224 46873.769704 46873.6396448 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 25003.49 12505.24 6256.11 2503.49 501.0499408 9.7999584 9.7999584 9.7999584 9.7999584 7.00 - total 1000000.0182352
2018-10-21 21:52:47 keypool added key 2284, size=1001
2018-10-21 21:52:47 init message: Loading wallet... (228.17 %)
2018-10-21 21:52:47 keypool reserve 1284
2018-10-21 21:52:47 CWallet::SelectCoinsMinConf best subset: 46880.57 46880.18 46879.91 46879.13 46878.61 46878.08 46877.5599408 46877.4299408 46877.0399408 46876.6399408 46876.3799408 46875.9899408 46875.7299408 46875.4698816 46875.3398816 46874.5498224 46874.4198224 46874.2898224 46874.1598224 46873.769704 46873.6396448 12505.24 2503.49 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 - total 1000000.01728
2018-10-21 21:52:47 CWallet::SelectCoinsMinConf best subset: 50000.00 46881.88 46881.75 46880.83 46880.57 46879.91 46878.61 46878.48 46877.82 46877.6899408 46877.5599408 46877.1699408 46876.7799408 46876.6399408 46876.3799408 46875.7299408 46875.4698816 46874.0297632 46873.8997632 46873.6396448 25003.49 25003.49 6256.11 2503.49 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 7.00 5.5999584 5.5999584 5.5999584 5.5999584 5.5999584 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 2.80 - total 1000000.018056
2018-10-21 21:52:48 CWallet::SelectCoinsMinConf best subset: 46880.57 46880.31 46879.91 46879.78 46878.61 46877.82 46877.4299408 46877.1699408 46876.7799408 46876.6399408 46876.5099408 46876.3799408 46876.1199408 46875.3398816 46874.4198224 46874.1598224 46873.8997632 46873.769704 46873.6396448 25003.49 25003.49 25003.49 25003.49 6255.07 2503.49 505.24 9.7999584 9.7999584 9.7999584 9.7999584 9.7999584 7.00 7.00 - total 1000000.018016
2018-10-21 21:52:48 CommitTransaction:
CTransaction(hash=e9e28d125f, ver=1, vin.size=33, vout.size=2, nLockTime=0)
CTxIn(COutPoint(d96b9b2c7cb0e5f99016a50c996747203af44ac123c74786d6a4495bd9ac32f0, 1), scriptSig=30440220724dc071b867c78a)
CTxIn(COutPoint(0a13e603159d90bea52811492aa651df7a003d7e744ef1e270ed36eed92af9b0, 1), scriptSig=304402207faa33c7d757821b)
CTxIn(COutPoint(326323edb831a448664c1a6e19ccbfd8edc100ce3f0b9c2a1ea5a7d68d994292, 1), scriptSig=304402200100e1be747da9ab)
CTxIn(COutPoint(d3158b5c70420f372abe0c9d241014e3af1dacd2166d669db6ce1f3a234aa113, 1), scriptSig=3045022100dbe51acc3ca289)
CTxIn(COutPoint(8a2950fe22ba39f9f3da243c2e4744ac670b0d6a28ae898554f62f1ce756fc49, 1), scriptSig=30450221008ebefd06a83727)
CTxIn(COutPoint(c3a8ca9d3c7d8ffef173d346c4da2236e11894e3008be0d1906630e113800f1c, 1), scriptSig=304402206005992e082fcaeb)
CTxIn(COutPoint(2d919be4f2e8cfcd46aad8b269c45d58bc7570299b3246f87953974971854059, 1), scriptSig=30440220750ea40cc1d352ff)
CTxIn(COutPoint(51733c7e25b3fcc689858df8fa937158dd487c0ef4c208cad67294bbada03df6, 1), scriptSig=3045022100cd29e8a0d6956d)
CTxIn(COutPoint(20f6049ec091fd07961f2f91c54ffb371f90e14feca55034efc6b92b4834d761, 1), scriptSig=3044022063fff07721d44ff6)
CTxIn(COutPoint(2190ad04514d7ec96fc181b929afe7b9907c9354b394bbd66383f49d785d3c3c, 2), scriptSig=3045022100f3fb52f90f5f7d)
CTxIn(COutPoint(312e5f55087c11ca2efbcf8fb00661abae20af694ee6fb60228f062f0caf0464, 2), scriptSig=3045022100b0523fd351adf1)
CTxIn(COutPoint(6b81ff1b00ca2bbfd61f66666d4e2e5e20a12e278669874a7000ae67e15c4331, 1), scriptSig=3045022100cef76412ad5fe5)
CTxIn(COutPoint(4466c6dd2601a856c03d49e9d15ce4759c83fe8caabbbd0f5f6ac6d126d17b2d, 1), scriptSig=3045022100a71c415513b41c)
CTxIn(COutPoint(8317b7f4e17b533d4ad1863a524fec38117f8b6ed3c3147e9c16b8c1a25aa06b, 2), scriptSig=3045022100c3b0b517c26428)
CTxIn(COutPoint(6d55b8630c22ed3d4d989ff1f9f40d7737fdb1d486297d1282b89e8fa0c9d706, 1), scriptSig=304402202ae28904f582fbfd)
CTxIn(COutPoint(593685734a542b1768247eca6758d3c5ec5a1aef2f93f20861609187704af944, 1), scriptSig=304402205aff580606e34a94)
CTxIn(COutPoint(593685734a542b1768247eca6758d3c5ec5a1aef2f93f20861609187704af944, 2), scriptSig=30450221009e107b43e2ca65)
CTxIn(COutPoint(bfb7d986cece74d774e1bbb645ba593e32c973f2e4f2c824598c2e9f9b829f44, 1), scriptSig=3044022076282acc8ca3c33c)
CTxIn(COutPoint(bfb7d986cece74d774e1bbb645ba593e32c973f2e4f2c824598c2e9f9b829f44, 2), scriptSig=304402202ab0e400bde3c442)
CTxIn(COutPoint(32bfeec497e15246e709c031342a9dd0a679fb1f8fa1a4317d33689d692cba77, 2), scriptSig=304402200198d8936bf15366)
CTxIn(COutPoint(a0d6f067fc1d5c0dace25775338215963b38d2f20586ff552a576fbcb1219a1e, 2), scriptSig=3044022035540acdf40927e0)
CTxIn(COutPoint(891d3ac719a9741fffaf2febfd2b5c1d0062cfb4252a6a8a90e5199dfa602f59, 1), scriptSig=30440220358c629061974b50)
CTxIn(COutPoint(891d3ac719a9741fffaf2febfd2b5c1d0062cfb4252a6a8a90e5199dfa602f59, 2), scriptSig=304402202d215b25eb591f6c)
CTxIn(COutPoint(f052ab71266242bd32d60804435c5e9913ca8693481387a3fcbb6a063169e061, 1), scriptSig=304402206c81df22cee7564a)
CTxIn(COutPoint(023c9491768d96176aab8bbb2bbf02f935be84f215085e913c2ef9e750a6401b, 2), scriptSig=304502210096c10c31d2abc9)
CTxIn(COutPoint(57e61cc574f9394e30040692564a43fd98aba28029c4baec40ef9de2c1eb4041, 1), scriptSig=304402203f1be29e782f5ad5)
CTxIn(COutPoint(57e61cc574f9394e30040692564a43fd98aba28029c4baec40ef9de2c1eb4041, 2), scriptSig=3045022100d3b92647731d3b)
CTxIn(COutPoint(f8bdb9f704ea848827a92d230dfdbad0d9f8f6d80cec08f5f08fa5492fa9cd85, 2), scriptSig=304402206247b45373304023)
CTxIn(COutPoint(88cfd7ff256755dea4f82be75a2a4e7e769c9722eaabbd5eb55b4ccd85e06dd4, 2), scriptSig=30450221009f93c526454001)
CTxIn(COutPoint(c9f03871e68a84172ba96ac8b84501af7eb7f24d5794186514370671b72f1d78, 2), scriptSig=3044022070f781bd8e154318)
CTxIn(COutPoint(6c288dfc8b8bf35ff30480a1155a8f87d57694f57a4b53bde01f66c8f0d02b3e, 1), scriptSig=3044022076500667773a7bde)
CTxIn(COutPoint(26c29b9fb7dffbbddfe7fc36eed3df069010824eb661af683c1faf868c2cbd54, 0), scriptSig=3045022100e049bc1d62010c)
CTxIn(COutPoint(ca113955283f5af074f4fa85632ac751210dfd2af84cdf66a2d1be0e739d50f4, 0), scriptSig=3045022100e8b86d3561f4ad)
CTxOut(nValue=0.01625730, scriptPubKey=OP_DUP OP_HASH160 e31d1c500a96)
CTxOut(nValue=1000000.00000000, scriptPubKey=0 6dcbb91433bb85bf5374038a64d9)

They were both sending 1 million tPHR to a bech32 address, but this may have to do with the transaction size given different numbers of inputs.

It may or may not be relevant, but the one that succeeded was within the same wallet, and the one that failed was sending to a different wallet.

@tohsnoom tohsnoom changed the title Testnet - SegWit transaction - Assertion `tx.wit.vtxinwit.size() <= tx.vin.size()' failed Testnet - SegWit bech32 address transaction - Assertion `tx.wit.vtxinwit.size() <= tx.vin.size()' failed Oct 22, 2018
@tohsnoom
Copy link
Member Author

I just had this happen again while sending to a bech32 address, the client crashed the same assert failure:

Assertion failed: (tx.wit.vtxinwit.size() <= tx.vin.size()), function SerializeTransaction, file ./primitives/transaction.h, line 348.

The transaction was similar to the above, and was sending to a bech32 address within it's own wallet.

@tohsnoom
Copy link
Member Author

I tried sending slightly smaller amounts of 250,000 tPHR to an internal wallet bech32 address, and did the same transaction twice. The first one succeeded, the 2nd one crashed with the same assertion.

@wqking
Copy link
Collaborator

wqking commented Oct 25, 2018

I used the GUI to send 100K tPHR several times and didn't reproduce this problem. But I doubt that it's related CLI/GUI. Seems this happens randomly so we'd better see how to reproduce it reliably.

@meyer9
For most resizing of vtxinwit, they are vtxinwit.resize(tx.vin.size()), so they should be no problem.
The only possible problem is that, in main.cpp, function UpdateUncommittedBlockStructures, there is a line block.vtx[1].wit.vtxinwit[0].scriptWitness.stack.resize(1), note in previous code it's block.vtx[0], not 1.
That function is called by GenerateCoinbaseCommitment, and GenerateCoinbaseCommitment is called only once, in miner.cpp, function CreateNewBlock.

        pblock->vtx[0].vin[0].scriptSig = CScript() << nHeight << OP_0;
        pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev);

The latest code has changed the vtx index from 0 to 1 in GenerateCoinbaseCommitment, but the previous line only operates on index 0, not 1.
I'm not sure if it's the problem.

@tohsnoom
Copy link
Member Author

I've been able to do this mulitple times pretty reliably. I'd suggest you do the following:

  1. Take a large amount of tPHR and split it into 2000+ small inputs with the UTXO split option.
  2. Send a transaction to a bech32 address that requires a very large number of those inputs to send the required amount. If you still have a large input, use that first, then send more similar transactions right after the first one, thus forcing it to use all the smaller inputs.

@tohsnoom tohsnoom assigned wqking and unassigned meyer9 Oct 25, 2018
@tohsnoom
Copy link
Member Author

As another data point, I just replicated it again. First I sent a series of 500,000 tPHR transactions to bech32 addresses, all succeeded.

Then I tried a 2 million tPHR transaction and that gave a "transaction too large" error message (that's as designed).

Then I backed off the amount to 1 million, and the wallet crashed. Here are the inputs it attempted to use when it crashed:

2018-10-25 17:58:36 CWallet::SelectCoinsMinConf best subset: 250000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 4.1901165 - total 1000004.1901165
2018-10-25 17:58:36 keypool reserve 989
2018-10-25 17:58:36 CWallet::SelectCoinsMinConf best subset: 250000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 5000.00 4.1901165 - total 1000004.1901165
2018-10-25 17:58:36 CWallet::SelectCoinsMinConf best subset: 1000000.00 4.1901165 - total 1000004.1901165

@wqking
Copy link
Collaborator

wqking commented Dec 6, 2018

Fixed in PR #130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants