From fc41c3ac48c526636373cdfb4c319d3bed04306d Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 8 Jan 2015 16:31:05 +0100 Subject: [PATCH 1/4] fixed ETH_BUILD_TYPE being undefined #669 #728 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db5ddb864..a055a5c8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ function(createBuildInfo) endif () #cmake build type may be not specified when using msvc - if (${CMAKE_BUILD_TYPE}) + if (CMAKE_BUILD_TYPE) set(_cmake_build_type ${CMAKE_BUILD_TYPE}) else() set(_cmake_build_type "undefined") From 197b603c98b3cb5356f24988019bf4180d7838e7 Mon Sep 17 00:00:00 2001 From: debris Date: Thu, 8 Jan 2015 16:44:18 +0100 Subject: [PATCH 2/4] fixed undefined buildtype for multi-configuration generators --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a055a5c8d..a3a5702f1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ function(createBuildInfo) if (CMAKE_BUILD_TYPE) set(_cmake_build_type ${CMAKE_BUILD_TYPE}) else() - set(_cmake_build_type "undefined") + set(_cmake_build_type "${CMAKE_CFG_INTDIR}") endif() # Generate header file containing useful build information From 8ad6951f38ecd5d985fb3749725cc1f864509e28 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 9 Jan 2015 15:00:47 +0100 Subject: [PATCH 3/4] Some changes to the log functions. --- libevmcore/Instruction.h | 8 +++++ libsolidity/ExpressionCompiler.cpp | 56 +++++------------------------- test/SolidityEndToEndTest.cpp | 45 +++++++++++++----------- 3 files changed, 42 insertions(+), 67 deletions(-) diff --git a/libevmcore/Instruction.h b/libevmcore/Instruction.h index a28e8f8da..5cf002c4c 100644 --- a/libevmcore/Instruction.h +++ b/libevmcore/Instruction.h @@ -215,6 +215,14 @@ inline Instruction swapInstruction(unsigned _number) return Instruction(unsigned(Instruction::SWAP1) + _number - 1); } +/// @returns the LOG<_number> instruction +inline Instruction logInstruction(unsigned _number) +{ + if (asserts(_number <= 4)) + BOOST_THROW_EXCEPTION(InvalidOpcode() << errinfo_comment("Invalid LOG instruction requested.")); + return Instruction(unsigned(Instruction::LOG0) + _number); +} + /// Information structure for a particular instruction. struct InstructionInfo { diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 7238a6a1b..6c40a0028 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -257,60 +257,22 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall) m_context << u256(32) << u256(0) << eth::Instruction::SHA3; break; case Location::LOG0: - arguments.front()->accept(*this); - appendTypeConversion(*arguments.front()->getType(), *function.getParameterTypes().front(), true); - // @todo move this once we actually use memory - CompilerUtils(m_context).storeInMemory(0); - m_context << u256(32) << u256(0) << eth::Instruction::LOG0; - break; case Location::LOG1: - arguments[1]->accept(*this); - arguments[0]->accept(*this); - appendTypeConversion(*arguments[1]->getType(), *function.getParameterTypes()[1], true); - appendTypeConversion(*arguments[0]->getType(), *function.getParameterTypes()[0], true); - // @todo move this once we actually use memory - CompilerUtils(m_context).storeInMemory(0); - m_context << u256(32) << u256(0) << eth::Instruction::LOG1; - break; case Location::LOG2: - arguments[2]->accept(*this); - arguments[1]->accept(*this); - arguments[0]->accept(*this); - appendTypeConversion(*arguments[2]->getType(), *function.getParameterTypes()[2], true); - appendTypeConversion(*arguments[1]->getType(), *function.getParameterTypes()[1], true); - appendTypeConversion(*arguments[0]->getType(), *function.getParameterTypes()[0], true); - // @todo move this once we actually use memory - CompilerUtils(m_context).storeInMemory(0); - m_context << u256(32) << u256(0) << eth::Instruction::LOG2; - break; case Location::LOG3: - arguments[3]->accept(*this); - arguments[2]->accept(*this); - arguments[1]->accept(*this); - arguments[0]->accept(*this); - appendTypeConversion(*arguments[3]->getType(), *function.getParameterTypes()[3], true); - appendTypeConversion(*arguments[2]->getType(), *function.getParameterTypes()[2], true); - appendTypeConversion(*arguments[1]->getType(), *function.getParameterTypes()[1], true); - appendTypeConversion(*arguments[0]->getType(), *function.getParameterTypes()[0], true); - // @todo move this once we actually use memory - CompilerUtils(m_context).storeInMemory(0); - m_context << u256(32) << u256(0) << eth::Instruction::LOG3; - break; case Location::LOG4: - arguments[4]->accept(*this); - arguments[3]->accept(*this); - arguments[2]->accept(*this); - arguments[1]->accept(*this); - arguments[0]->accept(*this); - appendTypeConversion(*arguments[4]->getType(), *function.getParameterTypes()[4], true); - appendTypeConversion(*arguments[3]->getType(), *function.getParameterTypes()[3], true); - appendTypeConversion(*arguments[2]->getType(), *function.getParameterTypes()[2], true); - appendTypeConversion(*arguments[1]->getType(), *function.getParameterTypes()[1], true); - appendTypeConversion(*arguments[0]->getType(), *function.getParameterTypes()[0], true); + { + unsigned logNumber = int(function.getLocation()) - int(Location::LOG0); + for (int arg = logNumber; arg >= 0; --arg) + { + arguments[arg]->accept(*this); + appendTypeConversion(*arguments[arg]->getType(), *function.getParameterTypes()[arg], true); + } // @todo move this once we actually use memory CompilerUtils(m_context).storeInMemory(0); - m_context << u256(32) << u256(0) << eth::Instruction::LOG4; + m_context << u256(32) << u256(0) << eth::logInstruction(logNumber); break; + } case Location::ECRECOVER: case Location::SHA256: case Location::RIPEMD160: diff --git a/test/SolidityEndToEndTest.cpp b/test/SolidityEndToEndTest.cpp index 1ddd26f75..bc184dfca 100644 --- a/test/SolidityEndToEndTest.cpp +++ b/test/SolidityEndToEndTest.cpp @@ -857,10 +857,8 @@ BOOST_AUTO_TEST_CASE(log0) " log0(1);\n" " }\n" "}\n"; - u256 amount(130); - compileAndRun(sourceCode, amount + 1); - u160 address(23); - callContractFunction("a()", address, amount); + compileAndRun(sourceCode); + callContractFunction("a()"); BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); @@ -874,10 +872,8 @@ BOOST_AUTO_TEST_CASE(log1) " log1(1, 2);\n" " }\n" "}\n"; - u256 amount(130); - compileAndRun(sourceCode, amount + 1); - u160 address(23); - callContractFunction("a()", address, amount); + compileAndRun(sourceCode); + callContractFunction("a()"); BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); @@ -892,10 +888,8 @@ BOOST_AUTO_TEST_CASE(log2) " log2(1, 2, 3);\n" " }\n" "}\n"; - u256 amount(130); - compileAndRun(sourceCode, amount + 1); - u160 address(23); - callContractFunction("a()", address, amount); + compileAndRun(sourceCode); + callContractFunction("a()"); BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); @@ -911,10 +905,8 @@ BOOST_AUTO_TEST_CASE(log3) " log3(1, 2, 3, 4);\n" " }\n" "}\n"; - u256 amount(130); - compileAndRun(sourceCode, amount + 1); - u160 address(23); - callContractFunction("a()", address, amount); + compileAndRun(sourceCode); + callContractFunction("a()"); BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); @@ -930,10 +922,8 @@ BOOST_AUTO_TEST_CASE(log4) " log4(1, 2, 3, 4, 5);\n" " }\n" "}\n"; - u256 amount(130); - compileAndRun(sourceCode, amount + 1); - u160 address(23); - callContractFunction("a()", address, amount); + compileAndRun(sourceCode); + callContractFunction("a()"); BOOST_CHECK_EQUAL(m_logs.size(), 1); BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); @@ -942,6 +932,21 @@ BOOST_AUTO_TEST_CASE(log4) BOOST_CHECK_EQUAL(m_logs[0].topics[i], h256(u256(i + 2))); } +BOOST_AUTO_TEST_CASE(log_in_constructor) +{ + char const* sourceCode = "contract test {\n" + " function test() {\n" + " log1(1, 2);\n" + " }\n" + "}\n"; + compileAndRun(sourceCode); + BOOST_CHECK_EQUAL(m_logs.size(), 1); + BOOST_CHECK_EQUAL(m_logs[0].address, m_contractAddress); + BOOST_CHECK_EQUAL(h256(m_logs[0].data), h256(u256(1))); + BOOST_CHECK_EQUAL(m_logs[0].topics.size(), 1); + BOOST_CHECK_EQUAL(m_logs[0].topics[0], h256(u256(2))); +} + BOOST_AUTO_TEST_CASE(suicide) { char const* sourceCode = "contract test {\n" From 7b0347798383aebc5d323fd97c27d895a373d39a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 9 Jan 2015 16:21:02 +0100 Subject: [PATCH 4/4] Warning fix. --- neth/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/neth/main.cpp b/neth/main.cpp index 06be53393..0b48edc11 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -299,6 +299,7 @@ int main(int argc, char** argv) unsigned short remotePort = 30303; string dbPath; unsigned mining = ~(unsigned)0; + (void)mining; NodeMode mode = NodeMode::Full; unsigned peers = 5; #if ETH_JSONRPC