tradecraftio / tradecraft

Tradecraft integration/staging tree https://tradecraft.io/download
Other
13 stars 9 forks source link

Remove segwit script limits #53

Closed maaku closed 4 years ago

maaku commented 4 years ago

EDIT: Scope of PR expanded (see discussion). Original title was "Remove limits on witness script size"

The maximum script size for non-witness scripts remains 10,000 bytes. This limit does not apply to witness scripts: the only limit is implicit due to transaction and block sizes.

Todo: investigate whether changes need to be made to the scriptCode in signature validation in order to prevent quadratic hashing problems.

maaku commented 4 years ago

This PR now does quite a bit more than just remove a single script limit. Rather than have a dozen different pull requests, I'm consolidating all the segwit script changes into this one PR. So far, all the limits dropped by protocol_cleanup are now dropped for segwit scripts, as well as the implicit CLEANSTACK requirement.

The one new limit is that the stack+altstack must be less than 32,768 (=2^15) elements. The previous limit of 1,000 is conceivably too small for some conceivable use cases, but a limit is still required for DoS prevention purposes.

maaku commented 4 years ago

Merging because some of the other waiting PRs depend on this one. However with the newly relaxed script limitations, there are two new DoS prevention limits that need to be added: one per-script accounting of bytes used, and an evaluation of the signature hashing for any quadratic hashing problems given the new unrestricted script lengths. Both of these are best accomplished with separate PRs.