make better show for asm code #4080

pull arowser wants to merge 4 commits into bitcoin:master from arowser:optimize_disassembler changing 1 files +18 −18
  1. arowser commented at 8:24 AM on April 22, 2014: contributor

    Sample: ./bitcoind getrawtransaction 7b80040a18c70f279ac32c7032e69c46aff50ee76398df7babf6f9039ed2561d 1

    in vout->scriptPubKey:

    "asm" : "1 0424e0d192e25d4eea9ef8ba4f32d45a025d0aa80172c45580762f3d417b6eb804d8d7f3e1ee43863a165ae507bbf67b15bf137ed0d5072f1334e489cb6368c14d 20434e5452505254590000000a000000000000000100000004a817c80000000000 2 OP_CHECKMULTISIG"
    

    Better to change:

    "asm" : "OP_1 0424e0d192e25d4eea9ef8ba4f32d45a025d0aa80172c45580762f3d417b6eb804d8d7f3e1ee43863a165ae507bbf67b15bf137ed0d5072f1334e489cb6368c14d 20434e5452505254590000000a000000000000000100000004a817c80000000000 OP_2 OP_CHECKMULTISIG"
    
  2. add --enable-debug for configure 69813b6769
  3. change --enable-debug options better ae3c8ffede
  4. Merge branch 'master' of https://github.com/bitcoin/bitcoin 58752ec344
  5. optimize asm show b75554b31f
  6. BitcoinPullTester commented at 8:55 AM on April 22, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/b75554b31fd90811d0aa645d294060e03ad86e52 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  7. gmaxwell commented at 9:04 AM on April 22, 2014: contributor

    As an aside you have some extraneous commits in this pull.

    Can you explain the motivations behind your main change? The prior philosophy seems to have been to show the value pushed to the stack, not the specific encoding of the value. With your change one still can't distinguish the different pushdata forms and while the non-pushdata numbers are more clear, I'm concerned that it might be at the expense of making it less clear what ends up on the stack (E.g. "OP_1NEGATE" doesn't end up on the stack, -1 does).

  8. laanwj commented at 11:48 AM on April 22, 2014: member

    It would be a little bit more consistent to print OP_XXX for all opcodes, but 'better' is very much in the eye of the beholder here.

  9. arowser commented at 1:15 PM on April 22, 2014: contributor
    1. I think the asm code like "1 0424e0d192e2.." confuse people, they don't know "1" is integer number or opcode if they not understand the script engine.
    2. "OP_XXX" is more consistent than "1", and the blockchain.info web site and other some open source bitcoin client have change to "OP_XXX", its looks better.
  10. laanwj commented at 1:24 PM on April 22, 2014: member

    In a way it is already consistent. "1" is shorthand for "push 1", just like the "0424e0d192e2.." is shorthand for "push 0424e0d192e2". If you want to prepend which opcodes push something to the stack, you'd have to be consistent with pushdata too (that's what @gmaxwell says as well).

  11. arowser commented at 2:25 PM on April 22, 2014: contributor

    @lannwj, you said make sense, but all opcodes in asm is "OPXXX" except OP_1...OP_16, and OP_1 in memory is 0x51 but not 0x1, and "0424e0d192e2.." in memory is still 0x0424e0d192e2...

  12. sipa commented at 2:32 PM on April 22, 2014: member

    There are different ways of doing data pushes in script:

    • OP_1 through OP_16 (which push the single byte 0x01 through 0x10).
    • Direct data push (one byte length descriptor (up to 76), followed by that many bytes). OP_0 can be considered a special case of this (which pushes the empty vector).
    • Indirect data push (OP_PUSHDATA{1,2,4} followed by 1/2/4 byte length descriptor, followed by that many bytes).

    These are not deserialized as actual operations, because we usually just care about what is being pushed, not which method is used (and BIP62 will make sure only one method is allowed for a given byte vector). In particular, the direct data push doesn't actually have any associated opcodes.

    If we choose the change it, I too vote for making it fully explicit.

  13. laanwj commented at 8:14 AM on May 1, 2014: member

    Closing this - how to show ASM is just a matter of convention, it's hard to define better or worse (remember AT&T versus Intel style for x86?).

  14. laanwj closed this on May 1, 2014

  15. DrahtBot locked this on Sep 8, 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-05-03 00:15 UTC

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