Skip to content

Commit 6854e2b

Browse files
committed
fix: bytecodeHash cannot be set to non-none for appendCBOR=false
Testing: see `test/cmdlineTests/metadata_append_standard_json_error` Closes: #13628
1 parent 238ac4f commit 6854e2b

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

libsolidity/interface/StandardCompiler.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,13 @@ std::variant<StandardCompiler::InputsAndSettings, Json::Value> StandardCompiler:
929929
metadataHash == "bzzr1" ?
930930
CompilerStack::MetadataHash::Bzzr1 :
931931
CompilerStack::MetadataHash::None;
932+
if (ret.metadataFormat == CompilerStack::MetadataFormat::NoMetadata && ret.metadataHash != CompilerStack::MetadataHash::None)
933+
return formatFatalError(
934+
Error::Type::JSONError,
935+
"When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"" +
936+
metadataHash +
937+
"\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\"."
938+
);
932939
}
933940

934941
Json::Value outputSelection = settings.get("outputSelection", Json::Value());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--pretty-json --json-indent 4
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"language": "Solidity",
3+
"sources":
4+
{
5+
"A":
6+
{
7+
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.0;\n\ncontract test {}"
8+
}
9+
},
10+
"settings":
11+
{
12+
"viaIR": true,
13+
"optimizer": {
14+
"enabled": true
15+
},
16+
"metadata":
17+
{
18+
"appendCBOR": false,
19+
"bytecodeHash": "ipfs"
20+
},
21+
"outputSelection":
22+
{
23+
"A":
24+
{
25+
"test": ["evm.bytecode"]
26+
}
27+
}
28+
}
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"errors":
3+
[
4+
{
5+
"component": "general",
6+
"formattedMessage": "When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"ipfs\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\".",
7+
"message": "When the parameter \"appendCBOR\" is set to false, the parameter \"bytecodeHash\" cannot be set to \"ipfs\". The parameter \"bytecodeHash\" should either be skipped, or set to \"none\".",
8+
"severity": "error",
9+
"type": "JSONError"
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)