Title: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: Cricktor on April 01, 2023, 08:42:05 AM I've just seen this in the debug.log of my Core bitcoind (v24.0.1):
Code: ... What's the reason, that one of my peers tries to relay a block with "too many sigops"? I assume the following InvalidChainFound errors are a result of the first error condition that ConnectBlock() spitted out. Malicious peer node? Bug in Core? I'm curious to hear some explanations, please. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: BlackHatCoiner on April 01, 2023, 08:52:55 AM I assume the following InvalidChainFound errors are a result of the first error condition that ConnectBlock() spitted out. Yes, Bitcoin Core has a limit on the number of sigops in a block. From consensus.h (https://github.com/bitcoin/bitcoin/blob/master/src/consensus/consensus.h), it's set to 80,000. That is consensus rule.What's the reason, that one of my peers tries to relay a block with "too many sigops"? It's indeed weird. There is either some malicious node out there, or a miner who failed to to validate the block properly. Maybe some Bitcoin Core developer can enlighten us.Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: Cricktor on April 01, 2023, 10:31:11 AM In the meantime I learned, not verified though, that a mined block might at the very beginning be propagated by only its block header and then there's also Compact Block Relay (https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki). The block header of the too-many-sigops-block seemed to be valid, while its block content wasn't. So block header only relay wouldn't have detected the error at first, only after a valid node had checked the full block and detect the consensus violation, it would've dropped the block as faulty.
But take this with a big pinch of salt as I clearly am lacking detail knowledge here. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: pooya87 on April 01, 2023, 10:58:15 AM In the meantime I learned, not verified though, that a mined block might at the very beginning be propagated by only its block header and then there's also Compact Block Relay (https://github.com/bitcoin/bips/blob/master/bip-0152.mediawiki). The block header of the too-many-sigops-block seemed to be valid, while its block content wasn't. So block header only relay wouldn't have detected the error at first, only after a valid node had checked the full block and detect the consensus violation, it would've dropped the block as faulty. That's only for receiving blocks not for relaying them. In other words the nodes must not relay the header alone before fully verifying the block itself. If a node sent you an invalid block that node is either malicious or a broken/buggy implementation.But take this with a big pinch of salt as I clearly am lacking detail knowledge here. Additionally compact block feature is about reducing your node's traffic consumption. Basically your node already has most of the transactions that are waiting to be confirmed in its mempool and a new block usually contains transactions that you already have in your mempool (verified). So your node can skip re-downloading and re-verifying them and instead download the parts it doesn't already have. P.S. I wish you shared the entire block not just its hash if you had it. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: garlonicon on April 01, 2023, 01:13:21 PM Quote P.S. I wish you shared the entire block not just its hash if you had it. It seems my full node has it, here you are: https://pastebin.com/ETVD9yf9Edit: I guess the coinbase transaction can be also needed: Code: $ ./bitcoin-cli getrawtransaction eb6e6080a351e20f840741b56b1d92f920d19a1bb1dc10970dfa6e0fdc032dea true 00000000000000000002ec935e245f8ae70fc68cc828f05bf4cfa002668599e4 Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: Cricktor on April 01, 2023, 01:40:14 PM P.S. I wish you shared the entire block not just its hash if you had it. I'm eager to learn how to extract that data from my node. I haven't done this before. Any hints or instructions, please?Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: garlonicon on April 01, 2023, 01:49:55 PM You can use "bitcoin-cli" command. It has "help" with all available commands. For example, I extracted the whole block, if someone needs that: https://mega.nz/file/FAdXWLaR#UR0BSrx1WxMVqPszITF5FxcElufHJyt3InILB-GZR4E
Code: ./bitcoin-cli getblock 00000000000000000002ec935e245f8ae70fc68cc828f05bf4cfa002668599e4 0 > block.txt Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: pooya87 on April 01, 2023, 05:17:24 PM I don't have a full chainstate to perform a full block verification but by verifying the block with what I have it seems like the block that @garlonicon shared on mega contains a bunch of transactions like [1] and [2] that are using multiple outputs with P2MS scripts. These scripts using OP_CHECKMULTISIG have a very high cost per OP, 20*4 to be exact. For example by my calculations tx [1] has a sigOpCount of 644 and [2] 2084.
The record belongs to [3] with 158 outputs and a sigOpCount of 12564[4]! Note that these transactions aren't invalid on their own (as you can see from links below they are already included in another valid block), my guess is that the miner who mined the invalid block (00000000000000000002ec935e245f8ae70fc68cc828f05bf4cfa002668599e4) was running a modified code that didn't check sigOpCounts of blocks they constructed and they ended up including more of these transactions in their candid block as they should have hence creating the invalid block with too many (more than 80k) sigOps. [1] https://blockchair.com/bitcoin/transaction/0b71a358a1f82e66143fb2dfd54b7cc9227dc8c054397f3fae703f474950f2c1 [2] https://blockchair.com/bitcoin/transaction/4af11e9067eade98e4210a4f739e3c651734b53164dd82e3821363cb586536c6 [3] https://blockchair.com/bitcoin/transaction/87dae4c816c9611038ee35e4662d71089e73f3041863165e56e3dd70d309b274 [4] If they had used something like P2WSH the sigOpCount of these 1of3 multi-sigs would have been something like 160 for this transaction instead of 12564. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: CohibAA on April 06, 2023, 01:49:03 AM I've just found one in my logs as well:
Code: 2023-04-06T00:47:01Z UpdateTip: new best=00000000000000000004ef043082d84196e3845c9628ee20764c591c1fb29d6c height=784120 version=0x37ffe000 log2_work=94.102717 tx=821173080 date='2023-04-06T00:46:39Z' progress=1.000000 cache=6.9MiB(11094txo) This is the result of "bitcoin-cli getblock 000000000000000000046a2698233ed93bb5e74ba7d2146a68ddb0c2504c980d": Code: { The full output with tx data is here: block.txt (https://bitcoin-node.com/tmp/block.txt) Interesting, indeed. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: pooya87 on April 06, 2023, 03:49:36 AM The full output with tx data is here: block.txt (https://bitcoin-node.com/tmp/block.txt) This only contains transaction hashes no the full tx data that is needed to verify the block manually and see what the problem is. I checked a couple of transactions in the block, the first being coinbase is obviously not found anywhere else but also the second transaction is not found either.P.S. I noticed something in the previous block's coinbase transaction, the signature script contains the word "F2Pool" in it. Could it be the F2Pool that messed up or is it someone else using that name? If we had the full block of this new one we could speculate if this is from the same miner/pool. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: CohibAA on April 06, 2023, 04:10:27 AM The full output with tx data is here: block.txt (https://bitcoin-node.com/tmp/block.txt) This only contains transaction hashes no the full tx data that is needed to verify the block manually and see what the problem is. I'm a little high. Here is the correct one I think: block2.txt (https://bitcoin-node.com/tmp/block2.txt) I checked a couple of transactions in the block, the first being coinbase is obviously not found anywhere else but also the second transaction is not found either. Yes, some of the transactions I looked for are missing, but the few I found did come back as being confirmed in the real block 784121 (https://www.blockchain.com/explorer/blocks/btc/784121), such as these randoms transactions (1 (https://www.blockchain.com/explorer/transactions/btc/c1a398002f16d9484a1736964501a7a2521c6185f10a31ff072d92b46749f32b)) (2 (https://www.blockchain.com/explorer/transactions/btc/e3a50a459da0a51c38b3fbb67cf5533928409eed9ff7b73a805089d36e4b51f8)) (3 (https://www.blockchain.com/explorer/transactions/btc/fe0aa7eedfab72f3d410d9d7562ac1dacc5303495ca3150ecae1138783ef589a)) I selected. P.S. I noticed something in the previous block's coinbase transaction, the signature script contains the word "F2Pool" in it. Could it be the F2Pool that messed up or is it someone else using that name? If we had the full block of this new one we could speculate if this is from the same miner/pool. It's curious that it's happened more than once over the previous days. If indeed this is a configuration error, which seems likely, someone is losing a fair amount of mining rewards I think. I wonder, would it be possible for a competing miner to capture these blocks and insert their own (valid) transactions in place for broadcast? Maybe a dumb question, lol. In my log there were several minutes seperation from valid blocks on either side on the bogus block. What would be the goal or take away from a malicious node broadcasting these intentionally? Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: pooya87 on April 06, 2023, 04:42:01 AM This seems to be the same problem as above. A block containing transactions like this one [1] that are creating P2MS outputs (1 of 3 which is strange itself) hence inflating their sigopcount (884 in case of [1] which is the highest in that block) and the miner doesn't check the limit ergo produces an invalid block exceeding 80k sigopcount limit.
The miner/mining-pool also seems to be the same since coinbase script contains F2Pool string again. [1] https://blockchair.com/bitcoin/transaction/0450a1fc590465796e9a1099328fdc4726b86558b7010704ae04cf2cca9643ae It's curious that it's happened more than once over the previous days. If indeed this is a configuration error, which seems likely, someone is losing a fair amount of mining rewards I think. That's true, specially when it is a pool where miners are trusting to not waste their hard work.I wonder, would it be possible for a competing miner to capture these blocks and insert their own (valid) transactions in place for broadcast? No because the block has to be changed and if you change even a single bit the final hash will be entirely different meaning it will no longer satisfy the target check so it has to be mined again.What would be the goal or take away from a malicious node broadcasting these intentionally? I don't think this is intentional. To give a better answer we have to know the client the said node is running which may be acquired if your logs stored the IP address of the node that sent the invalid block. In which case we may be able to connect to that node and see if it sends its useragent and that may give us more information like the client name which we could find on GitHub and report this bug.Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: CohibAA on April 06, 2023, 04:54:40 AM I wonder, would it be possible for a competing miner to capture these blocks and insert their own (valid) transactions in place for broadcast? No because the block has to be changed and if you change even a single bit the final hash will be entirely different meaning it will no longer satisfy the target check so it has to be mined again.As I was typing that, I was thinking that was the case, but it's been quite some time since I've dove into the technical details of bitcoin mining. Thanks for clarifying. What would be the goal or take away from a malicious node broadcasting these intentionally? I don't think this is intentional. To give a better answer we have to know the client the said node is running which may be acquired if your logs stored the IP address of the node that sent the invalid block. In which case we may be able to connect to that node and see if it sends its useragent and that may give us more information like the client name which we could find on GitHub and report this bug.While I do have logips set to 1, everything I can see in the debug.log is quoted above. Is there somewhere else I can pull the IP of the invalid broadcaster from? Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: Cricktor on April 06, 2023, 06:50:23 PM The coinbase target address for both invalid blocks is 1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY and this one is attributed to the F2Pool.
It's puzzling that they failed now twice with the same problem within just a few days in between. Lol, maybe some other mining pool exploits F2Pool's buggy candidate block assembly by sending them those sigops costly big P2MS transactions... Just a wild guess, don't take this serious! Having lost almost 13BTC with those two invalid blocks, F2Pool should really fix their mining software. Title: Re: ERROR: ConnectBlock(): too many sigops / InvalidChainFound: invalid block=... Post by: o_e_l_e_o on April 28, 2023, 09:27:52 AM Stumbled across this question on Stack Exchange, so thought I would link it here for everyone's information: https://bitcoin.stackexchange.com/questions/117837/how-many-sigops-are-in-the-invalid-block-783426
The invalid block in OP's post was only 3 sigops over the limit, for a total of 80,003. Also Vojtěch Strnad shared a handy script to calculate the number of sigops in a block. |