Skip to content

Commit cb7b053

Browse files
committed
Consider extcodehash as part of Constantinople
1 parent 5fc8e29 commit cb7b053

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Language Features:
44

55

66
Compiler Features:
7+
* Inline Assembly: Consider ``extcodehash`` as part of Constantinople.
78
* SMTChecker: Do not report underflow/overflow if they always revert. This removes false positives when using ``SafeMath``.
89
* Static Analyzer: Warn about expressions with custom types when they have no effect.
910
* Optimizer: Add rule for shifts with constants for Constantinople.

liblangutil/EVMVersion.h

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class EVMVersion:
7474
bool hasStaticCall() const { return *this >= byzantium(); }
7575
bool hasBitwiseShifting() const { return *this >= constantinople(); }
7676
bool hasCreate2() const { return *this >= constantinople(); }
77+
bool hasExtCodeHash() const { return *this >= constantinople(); }
7778

7879
/// Whether we have to retain the costs for the call opcode itself (false),
7980
/// or whether we can just forward easily all remaining gas (true).

libyul/AsmAnalysis.cpp

+5-13
Original file line numberDiff line numberDiff line change
@@ -655,19 +655,7 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
655655
);
656656
};
657657

658-
if (_instr == solidity::Instruction::EXTCODEHASH)
659-
{
660-
m_errorReporter.warning(
661-
_location,
662-
"The \"" +
663-
boost::to_lower_copy(instructionInfo(_instr).name)
664-
+ "\" instruction is not supported by the VM version \"" +
665-
"" + m_evmVersion.name() +
666-
"\" you are currently compiling for. " +
667-
"It will be interpreted as an invalid instruction on this VM."
668-
);
669-
}
670-
else if ((
658+
if ((
671659
_instr == solidity::Instruction::RETURNDATACOPY ||
672660
_instr == solidity::Instruction::RETURNDATASIZE
673661
) && !m_evmVersion.supportsReturndata())
@@ -690,6 +678,10 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
690678
{
691679
warningForVM("only available for Constantinople-compatible");
692680
}
681+
else if (_instr == solidity::Instruction::EXTCODEHASH && !m_evmVersion.hasExtCodeHash())
682+
{
683+
warningForVM("only available for Constantinople-compatible");
684+
}
693685
else if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI || _instr == solidity::Instruction::JUMPDEST)
694686
{
695687
if (m_dialect->flavour == AsmFlavour::Loose)

test/libsolidity/SolidityNameAndTypeResolution.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -417,10 +417,12 @@ BOOST_AUTO_TEST_CASE(extcodehash_as_variable)
417417
)";
418418
// This needs special treatment, because the message mentions the EVM version,
419419
// so cannot be run via isoltest.
420-
CHECK_ALLOW_MULTI(text, (std::vector<std::pair<Error::Type, std::string>>{
421-
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"},
422-
{Error::Type::Warning, "The \"extcodehash\" instruction is not supported by the VM version"},
423-
}));
420+
vector<pair<Error::Type, std::string>> expectations(vector<pair<Error::Type, std::string>>{
421+
{Error::Type::Warning, "Variable is shadowed in inline assembly by an instruction of the same name"}
422+
});
423+
if (!dev::test::Options::get().evmVersion().hasExtCodeHash())
424+
expectations.emplace_back(make_pair(Error::Type::Warning, std::string("\"extcodehash\" instruction is only available for Constantinople-compatible VMs.")));
425+
CHECK_ALLOW_MULTI(text, expectations);
424426
}
425427

426428
BOOST_AUTO_TEST_CASE(getter_is_memory_type)

0 commit comments

Comments
 (0)