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

Cannot link unqualified library names via Standard JSON #12145

Open
cameel opened this issue Oct 14, 2021 · 0 comments
Open

Cannot link unqualified library names via Standard JSON #12145

cameel opened this issue Oct 14, 2021 · 0 comments
Labels
breaking change ⚠️ bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. low impact Changes are not very noticeable or potential benefits are limited. needs design The proposal is too vague to be implemented right away nice to have We don’t see a good reason not to have it but won’t go out of our way to implement it.

Comments

@cameel
Copy link
Member

cameel commented Oct 14, 2021

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:

{
    "language": "Yul",
    "sources": {
        "contract.sol": {"content": "{ sstore(0, linkersymbol(\"L\")) }"}
    },
    "settings": {
        "outputSelection": {"*": {"*": ["evm.bytecode"]}},
        "libraries": {
            "": {
                "L": "0x1234567890123456789012345678901234567890"
            }
        }
    }
}
solc --json-indent 4 --standard-json input.json

Output:

{
    "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.

@cameel cameel added low effort There is not much implementation work to be done. The task is very easy or tiny. low impact Changes are not very noticeable or potential benefits are limited. needs design The proposal is too vague to be implemented right away nice to have We don’t see a good reason not to have it but won’t go out of our way to implement it. labels Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change ⚠️ bug 🐛 low effort There is not much implementation work to be done. The task is very easy or tiny. low impact Changes are not very noticeable or potential benefits are limited. needs design The proposal is too vague to be implemented right away nice to have We don’t see a good reason not to have it but won’t go out of our way to implement it.
Projects
None yet
Development

No branches or pull requests

1 participant