Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions libsolidity/analysis/TypeChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3002,12 +3002,6 @@ bool TypeChecker::visit(FunctionCallOptions const& _functionCallOptions)
_functionCallOptions.location(),
"Function call option \"gas\" cannot be used with \"new\"."
);
else if (m_eofVersion.has_value())
m_errorReporter.typeError(
3765_error,
_functionCallOptions.location(),
"Function call option \"gas\" cannot be used when compiling to EOF."
);
else
{
expectType(*_functionCallOptions.options()[i], *TypeProvider::uint256());
Expand Down
4 changes: 1 addition & 3 deletions libsolidity/analysis/TypeChecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ class TypeChecker: private ASTConstVisitor
{
public:
/// @param _errorReporter provides the error logging functionality.
TypeChecker(langutil::EVMVersion _evmVersion, std::optional<uint8_t> _eofVersion, langutil::ErrorReporter& _errorReporter):
TypeChecker(langutil::EVMVersion _evmVersion, langutil::ErrorReporter& _errorReporter):
m_evmVersion(_evmVersion),
m_eofVersion(_eofVersion),
m_errorReporter(_errorReporter)
{}

Expand Down Expand Up @@ -218,7 +217,6 @@ class TypeChecker: private ASTConstVisitor
ContractDefinition const* m_currentContract = nullptr;

langutil::EVMVersion m_evmVersion;
std::optional<uint8_t> m_eofVersion;

langutil::ErrorReporter& m_errorReporter;
};
Expand Down
7 changes: 0 additions & 7 deletions libsolidity/ast/ASTJsonExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,13 +689,6 @@ bool ASTJsonExporter::visit(InlineAssembly const& _node)
std::make_pair("evmVersion", evmDialect.evmVersion().name())
};

// TODO: Add test in test/linsolidity/ASTJSON/assembly. This requires adding support for eofVersion in ASTJSONTest
if (evmDialect.eofVersion())
{
solAssert(*evmDialect.eofVersion() > 0);
attributes.push_back(std::make_pair("eofVersion", *evmDialect.eofVersion()));
}

