mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10290 from ethereum/fix-standard-json-ignoring-library-file-names
Fix Standard JSON ignoring library file names
This commit is contained in:
commit
e1292380bd
@ -32,6 +32,7 @@ Bugfixes:
|
||||
* SMTChecker: Fix CHC false positives when branches are used inside modifiers.
|
||||
* Code generator: Fix missing creation dependency tracking for abstract contracts.
|
||||
* NatSpec: Fix internal error when inheriting return parameter documentation but the parameter names differ between base and inherited.
|
||||
* Standard JSON: Fix library addresses specified in ``libraries`` being used for linking even if the file names do not match.
|
||||
|
||||
|
||||
### 0.7.4 (2020-10-19)
|
||||
|
@ -839,8 +839,7 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
|
||||
|
||||
try
|
||||
{
|
||||
// @TODO use libraries only for the given source
|
||||
ret.libraries[library] = util::h160(address);
|
||||
ret.libraries[sourceName + ":" + library] = util::h160(address);
|
||||
}
|
||||
catch (util::BadHexCharacter const&)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"contract/test.sol": {
|
||||
"A": {
|
||||
"L": "0x1234567890123456789012345678901234567890"
|
||||
}
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"A": {
|
||||
"A\"B": {
|
||||
"content": "
|
||||
// SPDX-License-Identifier: GPL-3.0
|
||||
pragma solidity >=0.0;
|
||||
@ -20,7 +20,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"contract/test\"test.sol": {
|
||||
"A\"B": {
|
||||
"L": "0x1234567890123456789012345678901234567890"
|
||||
}
|
||||
},
|
||||
|
@ -1 +1 @@
|
||||
{"contracts":{"A":{"C":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"A":{"id":0}}}
|
||||
{"contracts":{"A\"B":{"C":{"evm":{"bytecode":{"generatedSources":[],"linkReferences":{},"object":"<BYTECODE REMOVED>","opcodes":"<OPCODES REMOVED>","sourceMap":"<SOURCEMAP REMOVED>"}}}}},"sources":{"A\"B":{"id":0}}}
|
||||
|
@ -28,7 +28,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"contract/test.sol": {
|
||||
"A": {
|
||||
"L1": "0x1234567890123456789012345678901234567890"
|
||||
}
|
||||
},
|
||||
|
@ -0,0 +1 @@
|
||||
--strict-assembly --libraries library1.sol:L:0x1234567890123456789012345678901234567890
|
@ -0,0 +1 @@
|
||||
Warning: Yul is still experimental. Please use the output with care.
|
@ -0,0 +1,6 @@
|
||||
object "a" {
|
||||
code {
|
||||
let addr1 := linkersymbol("library1.sol:L")
|
||||
let addr2 := linkersymbol("library2.sol:L")
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
|
||||
======= linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul (EVM) =======
|
||||
|
||||
Pretty printed source:
|
||||
object "a" {
|
||||
code {
|
||||
let addr1 := linkersymbol("library1.sol:L")
|
||||
let addr2 := linkersymbol("library2.sol:L")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Binary representation:
|
||||
73123456789012345678901234567890123456789073__$c3523432985587641d17c68161d2f700c5$__5050
|
||||
|
||||
Text representation:
|
||||
linkerSymbol("f3ffc10c396a7cc41ae954b050792839d20947bf73497d30c49a9fda1ea477ec")
|
||||
/* "linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul":32:75 */
|
||||
linkerSymbol("c3523432985587641d17c68161d2f700c57aaf4ed21cda4f25d76193c831f97f")
|
||||
/* "linking_strict_assembly_same_library_name_different_files_in_link_references/input.yul":22:133 */
|
||||
pop
|
||||
pop
|
@ -903,6 +903,38 @@ BOOST_AUTO_TEST_CASE(library_linking)
|
||||
expectLinkReferences(contractResult, {{"library2.sol", {"L2"}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul)
|
||||
{
|
||||
char const* input = R"(
|
||||
{
|
||||
"language": "Yul",
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"fileB": {
|
||||
"L": "0x4200000000000000000000000000000000000001"
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"fileA": {
|
||||
"*": [
|
||||
"evm.bytecode.linkReferences"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"sources": {
|
||||
"fileA": {
|
||||
"content": "object \"a\" { code { let addr := linkersymbol(\"fileB:L\") } }"
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
|
||||
{
|
||||
char const* input = R"(
|
||||
@ -932,7 +964,7 @@ BOOST_AUTO_TEST_CASE(linking_yul_empty_link_reference)
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {});
|
||||
expectLinkReferences(contractResult, {{"", {""}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
|
||||
@ -964,7 +996,39 @@ BOOST_AUTO_TEST_CASE(linking_yul_no_filename_in_link_reference)
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {});
|
||||
expectLinkReferences(contractResult, {{"", {"L"}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(linking_yul_same_library_name_different_files)
|
||||
{
|
||||
char const* input = R"(
|
||||
{
|
||||
"language": "Yul",
|
||||
"settings": {
|
||||
"libraries": {
|
||||
"fileB": {
|
||||
"L": "0x4200000000000000000000000000000000000001"
|
||||
}
|
||||
},
|
||||
"outputSelection": {
|
||||
"fileA": {
|
||||
"*": [
|
||||
"evm.bytecode.linkReferences"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"sources": {
|
||||
"fileA": {
|
||||
"content": "object \"a\" { code { let addr := linkersymbol(\"fileC:L\") } }"
|
||||
}
|
||||
}
|
||||
}
|
||||
)";
|
||||
Json::Value result = compile(input);
|
||||
BOOST_TEST(containsAtMostWarnings(result));
|
||||
Json::Value contractResult = getContractResult(result, "fileA", "a");
|
||||
expectLinkReferences(contractResult, {{"fileC", {"L"}}});
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(evm_version)
|
||||
|
Loading…
Reference in New Issue
Block a user