Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: cfg graph starts from offset 0x01 instead of 0x00 #499

Open
2 tasks done
alessandromazza98 opened this issue Sep 18, 2024 · 0 comments
Open
2 tasks done

bug: cfg graph starts from offset 0x01 instead of 0x00 #499

alessandromazza98 opened this issue Sep 18, 2024 · 0 comments
Assignees
Labels
T-bug Type: bug

Comments

@alessandromazza98
Copy link

Component

Heimdall (Core)

Have you ensured that you are up to date?

  • Bifrost
  • Heimdall

What version of Heimdall are you on?

heimdall 0.8.4

Operating System

macOS (Apple Silicon)

Describe the bug

I'm generating the cfg of a very simple contract to try heimdall.

everything works fine but I don't understand why heimdall uses offset in the bytecode starting from 0x01 instead of 0x00.

This creates some confusion because, take the example I have in the image, the first block has a jumpi that should point to 0x20. But heimdall shows the jumpdest at offset 0x21 (because of the shifts of the offset). While at offset 0x20 heimdall shows a different opcode (JUMP in this example).

The contract:

// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.27;
contract Faucet {
  // Give out ether to anyone who asks
  function withdraw(uint256 _withdrawAmount, address payable _to) public {
    // Limit withdrawal amount
    require(_withdrawAmount <= 1000000000000);
    // Send the amount to the address that requested it
    _to.transfer(_withdrawAmount);
  }
  fallback() external payable {}
}

I took the runtime bytecode through solc and gave it to heimdall cfg

The graph:
image

tg discussion here: https://t.me/heimdallsupport/388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
None yet
Development

No branches or pull requests

2 participants