argotorg / argotorg/solidity

Cannot link unqualified library names via Standard JSON

Open
#12,145 1 comment 0 reactions 0 assignees View on GitHub
breaking change :warning: bug :bug: low effort low impact needs design nice to have
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Description
In Standard JSON library addresses for linking require providing a source unit name and a library name as two separate components. For linking, these two parts are joined with a colon so even if the source unit name is empty, the colon is there.

This is different from the CLI where you can provide both `L` and `:L` in the `--libraries` option and for the former will let you match a reference without a colon.

I don't see a good way to support unqualified library names in the current Standard JSON structure so maybe we should just disallow unqualified library names in `linkersymbol()`. This would be a breaking change though.

## Environment

- Compiler version: 0.8.9 (`develop`)

## Steps to Reproduce
`input.json`:
```json
{
"language": "Yul",
"sources": {
"contract.sol": {"content": "{ sstore(0, linkersymbol(\"L\")) }"}
},
"settings": {
"outputSelection": {"*": {"*": ["evm.bytecode"]}},
"libraries": {
"": {
"L": "0x1234567890123456789012345678901234567890"
}
}
}
}
```
```bash
solc --json-indent 4 --standard-json input.json
```
Output:
```json
{
"contracts":
{
"contract.sol":
{
"object":
{
"evm":
{
"bytecode":
{
"functionDebugData": {},
"generatedSources": [],
"linkReferences":
{
"":
{
"L":
[
{
"length": 20,
"start": 1
}
]
}
},
"object": "73__$8aa64f937099b65a4febc243a5ae0f2d64$__600055",
"opcodes": "PUSH20 0x0 PUSH1 0x0 SSTORE ",
"sourceMap": "12:17:0:-:0;9:1;2:28"
}
}
}
}
}
}
```

If you change `linkersymbol("L"))` in the input to `linkersymbol(":L"))`, the unlinked reference disappears.

Contributor guide

Open the contributing guide

Research direction

Start with the provided input.json and run solc --standard-json to compare linkersymbol("L") with linkersymbol(":L") under the Standard JSON libraries setting. Compare this with the CLI --libraries behavior, then determine whether unqualified names should be supported or rejected. Done means the behavior is consistent and the breaking-change decision is reflected in the compiler's result.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.