refactor: Use proper MAX_SCRIPT_ELEMENT_SIZE constants consistently #17439

pull hebasto wants to merge 2 commits into bitcoin:master from hebasto:20191111-maxscriptelementsize-const changing 2 files +4 −4
  1. hebasto commented at 10:16 AM on November 11, 2019: member

    This PR replaces well-known "magic" numbers with proper MAX_SCRIPT_ELEMENT_SIZE constants.

  2. refactor: Use proper MAX_SCRIPT_ELEMENT_SIZE const 402ee706d8
  3. test: Use proper MAX_SCRIPT_ELEMENT_SIZE cb9d830a00
  4. practicalswift commented at 10:27 AM on November 11, 2019: contributor

    ACK cb9d830a00995ee60e71780c04f6193efd02c511 -- diff looks correct and change appears to be complete

    $ git grep -iE '[^0-9a-z]520[^0-9a-z]' -- "*.cpp" "*.h"
    src/net_processing.cpp:        // Nodes must NEVER send a data item > 520 bytes (the max size for a script data object,
    src/outputtype.cpp:    // Note that scripts over 520 bytes are not yet supported.
    src/policy/policy.cpp:        // keys (remember the 520 byte limit on redeemScript size). That works
    src/script/descriptor.cpp:            if (script_size + 3 > 520) {
    src/script/descriptor.cpp:                error = strprintf("P2SH script is too large, %d bytes is larger than 520 bytes", script_size + 3);
    src/script/script.h:static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520;
    src/test/descriptor_tests.cpp:    CheckUnparsable("sh(multi(16,KzoAz5CanayRKex3fSLQ2BwJpN7U52gZvxMyk78nDMHuqrUxuSJy,KwGNz6YCCQtYvFzMtrC6D3tKTKdBBboMrLTsjr2NYVBwapCkn7Mr,KxogYhiNfwxuswvXV66eFyKcCpm7dZ7TqHVqujHAVUjJxyivxQ9X,L2BUNduTSyZwZjwNHynQTF14mv2uz2NRq5n5sYWTb4FkkmqgEE9f,L1okJGHGn1kFjdXHKxXjwVVtmCMR2JA5QsbKCSpSb7ReQjezKeoD,KxDCNSST75HFPaW5QKpzHtAyaCQC7p9Vo3FYfi2u4dXD1vgMiboK,L5edQjFtnkcf5UWURn6UuuoFrabgDQUHdheKCziwN42aLwS3KizU,KzF8UWFcEC7BYTq8Go1xVimMkDmyNYVmXV5PV7RuDicvAocoPB8i,L3nHUboKG2w4VSJ5jYZ5CBM97oeK6YuKvfZxrefdShECcjEYKMWZ,KyjHo36dWkYhimKmVVmQTq3gERv3pnqA4xFCpvUgbGDJad7eS8WE,KwsfyHKRUTZPQtysN7M3tZ4GXTnuov5XRgjdF2XCG8faAPmFruRF,KzCUbGhN9LJhdeFfL9zQgTJMjqxdBKEekRGZX24hXdgCNCijkkap,KzgpMBwwsDLwkaC5UrmBgCYaBD2WgZ7PBoGYXR8KT7gCA9UTN5a3,KyBXTPy4T7YG4q9tcAM3LkvfRpD1ybHMvcJ2ehaWXaSqeGUxEdkP,KzJDe9iwJRPtKP2F2AoN6zBgzS7uiuAwhWCfGdNeYJ3PC1HNJ8M8,L1xbHrxynrqLKkoYc4qtoQPx6uy5qYXR5ZDYVYBSRmCV5piU3JG9))","sh(multi(16,03669b8afcec803a0d323e9a17f3ea8e68e8abe5a278020a929adbec52421adbd0,0260b2003c386519fc9eadf2b5cf124dd8eea4c4e68d5e154050a9346ea98ce600,0362a74e399c39ed5593852a30147f2959b56bb827dfa3e60e464b02ccf87dc5e8,0261345b53de74a4d721ef877c255429961b7e43714171ac06168d7e08c542a8b8,02da72e8b46901a65d4374fe6315538d8f368557dda3a1dcf9ea903f3afe7314c8,0318c82dd0b53fd3a932d16e0ba9e278fcc937c582d5781be626ff16e201f72286,0297ccef1ef99f9d73dec9ad37476ddb232f1238aff877af19e72ba04493361009,02e502cfd5c3f972fe9a3e2a18827820638f96b6f347e54d63deb839011fd5765d,03e687710f0e3ebe81c1037074da939d409c0025f17eb86adb9427d28f0f7ae0e9,02c04d3a5274952acdbc76987f3184b346a483d43be40874624b29e3692c1df5af,02ed06e0f418b5b43a7ec01d1d7d27290fa15f75771cb69b642a51471c29c84acd,036d46073cbb9ffee90473f3da429abc8de7f8751199da44485682a989a4bebb24,02f5d1ff7c9029a80a4e36b9a5497027ef7f3e73384a4a94fbfe7c4e9164eec8bc,02e41deffd1b7cce11cde209a781adcffdabd1b91c0ba0375857a2bfd9302419f3,02d76625f7956a7fc505ab02556c23ee72d832f1bac391bcd2d3abce5710a13d06,0399eb0a5487515802dc14544cf10b3666623762fbed2ec38a3975716e2c29c232))", "P2SH script is too large, 547 bytes is larger than 520 bytes"); // P2SH does not fit 16 compressed pubkeys in a redeemscript
    src/test/miner_tests.cpp:    std::vector<unsigned char> vchData(520);
    
  5. DrahtBot added the label Refactoring on Nov 11, 2019
  6. DrahtBot added the label Tests on Nov 11, 2019
  7. MarcoFalke removed the label Tests on Nov 11, 2019
  8. egp approved
  9. egp commented at 1:42 AM on November 14, 2019: none

    LGTM

  10. instagibbs commented at 2:22 PM on November 21, 2019: member
  11. MarcoFalke referenced this in commit 5ff798c39b on Nov 21, 2019
  12. MarcoFalke merged this on Nov 21, 2019
  13. MarcoFalke closed this on Nov 21, 2019

  14. hebasto deleted the branch on Nov 21, 2019
  15. sidhujag referenced this in commit 9b8082749a on Nov 22, 2019
  16. jasonbcox referenced this in commit 410759abbd on Sep 25, 2020
  17. sidhujag referenced this in commit af3ea2205e on Nov 10, 2020
  18. MarcoFalke locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 06:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me