argotorg / argotorg/solidity

Resuming compilation from AST import does not produce identical metadata

Open
#14,986 1 comment 0 reactions 0 assignees View on GitHub
feature high effort medium impact must have eventually
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description

AST import leads to inconsistent bytecode.

## Environment

- Compiler version: 0.8.25
- Target EVM version (as per compiler settings): No restrictions
- Framework/IDE: Command-line
- EVM execution environment / backend / blockchain client: None
- Operating system: Linux

## Steps to Reproduce

```solidity
contract C {
function f() public returns (bytes32) {
return address(this).codehash;
}
}
```
### 1. Get ast json
```
solc C.sol --combined-json ast >> C.json
```
### 2. Get bin-runtime by importing ast
```
solc --bin-runtime --import-ast C.json
```
```
6080604052348015600e575f80fd5b50600436106026575f3560e01c806326121ff014602a575b5f80fd5b60306044565b604051603b91906078565b60405180910390f35b5f3073ffffffffffffffffffffffffffffffffffffffff163f905090565b5f819050919050565b6072816062565b82525050565b5f60208201905060895f830184606b565b9291505056fea2646970667358221220fbde534a68865754b695d6f3d9100ab6db0b8f6d336671369335137e84faf43c64736f6c63430008180033
```
### 3. Get bin-runtime by directly compiling
```
solc --bin-runtime C.sol
```
```
6080604052348015600e575f80fd5b50600436106026575f3560e01c806326121ff014602a575b5f80fd5b60306044565b604051603b91906078565b60405180910390f35b5f3073ffffffffffffffffffffffffffffffffffffffff163f905090565b5f819050919050565b6072816062565b82525050565b5f60208201905060895f830184606b565b9291505056fea2646970667358221220a836f31a61ac087171816a7ee56fc5a4b688af164c9acd228bb73fd2c0644f1764736f6c63430008180033
```
### 4. Compare
The bytecode obtained from two methods differs, resulting in different return values for this function **f()**

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the Solidity contract and the two command-line paths shown: `solc --import-ast` versus direct compilation with `--bin-runtime`. Compare the resulting runtime bytecode and the return value of `f()`; done means AST-import compilation produces identical metadata and behavior to direct compilation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
blockchain, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.