From 81d7d0874e16584754dabe466d7c2e403571bacf Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 27 Apr 2015 21:42:51 +0200 Subject: [PATCH 01/26] v8 integration initial commit --- CMakeLists.txt | 4 ++++ libethconsole/CMakeLists.txt | 7 +++++++ libethconsole/JSV8ScopeBase.cpp | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 libethconsole/CMakeLists.txt create mode 100644 libethconsole/JSV8ScopeBase.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a97bb86fc..2413fc0a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ add_subdirectory(libethereum) add_subdirectory(libevm) add_subdirectory(libnatspec) add_subdirectory(libp2p) +add_subdirectory(libethconsole) + if (SOLIDITY) add_subdirectory(libsolidity) endif () @@ -40,6 +42,7 @@ include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${CRYPTOPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) +include_directories(${V8_INCLUDE_DIRS}) # search for test names and create ctest tests enable_testing() @@ -65,6 +68,7 @@ target_link_libraries(testeth ${CURL_LIBRARIES}) target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) +target_link_libraries(testeth ethconsole) if (SOLIDITY) target_link_libraries(testeth solidity) endif () diff --git a/libethconsole/CMakeLists.txt b/libethconsole/CMakeLists.txt new file mode 100644 index 000000000..610c58889 --- /dev/null +++ b/libethconsole/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_policy(SET CMP0015 NEW) + +aux_source_directory(. SRCS) + +add_sources(${SRCS}) + + diff --git a/libethconsole/JSV8ScopeBase.cpp b/libethconsole/JSV8ScopeBase.cpp new file mode 100644 index 000000000..5bd7bf6a5 --- /dev/null +++ b/libethconsole/JSV8ScopeBase.cpp @@ -0,0 +1,21 @@ +// +// Created by Marek Kotewicz on 27/04/15. +// + +#include +#include "../../libethconsole/JSV8ScopeBase.h" + +using namespace std; +using namespace dev; +using namespace dev::eth; + +BOOST_AUTO_TEST_SUITE(jsscope) + +BOOST_AUTO_TEST_CASE(common) +{ + JSV8ScopeBase scope; + string result = scope.evaluate("1 + 1"); + BOOST_CHECK_EQUAL(result, "2"); +} + +BOOST_AUTO_TEST_SUITE_END() From 189c0d460ba316f613388b22ca6108f757eabca6 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 27 Apr 2015 22:20:57 +0200 Subject: [PATCH 02/26] cleanup, libjsengine --- CMakeLists.txt | 4 ++-- libethconsole/CMakeLists.txt | 7 ------- libethconsole/JSV8ScopeBase.cpp | 21 --------------------- 3 files changed, 2 insertions(+), 30 deletions(-) delete mode 100644 libethconsole/CMakeLists.txt delete mode 100644 libethconsole/JSV8ScopeBase.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2413fc0a9..349ca9800 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,7 @@ add_subdirectory(libethereum) add_subdirectory(libevm) add_subdirectory(libnatspec) add_subdirectory(libp2p) -add_subdirectory(libethconsole) +add_subdirectory(libjsengine) if (SOLIDITY) add_subdirectory(libsolidity) @@ -68,7 +68,7 @@ target_link_libraries(testeth ${CURL_LIBRARIES}) target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) -target_link_libraries(testeth ethconsole) +target_link_libraries(testeth jsengine) if (SOLIDITY) target_link_libraries(testeth solidity) endif () diff --git a/libethconsole/CMakeLists.txt b/libethconsole/CMakeLists.txt deleted file mode 100644 index 610c58889..000000000 --- a/libethconsole/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -cmake_policy(SET CMP0015 NEW) - -aux_source_directory(. SRCS) - -add_sources(${SRCS}) - - diff --git a/libethconsole/JSV8ScopeBase.cpp b/libethconsole/JSV8ScopeBase.cpp deleted file mode 100644 index 5bd7bf6a5..000000000 --- a/libethconsole/JSV8ScopeBase.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// -// Created by Marek Kotewicz on 27/04/15. -// - -#include -#include "../../libethconsole/JSV8ScopeBase.h" - -using namespace std; -using namespace dev; -using namespace dev::eth; - -BOOST_AUTO_TEST_SUITE(jsscope) - -BOOST_AUTO_TEST_CASE(common) -{ - JSV8ScopeBase scope; - string result = scope.evaluate("1 + 1"); - BOOST_CHECK_EQUAL(result, "2"); -} - -BOOST_AUTO_TEST_SUITE_END() From 5cb7fa670f2efe5dd98c4f1f37b3c07987897639 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 28 Apr 2015 00:43:37 +0200 Subject: [PATCH 03/26] libjsconsole init From b79f8a0b57acc7b9c7ca04eac87b6104c9dba557 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 28 Apr 2015 08:24:39 +0200 Subject: [PATCH 04/26] jsvalueprinter From c2bcd771de816854e19cfb14dfa4e8bc17a7dff8 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Wed, 29 Apr 2015 09:31:22 +0200 Subject: [PATCH 05/26] console command line option From 1988cecef16795906c0ed5ce262b4e08202b309e Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 30 Apr 2015 13:27:55 +0200 Subject: [PATCH 06/26] jsconsole optional for tests --- CMakeLists.txt | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 349ca9800..39a235c58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,7 +25,10 @@ add_subdirectory(libethereum) add_subdirectory(libevm) add_subdirectory(libnatspec) add_subdirectory(libp2p) -add_subdirectory(libjsengine) + +if (JSCONSOLE) + add_subdirectory(libjsengine) +endif() if (SOLIDITY) add_subdirectory(libsolidity) @@ -42,7 +45,10 @@ include_directories(BEFORE ..) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${CRYPTOPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) -include_directories(${V8_INCLUDE_DIRS}) + +if (JSCONSOLE) + include_directories(${V8_INCLUDE_DIRS}) +endif() # search for test names and create ctest tests enable_testing() @@ -68,15 +74,22 @@ target_link_libraries(testeth ${CURL_LIBRARIES}) target_link_libraries(testeth ethereum) target_link_libraries(testeth ethcore) target_link_libraries(testeth secp256k1) -target_link_libraries(testeth jsengine) + +if (JSCONSOLE) + target_link_libraries(testeth jsengine) +endif() + if (SOLIDITY) target_link_libraries(testeth solidity) endif () + target_link_libraries(testeth testutils) + if (GUI AND NOT JUSTTESTS) target_link_libraries(testeth webthree) target_link_libraries(testeth natspec) endif() + if (JSONRPC) target_link_libraries(testeth web3jsonrpc) target_link_libraries(testeth ${JSON_RPC_CPP_CLIENT_LIBRARIES}) From b759ee60ddb14d20b289f3f3630eea05ae166ce2 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 30 Apr 2015 17:40:17 +0200 Subject: [PATCH 07/26] printing v8 errors From 3bc28c100c5d42ca9f4ae9e501dc9b948c16f214 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Mon, 4 May 2015 12:58:56 +0200 Subject: [PATCH 08/26] rpc provider in progress From f59d81d33f4b7330f2bbcbe4afba19fc9564ac7a Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Tue, 5 May 2015 10:37:14 +0200 Subject: [PATCH 09/26] wrap const char* in jsstring From 8416a6260f3545ae7109091a09bef9291db59179 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 29 Apr 2015 18:16:05 +0200 Subject: [PATCH 10/26] Split known state from common subexpression eliminator. --- libsolidity/SolidityOptimizer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp index 9cdaa5886..71463f919 100644 --- a/libsolidity/SolidityOptimizer.cpp +++ b/libsolidity/SolidityOptimizer.cpp @@ -90,7 +90,8 @@ public: for (AssemblyItem& item: input) item.setLocation(SourceLocation(1, 3, make_shared(""))); - eth::CommonSubexpressionEliminator cse; + eth::KnownState state; + eth::CommonSubexpressionEliminator cse(state); BOOST_REQUIRE(cse.feedItems(input.begin(), input.end()) == input.end()); AssemblyItems output = cse.getOptimizedItems(); @@ -231,7 +232,8 @@ BOOST_AUTO_TEST_CASE(function_calls) BOOST_AUTO_TEST_CASE(cse_intermediate_swap) { - eth::CommonSubexpressionEliminator cse; + eth::KnownState state; + eth::CommonSubexpressionEliminator cse(state); AssemblyItems input{ Instruction::SWAP1, Instruction::POP, Instruction::ADD, u256(0), Instruction::SWAP1, Instruction::SLOAD, Instruction::SWAP1, u256(100), Instruction::EXP, Instruction::SWAP1, From 3649c1fc60bf64171f843ec1cb73697b9f0ebd3f Mon Sep 17 00:00:00 2001 From: chriseth Date: Thu, 30 Apr 2015 14:41:55 +0200 Subject: [PATCH 11/26] Common subexpression elimination ready for using pre-known state. --- libsolidity/SolidityOptimizer.cpp | 49 ++++++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp index 71463f919..59e8f04a8 100644 --- a/libsolidity/SolidityOptimizer.cpp +++ b/libsolidity/SolidityOptimizer.cpp @@ -83,15 +83,28 @@ public: "\nOptimized: " + toHex(optimizedOutput)); } - AssemblyItems getCSE(AssemblyItems const& _input) + AssemblyItems addDummyLocations(AssemblyItems const& _input) { // add dummy locations to each item so that we can check that they are not deleted AssemblyItems input = _input; for (AssemblyItem& item: input) item.setLocation(SourceLocation(1, 3, make_shared(""))); + return input; + } + eth::KnownState createInitialState(AssemblyItems const& _input) + { eth::KnownState state; - eth::CommonSubexpressionEliminator cse(state); + for (auto const& item: addDummyLocations(_input)) + state.feedItem(item); + return state; + } + + AssemblyItems getCSE(AssemblyItems const& _input, eth::KnownState const& _state = eth::KnownState()) + { + AssemblyItems input = addDummyLocations(_input); + + eth::CommonSubexpressionEliminator cse(_state); BOOST_REQUIRE(cse.feedItems(input.begin(), input.end()) == input.end()); AssemblyItems output = cse.getOptimizedItems(); @@ -102,9 +115,13 @@ public: return output; } - void checkCSE(AssemblyItems const& _input, AssemblyItems const& _expectation) + void checkCSE( + AssemblyItems const& _input, + AssemblyItems const& _expectation, + KnownState const& _state = eth::KnownState() + ) { - AssemblyItems output = getCSE(_input); + AssemblyItems output = getCSE(_input, _state); BOOST_CHECK_EQUAL_COLLECTIONS(_expectation.begin(), _expectation.end(), output.begin(), output.end()); } @@ -756,6 +773,30 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_noninterfering_store_in_between BOOST_CHECK_EQUAL(1, count(output.begin(), output.end(), AssemblyItem(Instruction::SHA3))); } +BOOST_AUTO_TEST_CASE(cse_with_initially_known_stack) +{ + eth::KnownState state = createInitialState(AssemblyItems{ + u256(0x12), + u256(0x20), + Instruction::ADD + }); + AssemblyItems input{ + u256(0x12 + 0x20) + }; + checkCSE(input, AssemblyItems{Instruction::DUP1}, state); +} + +BOOST_AUTO_TEST_CASE(cse_equality_on_initially_known_stack) +{ + eth::KnownState state = createInitialState(AssemblyItems{Instruction::DUP1}); + AssemblyItems input{ + Instruction::EQ + }; + AssemblyItems output = getCSE(input, state); + // check that it directly pushes 1 (true) + BOOST_CHECK(find(output.begin(), output.end(), AssemblyItem(u256(1))) != output.end()); +} + BOOST_AUTO_TEST_CASE(control_flow_graph_remove_unused) { // remove parts of the code that are unused From a0cc8abb2a162f883b5afd4757f52d926cf6df0b Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 5 May 2015 17:45:58 +0200 Subject: [PATCH 12/26] CFG returns vector of blocks instead of assembly items. --- libsolidity/SolidityOptimizer.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libsolidity/SolidityOptimizer.cpp b/libsolidity/SolidityOptimizer.cpp index 59e8f04a8..3cb6a536a 100644 --- a/libsolidity/SolidityOptimizer.cpp +++ b/libsolidity/SolidityOptimizer.cpp @@ -131,8 +131,12 @@ public: // Running it four times should be enough for these tests. for (unsigned i = 0; i < 4; ++i) { - eth::ControlFlowGraph cfg(output); - output = cfg.optimisedItems(); + ControlFlowGraph cfg(output); + AssemblyItems optItems; + for (BasicBlock const& block: cfg.optimisedBlocks()) + copy(output.begin() + block.begin, output.begin() + block.end, + back_inserter(optItems)); + output = move(optItems); } BOOST_CHECK_EQUAL_COLLECTIONS(_expectation.begin(), _expectation.end(), output.begin(), output.end()); } From de01400fb4bb0e3dc2ab246a437fb4b5c5f2adb1 Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 7 May 2015 09:51:06 +0200 Subject: [PATCH 13/26] set and map to hash tables --- TestHelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestHelper.cpp b/TestHelper.cpp index 144a1a286..96e11e02c 100644 --- a/TestHelper.cpp +++ b/TestHelper.cpp @@ -305,7 +305,7 @@ void ImportTest::checkExpectedState(State const& _stateExpect, State const& _sta if (addressOptions.m_bHasStorage) { - map stateStorage = _statePost.storage(a.first); + unordered_map stateStorage = _statePost.storage(a.first); for (auto const& s: _stateExpect.storage(a.first)) CHECK(stateStorage[s.first] == s.second, "Check State: " << a.first << ": incorrect storage [" << s.first << "] = " << toHex(stateStorage[s.first]) << ", expected [" << s.first << "] = " << toHex(s.second)); From 21f2af4793fee8701f8ad2bf028b99f87d80417e Mon Sep 17 00:00:00 2001 From: winsvega Date: Mon, 27 Apr 2015 14:38:32 +0300 Subject: [PATCH 14/26] Total Difficulty test From cfff783c2876640528312128c70ebf3a16a2632e Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 28 Apr 2015 17:20:33 +0300 Subject: [PATCH 15/26] Total Difficulty: merge revert From 715643c3f28777aa69c4cdcde4fe1213d0b0df89 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 28 Apr 2015 17:43:29 +0300 Subject: [PATCH 16/26] Total Difficulty: blockweight test filler --- bcBlockWeightTestFiller.json | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 bcBlockWeightTestFiller.json diff --git a/bcBlockWeightTestFiller.json b/bcBlockWeightTestFiller.json new file mode 100644 index 000000000..62158032e --- /dev/null +++ b/bcBlockWeightTestFiller.json @@ -0,0 +1,106 @@ +{ +"diffTooHigh" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "3141592", + "gasUsed" : "0", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "expect" : { + "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { + "balance" : "30" + }, + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "nonce" : "3" + }, + "acde5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1312500000000000000" + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "314159", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "314159", + "gasPrice" : "1", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "", + "gasLimit" : "314159", + "gasPrice" : "1", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + { + "overwriteAndRedoPoW" : "difficulty", + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "acde5374fce5edbc8e2a8697c15331677e6ebf0b", + "difficulty" : "131073", + "extraData" : "0x", + "gasLimit" : "4141592", + "gasUsed" : "150000", + "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", + "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", + "nonce" : "18a524c1790fa83b", + "number" : "2", + "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", + "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", + "timestamp" : "142813170", + "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + } + ] + } + ] + } +} From 2233d4e315ca880da251cecd8c23bb8045601aa5 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 28 Apr 2015 17:47:25 +0300 Subject: [PATCH 17/26] Total Difficulty: test filler --- bcBlockWeightTestFiller.json | 106 ----------------------------------- 1 file changed, 106 deletions(-) delete mode 100644 bcBlockWeightTestFiller.json diff --git a/bcBlockWeightTestFiller.json b/bcBlockWeightTestFiller.json deleted file mode 100644 index 62158032e..000000000 --- a/bcBlockWeightTestFiller.json +++ /dev/null @@ -1,106 +0,0 @@ -{ -"diffTooHigh" : { - "genesisBlockHeader" : { - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", - "difficulty" : "131072", - "extraData" : "0x42", - "gasLimit" : "3141592", - "gasUsed" : "0", - "number" : "0", - "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", - "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", - "timestamp" : "0x54c98c81", - "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "nonce" : "0x0102030405060708", - "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - }, - "expect" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "30" - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "nonce" : "3" - }, - "acde5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1312500000000000000" - } - }, - "pre" : { - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "10000000000000", - "nonce" : "0", - "code" : "", - "storage": {} - } - }, - "blocks" : [ - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "0", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "1", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - ] - }, - { - "transactions" : [ - { - "data" : "", - "gasLimit" : "314159", - "gasPrice" : "1", - "nonce" : "2", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "10" - } - ], - "uncleHeaders" : [ - { - "overwriteAndRedoPoW" : "difficulty", - "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "coinbase" : "acde5374fce5edbc8e2a8697c15331677e6ebf0b", - "difficulty" : "131073", - "extraData" : "0x", - "gasLimit" : "4141592", - "gasUsed" : "150000", - "hash" : "9de9879b6a81d1b6c4993c63c90a3c9d1e775f14572694778e828bc64972ae04", - "mixHash" : "b557f905d29ed0fca99d65d0adcce698dee97cf72a13c7cd8d7a7826b8eee770", - "nonce" : "18a524c1790fa83b", - "number" : "2", - "parentHash" : "6134fc6b5d99ee03c4aab1592640f6f9dcbc850668d75d631aee34989b938fae", - "receiptTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "stateRoot" : "ff640b30d613c35dad43e3693329e1b1ee6350f989cf46a288025a1cbfdab9cd", - "timestamp" : "142813170", - "transactionsTrie" : "56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", - "uncleHash" : "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" - } - ] - } - ] - } -} From cd3a388f13ad8d719d6c41f3b40638009f135eb4 Mon Sep 17 00:00:00 2001 From: winsvega Date: Wed, 29 Apr 2015 18:56:28 +0300 Subject: [PATCH 18/26] Total Difficulty: new tests From c8092b4da3655924de1f3ceddc2a4127a325690d Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 30 Apr 2015 15:49:06 +0300 Subject: [PATCH 19/26] Total Difficulty: style + rebase From eaf95687fe12b84bfd6d07a9dd8f29c7d249c0c3 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 5 May 2015 18:25:51 +0300 Subject: [PATCH 20/26] Total Difficulty: lastblockhash check From 81c1e3b4fe8ed7039996468a1ed538f26043aff0 Mon Sep 17 00:00:00 2001 From: winsvega Date: Tue, 5 May 2015 22:11:37 +0300 Subject: [PATCH 21/26] Total Difficulty: bug fix From 917ce1ad55381ca985244f25225bd47a2c12e658 Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 7 May 2015 19:59:37 +0300 Subject: [PATCH 22/26] Total Difficulty: last block hash fix From ccf48882c9387bf153dca17777e1788de2277bca Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 8 May 2015 11:13:36 +0200 Subject: [PATCH 23/26] Basic key manager. From 757972b4e35ab30774355a4868b6bc5a49dda3d9 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Tue, 5 May 2015 12:33:41 +0200 Subject: [PATCH 24/26] added test --- libsolidity/SolidityNameAndTypeResolution.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index c317dad97..9616777ab 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1761,6 +1761,25 @@ BOOST_AUTO_TEST_CASE(uninitialized_var) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } +BOOST_AUTO_TEST_CASE(deny_overwriting_of_attributes_when_deriving) +{ + // bug #1798 + char const* sourceCode = R"( + contract owned { + address owner; + } + + contract reg { + function owner(bytes32 x) returns (address) {} + } + + contract x is owned, reg { + } + )"; + ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode), "Parsing and Name Resolving Failed"); + //BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); +} + BOOST_AUTO_TEST_SUITE_END() } From 960033de6bea1e436656ccc71b5152efd4314036 Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 7 May 2015 18:12:58 +0200 Subject: [PATCH 25/26] fixed the test --- libsolidity/SolidityEndToEndTest.cpp | 29 +++++++++++++++++++ libsolidity/SolidityNameAndTypeResolution.cpp | 19 ------------ 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index f168ad454..2fd1e2ec2 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -3910,6 +3910,35 @@ BOOST_AUTO_TEST_CASE(external_types_in_calls) BOOST_CHECK(callContractFunction("nonexisting") == encodeArgs(u256(9))); } +BOOST_AUTO_TEST_CASE(proper_order_of_overwriting_of_attributes) +{ + // bug #1798 + char const* sourceCode = R"( + contract init { + function isOk() returns (bool) { return false; } + bool public ok = false; + } + contract fix { + function isOk() returns (bool) { return true; } + bool public ok = true; + } + + contract init_fix is init, fix { + function checkOk() returns (bool) { return ok; } + } + contract fix_init is fix, init { + function checkOk() returns (bool) { return ok; } + } + )"; + compileAndRun(sourceCode, 0, "init_fix"); + BOOST_CHECK(callContractFunction("isOk()") == encodeArgs(true)); + BOOST_CHECK(callContractFunction("ok()") == encodeArgs(true)); + + compileAndRun(sourceCode, 0, "fix_init"); + BOOST_CHECK(callContractFunction("isOk()") == encodeArgs(false)); + BOOST_CHECK(callContractFunction("ok()") == encodeArgs(false)); +} + BOOST_AUTO_TEST_SUITE_END() } diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index 9616777ab..c317dad97 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1761,25 +1761,6 @@ BOOST_AUTO_TEST_CASE(uninitialized_var) BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); } -BOOST_AUTO_TEST_CASE(deny_overwriting_of_attributes_when_deriving) -{ - // bug #1798 - char const* sourceCode = R"( - contract owned { - address owner; - } - - contract reg { - function owner(bytes32 x) returns (address) {} - } - - contract x is owned, reg { - } - )"; - ETH_TEST_CHECK_NO_THROW(parseTextAndResolveNames(sourceCode), "Parsing and Name Resolving Failed"); - //BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError); -} - BOOST_AUTO_TEST_SUITE_END() } From 37fbf06c98c263052082a8a843e26b4cae69531c Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Fri, 8 May 2015 17:50:44 +0200 Subject: [PATCH 26/26] added one more test --- libsolidity/SolidityEndToEndTest.cpp | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/libsolidity/SolidityEndToEndTest.cpp b/libsolidity/SolidityEndToEndTest.cpp index 2fd1e2ec2..f32439a27 100644 --- a/libsolidity/SolidityEndToEndTest.cpp +++ b/libsolidity/SolidityEndToEndTest.cpp @@ -3939,6 +3939,61 @@ BOOST_AUTO_TEST_CASE(proper_order_of_overwriting_of_attributes) BOOST_CHECK(callContractFunction("ok()") == encodeArgs(false)); } +BOOST_AUTO_TEST_CASE(proper_overwriting_accessor_by_function) +{ + // bug #1798 + char const* sourceCode = R"( + contract attribute { + bool ok = false; + } + contract func { + function ok() returns (bool) { return true; } + } + + contract attr_func is attribute, func { + function checkOk() returns (bool) { return ok(); } + } + contract func_attr is func, attribute { + function checkOk() returns (bool) { return ok; } + } + )"; + compileAndRun(sourceCode, 0, "attr_func"); + BOOST_CHECK(callContractFunction("ok()") == encodeArgs(true)); + compileAndRun(sourceCode, 0, "func_attr"); + BOOST_CHECK(callContractFunction("checkOk()") == encodeArgs(false)); +} + + +BOOST_AUTO_TEST_CASE(overwriting_inheritance) +{ + // bug #1798 + char const* sourceCode = R"( + contract A { + function ok() returns (uint) { return 1; } + } + contract B { + function ok() returns (uint) { return 2; } + } + contract C { + uint ok = 6; + } + contract AB is A, B { + function ok() returns (uint) { return 4; } + } + contract reversedE is C, AB { + function checkOk() returns (uint) { return ok(); } + } + contract E is AB, C { + function checkOk() returns (uint) { return ok; } + } + )"; + compileAndRun(sourceCode, 0, "reversedE"); + BOOST_CHECK(callContractFunction("checkOk()") == encodeArgs(4)); + compileAndRun(sourceCode, 0, "E"); + BOOST_CHECK(callContractFunction("checkOk()") == encodeArgs(6)); +} + + BOOST_AUTO_TEST_SUITE_END() }