diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index 8ff96328cc..bf5e61c876 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -83,7 +83,7 @@ size_t AssemblyItem::bytesRequired(size_t _addressLength) const return 1 + _addressLength; case PushLibraryAddress: case PushDeployTimeAddress: - return 1 + 20; + return 1 + 22; case PushImmutable: return 1 + 32; case AssignImmutable: diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index 036240add1..3ffbb287dd 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -226,7 +226,7 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound { combineExternalFunctionType(true); m_context << Instruction::DUP2 << Instruction::MSTORE; - m_context << u256(_padToWordBoundaries ? 32 : 24) << Instruction::ADD; + m_context << u256(_type.calldataEncodedSize(_padToWordBoundaries)) << Instruction::ADD; } else if (_type.isValueType()) { @@ -714,10 +714,10 @@ void CompilerUtils::splitExternalFunctionType(bool _leftAligned) if (_leftAligned) { m_context << Instruction::DUP1; - rightShiftNumberOnStack(64 + 32); + rightShiftNumberOnStack(48 + 32); //
m_context << Instruction::SWAP1; - rightShiftNumberOnStack(64); + rightShiftNumberOnStack(48); } else { @@ -737,7 +737,7 @@ void CompilerUtils::combineExternalFunctionType(bool _leftAligned) leftShiftNumberOnStack(32); m_context << Instruction::OR; if (_leftAligned) - leftShiftNumberOnStack(64); + leftShiftNumberOnStack(48); } void CompilerUtils::pushCombinedFunctionEntryLabel(Declaration const& _function, bool _runtimeOnly) diff --git a/libsolidity/codegen/ContractCompiler.cpp b/libsolidity/codegen/ContractCompiler.cpp index 23ec6bf661..c6d08b517f 100644 --- a/libsolidity/codegen/ContractCompiler.cpp +++ b/libsolidity/codegen/ContractCompiler.cpp @@ -231,9 +231,9 @@ size_t ContractCompiler::deployLibrary(ContractDefinition const& _contract) m_context.appendInlineAssembly( Whiskers(R"( { - // If code starts at 11, an mstore(0) writes to the full PUSH20 plus data + // If code starts at 9, an mstore(0) writes to the full PUSH22 plus data // without the need for a shift. - let codepos := 11 + let codepos := 9 codecopy(codepos, subOffset, subSize) // Check that the first opcode is a PUSH22 if iszero(eq(0x75, byte(0, mload(codepos)))) { @@ -306,7 +306,7 @@ void ContractCompiler::appendConstructor(FunctionDefinition const& _constructor) void ContractCompiler::appendDelegatecallCheck() { // Special constant that will be replaced by the address at deploy time. - // At compilation time, this is just "PUSH20 00...000". + // At compilation time, this is just "PUSH22 00...000". m_context.appendDeployTimeAddress(); m_context << Instruction::ADDRESS << Instruction::EQ; // The result on the stack is diff --git a/libsolidity/formal/SMTEncoder.cpp b/libsolidity/formal/SMTEncoder.cpp index a25a5d373f..35b327ff74 100644 --- a/libsolidity/formal/SMTEncoder.cpp +++ b/libsolidity/formal/SMTEncoder.cpp @@ -779,13 +779,11 @@ void SMTEncoder::visitCryptoFunction(FunctionCall const& _funCall) { auto e = state().cryptoFunction("ecrecover"); auto arg0 = expr(*_funCall.arguments().at(0)); - auto arg1 = expr(*_funCall.arguments().at(1)); - auto arg2 = expr(*_funCall.arguments().at(2)); - auto arg3 = expr(*_funCall.arguments().at(3)); + auto arg1 = expr(*_funCall.arguments().at(1), TypeProvider::bytesStorage()); auto inputSort = dynamic_cast(*e.sort).domain; auto ecrecoverInput = smtutil::Expression::tuple_constructor( smtutil::Expression(make_shared(inputSort), ""), - {arg0, arg1, arg2, arg3} + {arg0, arg1} ); result = smtutil::Expression::select(e, ecrecoverInput); } diff --git a/libsolidity/formal/SymbolicState.h b/libsolidity/formal/SymbolicState.h index 4c266f9a85..e3c029f2fb 100644 --- a/libsolidity/formal/SymbolicState.h +++ b/libsolidity/formal/SymbolicState.h @@ -227,12 +227,10 @@ class SymbolicState {"ecrecover", std::make_shared( std::make_shared( "ecrecover_input_type", - std::vector{"hash", "v", "r", "s"}, + std::vector{"hash", "signature"}, std::vector{ smt::smtSort(*TypeProvider::fixedBytes(32)), - smt::smtSort(*TypeProvider::uint(8)), - smt::smtSort(*TypeProvider::fixedBytes(32)), - smt::smtSort(*TypeProvider::fixedBytes(32)) + smt::smtSort(*TypeProvider::bytesStorage()) } ), smtSort(*TypeProvider::address()) diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 53517c7afa..17c52988d8 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -342,7 +342,7 @@ Json::Value formatLinkReferences(std::map const& linkRefere Json::Value entry = Json::objectValue; entry["start"] = Json::UInt(ref.first); - entry["length"] = 20; + entry["length"] = 22; libraryArray.append(entry); fileObject[name] = libraryArray; diff --git a/libyul/backends/evm/AbstractAssembly.h b/libyul/backends/evm/AbstractAssembly.h index 1f222da250..21203207b9 100644 --- a/libyul/backends/evm/AbstractAssembly.h +++ b/libyul/backends/evm/AbstractAssembly.h @@ -74,7 +74,7 @@ class AbstractAssembly /// Returns a label identified by the given name. Creates it if it does not yet exist. virtual LabelID namedLabel(std::string const& _name) = 0; /// Append a reference to a to-be-linked symbol. - /// Currently, we assume that the value is always a 20 byte number. + /// Currently, we assume that the value is always a 22 byte number. virtual void appendLinkerSymbol(std::string const& _name) = 0; /// Append a jump instruction. diff --git a/libyul/backends/evm/EVMAssembly.h b/libyul/backends/evm/EVMAssembly.h index 00cea1208e..645c18145b 100644 --- a/libyul/backends/evm/EVMAssembly.h +++ b/libyul/backends/evm/EVMAssembly.h @@ -60,7 +60,7 @@ class EVMAssembly: public AbstractAssembly /// Returns a label identified by the given name. Creates it if it does not yet exist. LabelID namedLabel(std::string const& _name) override; /// Append a reference to a to-be-linked symbol. - /// Currently, we assume that the value is always a 20 byte number. + /// Currently, we assume that the value is always a 22 byte number. void appendLinkerSymbol(std::string const& _name) override; /// Append a jump instruction.