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

0x prefix inconsistent in object #787

Closed
1 of 2 tasks
r1cs opened this issue Feb 22, 2022 · 2 comments · Fixed by gakonst/ethers-rs#948
Closed
1 of 2 tasks

0x prefix inconsistent in object #787

r1cs opened this issue Feb 22, 2022 · 2 comments · Fixed by gakonst/ethers-rs#948
Assignees
Labels
T-bug Type: bug

Comments

@r1cs
Copy link

r1cs commented Feb 22, 2022

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.1.0 (ff4ec0f 2022-02-15T00:28:49.003614+00:00)

What command(s) is the bug in?

forge build

Operating System

macOS (M1)

Describe the bug

when I build contract, some object filed in bytecode&deployed_bytecode missing 0x prefix.making strict check for hex string failed.
Here is different object filed prefix with same command:
A contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

//import "../console.sol";
import "./MachineState.sol";
contract MemoryTest {
\\\
\\\
\\\
}

and out in bytecode filed:

"bytecode": {
 "object": "6080604052..."
  "sourceMap": "114:1488:18:-:0;;;;;;;;;;;;;;;;;;;",
"linkReferences": {
      "/Users/w/w/r/r/cs/r/Register.sol": {
        "Register": [
          {
            "start": 3692,
            "length": 20
          },
          {
            "start": 3885,
            "length": 20
          }
        ]
      }


}

but in contract B:

// SPDX-License-Identifier: GPL-v3
pragma solidity ^0.8.0;

import "../interfaces/IMemory.sol";
library MemoryLayout {
///
///
}

the output in bytecode fild is:

"bytecode": {
"object": "0x610196..."
"sourceMap": "97:1376:1..."
"linkReferences": {}
}

It seems that compiler treat library and contract differently, making object output format not consistent.

@r1cs r1cs added the T-bug Type: bug label Feb 22, 2022
@mattsse
Copy link
Member

mattsse commented Feb 22, 2022

thanks for the repro!
will take a look if that's due some serde settings in ethers-rs

@mattsse mattsse self-assigned this Feb 22, 2022
@mattsse
Copy link
Member

mattsse commented Feb 22, 2022

this happens because the MemoryTest has links and serialized as Bytecode::Unlinked
and string serialisation does not add 0x prefix,
I wonder what the consistent format should we, always 0x prefixed or never, like hardhat @gakonst?

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

Successfully merging a pull request may close this issue.

2 participants