if (_node.flags())
{
Json flags = Json::array();
Expand Down
11 changes: 1 addition & 10 deletions libsolidity/ast/ASTJsonImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,16 +735,7 @@ ASTPointer<InlineAssembly> ASTJsonImporter::createInlineAssembly(Json const& _no
astAssert(evmVersion.has_value(), "Invalid EVM version!");
astAssert(m_evmVersion == evmVersion, "Imported tree evm version differs from configured evm version!");

// TODO: Add test in test/linsolidity/ASTJSON/assembly. This requires adding support for eofVersion in ASTJSONTest
std::optional<uint8_t> eofVersion;
if (auto const it = _node.find("eofVersion"); it != _node.end())
{
eofVersion = it->get<uint8_t>();
astAssert(eofVersion > 0);
}
astAssert(m_eofVersion == eofVersion, "Imported tree EOF version differs from configured EOF version!");

yul::Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(evmVersion.value(), eofVersion);
yul::Dialect const& dialect = yul::EVMDialect::strictAssemblyForEVM(evmVersion.value(), std::nullopt);
ASTPointer<std::vector<ASTPointer<ASTString>>> flags;
if (_node.contains("flags"))
{
Expand Down
6 changes: 2 additions & 4 deletions libsolidity/ast/ASTJsonImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace solidity::frontend
class ASTJsonImporter
{
public:
ASTJsonImporter(langutil::EVMVersion _evmVersion, std::optional<uint8_t> _eofVersion)
:m_evmVersion(_evmVersion), m_eofVersion(_eofVersion)
ASTJsonImporter(langutil::EVMVersion _evmVersion)
:m_evmVersion(_evmVersion)
{}

/// Converts the AST from JSON-format to ASTPointer
Expand Down Expand Up @@ -167,8 +167,6 @@ class ASTJsonImporter
std::set<int64_t> m_usedIDs;
/// Configured EVM version
langutil::EVMVersion m_evmVersion;
/// Configured EOF version. Equals std::nullopt if non-EOF
std::optional<uint8_t> m_eofVersion;
};

}
3 changes: 1 addition & 2 deletions libsolidity/codegen/ABIFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,13 @@ class ABIFunctions
public:
explicit ABIFunctions(
langutil::EVMVersion _evmVersion,
std::optional<uint8_t> _eofVersion,
RevertStrings _revertStrings,
MultiUseYulFunctionCollector& _functionCollector
):
m_evmVersion(_evmVersion),
m_revertStrings(_revertStrings),
m_functionCollector(_functionCollector),
m_utils(_evmVersion, _eofVersion, m_revertStrings, m_functionCollector)
m_utils(_evmVersion, m_revertStrings, m_functionCollector)
{}

/// @returns name of an assembly function to ABI-encode values of @a _givenTypes
Expand Down
5 changes: 2 additions & 3 deletions libsolidity/codegen/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ class Compiler
public:
Compiler(
langutil::EVMVersion _evmVersion,
std::optional<uint8_t> _eofVersion,
RevertStrings _revertStrings,
OptimiserSettings _optimiserSettings
):
m_optimiserSettings(std::move(_optimiserSettings)),
m_runtimeContext(_evmVersion, _eofVersion, _revertStrings),
m_context(_evmVersion, _eofVersion, _revertStrings, &m_runtimeContext)
m_runtimeContext(_evmVersion, _revertStrings),
m_context(_evmVersion, _revertStrings, &m_runtimeContext)
{ }

/// Compiles a contract.
Expand Down
5 changes: 2 additions & 3 deletions libsolidity/codegen/CompilerContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class CompilerContext
public:
explicit CompilerContext(
langutil::EVMVersion _evmVersion,
std::optional<uint8_t> _eofVersion,
RevertStrings _revertStrings,
CompilerContext* _runtimeContext = nullptr
):
Expand All @@ -71,8 +70,8 @@ class CompilerContext
m_revertStrings(_revertStrings),
m_reservedMemory{0},
m_runtimeContext(_runtimeContext),
m_abiFunctions(m_evmVersion, _eofVersion, m_revertStrings, m_yulFunctionCollector),
m_yulUtilFunctions(m_evmVersion, _eofVersion, m_revertStrings, m_yulFunctionCollector)
m_abiFunctions(m_evmVersion, m_revertStrings, m_yulFunctionCollector),
m_yulUtilFunctions(m_evmVersion, m_revertStrings, m_yulFunctionCollector)
{
if (m_runtimeContext)
m_runtimeSub = evmasm::SubAssemblyID{m_asm->newSub(m_runtimeContext->m_asm).data()};
Expand Down
30 changes: 11 additions & 19 deletions libsolidity/codegen/YulUtilFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ std::string YulUtilFunctions::revertWithError(
errorArgumentTypes.push_back(arg->annotation().type);
}
templ("argumentVars", joinHumanReadablePrefixed(errorArgumentVars));
templ("encode", ABIFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector).tupleEncoder(errorArgumentTypes, _parameterTypes));
templ("encode", ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector).tupleEncoder(errorArgumentTypes, _parameterTypes));

return templ.render();
}
Expand Down Expand Up @@ -2622,7 +2622,7 @@ std::string YulUtilFunctions::copyArrayFromStorageToMemoryFunction(ArrayType con
if (_from.baseType()->isValueType())
{
solAssert(*_from.baseType() == *_to.baseType(), "");
ABIFunctions abi(m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector);
ABIFunctions abi(m_evmVersion, m_revertStrings, m_functionCollector);
return Whiskers(R"(
function <functionName>(slot) -> memPtr {
memPtr := <allocateUnbounded>()
Expand Down Expand Up @@ -2727,7 +2727,7 @@ std::string YulUtilFunctions::bytesOrStringConcatFunction(
templ("finalizeAllocation", finalizeAllocationFunction());
templ(
"encodePacked",
ABIFunctions{m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector}.tupleEncoderPacked(
ABIFunctions{m_evmVersion, m_revertStrings, m_functionCollector}.tupleEncoderPacked(
_argumentTypes,
targetTypes
)
Expand Down Expand Up @@ -3608,7 +3608,7 @@ std::string YulUtilFunctions::conversionFunction(Type const& _from, Type const&
)")
(
"abiDecode",
ABIFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector).abiDecodingFunctionStruct(
ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector).abiDecodingFunctionStruct(
toStructType,
false
)
Expand Down Expand Up @@ -3937,7 +3937,6 @@ std::string YulUtilFunctions::arrayConversionFunction(ArrayType const& _from, Ar
_from.dataStoredIn(DataLocation::CallData) ?
ABIFunctions(
m_evmVersion,
m_eofVersion,
m_revertStrings,
m_functionCollector
).abiDecodingFunctionArrayAvailableLength(_to, false) :
Expand Down Expand Up @@ -4138,7 +4137,7 @@ std::string YulUtilFunctions::packedHashFunction(
templ("allocateUnbounded", allocateUnboundedFunction());
templ(
"packedEncode",
ABIFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector).tupleEncoderPacked(_givenTypes, _targetTypes)
ABIFunctions(m_evmVersion, m_revertStrings, m_functionCollector).tupleEncoderPacked(_givenTypes, _targetTypes)
);
return templ.render();
});
Expand Down Expand Up @@ -4775,21 +4774,15 @@ std::string YulUtilFunctions::copyConstructorArgumentsToMemoryFunction(

return m_functionCollector.createFunction(functionName, [&]() {
std::string returnParams = suffixedVariableNameList("ret_param_",0, CompilerUtils::sizeOnStack(_contract.constructor()->parameters()));
ABIFunctions abiFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functionCollector);
ABIFunctions abiFunctions(m_evmVersion, m_revertStrings, m_functionCollector);

return util::Whiskers(R"(
function <functionName>() -> <retParams> {
<?eof>
let argSize := calldatasize()
let memoryDataOffset := <allocate>(argSize)
calldatacopy(memoryDataOffset, 0, argSize)
<!eof>
let programSize := datasize("<object>")
let argSize := sub(codesize(), programSize)

let memoryDataOffset := <allocate>(argSize)
codecopy(memoryDataOffset, programSize, argSize)
</eof>
let programSize := datasize("<object>")
let argSize := sub(codesize(), programSize)

let memoryDataOffset := <allocate>(argSize)
codecopy(memoryDataOffset, programSize, argSize)

<retParams> := <abiDecode>(memoryDataOffset, add(memoryDataOffset, argSize))
}
Expand All @@ -4799,7 +4792,6 @@ std::string YulUtilFunctions::copyConstructorArgumentsToMemoryFunction(
("object", _creationObjectName)
("allocate", allocationFunction())
("abiDecode", abiFunctions.tupleDecoder(FunctionType(*_contract.constructor()).parameterTypes(), true))
("eof", m_eofVersion.has_value())
.render();
});
}
Expand Down
3 changes: 0 additions & 3 deletions libsolidity/codegen/YulUtilFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ class YulUtilFunctions
public:
explicit YulUtilFunctions(
langutil::EVMVersion _evmVersion,
std::optional<uint8_t> _eofVersion,
RevertStrings _revertStrings,
MultiUseYulFunctionCollector& _functionCollector
):
m_evmVersion(_evmVersion),
m_eofVersion(_eofVersion),
m_revertStrings(_revertStrings),
m_functionCollector(_functionCollector)
{}
Expand Down Expand Up @@ -653,7 +651,6 @@ class YulUtilFunctions
std::string longByteArrayStorageIndexAccessNoCheckFunction();

langutil::EVMVersion m_evmVersion;
std::optional<uint8_t> m_eofVersion;
RevertStrings m_revertStrings;
MultiUseYulFunctionCollector& m_functionCollector;
};
Expand Down
7 changes: 3 additions & 4 deletions libsolidity/codegen/ir/IRGenerationContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ size_t IRGenerationContext::reservedMemory()
size_t reservedMemory = *m_reservedMemory;

// We assume reserved memory contains only immutable variables.
// This memory is used i.e. by RETURNCONTRACT to create new EOF container with aux data.
size_t immutableVariablesSize = 0;
for (auto const* var: keys(m_immutableVariables))
{
Expand All @@ -159,7 +158,7 @@ size_t IRGenerationContext::reservedMemory()
}

// In Creation context check that only immutable variables or library address are stored in the reserved memory.
// In Deployed context (for EOF) m_immutableVariables contains offsets in EOF data section.
// In Deployed context m_immutableVariables is empty.
solAssert(
(m_executionContext == ExecutionContext::Creation &&
reservedMemory == immutableVariablesSize + (m_libraryAddressImmutableOffset.has_value() ? 32 : 0)) ||
Expand Down Expand Up @@ -224,10 +223,10 @@ void IRGenerationContext::internalFunctionCalledThroughDispatch(YulArity const&

YulUtilFunctions IRGenerationContext::utils()
{
return YulUtilFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functions);
return YulUtilFunctions(m_evmVersion, m_revertStrings, m_functions);
}

ABIFunctions IRGenerationContext::abiFunctions()
{
return ABIFunctions(m_evmVersion, m_eofVersion, m_revertStrings, m_functions);
return ABIFunctions(m_evmVersion, m_revertStrings, m_functions);
}
18 changes: 1 addition & 17 deletions libsolidity/codegen/ir/IRGenerationContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,13 @@ class IRGenerationContext

IRGenerationContext(
langutil::EVMVersion _evmVersion,
std::optional<uint8_t> _eofVersion,
ExecutionContext _executionContext,
RevertStrings _revertStrings,
std::map<std::string, unsigned> _sourceIndices,
langutil::DebugInfoSelection const& _debugInfoSelection,
langutil::CharStreamProvider const* _soliditySourceProvider
):
m_evmVersion(_evmVersion),
m_eofVersion(_eofVersion),
m_executionContext(_executionContext),
m_revertStrings(_revertStrings),
m_sourceIndices(std::move(_sourceIndices)),
Expand Down Expand Up @@ -141,7 +139,6 @@ class IRGenerationContext
YulUtilFunctions utils();

langutil::EVMVersion evmVersion() const { return m_evmVersion; }
std::optional<uint8_t> eofVersion() const { return m_eofVersion; }
ExecutionContext executionContext() const { return m_executionContext; }

void setArithmetic(Arithmetic _value) { m_arithmetic = _value; }
Expand All @@ -166,30 +163,17 @@ class IRGenerationContext
langutil::DebugInfoSelection debugInfoSelection() const { return m_debugInfoSelection; }
langutil::CharStreamProvider const* soliditySourceProvider() const { return m_soliditySourceProvider; }
std::map<VariableDeclaration const*, size_t> const& immutableVariables() const { return m_immutableVariables; }
void setImmutableVariables(std::map<VariableDeclaration const*, size_t> _immutableVariables)
{
solAssert(m_eofVersion.has_value());
solAssert(m_executionContext == ExecutionContext::Deployed);
m_immutableVariables = std::move(_immutableVariables);
}
void setLibraryAddressImmutableOffset(size_t _libraryAddressImmutableOffset)
{
solAssert(m_eofVersion.has_value());
solAssert(m_executionContext == ExecutionContext::Deployed);
m_libraryAddressImmutableOffset = _libraryAddressImmutableOffset;
}

private:
langutil::EVMVersion m_evmVersion;
std::optional<uint8_t> m_eofVersion;
ExecutionContext m_executionContext;
RevertStrings m_revertStrings;
std::map<std::string, unsigned> m_sourceIndices;
std::set<std::string> m_usedSourceNames;
ContractDefinition const* m_mostDerivedContract = nullptr;
std::map<VariableDeclaration const*, IRVariable> m_localVariables;
/// Memory offsets reserved for the values of immutable variables during contract creation.
/// This map is empty in the legacy runtime context and may be not empty in EOF runtime context.
/// This map is empty in the runtime context.
std::map<VariableDeclaration const*, size_t> m_immutableVariables;
std::optional<size_t> m_libraryAddressImmutableOffset;
/// Total amount of reserved memory. Reserved memory is used to store
Expand Down
Loading