Bytespersigop #9

Merged
merged 14 commits into from Nov 20, 2016

Conversation

Projects
None yet
2 participants
@rubensayshi
Owner

rubensayshi commented May 23, 2016

In Bitcoin Core v0.12.1 a PR was merged to add -bytespersigop which limits the ratio of sigops:bytes.
This DOS protection uses a shortcut way of counting sigops which counts OP_CHECKMULTISIG as 20 sigops (the max allowed) and results in CP TXs that use multisig encoding not being relayed and mined by v0.12.1 nodes (when > 80 bytes it no longer fits in opreturn).

this is an edge case, there's been 250 CP TXs with > 80 bytes in the history of CP;

  • of which 129 were of an experimental feature (rock paper scissors) which were only early on.
  • 61 issuances (0.1% of all issuances), depending on the length of the description it sometimes tips over the 80 bytes.
  • 57 broadcasts (0.7% of all broadcasts), with 'random' text, mostly people testing out the feature and Adam testing how much data he could embed in a transaction.

I'm talking to core devs to get this fixed in core, hopefully for the next release, but before v0.12.1 is widely adopted we need a fix for this that we keep in place until v0.12.1 is phased out.

This PR consists of 2 fallbacks to deal with this problem:

  1. it will try to spend from extra UTXOs to tip the bytes:sigops ratio in our favor, 2x as many inputs as data outputs does the trick.
  2. it will fallback to pubkeyhash encoding when the above isn't possible, unfortunately our last resort and a solution that will pollute the UTXO set...
counterpartylib/lib/transaction.py
+ desired_input_count = 1
+
+ if encoding == 'multisig' and data_output and util.enabled('bytespersigop'):
+ desired_input_count = len(data_output) * 2

This comment has been minimized.

@robby-dermody

robby-dermody May 31, 2016

given that data_output = (data_array, data_value), do you mean desired_input_count = len(data_output[0]) * 2 ??

@robby-dermody

robby-dermody May 31, 2016

given that data_output = (data_array, data_value), do you mean desired_input_count = len(data_output[0]) * 2 ??

This comment has been minimized.

@rubensayshi

rubensayshi Jun 23, 2016

Owner

was supposed to be len(data_array)

@rubensayshi

rubensayshi Jun 23, 2016

Owner

was supposed to be len(data_array)

counterpartylib/lib/transaction.py
+ # in bitcoin core v0.12.1 a -bytespersigop was added that messes with bare multisig transactions,
+ # as a safeguard we fall back to pubkeyhash encoding when unsure
+ # when len(inputs) > len(data_outputs) there's more bytes:sigops ratio and we can safely continue
+ if encoding == 'multisig' and inputs and data_output and len(inputs) < len(data_output) * 2 and util.enabled('bytespersigop'):

This comment has been minimized.

@robby-dermody

robby-dermody May 31, 2016

same here -- len(data_output[0]) * 2

@robby-dermody

robby-dermody May 31, 2016

same here -- len(data_output[0]) * 2

counterpartylib/protocol_changes.json
+ "minimum_version_major": 9,
+ "minimum_version_minor": 54,
+ "minimum_version_revision": 0,
+ "block_index": 413083

This comment has been minimized.

@robby-dermody

robby-dermody May 31, 2016

make this 500k so that we can safely merge into develop and commit with the next release, as this problem has an impact but not a huge one

@robby-dermody

robby-dermody May 31, 2016

make this 500k so that we can safely merge into develop and commit with the next release, as this problem has an impact but not a huge one

@rubensayshi rubensayshi merged commit 0b947f4 into develop Nov 20, 2016

1 check passed

continuous-integration/travis-ci/push The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment