question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Syntactically invalid txdata is generated for some solc

See original GitHub issue

Description

Generated txdata cannot be sometimes properly decoded for some solc. In the below example, I obtained a valid input using solc 0.5.12. But I obatined an invalid input not solc 0.4.25, which cannot be properly decoded using off-the-shelf abi decoder.

In the below examples, you can see that, for example, the input fields in the last steps for each output have quite different lengths, though the contract used for testing is the same.

In the output1 (used solc 0.5.12),

0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000

this input value can be successfully decoded using the abi decoder in here: https://github.com/miguelmota/ethereum-input-data-decoder

However, in the output2 (used solc 0.4.25),

0x82668f20666666666666666666666666666666666666666666666666666666666666660a

now we have much shorter input value, which cannot be decoded using the abi decoder above. Specifically, it produces a mesage: insufficient data for uint256 type. So I guess Mythril may have generated the syntactically invalid input.

How to Reproduce

Testing program:

contract Test{
  uint n;

  constructor (uint _n) public {
    require (_n==1);
    n = _n;
  }

  function test (uint8 a, uint[] memory b) public {
    require (a==10);
    n--;
  }
}

Command1 (that generates valid txdata):

sudo docker exec CONTAINER_NAME myth analyze /tmp/test.sol --solv 0.5.12 -m integer,exceptions -o json

Output1 for Command1 (simplified):

                             'steps': [{'address': '',
                                        'calldata': '00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
                                        'input': '0x608060405234801561001057600080fd5b506040516101b83803806101b88339818101604052602081101561003357600080fd5b81019080805190602001909291905050506001811461005157600080fd5b8060008190555050610150806100686000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c806382668f2014610030575b600080fd5b6100f36004803603604081101561004657600080fd5b81019080803560ff1690602001909291908035906020019064010000000081111561007057600080fd5b82018360208201111561008257600080fd5b803590602001918460208302840111640100000000831117156100a457600080fd5b919080806020026020016040519081016040528093929190818152602001838360200280828437600081840152601f19601f8201169050808301925050505050505091929192905050506100f5565b005b600a8260ff161461010557600080fd5b600080815480929190600190039190505550505056fea265627a7a72315820bb01cda6ba4124fde44870a05970c0990509bdf9da47ca0bc0a3f8d8be43907c64736f6c634300050c003200000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
                                        'name': 'unknown',
                                        'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
                                        'value': '0x0'},
                                       {'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
                                        'calldata': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
                                        'input': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
                                        'name': 'test(uint8,uint256[])',
                                        'origin': '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                                        'value': '0x0'},
                                       {'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
                                        'calldata': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
                                        'input': '0x82668f20000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000',
                                        'name': 'test(uint8,uint256[])',
                                        'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
                                        'value': '0x0'}]}}],
 'success': True}

Command2 (that generates invalid txdata):

sudo docker exec CONTAINER_NAME myth analyze /tmp/test.sol --solv 0.4.25 -m integer,exceptions -o json

where the only difference is the provided --solv option.

Output2 for Command2 (simplified):

                             'steps': [{'address': '',
                                        'calldata': '0000000000000000000000000000000000000000000000000000000000000001',
                                        'input': '0x608060405234801561001057600080fd5b506040516020806101608339810180604052810190808051906020019092919050505060018114151561004257600080fd5b8060008190555050610107806100596000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806382668f20146044575b600080fd5b348015604f57600080fd5b5060b2600480360381019080803560ff1690602001909291908035906020019082018035906020019080806020026020016040519081016040528093929190818152602001838360200280828437820191505050505050919291929050505060b4565b005b600a8260ff1614151560c557600080fd5b60008081548092919060019003919050555050505600a165627a7a723058203afae6d203291064d5f94ced7ff9c6a3567929d136ffa919f2e3b5fdcd569c7900290000000000000000000000000000000000000000000000000000000000000001',
                                        'name': 'unknown',
                                        'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
                                        'value': '0x0'},
                                       {'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
                                        'calldata': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
                                        'input': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
                                        'name': 'test(uint8,uint256[])',
                                        'origin': '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
                                        'value': '0x0'},
                                       {'address': '0x901d12ebe1b195e5aa8748e62bd7734ae19b51f',
                                        'calldata': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
                                        'input': '0x82668f20666666666666666666666666666666666666666666666666666666666666660a',
                                        'name': 'test(uint8,uint256[])',
                                        'origin': '0xaffeaffeaffeaffeaffeaffeaffeaffeaffeaffe',
                                        'value': '0x0'}]}}],
 'success': True}

Expected behavior

Valid txdata should be generated for any solc.

Environment

  • Mythril version: v 0.21.21 (from docker image)
  • Solidity compiler and version: 0.5.12
  • Python version: 3.6.9 (the one installed in the docker container)
  • OS and Version: Ubuntu 18.04 (Host OS)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
norhhcommented, Jan 31, 2020

Oh! sorry about that. Mythril doesn’t 0 pad the end, that might be the problem for the error with the ABI decoder.

0reactions
SunBeomSocommented, Jan 31, 2020

@norhh Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntactically invalid txdata is generated for some solc issue ...
Description. Generated txdata cannot be sometimes properly decoded for some solc. In the below example, I obtained a valid input using solc 0.5.12....
Read more >
ConsenSys/truffle - Gitter
Yeah I get the same error you get with truffle debug with the pesky contracts that won't deploy for me... but it works...
Read more >
clojurians.slack.com #om scrape
dvcrn: I'll just dump my question in here. If someone knows what I'm doing wrong, please ping me. dvcrn: Sooo, I have a...
Read more >
Documentation - Ethers.js
This is a brief overview of some aspects of Ethereum and blockchains which developers can make use ... The address of the contract...
Read more >
Oracle Discontinues Free Java Time Zone Updates
This tool can be used to apply a patch to the Java runtime so that time zone information is correct. This is necessary...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found