From f18c2aa378fd60a977649480bb3cd9fa80e77ddc Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 12 Feb 2015 22:26:10 +0300 Subject: [PATCH 01/22] New Tests Solidity test Transaction test update --- test/stSolidityTestFiller.json | 237 ++++++++++++++++++++++++++++++ test/state.cpp | 5 + test/ttTransactionTestFiller.json | 70 ++++++--- 3 files changed, 292 insertions(+), 20 deletions(-) create mode 100644 test/stSolidityTestFiller.json diff --git a/test/stSolidityTestFiller.json b/test/stSolidityTestFiller.json new file mode 100644 index 000000000..fc0770c5e --- /dev/null +++ b/test/stSolidityTestFiller.json @@ -0,0 +1,237 @@ +{ + "SolidityTest" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000000000000", + "currentNumber" : "120", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000000000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "d94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "100000", + "//" : " ", + "//" : "contract TestContract ", + "//" : "{ ", + "//" : " function testMethod() returns (int res) ", + "//" : " { ", + "//" : " return 225; ", + "//" : " } ", + "//" : " ", + "//" : " function destroy(address sendFoundsTo) ", + "//" : " { ", + "//" : " suicide(sendFoundsTo); ", + "//" : " } ", + "//" : "} ", + "//" : " ", + "//" : "contract TestSolidityContracts ", + "//" : "{ ", + "//" : "struct StructTest ", + "//" : " { ", + "//" : " address addr; ", + "//" : " int amount; ", + "//" : " string32 str; ", + "//" : " mapping (uint => address) funders; ", + "//" : " } ", + "//" : " ", + "//" : " int globalValue; ", + "//" : " StructTest globalData; ", + "//" : " function runSolidityTests() returns (hash res) ", + "//" : " { ", + "//" : " //res is a mask of failing tests given the first byte is first test ", + "//" : " res = 0x0000000000000000000000000000000000000000000000000000000000000000; ", + "//" : " ", + "//" : " createContractFromMethod(); ", + "//" : " ", + "//" : " if (!testKeywords()) ", + "//" : " res = hash(int(res) + int(0xf000000000000000000000000000000000000000000000000000000000000000)); ", + "//" : " ", + "//" : " if (!testContractInteraction()) ", + "//" : " res = hash(int(res) + int(0x0f00000000000000000000000000000000000000000000000000000000000000)); ", + "//" : " ", + "//" : " if (!testContractSuicide()) ", + "//" : " res = hash(int(res) + int(0x00f0000000000000000000000000000000000000000000000000000000000000)); ", + "//" : " ", + "//" : " if (!testBlockAndTransactionProperties()) ", + "//" : " res = hash(int(res) + int(0x000f000000000000000000000000000000000000000000000000000000000000)); ", + "//" : " ", + "//" : " globalValue = 255; ", + "//" : " globalData.addr = 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", + "//" : " globalData.amount = 255; ", + "//" : " globalData.str = 'global data 32 length string'; ", + "//" : " globalData.funders[0] = 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b; ", + "//" : " if (!testStructuresAndVariabless()) ", + "//" : " res = hash(int(res) + int(0x0000f00000000000000000000000000000000000000000000000000000000000)); ", + "//" : " ", + "//" : " //Tested 27.01.2015 ", + "//" : " //should run out of gas ", + "//" : " //if (!testInfiniteLoop()) ", + "//" : " // res = hash(int(res) + int(0x000f000000000000000000000000000000000000000000000000000000000000)); ", + "//" : " // ", + "//" : " //should run out of gas ", + "//" : " //if (!testRecursiveMethods()) ", + "//" : " // res = hash(int(res) + int(0x0000000000000000000000000000000000000000000000000000000000000000)); ", + "//" : " } ", + "//" : " ", + "//" : " function testStructuresAndVariabless() returns (bool res) ", + "//" : " { ", + "//" : " res = true; ", + "//" : " if (globalValue != 255) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalValue != globalData.amount) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalData.addr != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalData.str != 'global data 32 length string') ", + "//" : " return false; ", + "//" : " ", + "//" : " if (globalData.funders[0] != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " } ", + "//" : " ", + "//" : " function testBlockAndTransactionProperties() returns (bool res) ", + "//" : " { ", + "//" : " res = true; ", + "//" : " if (block.coinbase != 0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (block.difficulty != 45678256) ", + "//" : " return false; ", + "//" : " ", + "//" : " //for some reason does not work 27.01.2015 ", + "//" : " //if (block.gaslimit != 1000000000000000000000) ", + "//" : " // return false; ", + "//" : " ", + "//" : " if (block.number != 120) ", + "//" : " return false; ", + "//" : " ", + "//" : " //try to call this ", + "//" : " block.blockhash(120); ", + "//" : " block.timestamp; ", + "//" : " msg.gas; ", + "//" : " ", + "//" : " if (msg.sender != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (msg.value != 100) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (tx.gasprice != 1) ", + "//" : " return false; ", + "//" : " ", + "//" : " if (tx.origin != 0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b) ", + "//" : " return false; ", + "//" : " ", + "//" : " } ", + "//" : " ", + "//" : " function testInfiniteLoop() returns (bool res) ", + "//" : " { ", + "//" : " res = false; ", + "//" : " while(true){} ", + "//" : " return true; ", + "//" : " } ", + "//" : " ", + "//" : " function testRecursiveMethods() returns (bool res) ", + "//" : " { ", + "//" : " res = false; ", + "//" : " testRecursiveMethods2(); ", + "//" : " return true; ", + "//" : " } ", + "//" : " function testRecursiveMethods2() ", + "//" : " { ", + "//" : " testRecursiveMethods(); ", + "//" : "} ", + "//" : " ", + "//" : " ", + "//" : " function testContractSuicide() returns (bool res) ", + "//" : " { ", + "//" : " TestContract a = new TestContract(); ", + "//" : " a.destroy(block.coinbase); ", + "//" : " if (a.testMethod() == 225) //we should be able to call a contract ", + "//" : " return true; ", + "//" : " return false; ", + "//" : " } ", + "//" : " ", + "//" : " function testContractInteraction() returns (bool res) ", + "//" : " { ", + "//" : " TestContract a = new TestContract(); ", + "//" : " if (a.testMethod() == 225) ", + "//" : " return true; ", + "//" : " return false; ", + "//" : " } ", + "//" : " ", + "//" : " function testKeywords() returns (bool res) ", + "//" : " { ", + "//" : " //some simple checks for the if statemnt ", + "//" : " //if, else, while, for, break, continue, return ", + "//" : " int i = 0; ", + "//" : " res = false; ", + "//" : " ", + "//" : " if (i == 0) ", + "//" : " { ", + "//" : " if( i <= -25) ", + "//" : " { ", + "//" : " return false; ", + "//" : " } ", + "//" : " else ", + "//" : " { ", + "//" : " while(i < 10) ", + "//" : " i++; ", + "//" : " ", + "//" : " if (i == 10) ", + "//" : " { ", + "//" : " for(var j=10; j>0; j--) ", + "//" : " { ", + "//" : " i--; ", + "//" : " } ", + "//" : " } ", + "//" : " } ", + "//" : " } ", + "//" : " ", + "//" : " ", + "//" : " if (i == 0) ", + "//" : " return true; ", + "//" : " ", + "//" : " return false; ", + "//" : " } ", + "//" : " ", + "//" : " function createContractFromMethod() returns (TestContract a) ", + "//" : " { ", + "//" : " a = new TestContract(); ", + "//" : " } ", + "//" : "} ", + "code" : "0x60e060020a6000350480630c4c9a8014610078578063296df0df1461008a5780632a9afb831461009c578063380e4396146100ae5780634893d88a146100c05780637ee17e12146100ce578063981a3165146100dc578063a60eedda146100ee578063e97384dc14610100578063ed973fe91461011257005b610080610431565b8060005260206000f35b6100926103f7565b8060005260206000f35b6100a46105d1565b8060005260206000f35b6100b6610220565b8060005260206000f35b6100c8610426565b60006000f35b6100d66102df565b60006000f35b6100e4610411565b8060005260206000f35b6100f6610124565b8060005260206000f35b6101086102f5565b8060005260206000f35b61011a6101be565b8060005260206000f35b60006000605f6106be600039605f60006000f0905080600160a060020a031662f55d9d8060e060020a0260005241600160a060020a0316600452600060006024600060008660155a03f150505080600160a060020a031663b9c3d0a58060e060020a02600052602060006004600060008660155a03f150505060005160e1146101ac576101b5565b600191506101ba565b600091505b5090565b60006000605f6106be600039605f60006000f0905080600160a060020a031663b9c3d0a58060e060020a02600052602060006004600060008660155a03f150505060005160e11461020e57610217565b6001915061021c565b600091505b5090565b60006000600060009150600092508160001461023b576102bf565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe78213156102b5575b600a82121561027a578180600101925050610264565b81600a14610287576102b0565b600a90505b60008160ff1611156102af5781806001900392505080806001900391505061028c565b5b6102be565b600092506102da565b5b816000146102cc576102d5565b600192506102da565b600092505b505090565b6000605f6106be600039605f60006000f0905090565b60006001905041600160a060020a0316732adc25665018aa1fe0e6bc666dac8fc2697ff9ba14156103255761032e565b600090506103f4565b446302b8feb0141561033f57610348565b600090506103f4565b43607814156103565761035f565b600090506103f4565b33600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b141561038957610392565b600090506103f4565b34606414156103a0576103a9565b600090506103f4565b3a600114156103b7576103c0565b600090506103f4565b32600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156103ea576103f3565b600090506103f4565b5b90565b6000600090505b60011561040a576103fe565b6001905090565b60006000905061041f610426565b6001905090565b61042e610411565b50565b60006000905061043f6102df565b50610448610220565b1561045257610478565b7ff000000000000000000000000000000000000000000000000000000000000000810190505b6104806101be565b1561048a576104b0565b7f0f00000000000000000000000000000000000000000000000000000000000000810190505b6104b8610124565b156104c2576104e7565b7ef0000000000000000000000000000000000000000000000000000000000000810190505b6104ef6102f5565b156104f95761051e565b7e0f000000000000000000000000000000000000000000000000000000000000810190505b60ff60008190555073a94f5374fce5edbc8e2a8697c15331677e6ebf0b60018190555060ff6002819055507f676c6f62616c2064617461203332206c656e67746820737472696e670000000060038190555073a94f5374fce5edbc8e2a8697c15331677e6ebf0b600460006000526020526040600020819055506105a06105d1565b156105aa576105ce565b7df00000000000000000000000000000000000000000000000000000000000810190505b90565b60006001905060005460ff14156105e7576105f0565b600090506106ba565b60025460005414156106015761060a565b600090506106ba565b600154600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156106365761063f565b600090506106ba565b6003547f676c6f62616c2064617461203332206c656e67746820737472696e6700000000141561066e57610677565b600090506106ba565b60046000600052602052604060002054600160a060020a031673a94f5374fce5edbc8e2a8697c15331677e6ebf0b14156106b0576106b9565b600090506106ba565b5b905600605380600c6000396000f30060e060020a600035048062f55d9d14601d578063b9c3d0a514602c57005b60266004356045565b60006000f35b6032603c565b8060005260206000f35b600060e1905090565b80600160a060020a0316ff5056", + "nonce" : "0", + "storage" : { + } + } + }, + + "transaction" : + { + "//" : "createContractFromMethod()", + "data" : "0x7ee17e12", + "//" : "runSolidityTests()", + "data" : "0x0c4c9a80", + "gasLimit" : "465224", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "d94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "100" + } + } +} diff --git a/test/state.cpp b/test/state.cpp index fb54a62ae..03f01d0fb 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -159,6 +159,11 @@ BOOST_AUTO_TEST_CASE(stBlockHashTest) dev::test::executeTests("stBlockHashTest", "/StateTests", dev::test::doStateTests); } +BOOST_AUTO_TEST_CASE(stSolidityTest) +{ + dev::test::executeTests("stSolidityTest", "/StateTests", dev::test::doStateTests); +} + BOOST_AUTO_TEST_CASE(stCreateTest) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) diff --git a/test/ttTransactionTestFiller.json b/test/ttTransactionTestFiller.json index 49831261a..e9ae27188 100644 --- a/test/ttTransactionTestFiller.json +++ b/test/ttTransactionTestFiller.json @@ -44,6 +44,21 @@ } }, + "WrongVRSTestIncorrectSize" : { + "transaction" : + { + "data" : "", + "gasLimit" : "2000", + "gasPrice" : "1", + "nonce" : "0", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10", + "v" : "28", + "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a02c3", + "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a302c3" + } + }, + "SenderTest" : { "//" : "sender a94f5374fce5edbc8e2a8697c15331677e6ebf0b", "transaction" : @@ -196,33 +211,18 @@ } }, - "RLPElementsWithZeros" : { + "AddressMoreThan20PrefixedBy0" : { "transaction" : { - "data" : "0x0000011222333", - "gasLimit" : "1000", - "gasPrice" : "00123", - "nonce" : "0054", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "00000011", - "v" : "27", - "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", - "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" - } - }, - - "RLPWrongHexElements" : { - "transaction" : - { - "data" : "0x0000000012", + "data" : "0x12", "gasLimit" : "1000", "gasPrice" : "123", "nonce" : "54", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "to" : "0x0000000000000000095e7baea6a6c7c4c2dfeb977efac326af552d87", "value" : "11", "v" : "27", - "r" : "0x0048b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", - "s" : "0x00efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" + "r" : "0x48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353", + "s" : "0xefffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c804" } }, @@ -299,5 +299,35 @@ "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a", "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3" } + }, + + "ValuesAsHex" : { + "transaction" : + { + "data" : "", + "gasLimit" : "0xadc053", + "gasPrice" : "1", + "nonce" : "0xffdc5", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "0xfffdc12c", + "v" : "28", + "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a", + "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3" + } + }, + + "ValuesAsDec" : { + "transaction" : + { + "data" : "", + "gasLimit" : "11386963", + "gasPrice" : "1", + "nonce" : "1048005", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "4501151495864620", + "v" : "28", + "r" : "0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a", + "s" : "0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3" + } } } From 29abb4fb551f17442955e56160ff86ea4a622892 Mon Sep 17 00:00:00 2001 From: winsvega Date: Thu, 12 Feb 2015 23:43:57 +0300 Subject: [PATCH 02/22] New Tests Transaction with RLP object and catching exceptions from importByteArray --- test/TestHelper.cpp | 2 +- test/stTransactionTestFiller.json | 152 +++++++++++++++++++++++++++++- test/transaction.cpp | 11 ++- 3 files changed, 157 insertions(+), 8 deletions(-) diff --git a/test/TestHelper.cpp b/test/TestHelper.cpp index 8a00a5462..5e7472105 100644 --- a/test/TestHelper.cpp +++ b/test/TestHelper.cpp @@ -247,7 +247,7 @@ byte toByte(json_spirit::mValue const& _v) bytes importByteArray(std::string const& _str) { - return fromHex(_str.substr(0, 2) == "0x" ? _str.substr(2) : _str); + return fromHex(_str.substr(0, 2) == "0x" ? _str.substr(2) : _str, ThrowType::Throw); } bytes importData(json_spirit::mObject& _o) diff --git a/test/stTransactionTestFiller.json b/test/stTransactionTestFiller.json index e5369f0cd..214a0ae7c 100644 --- a/test/stTransactionTestFiller.json +++ b/test/stTransactionTestFiller.json @@ -189,6 +189,53 @@ } }, + "InternalCallHittingGasLimit" : { + "env" : { + "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1100", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "1000000", + "code" : "{ (CALL 5000 0xc94f5374fce5edbc8e2a8697c15331677e6ebf0b 1 0 0 0 0) }", + "nonce" : "0", + "storage" : { + } + }, + + "c94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0", + "code" : "{[[1]]55}", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "1100", + "gasPrice" : "1", + "nonce" : "", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "10" + } + }, + "TransactionFromCoinbaseHittingBlockGasLimit" : { "env" : { "currentCoinbase" : "a94f5374fce5edbc8e2a8697c15331677e6ebf0b", @@ -623,7 +670,7 @@ "balance" : "100000", "code" : "", "nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "nonce" : "10000000", + "nonce" : "10000", "storage" : { } } @@ -634,7 +681,7 @@ "gasLimit" : "1000", "gasPrice" : "1", "nonce" : "115792089237316195423570985008687907853269984665640564039457584007913129639935", - "nonce" : "10000000", + "nonce" : "10000", "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", "value" : "100" @@ -864,5 +911,106 @@ "to" : "0xffffffffffffffffffffffffffffffffffffffff", "value" : "100" } + }, + + "CreateTransactionReverted" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", + "gasLimit" : "882", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "" + } + }, + + "CreateTransactionWorking" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "0x602280600c6000396000f30060e060020a600035048063f8a8fd6d14601457005b601a6020565b60006000f35b56", + "gasLimit" : "883", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "", + "value" : "100" + } + }, + + "CreateMessageReverted" : { + "env" : { + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba", + "currentDifficulty" : "45678256", + "currentGasLimit" : "1000000000000", + "currentNumber" : "0", + "currentTimestamp" : 1, + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6" + }, + "pre" : + { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000", + "code" : "", + "nonce" : "0", + "storage" : { + } + }, + + "b94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "0", + "code" : "{(MSTORE 0 0x600c600055) (CREATE 0 27 5)}", + "nonce" : "0", + "storage" : { + } + } + }, + "transaction" : + { + "data" : "", + "gasLimit" : "882", + "gasPrice" : "1", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "b94f5374fce5edbc8e2a8697c15331677e6ebf0b", + "value" : "100" + } } } diff --git a/test/transaction.cpp b/test/transaction.cpp index b51494d84..9f9429534 100644 --- a/test/transaction.cpp +++ b/test/transaction.cpp @@ -64,7 +64,7 @@ RLPStream createRLPStreamFromTransactionFields(mObject& _tObj) rlpStream << bigint(_tObj["r"].get_str()); if (_tObj.count("s") > 0) - rlpStream << bigint(_tObj["s"].get_str()); + rlpStream << bigint(_tObj["s"].get_str()); if (_tObj.count("extrafield") > 0) rlpStream << bigint(_tObj["extrafield"].get_str()); @@ -82,18 +82,18 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin) if (_fillin == false) { BOOST_REQUIRE(o.count("rlp") > 0); - bytes rlpReaded = importByteArray(o["rlp"].get_str()); Transaction txFromRlp; - try { - txFromRlp = Transaction(rlpReaded, CheckSignature::Sender); + bytes stream = importByteArray(o["rlp"].get_str()); + RLP rlp(stream); + txFromRlp = Transaction(rlp.data(), CheckSignature::Sender); if (!txFromRlp.signature().isValid()) BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("transaction from RLP signature is invalid") ); } catch(...) { - BOOST_CHECK_MESSAGE(o.count("transaction") == 0, "A transction object should not be defined because the RLP is invalid!"); + BOOST_CHECK_MESSAGE(o.count("transaction") == 0, "A transaction object should not be defined because the RLP is invalid!"); return; } @@ -115,6 +115,7 @@ void doTransactionTests(json_spirit::mValue& _v, bool _fillin) Address addressReaded = Address(o["sender"].get_str()); BOOST_CHECK_MESSAGE(txFromFields.sender() == addressReaded || txFromRlp.sender() == addressReaded, "Signature address of sender does not match given sender address!"); + } else { From e1666c85e5ccbfaa7d2cd757fb5172b4feb8511d Mon Sep 17 00:00:00 2001 From: arkpar Date: Thu, 12 Feb 2015 21:52:30 +0100 Subject: [PATCH 03/22] Ctrl+C/Cmd+C to copy data from debug panes --- mix/qml/DebugInfoList.qml | 11 ++++++++++- mix/qml/Debugger.qml | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/mix/qml/DebugInfoList.qml b/mix/qml/DebugInfoList.qml index c1ab11596..ae7e6fabe 100644 --- a/mix/qml/DebugInfoList.qml +++ b/mix/qml/DebugInfoList.qml @@ -8,7 +8,7 @@ ColumnLayout { property string title property variant listModel; property bool collapsible; - property bool enableSelection; + property bool enableSelection: false; property real storedHeight: 0; property Component itemDelegate signal rowActivated(int index) @@ -116,6 +116,15 @@ ColumnLayout { } } onActivated: rowActivated(row); + Keys.onPressed: { + if ((event.modifiers & Qt.ControlModifier) && event.key === Qt.Key_C && currentRow >=0 && currentRow < listModel.length) { + var str = ""; + for (var i = 0; i < listModel.length; i++) + str += listModel[i] + "\n"; + appContext.toClipboard(str); + } + } + TableViewColumn { role: "modelData" width: parent.width diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index 61bf5e8cc..df91aa1c4 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -529,7 +529,7 @@ Rectangle { Text { anchors.leftMargin: 5 width: parent.width - 5 - wrapMode: Text.Wrap + wrapMode: Text.NoWrap anchors.left: parent.left font.family: "monospace" anchors.verticalCenter: parent.verticalCenter @@ -600,7 +600,7 @@ Rectangle { Text { anchors.leftMargin: 5 width: parent.width - 5 - wrapMode: Text.Wrap + wrapMode: Text.NoWrap anchors.left: parent.left font.family: "monospace" anchors.verticalCenter: parent.verticalCenter From 1ffdd5d7ff32558437a6c1277a9b33b6daad2e88 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 13 Feb 2015 01:29:21 +0100 Subject: [PATCH 04/22] Copying calldata directly to memory. --- libsolidity/CompilerUtils.cpp | 63 ++++++++++++++++++++--------------- test/SolidityEndToEndTest.cpp | 15 +++++++++ 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/libsolidity/CompilerUtils.cpp b/libsolidity/CompilerUtils.cpp index 73be38176..dda1736d6 100644 --- a/libsolidity/CompilerUtils.cpp +++ b/libsolidity/CompilerUtils.cpp @@ -76,35 +76,44 @@ void CompilerUtils::storeInMemoryDynamic(Type const& _type, bool _padToWordBound if (_type.getCategory() == Type::Category::ByteArray) { auto const& type = dynamic_cast(_type); - solAssert(type.getLocation() == ByteArrayType::Location::Storage, "Non-storage byte arrays not yet implemented."); - m_context << eth::Instruction::DUP1 << eth::Instruction::SLOAD; - // stack here: memory_offset storage_offset length_bytes - // jump to end if length is zero - m_context << eth::Instruction::DUP1 << eth::Instruction::ISZERO; - eth::AssemblyItem loopEnd = m_context.newTag(); - m_context.appendConditionalJumpTo(loopEnd); - // compute memory end offset - m_context << eth::Instruction::DUP3 << eth::Instruction::ADD << eth::Instruction::SWAP2; - // actual array data is stored at SHA3(storage_offset) - m_context << eth::Instruction::SWAP1; - CompilerUtils(m_context).computeHashStatic(); - m_context << eth::Instruction::SWAP1; + if (type.getLocation() == ByteArrayType::Location::CallData) + { + m_context << eth::Instruction::CALLDATASIZE << u256(0) << eth::Instruction::DUP3 + << eth::Instruction::CALLDATACOPY + << eth::Instruction::CALLDATASIZE << eth::Instruction::ADD; + } + else + { + solAssert(type.getLocation() == ByteArrayType::Location::Storage, "Memory byte arrays not yet implemented."); + m_context << eth::Instruction::DUP1 << eth::Instruction::SLOAD; + // stack here: memory_offset storage_offset length_bytes + // jump to end if length is zero + m_context << eth::Instruction::DUP1 << eth::Instruction::ISZERO; + eth::AssemblyItem loopEnd = m_context.newTag(); + m_context.appendConditionalJumpTo(loopEnd); + // compute memory end offset + m_context << eth::Instruction::DUP3 << eth::Instruction::ADD << eth::Instruction::SWAP2; + // actual array data is stored at SHA3(storage_offset) + m_context << eth::Instruction::SWAP1; + CompilerUtils(m_context).computeHashStatic(); + m_context << eth::Instruction::SWAP1; - // stack here: memory_end_offset storage_data_offset memory_offset - eth::AssemblyItem loopStart = m_context.newTag(); - m_context << loopStart - // load and store - << eth::Instruction::DUP2 << eth::Instruction::SLOAD - << eth::Instruction::DUP2 << eth::Instruction::MSTORE - // increment storage_data_offset by 1 - << eth::Instruction::SWAP1 << u256(1) << eth::Instruction::ADD - // increment memory offset by 32 - << eth::Instruction::SWAP1 << u256(32) << eth::Instruction::ADD - // check for loop condition - << eth::Instruction::DUP1 << eth::Instruction::DUP4 << eth::Instruction::GT; - m_context.appendConditionalJumpTo(loopStart); - m_context << loopEnd << eth::Instruction::POP << eth::Instruction::POP; + // stack here: memory_end_offset storage_data_offset memory_offset + eth::AssemblyItem loopStart = m_context.newTag(); + m_context << loopStart + // load and store + << eth::Instruction::DUP2 << eth::Instruction::SLOAD + << eth::Instruction::DUP2 << eth::Instruction::MSTORE + // increment storage_data_offset by 1 + << eth::Instruction::SWAP1 << u256(1) << eth::Instruction::ADD + // increment memory offset by 32 + << eth::Instruction::SWAP1 << u256(32) << eth::Instruction::ADD + // check for loop condition + << eth::Instruction::DUP1 << eth::Instruction::DUP4 << eth::Instruction::GT; + m_context.appendConditionalJumpTo(loopStart); + m_context << loopEnd << eth::Instruction::POP << eth::Instruction::POP; + } } else { diff --git a/test/SolidityEndToEndTest.cpp b/test/SolidityEndToEndTest.cpp index abfc97b73..259123db6 100644 --- a/test/SolidityEndToEndTest.cpp +++ b/test/SolidityEndToEndTest.cpp @@ -2273,6 +2273,21 @@ BOOST_AUTO_TEST_CASE(store_bytes) BOOST_CHECK(callContractFunction("save()", "abcdefg") == encodeArgs(24)); } +BOOST_AUTO_TEST_CASE(bytes_from_calldata_to_memory) +{ + char const* sourceCode = R"( + contract C { + function() returns (hash) { + return sha3("abc", msg.data); + } + } + )"; + compileAndRun(sourceCode); + bytes calldata = bytes(61, 0x22) + bytes(12, 0x12); + sendMessage(calldata, false); + BOOST_CHECK(m_output == encodeArgs(dev::sha3(bytes{'a', 'b', 'c'} + calldata))); +} + BOOST_AUTO_TEST_CASE(call_forward_bytes) { char const* sourceCode = R"( From 483ce3a2ea136f840ae6f1eac9dbf7fd0258a8e9 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 09:00:51 +0100 Subject: [PATCH 05/22] performance test --- test/vm.cpp | 28 +++++++++++++++++++++++ test/vmPerformanceTestFiller.json | 38 +++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 test/vmPerformanceTestFiller.json diff --git a/test/vm.cpp b/test/vm.cpp index f15dc048a..af946777f 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -32,6 +32,8 @@ using namespace dev; using namespace dev::eth; using namespace dev::test; +using Millisecs = chrono::duration; + FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {} @@ -513,13 +515,39 @@ BOOST_AUTO_TEST_CASE(vmSystemOperationsTest) dev::test::executeTests("vmSystemOperationsTest", "/VMTests", dev::test::doVMTests); } +BOOST_AUTO_TEST_CASE(vmPerformanceTest) +{ + for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) + { + string arg = boost::unit_test::framework::master_test_suite().argv[i]; + if (arg == "--performance") + { + chrono::steady_clock::time_point start = chrono::steady_clock::now(); + + dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); + + chrono::steady_clock::time_point end = chrono::steady_clock::now(); + Millisecs duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } + } +} + BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) { for (int i = 1; i < boost::unit_test::framework::master_test_suite().argc; ++i) { string arg = boost::unit_test::framework::master_test_suite().argv[i]; if (arg == "--inputlimits") + { + chrono::steady_clock::time_point start = chrono::steady_clock::now(); + dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); + + chrono::steady_clock::time_point end = chrono::steady_clock::now(); + Millisecs duration(chrono::duration_cast(end - start)); + cnote << "test duration: " << duration.count() << " milliseconds.\n"; + } } } diff --git a/test/vmPerformanceTestFiller.json b/test/vmPerformanceTestFiller.json new file mode 100644 index 000000000..7979bfbdb --- /dev/null +++ b/test/vmPerformanceTestFiller.json @@ -0,0 +1,38 @@ +{ + "ackermann33": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "contract PerformanceTester {", + "//" : " function ackermann(uint m, uint n) returns (uint) {", + "//" : " if (m == 0)", + "//" : " return n + 1;", + "//" : " if (n == 0)", + "//" : " return ackermann(m - 1, 1);", + "//" : " return ackermann(m - 1, ackermann(m, n - 1));", + "//" : " }", + "//" : "}", + "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003", + "gasPrice" : "100000000000000", + "gas" : "100000000000" + } + } +} From 0520e0f4db7fa8b49b6c294135b689b1fdce4427 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 13 Feb 2015 09:03:03 +0100 Subject: [PATCH 06/22] fixed issue with including wrong json/json.h file --- alethzero/CMakeLists.txt | 4 ++-- libsolidity/CMakeLists.txt | 4 ++-- lllc/CMakeLists.txt | 4 ++-- mix/CMakeLists.txt | 3 ++- solc/CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 5 +++-- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt index ed2d8fa5e..c18a76c36 100644 --- a/alethzero/CMakeLists.txt +++ b/alethzero/CMakeLists.txt @@ -10,9 +10,9 @@ endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) aux_source_directory(. SRC_LIST) -include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) -include_directories(${JSONCPP_INCLUDE_DIRS}) include_directories(..) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) +include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) qt5_wrap_ui(ui_Main.h Main.ui) diff --git a/libsolidity/CMakeLists.txt b/libsolidity/CMakeLists.txt index 9c0b50775..cccc5e165 100644 --- a/libsolidity/CMakeLists.txt +++ b/libsolidity/CMakeLists.txt @@ -11,9 +11,9 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSTATICLIB") aux_source_directory(. SRC_LIST) -include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${JSONCPP_INCLUDE_DIRS}) include_directories(..) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) +include_directories(${Boost_INCLUDE_DIRS}) set(EXECUTABLE solidity) diff --git a/lllc/CMakeLists.txt b/lllc/CMakeLists.txt index 5aaca0ccc..2157fea74 100644 --- a/lllc/CMakeLists.txt +++ b/lllc/CMakeLists.txt @@ -3,9 +3,9 @@ set(CMAKE_AUTOMOC OFF) aux_source_directory(. SRC_LIST) -include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${JSONCPP_INCLUDE_DIRS}) include_directories(..) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) +include_directories(${Boost_INCLUDE_DIRS}) set(EXECUTABLE lllc) diff --git a/mix/CMakeLists.txt b/mix/CMakeLists.txt index 755f3df04..4390a4eb0 100644 --- a/mix/CMakeLists.txt +++ b/mix/CMakeLists.txt @@ -10,8 +10,9 @@ endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) aux_source_directory(. SRC_LIST) -include_directories(${JSONCPP_INCLUDE_DIRS}) + include_directories(..) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) find_package (Qt5WebEngine QUIET) qt5_add_resources(UI_RESOURCES res.qrc) diff --git a/solc/CMakeLists.txt b/solc/CMakeLists.txt index 2a7bd7b6d..747effad0 100644 --- a/solc/CMakeLists.txt +++ b/solc/CMakeLists.txt @@ -3,9 +3,9 @@ set(CMAKE_AUTOMOC OFF) aux_source_directory(. SRC_LIST) -include_directories(${Boost_INCLUDE_DIRS}) -include_directories(${JSONCPP_INCLUDE_DIRS}) include_directories(..) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) +include_directories(${Boost_INCLUDE_DIRS}) set(EXECUTABLE solc) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ab8afcd70..6ba07f280 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,11 +4,12 @@ aux_source_directory(. SRC_LIST) list(REMOVE_ITEM SRC_LIST "./createRandomTest.cpp") list(REMOVE_ITEM SRC_LIST "./checkRandomTest.cpp") +include_directories(..) +include_directories(BEFORE ${JSONCPP_INCLUDE_DIRS}) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${CRYPTOPP_INCLUDE_DIRS}) -include_directories(${JSONCPP_INCLUDE_DIRS}) include_directories(${JSON_RPC_CPP_INCLUDE_DIRS}) -include_directories(..) + file(GLOB HEADERS "*.h") add_executable(testeth ${SRC_LIST} ${HEADERS}) From d892a39cb21a9fcd871977d61ceecf8e23c0e052 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 09:07:07 +0100 Subject: [PATCH 07/22] style fix --- test/vmPerformanceTestFiller.json | 64 +++++++++++++++---------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/test/vmPerformanceTestFiller.json b/test/vmPerformanceTestFiller.json index 7979bfbdb..7cfe659d5 100644 --- a/test/vmPerformanceTestFiller.json +++ b/test/vmPerformanceTestFiller.json @@ -1,38 +1,38 @@ { "ackermann33": { - "env" : { - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", - "currentNumber" : "0", - "currentGasLimit" : "100000000000", - "currentDifficulty" : "256", - "currentTimestamp" : "1", - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" - }, - "pre" : { - "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { - "balance" : "1000000000000000000", - "nonce" : "0", - "//" : "contract PerformanceTester {", - "//" : " function ackermann(uint m, uint n) returns (uint) {", - "//" : " if (m == 0)", - "//" : " return n + 1;", - "//" : " if (n == 0)", - "//" : " return ackermann(m - 1, 1);", - "//" : " return ackermann(m - 1, ackermann(m, n - 1));", - "//" : " }", - "//" : "}", - "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", - "storage": {} - } - }, + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "contract PerformanceTester {", + "//" : " function ackermann(uint m, uint n) returns (uint) {", + "//" : " if (m == 0)", + "//" : " return n + 1;", + "//" : " if (n == 0)", + "//" : " return ackermann(m - 1, 1);", + "//" : " return ackermann(m - 1, ackermann(m, n - 1));", + "//" : " }", + "//" : "}", + "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", + "storage": {} + } + }, "exec" : { - "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", - "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", - "value" : "1000000000000000000", + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003", - "gasPrice" : "100000000000000", + "gasPrice" : "100000000000000", "gas" : "100000000000" - } - } + } + } } From 0696ee87da8d34d09fd1286cc7d08e535b514ce3 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 13 Feb 2015 10:25:56 +0100 Subject: [PATCH 08/22] Windows compile fix. --- libp2p/Host.cpp | 2 +- libp2p/Session.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libp2p/Host.cpp b/libp2p/Host.cpp index f09468e0d..f117df37a 100644 --- a/libp2p/Host.cpp +++ b/libp2p/Host.cpp @@ -54,7 +54,7 @@ Host::Host(std::string const& _clientVersion, NetworkPreferences const& _n, byte m_ioService(2), m_tcp4Acceptor(m_ioService), m_alias(networkAlias(_restoreNetwork)), - m_lastPing(chrono::time_point::min()) + m_lastPing(chrono::steady_clock::time_point::min()) { for (auto address: m_ifAddresses) if (address.is_v4()) diff --git a/libp2p/Session.cpp b/libp2p/Session.cpp index cb7225f0f..6ff765cf6 100644 --- a/libp2p/Session.cpp +++ b/libp2p/Session.cpp @@ -40,10 +40,10 @@ Session::Session(Host* _s, bi::tcp::socket _socket, std::shared_ptr const& m_server(_s), m_socket(std::move(_socket)), m_peer(_n), - m_info({NodeId(), "?", m_socket.remote_endpoint().address().to_string(), 0, std::chrono::steady_clock::duration(0), CapDescSet(), 0, map()}), - m_ping(chrono::time_point::max()) + m_info({NodeId(), "?", m_socket.remote_endpoint().address().to_string(), 0, chrono::steady_clock::duration(0), CapDescSet(), 0, map()}), + m_ping(chrono::steady_clock::time_point::max()) { - m_lastReceived = m_connect = std::chrono::steady_clock::now(); + m_lastReceived = m_connect = chrono::steady_clock::now(); } Session::~Session() From f5022ee58f2262624b991487006e3fd56991ce07 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 10:27:38 +0100 Subject: [PATCH 09/22] use auto for steady clock and chrono::milliseconds --- test/vm.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/vm.cpp b/test/vm.cpp index af946777f..faab48129 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -32,8 +32,6 @@ using namespace dev; using namespace dev::eth; using namespace dev::test; -using Millisecs = chrono::duration; - FakeExtVM::FakeExtVM(eth::BlockInfo const& _previousBlock, eth::BlockInfo const& _currentBlock, unsigned _depth): /// TODO: XXX: remove the default argument & fix. ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, test::lastHashes(_currentBlock.number), _depth) {} @@ -522,12 +520,12 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest) string arg = boost::unit_test::framework::master_test_suite().argv[i]; if (arg == "--performance") { - chrono::steady_clock::time_point start = chrono::steady_clock::now(); + auto start = chrono::steady_clock::now(); dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); - chrono::steady_clock::time_point end = chrono::steady_clock::now(); - Millisecs duration(chrono::duration_cast(end - start)); + auto end = chrono::steady_clock::now(); + chrono::milliseconds duration(chrono::duration_cast(end - start)); cnote << "test duration: " << duration.count() << " milliseconds.\n"; } } @@ -540,12 +538,12 @@ BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) string arg = boost::unit_test::framework::master_test_suite().argv[i]; if (arg == "--inputlimits") { - chrono::steady_clock::time_point start = chrono::steady_clock::now(); + auto start = chrono::steady_clock::now(); dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); - chrono::steady_clock::time_point end = chrono::steady_clock::now(); - Millisecs duration(chrono::duration_cast(end - start)); + auto end = chrono::steady_clock::now(); + chrono::milliseconds duration(chrono::duration_cast(end - start)); cnote << "test duration: " << duration.count() << " milliseconds.\n"; } } From 5d15c00aba00bacac7748b7dbf9b6c814018d131 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 13 Feb 2015 10:43:46 +0100 Subject: [PATCH 10/22] Windows warning fix. --- libp2p/NodeTable.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libp2p/NodeTable.h b/libp2p/NodeTable.h index 04e8d009c..0217c700e 100644 --- a/libp2p/NodeTable.h +++ b/libp2p/NodeTable.h @@ -163,7 +163,7 @@ public: std::list snapshot() const; /// Returns true if node id is in node table. - bool haveNode(NodeId const& _id) { Guard l(x_nodes); return m_nodes.count(_id); } + bool haveNode(NodeId const& _id) { Guard l(x_nodes); return m_nodes.count(_id) > 0; } /// Returns the Node to the corresponding node id or the empty Node if that id is not found. Node node(NodeId const& _id); @@ -418,4 +418,4 @@ struct NodeTableEgress: public LogChannel { static const char* name() { return " struct NodeTableIngress: public LogChannel { static const char* name() { return "< Date: Fri, 13 Feb 2015 11:24:14 +0100 Subject: [PATCH 11/22] auto reccommendations. --- CodingStandards.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CodingStandards.txt b/CodingStandards.txt index f883c9147..8acea78ae 100644 --- a/CodingStandards.txt +++ b/CodingStandards.txt @@ -96,12 +96,18 @@ e. Always pass non-trivial parameters with a const& suffix. f. If a function returns multiple values, use std::tuple (std::pair acceptable). Prefer not using */& arguments, except where efficiency requires. g. Never use a macro where adequate non-preprocessor C++ can be written. h. Prefer "using NewType = OldType" to "typedef OldType NewType". +i. Make use of auto whenever type is clear or unimportant: +- Always avoid doubly-stating the type. +- Use to avoid vast and unimportant type declarations + (WRONG) const double d = 0; int i, j; char *s; float meanAndSigma(std::vector _v, float* _sigma); +Derived* x(dynamic_cast(base)); +for (map::iterator i = l.begin(); i != l.end(); ++l) {} (CORRECT) double const d = 0; @@ -109,7 +115,8 @@ int i; int j; char* s; std::tuple meanAndSigma(std::vector const& _v); - +auto x = dynamic_cast(base); +for (auto i = x.begin(); i != x.end(); ++i) {} 7. Structs & classes From 814005ddb42760e2767ab3a2f3397136d7c3340c Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 13 Feb 2015 11:22:46 +0100 Subject: [PATCH 12/22] enable parallel compilation for windows build style --- cmake/EthCompilerSettings.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 12adc1d02..4d56c808b 100755 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -27,13 +27,14 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + # enable parallel compilation # specify Exception Handling Model in msvc # disable unknown pragma warning (4068) # disable unsafe function warning (4996) # disable decorated name length exceeded, name was truncated (4503) # disable warning C4535: calling _set_se_translator() requires /EHa (for boost tests) # declare Windows XP requirement - add_compile_options(/EHsc /wd4068 /wd4996 /wd4503 -D_WIN32_WINNT=0x0501) + add_compile_options(/MP /EHsc /wd4068 /wd4996 /wd4503 -D_WIN32_WINNT=0x0501) # disable empty object file warning set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221") # warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification From 6107f678d8c86e594ce8d003525606314ee85ff5 Mon Sep 17 00:00:00 2001 From: CJentzsch Date: Fri, 13 Feb 2015 11:30:59 +0100 Subject: [PATCH 13/22] style - auto --- test/vm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vm.cpp b/test/vm.cpp index faab48129..66925f929 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -525,7 +525,7 @@ BOOST_AUTO_TEST_CASE(vmPerformanceTest) dev::test::executeTests("vmPerformanceTest", "/VMTests", dev::test::doVMTests); auto end = chrono::steady_clock::now(); - chrono::milliseconds duration(chrono::duration_cast(end - start)); + auto duration(chrono::duration_cast(end - start)); cnote << "test duration: " << duration.count() << " milliseconds.\n"; } } @@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(vmInputLimitsTest1) dev::test::executeTests("vmInputLimitsTest1", "/VMTests", dev::test::doVMTests); auto end = chrono::steady_clock::now(); - chrono::milliseconds duration(chrono::duration_cast(end - start)); + auto duration(chrono::duration_cast(end - start)); cnote << "test duration: " << duration.count() << " milliseconds.\n"; } } From 5910aa823dcf402bc63acaf3083ca3b4612c1102 Mon Sep 17 00:00:00 2001 From: arkpar Date: Fri, 13 Feb 2015 14:02:11 +0100 Subject: [PATCH 14/22] reorder import statements to work around macdeployqt bug --- mix/qml/BasicMessage.qml | 2 +- mix/qml/Debugger.qml | 2 +- mix/qml/StateList.qml | 2 +- mix/qml/StateListModel.qml | 2 +- mix/qml/TransactionLog.qml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mix/qml/BasicMessage.qml b/mix/qml/BasicMessage.qml index 8ac8bcd45..7ab04d57c 100644 --- a/mix/qml/BasicMessage.qml +++ b/mix/qml/BasicMessage.qml @@ -1,6 +1,6 @@ import QtQuick 2.2 -import QtQuick.Controls.Styles 1.1 import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.1 diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index df91aa1c4..644a7f975 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -1,6 +1,6 @@ import QtQuick 2.2 -import QtQuick.Controls.Styles 1.1 import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.1 import Qt.labs.settings 1.0 diff --git a/mix/qml/StateList.qml b/mix/qml/StateList.qml index f6f778cd9..2e1bb4a06 100644 --- a/mix/qml/StateList.qml +++ b/mix/qml/StateList.qml @@ -1,6 +1,6 @@ import QtQuick 2.2 -import QtQuick.Controls.Styles 1.1 import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.1 import QtQuick.Window 2.0 diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 67372421c..c68a433f7 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -1,6 +1,6 @@ import QtQuick 2.2 -import QtQuick.Controls.Styles 1.1 import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 import QtQuick.Window 2.2 import QtQuick.Layouts 1.1 diff --git a/mix/qml/TransactionLog.qml b/mix/qml/TransactionLog.qml index 61d2e0920..75f7a4da3 100644 --- a/mix/qml/TransactionLog.qml +++ b/mix/qml/TransactionLog.qml @@ -1,6 +1,6 @@ import QtQuick 2.2 -import QtQuick.Controls.Styles 1.1 import QtQuick.Controls 1.1 +import QtQuick.Controls.Styles 1.1 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.1 From a2e2a6e1dbf4fd706a837f1a1d582ba83de637a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 13 Feb 2015 14:56:27 +0100 Subject: [PATCH 15/22] Performance tests: more ackermann calls, fibonacci. - ackermann(3, 1) - ackermann(3, 2) - fibonacci(10) - fibonacci(16) Contract code included: PerformanceTester.sol --- test/PerformaceTester.sol | 17 ++++ test/vmPerformanceTestFiller.json | 131 +++++++++++++++++++++++++++--- 2 files changed, 137 insertions(+), 11 deletions(-) create mode 100644 test/PerformaceTester.sol diff --git a/test/PerformaceTester.sol b/test/PerformaceTester.sol new file mode 100644 index 000000000..3b1202cea --- /dev/null +++ b/test/PerformaceTester.sol @@ -0,0 +1,17 @@ +contract PerformanceTester { + function ackermann(uint m, uint n) returns (uint) { + if (m == 0) + return n + 1; + + if (n == 0) + return ackermann(m - 1, 1); + + return ackermann(m - 1, ackermann(m, n - 1)); + } + + function fibonacci(uint n) returns (uint) { + if (n == 0 || n == 1) + return n; + return fibonacci(n - 1) + fibonacci(n - 2); + } +} \ No newline at end of file diff --git a/test/vmPerformanceTestFiller.json b/test/vmPerformanceTestFiller.json index 7cfe659d5..3292916ec 100644 --- a/test/vmPerformanceTestFiller.json +++ b/test/vmPerformanceTestFiller.json @@ -1,4 +1,62 @@ { + "ackermann31": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "PerformanceTester.sol", + "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "//" : "ackermann(3, 1)", + "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001", + "gasPrice" : "100000000000000", + "gas" : "10000" + } + }, + "ackermann32": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "PerformanceTester.sol", + "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "//" : "ackermann(3, 2)", + "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000002", + "gasPrice" : "100000000000000", + "gas" : "100000" + } + }, "ackermann33": { "env" : { "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", @@ -12,16 +70,8 @@ "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { "balance" : "1000000000000000000", "nonce" : "0", - "//" : "contract PerformanceTester {", - "//" : " function ackermann(uint m, uint n) returns (uint) {", - "//" : " if (m == 0)", - "//" : " return n + 1;", - "//" : " if (n == 0)", - "//" : " return ackermann(m - 1, 1);", - "//" : " return ackermann(m - 1, ackermann(m, n - 1));", - "//" : " }", - "//" : "}", - "code" : "0x60e060020a6000350480632839e92814601457005b6020600435602435602a565b8060005260206000f35b6000826000146037576041565b8160010190506076565b81600014604c57605e565b6058600184036001602a565b90506076565b607360018403606f8560018603602a565b602a565b90505b9291505056", + "//" : "PerformanceTester.sol", + "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", "storage": {} } }, @@ -30,9 +80,68 @@ "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", "value" : "1000000000000000000", + "//" : "ackermann(3, 3)", "data" : "0x2839e92800000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000003", "gasPrice" : "100000000000000", - "gas" : "100000000000" + "gas" : "100000" + } + }, + "fibonacci10": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "PerformanceTester.sol", + "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "//" : "fibonacci(10)", + "data" : "0x61047ff4000000000000000000000000000000000000000000000000000000000000000a", + "gasPrice" : "100000000000000", + "gas" : "100000" + } + }, + "fibonacci16": { + "env" : { + "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", + "currentNumber" : "0", + "currentGasLimit" : "100000000000", + "currentDifficulty" : "256", + "currentTimestamp" : "1", + "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" + }, + "pre" : { + "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6" : { + "balance" : "1000000000000000000", + "nonce" : "0", + "//" : "PerformanceTester.sol", + "code" : "0x60e060020a6000350480632839e92814601e57806361047ff414603457005b602a6004356024356047565b8060005260206000f35b603d6004356099565b8060005260206000f35b600082600014605457605e565b8160010190506093565b81600014606957607b565b60756001840360016047565b90506093565b609060018403608c85600186036047565b6047565b90505b92915050565b6000816000148060a95750816001145b60b05760b7565b81905060cf565b60c1600283036099565b60cb600184036099565b0190505b91905056", + "storage": {} + } + }, + "exec" : { + "address" : "0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6", + "origin" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "caller" : "cd1722f3947def4cf144679da39c4c32bdc35681", + "value" : "1000000000000000000", + "//" : "fibonacci(16)", + "data" : "0x61047ff40000000000000000000000000000000000000000000000000000000000000010", + "gasPrice" : "100000000000000", + "gas" : "100000000" } } } From 8457bc4efb87ec375a45d2ab5ee9fe6b6892fe9f Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 13 Feb 2015 15:47:29 +0100 Subject: [PATCH 16/22] bug fix: storage view in debug pane broken for long values. --- libethcore/CommonJS.cpp | 11 ++++++++--- libethcore/CommonJS.h | 2 +- mix/qml/Debugger.qml | 4 +++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index 3ed4e2796..aa39c8e0c 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -97,7 +97,7 @@ std::string fromRaw(h256 _n, unsigned* _inc) return ""; } -std::string prettyU256(u256 _n) +std::string prettyU256(u256 _n, bool _abridged) { unsigned inc = 0; std::string raw; @@ -110,11 +110,16 @@ std::string prettyU256(u256 _n) { Address a = right160(_n); - std::string n = a.abridged(); + std::string n; + if (_abridged) + n = a.abridged(); + else + n = toHex(a.ref()); + if (n.empty()) s << "0x" << a; else - s << n << "(0x" << a.abridged() << ")"; + s << n << "(0x" << n << ")"; } else if ((raw = fromRaw((h256)_n, &inc)).size()) return "\"" + raw + "\"" + (inc ? " + " + std::to_string(inc) : ""); diff --git a/libethcore/CommonJS.h b/libethcore/CommonJS.h index ccc3b3103..2f82d8945 100644 --- a/libethcore/CommonJS.h +++ b/libethcore/CommonJS.h @@ -59,7 +59,7 @@ bytes unpadded(bytes _s); /// Remove all 0 byte on the head of @a _s. bytes unpadLeft(bytes _s); /// Convert u256 into user-readable string. Returns int/hex value of 64 bits int, hex of 160 bits FixedHash. As a fallback try to handle input as h256. -std::string prettyU256(u256 _n); +std::string prettyU256(u256 _n, bool _abridged = true); /// Convert h256 into user-readable string (by directly using std::string constructor). std::string fromRaw(h256 _n, unsigned* _inc = nullptr); /// Convert string to Address (h160), returns empty address if (_a.size != 40). diff --git a/mix/qml/Debugger.qml b/mix/qml/Debugger.qml index 644a7f975..1dd05574f 100644 --- a/mix/qml/Debugger.qml +++ b/mix/qml/Debugger.qml @@ -598,9 +598,11 @@ Rectangle { Layout.minimumWidth: parent.width / 2 Layout.maximumWidth: parent.width / 2 Text { + maximumLineCount: 1 + clip: true anchors.leftMargin: 5 width: parent.width - 5 - wrapMode: Text.NoWrap + wrapMode: Text.WrapAnywhere anchors.left: parent.left font.family: "monospace" anchors.verticalCenter: parent.verticalCenter From e15859ed27cc33558ebad83f84831ad50dd8e2d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 13 Feb 2015 16:07:16 +0100 Subject: [PATCH 17/22] Windows fixes --- evmjit/libevmjit/Arith256.cpp | 2 +- libp2p/NodeTable.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/evmjit/libevmjit/Arith256.cpp b/evmjit/libevmjit/Arith256.cpp index 2ec227dcc..15d18c814 100644 --- a/evmjit/libevmjit/Arith256.cpp +++ b/evmjit/libevmjit/Arith256.cpp @@ -416,7 +416,7 @@ namespace explicit operator uint128() { uint128 r = lo; - r |= ((uint128) mid) << 64; + r = r + ((uint128) mid) << 64; return r; } diff --git a/libp2p/NodeTable.h b/libp2p/NodeTable.h index 0217c700e..23ca33661 100644 --- a/libp2p/NodeTable.h +++ b/libp2p/NodeTable.h @@ -168,10 +168,10 @@ public: /// Returns the Node to the corresponding node id or the empty Node if that id is not found. Node node(NodeId const& _id); -#ifndef BOOST_AUTO_TEST_SUITE -private: -#else +#if defined(BOOST_AUTO_TEST_SUITE) || defined(_MSC_VER) // MSVC includes access specifier in symbol name protected: +#else +private: #endif /// Constants for Kademlia, derived from address space. From d119c6c18817a24c1e3791704ea6a7e6e4a354a6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 13 Feb 2015 16:38:06 +0100 Subject: [PATCH 18/22] Coding standards update. --- CodingStandards.txt | 20 ++++++++++++++++++-- alethzero/MainWin.h | 3 +-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CodingStandards.txt b/CodingStandards.txt index 8acea78ae..76e1203a4 100644 --- a/CodingStandards.txt +++ b/CodingStandards.txt @@ -1,8 +1,11 @@ 0. Formatting +GOLDEN RULE: Never *ever* use spaces for formatting. + a. Use tabs for indentation! - tab stops are every 4 characters. - One indentation level -> exactly one byte (i.e. a tab character) in the source file. +- Never use spaces to line up sequential lines: If you have run-on lines, indent as you would for a block. b. Line widths: - Don't worry about having lines of code > 80-char wide. - Lines of comments should be formatted according to ease of viewing, but simplicity is to be prefered over beauty. @@ -17,10 +20,22 @@ j. Braces, when used, always have their own lines and are at same indentation le (WRONG) if( a==b[ i ] ) { printf ("Hello\n"); } +foo->bar(someLongVariableName, + anotherLongVariableName, + anotherLongVariableName, + anotherLongVariableName, + anotherLongVariableName); (RIGHT) if (a == b[i]) - printf("Hello\n"); // NOTE spaces used instead of tab here for clarify - first byte should be '\t'. + printf("Hello\n"); // NOTE spaces used instead of tab here for clarity - first byte should be '\t'. +foo->bar( + someLongVariableName, + anotherLongVariableName, + anotherLongVariableName, + anotherLongVariableName, + anotherLongVariableName +); @@ -98,7 +113,7 @@ g. Never use a macro where adequate non-preprocessor C++ can be written. h. Prefer "using NewType = OldType" to "typedef OldType NewType". i. Make use of auto whenever type is clear or unimportant: - Always avoid doubly-stating the type. -- Use to avoid vast and unimportant type declarations +- Use to avoid vast and unimportant type declarations. (WRONG) @@ -173,6 +188,7 @@ d. In general expressions should be roughly as important/semantically meaningful a. Comments should be doxygen-compilable, using @notation rather than \notation. + 12. Include Headers a. Includes should go in order of lower level (STL -> boost -> libdevcore -> libdevcrypto -> libethcore -> libethereum) to higher level. Lower levels are basically dependencies to the higher levels. For example: diff --git a/alethzero/MainWin.h b/alethzero/MainWin.h index 4e21d493f..2625f566d 100644 --- a/alethzero/MainWin.h +++ b/alethzero/MainWin.h @@ -239,8 +239,7 @@ private: /// Attempts to infer that @c _source contains Solidity code bool sourceIsSolidity(std::string const& _source); /// @eturns all method hashes of a Solidity contract in a string - std::string const getFunctionHashes(dev::solidity::CompilerStack const &_compiler, - std::string const& _contractName = ""); + std::string const getFunctionHashes(dev::solidity::CompilerStack const &_compiler, std::string const& _contractName = ""); std::unique_ptr ui; From 2ff89547d6013a84dbfe78ae06909a7911d2930c Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 13 Feb 2015 16:48:40 +0100 Subject: [PATCH 19/22] Change in formatting storage values. --- libethcore/CommonJS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index aa39c8e0c..cc63785bc 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -117,9 +117,9 @@ std::string prettyU256(u256 _n, bool _abridged) n = toHex(a.ref()); if (n.empty()) - s << "0x" << a; + s << "0x0"; else - s << n << "(0x" << n << ")"; + s << "0x" << n <<; } else if ((raw = fromRaw((h256)_n, &inc)).size()) return "\"" + raw + "\"" + (inc ? " + " + std::to_string(inc) : ""); From 9b7a2b7a2da4654d8aa8abcc9459a45ae5ecf830 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 13 Feb 2015 16:51:09 +0100 Subject: [PATCH 20/22] Coding standard updates on documentation. --- CodingStandards.txt | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/CodingStandards.txt b/CodingStandards.txt index 76e1203a4..e1a1b3ba9 100644 --- a/CodingStandards.txt +++ b/CodingStandards.txt @@ -72,6 +72,8 @@ e. Split complex macro on multiple lines with '\'. 3. Capitalization; +GOLDEN RULE: Preprocessor: ALL_CAPS; C++: camelCase. + a. Use camelCase for splitting words in names, except where obviously extending STL/boost functionality in which case follow those naming conventions. b. The following entities' first alpha is upper case: - Type names. @@ -80,6 +82,7 @@ b. The following entities' first alpha is upper case: - static const variables that form an external API. c. All preprocessor symbols (macros, macro argments) in full uppercase with underscore word separation. + All other entities' first alpha is lower case. @@ -137,6 +140,7 @@ for (auto i = x.begin(); i != x.end(); ++i) {} 7. Structs & classes a. Structs to be used when all members public and no virtual functions. +- In this case, members should be named naturally and not prefixed with 'm_' b. Classes to be used in all other circumstances. @@ -146,7 +150,7 @@ b. Classes to be used in all other circumstances. a. One member per line only. b. Private, non-static, non-const fields prefixed with m_. c. Avoid public fields, except in structs. -d. Use override, final and const judiciously. +d. Use override, final and const as much as possible. e. No implementations with the class declaration, except: - template or force-inline method (though prefer implementation at bottom of header file). - one-line implementation (in which case include it in same line as declaration). @@ -169,14 +173,18 @@ c. Avoid unpronouncable names; - If you need to shorten a name favour a pronouncable slice of the original to a scatterred set of consonants. - e.g. Manager shortens to Man rather than Mgr. d. Avoid prefixes of initials (e.g. DON'T use IMyInterface, CMyImplementation) -e. A dictionary and thesaurus are your friends. +e. Find short, memorable & (at least semi-) descriptive names for commonly used classes or name-fragments. +- A dictionary and thesaurus are your friends. - Spell correctly. -- Find short, memorable & (at least semi-) descriptive names for commonly used classes or name-fragments. +- Think carefully about the class's purpose. +- Imagine it as an isolated component to try to decontextualise it when considering its name. +- Don't be trapped into naming it (purely) in terms of its implementation. + 10. Type-definitions -a. Prefer using to typedef. e.g. using ints = std::vector; rather than typedef std::vector ints; +a. Prefer 'using' to 'typedef'. e.g. using ints = std::vector; rather than typedef std::vector ints; b. Generally avoid shortening a standard form that already includes all important information: - e.g. stick to shared_ptr rather than shortening to ptr. c. Where there are exceptions to this (due to excessive use and clear meaning), note the change prominently and use it consistently. @@ -184,9 +192,16 @@ c. Where there are exceptions to this (due to excessive use and clear meaning), d. In general expressions should be roughly as important/semantically meaningful as the space they occupy. + 11. Commenting a. Comments should be doxygen-compilable, using @notation rather than \notation. +b. Document the interface, not the implementation. +- Documentation should be able to remain completely unchanged, even if the method is reimplemented. +- Comment in terms of the method properties and intended alteration to class state (or what aspects of the state it reports). +- Be careful to scrutinise documentation that extends only to intended purpose and usage. +- Reject documentation that is simply an English transaction of the implementation. + 12. Include Headers From 53e901930dfdaffc74f2e1f2d90061e7f0cac34d Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 13 Feb 2015 16:52:10 +0100 Subject: [PATCH 21/22] small changes --- libethcore/CommonJS.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libethcore/CommonJS.cpp b/libethcore/CommonJS.cpp index cc63785bc..388738528 100644 --- a/libethcore/CommonJS.cpp +++ b/libethcore/CommonJS.cpp @@ -117,9 +117,9 @@ std::string prettyU256(u256 _n, bool _abridged) n = toHex(a.ref()); if (n.empty()) - s << "0x0"; + s << "0"; else - s << "0x" << n <<; + s << _n << "(0x" << n << ")"; } else if ((raw = fromRaw((h256)_n, &inc)).size()) return "\"" + raw + "\"" + (inc ? " + " + std::to_string(inc) : ""); From ece46d70ea403fc601a4865988e25a65e1c97ee2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Fri, 13 Feb 2015 18:55:59 +0100 Subject: [PATCH 22/22] WebPreview ui redesign --- mix/qml/CodeEditorView.qml | 3 +- mix/qml/WebPreview.qml | 124 +++++++++++++++++++++--------- mix/qml/WebPreviewStyle.qml | 14 ++++ mix/qml/img/available_updates.png | Bin 0 -> 889 bytes mix/qml/qmldir | 1 + mix/res.qrc | 2 + 6 files changed, 108 insertions(+), 36 deletions(-) create mode 100644 mix/qml/WebPreviewStyle.qml create mode 100644 mix/qml/img/available_updates.png diff --git a/mix/qml/CodeEditorView.qml b/mix/qml/CodeEditorView.qml index 4d54994fe..9c0b804d7 100644 --- a/mix/qml/CodeEditorView.qml +++ b/mix/qml/CodeEditorView.qml @@ -19,7 +19,8 @@ Item { function isDocumentOpen(documentId) { for (var i = 0; i < editorListModel.count; i++) - if (editorListModel.get(i).documentId === documentId) + if (editorListModel.get(i).documentId === documentId && + editors.itemAt(i).item) return true; return false; } diff --git a/mix/qml/WebPreview.qml b/mix/qml/WebPreview.qml index 10d0b3c83..88b992b54 100644 --- a/mix/qml/WebPreview.qml +++ b/mix/qml/WebPreview.qml @@ -6,6 +6,7 @@ import QtQuick.Controls.Styles 1.1 import QtWebEngine 1.0 import QtWebEngine.experimental 1.0 import HttpServer 1.0 +import "." Item { id: webPreview @@ -38,7 +39,7 @@ Item { function updateDocument(documentId, action) { for (var i = 0; i < pageListModel.count; i++) - if (pageListModel.get(i).documentId === i) + if (pageListModel.get(i).documentId === documentId) action(i); } @@ -82,10 +83,22 @@ Item { onDocumentRemoved: { updateDocument(documentId, function(i) { pageListModel.remove(i) } ) } + onDocumentUpdated: { updateDocument(documentId, function(i) { pageListModel.set(i, projectModel.getDocument(documentId)) } ) } + onDocumentOpened: { + if (!document.isHtml) + return; + for (var i = 0; i < pageListModel.count; i++) { + var doc = pageListModel.get(i); + if (doc.documentId === document.documentId) { + pageCombo.currentIndex = i; + } + } + } + onProjectLoading: { for (var i = 0; i < target.listModel.count; i++) { var document = target.listModel.get(i); @@ -146,45 +159,86 @@ Item { ColumnLayout { anchors.fill: parent - - RowLayout { - anchors.top: parent.top - Layout.fillWidth: true; - Text { - text: qsTr("Page") - } - ComboBox { - id: pageCombo - model: pageListModel - textRole: "name" - currentIndex: -1 - onCurrentIndexChanged: changePage() - } - Button { - text: qsTr("Reload") - onClicked: reload() + spacing: 0 + Rectangle + { + SourceSansProLight + { + id: regularFont } - CheckBox { - id: autoReloadOnSave - checked: true - text: qsTr("Auto reload on save") + + anchors.leftMargin: 4 + color: WebPreviewStyle.general.headerBackgroundColor + Layout.preferredWidth: parent.width + Layout.preferredHeight: 32 + Row { + anchors.top: parent.top + anchors.fill: parent + anchors.leftMargin: 3 + spacing: 3 + DefaultLabel { + text: qsTr("Preview of") + anchors.verticalCenter: parent.verticalCenter + } + + ComboBox { + id: pageCombo + model: pageListModel + textRole: "name" + currentIndex: -1 + onCurrentIndexChanged: changePage() + anchors.verticalCenter: parent.verticalCenter + style: ComboBoxStyle { + font: regularFont.name + } + } + + Action { + tooltip: qsTr("Reload") + id: buttonReloadAction + onTriggered: { + reload(); + } + } + + Button { + iconSource: "qrc:/qml/img/available_updates.png" + action: buttonReloadAction + anchors.verticalCenter: parent.verticalCenter + width: 26 + height: 26 + } + CheckBox { + id: autoReloadOnSave + checked: true + anchors.verticalCenter: parent.verticalCenter + style: CheckBoxStyle { + label: DefaultLabel { + text: qsTr("Auto reload on save") + } + } + } } } - WebEngineView { - Layout.fillWidth: true + Rectangle + { + Layout.preferredWidth: parent.width Layout.fillHeight: true - id: webView - experimental.settings.localContentCanAccessRemoteUrls: true - onJavaScriptConsoleMessage: { - console.log(sourceID + ":" + lineNumber + ":" + message); - } - onLoadingChanged: { - if (!loading) { - initialized = true; - webView.runJavaScript("init(\"" + httpServer.url + "/rpc/\")"); - if (pendingPageUrl) - setPreviewUrl(pendingPageUrl); + WebEngineView { + anchors.fill: parent + id: webView + experimental.settings.localContentCanAccessRemoteUrls: true + onJavaScriptConsoleMessage: { + console.log(sourceID + ":" + lineNumber + ":" + message); + } + onLoadingChanged: { + if (!loading) { + initialized = true; + webView.runJavaScript("init(\"" + httpServer.url + "/rpc/\")"); + if (pendingPageUrl) + setPreviewUrl(pendingPageUrl); + } } } } diff --git a/mix/qml/WebPreviewStyle.qml b/mix/qml/WebPreviewStyle.qml new file mode 100644 index 000000000..551f5a446 --- /dev/null +++ b/mix/qml/WebPreviewStyle.qml @@ -0,0 +1,14 @@ +pragma Singleton +import QtQuick 2.0 + +QtObject { + + function absoluteSize(rel) + { + return systemPointSize + rel; + } + + property QtObject general: QtObject { + property string headerBackgroundColor: "#f0f0f0" + } +} diff --git a/mix/qml/img/available_updates.png b/mix/qml/img/available_updates.png new file mode 100644 index 0000000000000000000000000000000000000000..fa08c1d80754a1edf631eef463a23958c6d0f9f1 GIT binary patch literal 889 zcmV-<1BU#GP)l0v$LNgbr{jfK-4}0Z;*^0@4Adf+Q8>s34&NOa(v%pwF{AbF*`|l6Lpb z&Wtsq@t?G-Cq3=y&Zj4bAzvko>zYtbYn&VTzLj-uML&w(l&*OQKsFNmJJCO)=i$|j z=MaGWmZ)EZ$nWI!%8f!C_6=kyF+3!J0|Y=W**6e+;(Zcv5yhqi@>&911WmL16ncUF zz$O(p#aaS^=QJ&+5R|DE7sXltA)}u}SGAGXP^=aR{9cR3Q>QVOUDKORu~Hxe&PA*R zg*5Ocij@EX1V`p8ErLeBn@%w=5J3E#kV<3NRf>6lcq;KjA|jJi?W|E{vJ~?Gp(i+6 zQ~4!dkg+Z(08$|d^b@)&1ec|l6-b;=`vHEJ59<)TC+Sq_(c=(o*^eY_hkPwS(!R(p zXbA9w*nBbAMU!vxW}_v{0wm5ue?vyx16>kyC!ZN#a>8EhL&XOxkUDEX7UIAubss9{ktw@fkfj!yND&kp7v*q+7`%q}B8GC=96Noo9m;DilD_t`fA1jhcGEL3BJ6Gq; z48_=O(Xt`{;MSK}iuaeI-E#u6kYLk?4^#s%twg;r*HmN~Dll}9!fZD5eF?CYII$P6 zqf!FoO`s2pk4e>&^{^-vW!wkAx#+eP5E^(bx-g_w-B?+JB=MgKdoj*rtHD}YMPdW9 zkOcs1GRazPQ#|-lg+47!Ny!1>^r4BpOh@L;=7)LltDi=XaB6)FK#~dv1ZA9J%JZL=6bE+KRS%Hf2c&*B~n4x}np6 zuyGB=EP?lJs091DK(K%X2zGN&jGh35nNIx-SbiFQxV*A6pLf~awI^4pG>?!#wgZ$Yqml/DefaultTextField.qml qml/CommonSeparator.qml qml/Style.qml + qml/WebPreviewStyle.qml + qml/img/available_updates.png