0

According to this, when the scriptPubKey equals to:

OP_n (with n between 0 and 16, inclusive) followed by a direct push of exactly 2 to 40 bytes inclusive

... it denotes the start of SegWit validating process. SegWit validation process include the checking whether the scriptSig is an empty field. If it is, old nodes (non-segWit) will automatically accept this as a valid script since after the "concatenation" (I know it's not a real concatenation) the top-most element in the stack will be non-zero, while the segWit nodes will go into further checking.

So, my question is: what will happen if someone just add OP_1 in scriptSig? I mean, for non-segWit nodes it would still be accepted as a valid script since top-most element in the stack is non-zero, and for segWit nodes it will considered as invalid since scriptSig is not an empty field. Will this make some kind of fork? How is this resolved?

Additional question is what will happen if non-segWit nodes accept some "segWit" transaction as valid since top-most item is non-zero, and segWit on the other hand do not accept that transaction since something in its witness data is not okay? What is happening in this case, how is this resolved?

Vojtěch Strnad
  • 8,292
  • 2
  • 12
  • 40
dassd
  • 1,069
  • 1
  • 4
  • 21

1 Answers1

3

For any soft fork, it's possible for a block to contain a transaction violating the new consensus rules. Old nodes would accept this block and new nodes would refuse it.

However as long as more than half of the network hashrate updated to the new rules the fork would only be temporary. This is because updated miners would not mine on top of an invalid block. If the majority of the hashrate does so they would eventually create a chain with more work than the one with the invalid block, which old nodes would therefore drop.

The lower the percentage of updated hashrate on the network, the higher the probability of a long chain containing an invalid block being created. This is why historically care has been taken to wait for miners to upgrade their nodes before full nodes started enforcing the new rules. You want to minimize the probability of an unsuspecting user receiving a payment on their non-updated node with a decent number of confirmations which eventually gets wiped as the invalid chain gets reorg'd out!

To go further:

  • "On the security of soft forks" a post from Pieter Wuille which examines the failure modes of a soft fork activation.
  • A tiny Python script by Jonas Nick which computes the probability of an old node seeing a chain longer than N blocks given the % of the network hashrate which updated to the new rules.
Antoine Poinsot
  • 8,334
  • 2
  • 17
  • 34
  • How will the old nodes know when to switch to the new chain? Also, won't the fork happen again when the old nodes switch to a "valid" chain because they will again have a similar problem with validation? Is the switch to a "valid" fork done only when they are updated? – dassd Sep 07 '23 at 12:26
  • Because it has more work. Bitcoin nodes follow the (valid) chain with the most work. By definition of a soft fork, the chain valid according to the new nodes is also valid according to the old nodes. If the valid chain gets longer (loosely speaking), old nodes will start following it. – Antoine Poinsot Sep 07 '23 at 12:27
  • Yes, but will the old node run into the problem again when validating those blocks? Is the switch to right chain only done after they are "updated"? – dassd Sep 07 '23 at 12:30
  • No, the valid blocks are valid in their view. They switch even without being updated, that's the beauty of a soft fork (combined with a majority hashrate). You should checkout the mailing list post i link above. – Antoine Poinsot Sep 07 '23 at 12:33
  • Oh sorry, I got confused. If I understand, the point of a soft fork is that the old nodes always accept "something" , while updated nodes have some additional rules. So, it may happen that some transaction is accepted by the old nodes but not by the new one (due to new rules), so a fork is created. The old nodes will at some point move to the right fork and accept all these block and their transactions because they are valid for them (the problem was that some of transactions were not valid for updated nodes, but they are not even part of the block). Is this correct? – dassd Sep 07 '23 at 13:27
  • The problem would occur if some transaction was accepted by the updated nodes while the old nodes reject it. In this case it would be imposible for the old and updated nodes to "synchronize" (to be on a same fork) since the old nodes will never accept these transaction as valid. In this case the fork is permanent, until the old nodes decide to move on a new rules. This is called hard fork. Is this correct? – dassd Sep 07 '23 at 13:37
  • 1
    Yes, exactly. One way of looking at it is that a soft fork tightens the validation rules whereas a hardfork loosens them. It doesn't make a soft fork necessarily safe or necessarily "compatible" though, as you could do many things by simply tightening the validation rules, but i guess it's a discussion for a different question. :) – Antoine Poinsot Sep 07 '23 at 13:53