From 9cd76d43fd148bf287290298cac1ec979b98a39c Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Mon, 3 Nov 2014 23:49:05 +0100 Subject: [PATCH 01/10] Fix ABAcalls OOG bug --- alethzero/MainWin.cpp | 4 ++-- libethereum/ExtVM.h | 2 +- libevm/ExtVMFace.cpp | 2 +- libevm/ExtVMFace.h | 4 ++-- test/createRandomTest.cpp | 4 ++-- test/state.cpp | 4 +--- test/vm.cpp | 10 +++++----- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index f413532b7..308df9947 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -1344,7 +1344,7 @@ void Main::populateDebugger(dev::bytesConstRef _r) debugFinished(); vector levels; m_codes.clear(); - bytesConstRef lastExtCode; + bytes lastExtCode; bytesConstRef lastData; h256 lastHash; h256 lastDataHash; @@ -1357,7 +1357,7 @@ void Main::populateDebugger(dev::bytesConstRef _r) lastExtCode = ext.code; lastHash = sha3(lastExtCode); if (!m_codes.count(lastHash)) - m_codes[lastHash] = ext.code.toBytes(); + m_codes[lastHash] = ext.code; } if (ext.data != lastData) { diff --git a/libethereum/ExtVM.h b/libethereum/ExtVM.h index cf80b2352..b1dbdbdc7 100644 --- a/libethereum/ExtVM.h +++ b/libethereum/ExtVM.h @@ -40,7 +40,7 @@ class ExtVM: public ExtVMFace public: /// Full constructor. ExtVM(State& _s, Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, Manifest* o_ms, unsigned _depth = 0): - ExtVMFace(_myAddress, _caller, _origin, _value, _gasPrice, _data, _code, _s.m_previousBlock, _s.m_currentBlock, _depth), m_s(_s), m_origCache(_s.m_cache), m_ms(o_ms) + ExtVMFace(_myAddress, _caller, _origin, _value, _gasPrice, _data, _code.toBytes(), _s.m_previousBlock, _s.m_currentBlock, _depth), m_s(_s), m_origCache(_s.m_cache), m_ms(o_ms) { m_s.ensureCached(_myAddress, true, true); } diff --git a/libevm/ExtVMFace.cpp b/libevm/ExtVMFace.cpp index da189d899..b30d3d77d 100644 --- a/libevm/ExtVMFace.cpp +++ b/libevm/ExtVMFace.cpp @@ -25,7 +25,7 @@ using namespace std; using namespace dev; using namespace dev::eth; -ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth): +ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth): myAddress(_myAddress), caller(_caller), origin(_origin), diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 5b26c3792..a8ebddabb 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -96,7 +96,7 @@ public: ExtVMFace() = default; /// Full constructor. - ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytesConstRef _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth); + ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth); virtual ~ExtVMFace() = default; @@ -145,7 +145,7 @@ public: u256 value; ///< Value (in Wei) that was passed to this address. u256 gasPrice; ///< Price of gas (that we already paid). bytesConstRef data; ///< Current input data. - bytesConstRef code; ///< Current code that is executing. + bytes code; ///< Current code that is executing. BlockInfo previousBlock; ///< The previous block's information. BlockInfo currentBlock; ///< The current block's information. SubState sub; ///< Sub-band VM state (suicides, refund counter, logs). diff --git a/test/createRandomTest.cpp b/test/createRandomTest.cpp index 28e4342d7..457478fd1 100644 --- a/test/createRandomTest.cpp +++ b/test/createRandomTest.cpp @@ -134,10 +134,10 @@ void doMyTests(json_spirit::mValue& v) o["pre"] = mValue(fev.exportState()); fev.importExec(o["exec"].get_obj()); - if (!fev.code) + if (!fev.code.size()) { fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress)); - fev.code = &fev.thisTxCode; + fev.code = fev.thisTxCode; } vm.reset(fev.gas); diff --git a/test/state.cpp b/test/state.cpp index 3a81821ef..cc772f2c9 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -20,8 +20,6 @@ * State test functions. */ -#define FILL_TESTS - #include #include #include "JsonSpiritHeaders.h" @@ -60,7 +58,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) if (_fillin) { importer.code = importer.m_statePre.code(importer.m_environment.myAddress); - importer.m_environment.code = &importer.code; + importer.m_environment.code = importer.code; } State theState = importer.m_statePre; diff --git a/test/vm.cpp b/test/vm.cpp index 4061d789e..876706711 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -29,7 +29,7 @@ using namespace dev::eth; using namespace dev::test; 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(), bytesConstRef(), _previousBlock, _currentBlock, _depth) {} + ExtVMFace(Address(), Address(), Address(), 0, 1, bytesConstRef(), bytes(), _previousBlock, _currentBlock, _depth) {} h160 FakeExtVM::create(u256 _endowment, u256* _gas, bytesConstRef _init, OnOpFunc const&) { @@ -206,11 +206,11 @@ void FakeExtVM::importExec(mObject& _o) gas = toInt(_o["gas"]); thisTxCode.clear(); - code = &thisTxCode; + code = thisTxCode; thisTxCode = importCode(_o); if (_o["code"].type() != str_type && _o["code"].type() != array_type) - code.reset(); + code.clear(); thisTxData.clear(); thisTxData = importData(_o); @@ -303,10 +303,10 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) o["pre"] = mValue(fev.exportState()); fev.importExec(o["exec"].get_obj()); - if (!fev.code) + if (!fev.code.size()) { fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress)); - fev.code = &fev.thisTxCode; + fev.code = fev.thisTxCode; } bytes output; From 9a97e73933b34e34670d1a998db5d3579f35e2a1 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 6 Nov 2014 21:51:06 +0000 Subject: [PATCH 02/10] New Whisper protocol - uint32s for topics. --- alethzero/MainWin.cpp | 2 +- libdevcore/RLP.h | 6 ++++- libjsqrc/main.js | 6 +++-- libweb3jsonrpc/WebThreeStubServer.cpp | 3 ++- libwhisper/Common.cpp | 35 ++++++++++++++++++++++----- libwhisper/Common.h | 8 +++--- libwhisper/Interface.cpp | 7 ++---- libwhisper/Interface.h | 2 +- libwhisper/Message.cpp | 4 +-- libwhisper/Message.h | 13 +++++++--- libwhisper/WhisperHost.cpp | 7 +++--- 11 files changed, 64 insertions(+), 29 deletions(-) diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 343097bbf..4d7318d8c 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -2218,7 +2218,7 @@ void Main::refreshWhispers() time_t ex = e.expiry(); QString t(ctime(&ex)); t.chop(1); - QString item = QString("[%1 - %2s] *%3 %5 %4").arg(t).arg(e.ttl()).arg(e.workProved()).arg(toString(e.topic()).c_str()).arg(msg); + QString item = QString("[%1 - %2s] *%3 %5 %4").arg(t).arg(e.ttl()).arg(e.workProved()).arg(toString(e.topics()).c_str()).arg(msg); ui->whispers->addItem(item); } } diff --git a/libdevcore/RLP.h b/libdevcore/RLP.h index 248a2e645..afedc68da 100644 --- a/libdevcore/RLP.h +++ b/libdevcore/RLP.h @@ -159,7 +159,11 @@ public: /// Best-effort conversion operators. explicit operator std::string() const { return toString(); } explicit operator RLPs() const { return toList(); } - explicit operator byte() const { return toInt(); } + explicit operator uint8_t() const { return toInt(); } + explicit operator uint16_t() const { return toInt(); } + explicit operator uint32_t() const { return toInt(); } + explicit operator uint64_t() const { return toInt(); } + explicit operator u160() const { return toInt(); } explicit operator u256() const { return toInt(); } explicit operator bigint() const { return toInt(); } template explicit operator FixedHash<_N>() const { return toHash>(); } diff --git a/libjsqrc/main.js b/libjsqrc/main.js index 821de6382..3b8ee0b45 100644 --- a/libjsqrc/main.js +++ b/libjsqrc/main.js @@ -410,8 +410,10 @@ }; Filter.prototype.trigger = function(messages) { - for(var i = 0; i < this.callbacks.length; i++) { - this.callbacks[i].call(this, messages); + if (!(messages instanceof Array) || messages.length) { + for(var i = 0; i < this.callbacks.length; i++) { + this.callbacks[i].call(this, messages); + } } }; diff --git a/libweb3jsonrpc/WebThreeStubServer.cpp b/libweb3jsonrpc/WebThreeStubServer.cpp index 83e56d97a..7e5d29080 100644 --- a/libweb3jsonrpc/WebThreeStubServer.cpp +++ b/libweb3jsonrpc/WebThreeStubServer.cpp @@ -268,7 +268,8 @@ static Json::Value toJson(h256 const& _h, shh::Envelope const& _e, shh::Message res["sent"] = (int)_e.sent(); res["ttl"] = (int)_e.ttl(); res["workProved"] = (int)_e.workProved(); - res["topic"] = toJS(_e.topic()); + for (auto const& t: _e.topics()) + res["topics"].append(toJS((u256)t)); res["payload"] = toJS(_m.payload()); res["from"] = toJS(_m.from()); res["to"] = toJS(_m.to()); diff --git a/libwhisper/Common.cpp b/libwhisper/Common.cpp index 15b07e433..8f58ae994 100644 --- a/libwhisper/Common.cpp +++ b/libwhisper/Common.cpp @@ -22,11 +22,21 @@ #include "Common.h" #include +#include "Message.h" using namespace std; using namespace dev; using namespace dev::p2p; using namespace dev::shh; +Topic BuildTopic::toTopic() const +{ + Topic ret; + ret.reserve(m_parts.size()); + for (auto const& h: m_parts) + ret.push_back((TopicPart)u256(h)); + return ret; +} + BuildTopic& BuildTopic::shiftBytes(bytes const& _b) { m_parts.push_back(dev::sha3(_b)); @@ -40,19 +50,32 @@ h256 TopicFilter::sha3() const return dev::sha3(s.out()); } +bool TopicFilter::matches(Envelope const& _e) const +{ + for (TopicMask const& t: m_topicMasks) + { + if (_e.topics().size() == t.size()) + for (unsigned i = 0; i < t.size(); ++i) + if (((t[i].first ^ _e.topics()[i]) & t[i].second) != 0) + goto NEXT_TOPICMASK; + return true; + NEXT_TOPICMASK:; + } + return false; +} + TopicMask BuildTopicMask::toTopicMask() const { TopicMask ret; - if (m_parts.size()) - for (auto i = 0; i < 32; ++i) - { - ret.first[i] = m_parts[i * m_parts.size() / 32][i]; - ret.second[i] = m_parts[i * m_parts.size() / 32] ? 255 : 0; - } + ret.reserve(m_parts.size()); + for (auto const& h: m_parts) + ret.push_back(make_pair((TopicPart)u256(h), h ? ~(uint32_t)0 : 0)); return ret; } + /* web3.shh.watch({}).arrived(function(m) { env.note("New message:\n"+JSON.stringify(m)); }) k = web3.shh.newIdentity() web3.shh.post({from: k, topic: web3.fromAscii("test"), payload: web3.fromAscii("Hello world!")}) */ + diff --git a/libwhisper/Common.h b/libwhisper/Common.h index 21296e193..f47778afe 100644 --- a/libwhisper/Common.h +++ b/libwhisper/Common.h @@ -59,7 +59,9 @@ enum WhisperPacket PacketCount }; -using Topic = h256; +using TopicPart = uint32_t; + +using Topic = std::vector; class BuildTopic { @@ -73,7 +75,7 @@ public: BuildTopic& shiftRaw(h256 const& _part) { m_parts.push_back(_part); return *this; } operator Topic() const { return toTopic(); } - Topic toTopic() const { Topic ret; for (auto i = 0; i < 32; ++i) ret[i] = m_parts[i * m_parts.size() / 32][i]; return ret; } + Topic toTopic() const; protected: BuildTopic& shiftBytes(bytes const& _b); @@ -81,7 +83,7 @@ protected: h256s m_parts; }; -using TopicMask = std::pair; +using TopicMask = std::vector>; using TopicMasks = std::vector; class TopicFilter diff --git a/libwhisper/Interface.cpp b/libwhisper/Interface.cpp index 9b6815f0d..c00c3ebb2 100644 --- a/libwhisper/Interface.cpp +++ b/libwhisper/Interface.cpp @@ -34,10 +34,7 @@ using namespace dev::shh; #endif #define clogS(X) dev::LogOutputStream(false) << "| " << std::setw(2) << session()->socketId() << "] " -bool TopicFilter::matches(Envelope const& _e) const +unsigned Interface::installWatch(TopicMask const& _mask) { - for (TopicMask const& t: m_topicMasks) - if (((t.first ^ _e.topic()) & t.second) == 0) - return true; - return false; + return installWatch(TopicFilter(_mask)); } diff --git a/libwhisper/Interface.h b/libwhisper/Interface.h index 56b3be599..1af93f591 100644 --- a/libwhisper/Interface.h +++ b/libwhisper/Interface.h @@ -69,7 +69,7 @@ public: virtual void inject(Envelope const& _m, WhisperPeer* _from = nullptr) = 0; - unsigned installWatch(TopicMask const& _mask) { return installWatch(TopicFilter(_mask)); } + unsigned installWatch(TopicMask const& _mask); virtual unsigned installWatch(TopicFilter const& _filter) = 0; virtual unsigned installWatchOnId(h256 _filterId) = 0; virtual void uninstallWatch(unsigned _watchId) = 0; diff --git a/libwhisper/Message.cpp b/libwhisper/Message.cpp index 93dcaa033..65da72f9d 100644 --- a/libwhisper/Message.cpp +++ b/libwhisper/Message.cpp @@ -97,7 +97,7 @@ Message Envelope::open(Secret const& _s) const unsigned Envelope::workProved() const { h256 d[2]; - d[0] = sha3NoNonce(); + d[0] = sha3(WithoutNonce); d[1] = m_nonce; return dev::sha3(bytesConstRef(d[0].data(), 64)).firstBitSet(); } @@ -106,7 +106,7 @@ void Envelope::proveWork(unsigned _ms) { // PoW h256 d[2]; - d[0] = sha3NoNonce(); + d[0] = sha3(WithoutNonce); uint32_t& n = *(uint32_t*)&(d[1][28]); unsigned bestBitSet = 0; bytesConstRef chuck(d[0].data(), 64); diff --git a/libwhisper/Message.h b/libwhisper/Message.h index 677d16f00..3b0d14aae 100644 --- a/libwhisper/Message.h +++ b/libwhisper/Message.h @@ -39,6 +39,12 @@ namespace shh class Message; +enum IncludeNonce +{ + WithoutNonce = 0, + WithNonce = 1 +}; + class Envelope { friend class Message; @@ -56,14 +62,13 @@ public: operator bool() const { return !!m_expiry; } - void streamRLP(RLPStream& _s, bool _withNonce) const { _s.appendList(_withNonce ? 5 : 4) << m_expiry << m_ttl << m_topic << m_data; if (_withNonce) _s << m_nonce; } - h256 sha3() const { RLPStream s; streamRLP(s, true); return dev::sha3(s.out()); } - h256 sha3NoNonce() const { RLPStream s; streamRLP(s, false); return dev::sha3(s.out()); } + void streamRLP(RLPStream& _s, IncludeNonce _withNonce = WithNonce) const { _s.appendList(_withNonce ? 5 : 4) << m_expiry << m_ttl << m_topic << m_data; if (_withNonce) _s << m_nonce; } + h256 sha3(IncludeNonce _withNonce = WithNonce) const { RLPStream s; streamRLP(s, _withNonce); return dev::sha3(s.out()); } unsigned sent() const { return m_expiry - m_ttl; } unsigned expiry() const { return m_expiry; } unsigned ttl() const { return m_ttl; } - Topic const& topic() const { return m_topic; } + Topic const& topics() const { return m_topic; } bytes const& data() const { return m_data; } Message open(Secret const& _s = Secret()) const; diff --git a/libwhisper/WhisperHost.cpp b/libwhisper/WhisperHost.cpp index 71030aae2..0fb7a206c 100644 --- a/libwhisper/WhisperHost.cpp +++ b/libwhisper/WhisperHost.cpp @@ -21,6 +21,7 @@ #include "WhisperHost.h" +#include #include #include using namespace std; @@ -48,14 +49,14 @@ void WhisperHost::streamMessage(h256 _m, RLPStream& _s) const { UpgradeGuard ll(l); auto const& m = m_messages.at(_m); - cnote << "streamRLP: " << m.expiry() << m.ttl() << m.topic() << toHex(m.data()); - m.streamRLP(_s, true); + cnote << "streamRLP: " << m.expiry() << m.ttl() << m.topics() << toHex(m.data()); + m.streamRLP(_s); } } void WhisperHost::inject(Envelope const& _m, WhisperPeer* _p) { - cnote << "inject: " << _m.expiry() << _m.ttl() << _m.topic() << toHex(_m.data()); + cnote << "inject: " << _m.expiry() << _m.ttl() << _m.topics() << toHex(_m.data()); if (_m.expiry() <= time(0)) return; From 038b865baa8e0bea54f760646e74bd4f50c73ee9 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 6 Nov 2014 21:52:38 +0000 Subject: [PATCH 03/10] Protocol bump for shh. --- libwhisper/WhisperHost.h | 2 +- libwhisper/WhisperPeer.cpp | 4 ++-- libwhisper/WhisperPeer.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libwhisper/WhisperHost.h b/libwhisper/WhisperHost.h index 4d761919c..91934dd98 100644 --- a/libwhisper/WhisperHost.h +++ b/libwhisper/WhisperHost.h @@ -46,7 +46,7 @@ public: WhisperHost(); virtual ~WhisperHost(); - unsigned protocolVersion() const { return 0; } + unsigned protocolVersion() const { return 1; } virtual void inject(Envelope const& _e, WhisperPeer* _from = nullptr) override; diff --git a/libwhisper/WhisperPeer.cpp b/libwhisper/WhisperPeer.cpp index 343f7ca1a..56f4e456e 100644 --- a/libwhisper/WhisperPeer.cpp +++ b/libwhisper/WhisperPeer.cpp @@ -37,7 +37,7 @@ using namespace dev::shh; WhisperPeer::WhisperPeer(Session* _s, HostCapabilityFace* _h, unsigned _i): Capability(_s, _h, _i) { RLPStream s; - sealAndSend(prep(s, StatusPacket, 1) << host()->protocolVersion()); + sealAndSend(prep(s, StatusPacket, 1) << version()); } WhisperPeer::~WhisperPeer() @@ -59,7 +59,7 @@ bool WhisperPeer::interpret(unsigned _id, RLP const& _r) clogS(NetMessageSummary) << "Status: " << protocolVersion; - if (protocolVersion != host()->protocolVersion()) + if (protocolVersion != version()) disable("Invalid protocol version."); if (session()->id() < host()->host()->id()) diff --git a/libwhisper/WhisperPeer.h b/libwhisper/WhisperPeer.h index 45d72ba89..f60de8f01 100644 --- a/libwhisper/WhisperPeer.h +++ b/libwhisper/WhisperPeer.h @@ -53,7 +53,7 @@ public: virtual ~WhisperPeer(); static std::string name() { return "shh"; } - static u256 version() { return 1; } + static u256 version() { return 2; } static unsigned messageCount() { return PacketCount; } WhisperHost* host() const; From 11f65d50b8b1c5eab725195581a34f8e4f6ca656 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 6 Nov 2014 22:39:02 +0100 Subject: [PATCH 04/10] Evaluate expressions in convenient order. --- libsolidity/ExpressionCompiler.cpp | 51 ++++++++------------ test/solidityExpressionCompiler.cpp | 73 ++++++++++++++--------------- 2 files changed, 53 insertions(+), 71 deletions(-) diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 6efb8b20c..015b9ab94 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -48,21 +48,15 @@ bool ExpressionCompiler::visit(Assignment& _assignment) { m_currentLValue = nullptr; - Expression& rightHandSide = _assignment.getRightHandSide(); - rightHandSide.accept(*this); - Type const& resultType = *_assignment.getType(); - appendTypeConversion(*rightHandSide.getType(), resultType); + _assignment.getRightHandSide().accept(*this); + appendTypeConversion(*_assignment.getRightHandSide().getType(), *_assignment.getType()); _assignment.getLeftHandSide().accept(*this); Token::Value op = _assignment.getAssignmentOperator(); - if (op != Token::ASSIGN) - { - // compound assignment - m_context << eth::Instruction::SWAP1; - appendOrdinaryBinaryOperatorCode(Token::AssignmentToBinaryOp(op), resultType); - } + if (op != Token::ASSIGN) // compound assignment + appendOrdinaryBinaryOperatorCode(Token::AssignmentToBinaryOp(op), *_assignment.getType()); else - m_context << eth::Instruction::POP; //@todo do not retrieve the value in the first place + m_context << eth::Instruction::POP; storeInLValue(_assignment); return false; @@ -123,11 +117,8 @@ bool ExpressionCompiler::visit(BinaryOperation& _binaryOperation) Type const& commonType = _binaryOperation.getCommonType(); Token::Value const op = _binaryOperation.getOperator(); - if (op == Token::AND || op == Token::OR) - { - // special case: short-circuiting + if (op == Token::AND || op == Token::OR) // special case: short-circuiting appendAndOrOperatorCode(_binaryOperation); - } else { bool cleanupNeeded = false; @@ -135,10 +126,10 @@ bool ExpressionCompiler::visit(BinaryOperation& _binaryOperation) if (Token::isCompareOp(op) || op == Token::DIV || op == Token::MOD) cleanupNeeded = true; - leftExpression.accept(*this); - appendTypeConversion(*leftExpression.getType(), commonType, cleanupNeeded); rightExpression.accept(*this); appendTypeConversion(*rightExpression.getType(), commonType, cleanupNeeded); + leftExpression.accept(*this); + appendTypeConversion(*leftExpression.getType(), commonType, cleanupNeeded); if (Token::isCompareOp(op)) appendCompareOperatorCode(op, commonType); else @@ -175,8 +166,7 @@ bool ExpressionCompiler::visit(FunctionCall& _functionCall) for (unsigned i = 0; i < arguments.size(); ++i) { arguments[i]->accept(*this); - appendTypeConversion(*arguments[i]->getType(), - *function.getParameters()[i]->getType()); + appendTypeConversion(*arguments[i]->getType(), *function.getParameters()[i]->getType()); } m_context.appendJumpTo(m_context.getFunctionEntryLabel(function)); @@ -267,23 +257,21 @@ void ExpressionCompiler::appendCompareOperatorCode(Token::Value _operator, Type IntegerType const& type = dynamic_cast(_type); bool const isSigned = type.isSigned(); - // note that EVM opcodes compare like "stack[0] < stack[1]", - // but our left value is at stack[1], so everyhing is reversed. switch (_operator) { case Token::GTE: - m_context << (isSigned ? eth::Instruction::SGT : eth::Instruction::GT) + m_context << (isSigned ? eth::Instruction::SLT : eth::Instruction::LT) << eth::Instruction::ISZERO; break; case Token::LTE: - m_context << (isSigned ? eth::Instruction::SLT : eth::Instruction::LT) + m_context << (isSigned ? eth::Instruction::SGT : eth::Instruction::GT) << eth::Instruction::ISZERO; break; case Token::GT: - m_context << (isSigned ? eth::Instruction::SLT : eth::Instruction::LT); + m_context << (isSigned ? eth::Instruction::SGT : eth::Instruction::GT); break; case Token::LT: - m_context << (isSigned ? eth::Instruction::SGT : eth::Instruction::GT); + m_context << (isSigned ? eth::Instruction::SLT : eth::Instruction::LT); break; default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown comparison operator.")); @@ -314,16 +302,16 @@ void ExpressionCompiler::appendArithmeticOperatorCode(Token::Value _operator, Ty m_context << eth::Instruction::ADD; break; case Token::SUB: - m_context << eth::Instruction::SWAP1 << eth::Instruction::SUB; + m_context << eth::Instruction::SUB; break; case Token::MUL: m_context << eth::Instruction::MUL; break; case Token::DIV: - m_context << eth::Instruction::SWAP1 << (isSigned ? eth::Instruction::SDIV : eth::Instruction::DIV); + m_context << (isSigned ? eth::Instruction::SDIV : eth::Instruction::DIV); break; case Token::MOD: - m_context << eth::Instruction::SWAP1 << (isSigned ? eth::Instruction::SMOD : eth::Instruction::MOD); + m_context << (isSigned ? eth::Instruction::SMOD : eth::Instruction::MOD); break; default: BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown arithmetic operator.")); @@ -364,10 +352,9 @@ void ExpressionCompiler::appendShiftOperatorCode(Token::Value _operator) void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type const& _targetType, bool _cleanupNeeded) { - // If the type of one of the operands is extended, we need to remove all - // higher-order bits that we might have ignored in previous operations. - // @todo: store in the AST whether the operand might have "dirty" higher - // order bits + // For a type extension, we need to remove all higher-order bits that we might have ignored in + // previous operations. + // @todo: store in the AST whether the operand might have "dirty" higher order bits if (_typeOnStack == _targetType && !_cleanupNeeded) return; diff --git a/test/solidityExpressionCompiler.cpp b/test/solidityExpressionCompiler.cpp index 8fc4a1a22..59a9e9336 100644 --- a/test/solidityExpressionCompiler.cpp +++ b/test/solidityExpressionCompiler.cpp @@ -154,10 +154,10 @@ BOOST_AUTO_TEST_CASE(comparison) "}\n"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(eth::Instruction::PUSH2), 0x10, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND), + bytes expectation({byte(eth::Instruction::PUSH1), 0x1, byte(eth::Instruction::PUSH2), 0x11, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND), - byte(eth::Instruction::GT), - byte(eth::Instruction::PUSH1), 0x1, + byte(eth::Instruction::PUSH2), 0x10, 0xaa, byte(eth::Instruction::PUSH2), 0xff, 0xff, byte(eth::Instruction::AND), + byte(eth::Instruction::LT), byte(eth::Instruction::EQ), byte(eth::Instruction::ISZERO)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); @@ -166,7 +166,7 @@ BOOST_AUTO_TEST_CASE(comparison) BOOST_AUTO_TEST_CASE(short_circuiting) { char const* sourceCode = "contract test {\n" - " function f() { var x = (10 + 8 >= 4 || 2 != 9) != true; }" + " function f() { var x = true != (4 <= 8 + 10 || 9 != 2); }" "}\n"; bytes code = compileFirstExpression(sourceCode); @@ -194,7 +194,7 @@ BOOST_AUTO_TEST_CASE(short_circuiting) BOOST_AUTO_TEST_CASE(arithmetics) { char const* sourceCode = "contract test {\n" - " function f() { var x = (1 * (2 / (3 % (4 + (5 - (6 | (7 & (8 ^ 9)))))))); }" + " function f() { var x = ((((((((9 ^ 8) & 7) | 6) - 5) + 4) % 3) / 2) * 1); }" "}\n"; bytes code = compileFirstExpression(sourceCode); bytes expectation({byte(eth::Instruction::PUSH1), 0x1, @@ -211,14 +211,11 @@ BOOST_AUTO_TEST_CASE(arithmetics) byte(eth::Instruction::XOR), byte(eth::Instruction::AND), byte(eth::Instruction::OR), - byte(eth::Instruction::SWAP1), byte(eth::Instruction::SUB), byte(eth::Instruction::ADD), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), - byte(eth::Instruction::SWAP1), byte(eth::Instruction::MOD), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), - byte(eth::Instruction::SWAP1), byte(eth::Instruction::DIV), byte(eth::Instruction::MUL)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); @@ -231,11 +228,11 @@ BOOST_AUTO_TEST_CASE(unary_operators) "}\n"; bytes code = compileFirstExpression(sourceCode); - bytes expectation({byte(eth::Instruction::PUSH1), 0x1, + bytes expectation({byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), + byte(eth::Instruction::PUSH1), 0x1, byte(eth::Instruction::PUSH1), 0x0, byte(eth::Instruction::SUB), byte(eth::Instruction::NOT), byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), - byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), byte(eth::Instruction::EQ), byte(eth::Instruction::ISZERO)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); @@ -244,7 +241,7 @@ BOOST_AUTO_TEST_CASE(unary_operators) BOOST_AUTO_TEST_CASE(unary_inc_dec) { char const* sourceCode = "contract test {\n" - " function f(uint a) { var x = ((a++ ^ ++a) ^ a--) ^ --a; }" + " function f(uint a) { var x = --a ^ (a-- ^ (++a ^ a++)); }" "}\n"; bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "x"}}); @@ -299,16 +296,15 @@ BOOST_AUTO_TEST_CASE(assignment) bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "a"}, {"test", "f", "b"}}); // Stack: a, b - bytes expectation({byte(eth::Instruction::DUP1), - byte(eth::Instruction::DUP3), - byte(eth::Instruction::SWAP1), + bytes expectation({byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), + byte(eth::Instruction::DUP2), + byte(eth::Instruction::DUP4), byte(eth::Instruction::ADD), - // Stack here: a b a+b - byte(eth::Instruction::SWAP2), + // Stack here: a b 2 a+b + byte(eth::Instruction::SWAP3), byte(eth::Instruction::POP), - byte(eth::Instruction::DUP2), - // Stack here: a+b b a+b - byte(eth::Instruction::PUSH1), 0x2, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), + byte(eth::Instruction::DUP3), + // Stack here: a+b b 2 a+b byte(eth::Instruction::MUL)}); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -323,21 +319,20 @@ BOOST_AUTO_TEST_CASE(function_call) {{"test", "f", "a"}, {"test", "f", "b"}}); // Stack: a, b - bytes expectation({byte(eth::Instruction::PUSH1), 0x0d, - byte(eth::Instruction::DUP3), + bytes expectation({byte(eth::Instruction::PUSH1), 0x02, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), + byte(eth::Instruction::PUSH1), 0x12, byte(eth::Instruction::PUSH1), 0x01, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), + byte(eth::Instruction::DUP5), byte(eth::Instruction::ADD), - // Stack here: a b (a+1) - byte(eth::Instruction::DUP3), - byte(eth::Instruction::PUSH1), 0x1a, + // Stack here: a b 2 (a+1) + byte(eth::Instruction::DUP4), + byte(eth::Instruction::PUSH1), 0x19, byte(eth::Instruction::JUMP), byte(eth::Instruction::JUMPDEST), - // Stack here: a b g(a+1, b) - byte(eth::Instruction::PUSH1), 0x02, byte(eth::Instruction::PUSH1), 0xff, byte(eth::Instruction::AND), + // Stack here: a b 2 g(a+1, b) byte(eth::Instruction::MUL), // Stack here: a b g(a+1, b)*2 byte(eth::Instruction::DUP3), - byte(eth::Instruction::SWAP1), byte(eth::Instruction::ADD), // Stack here: a b a+g(a+1, b)*2 byte(eth::Instruction::SWAP2), @@ -355,15 +350,15 @@ BOOST_AUTO_TEST_CASE(negative_literals_8bits) "}\n"; bytes code = compileFirstExpression(sourceCode); - bytes expectation(bytes({byte(eth::Instruction::PUSH1), 0x00, - byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + - bytes({byte(eth::Instruction::ADD), - byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + - bytes({byte(eth::Instruction::ADD), - byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x81) + - bytes({byte(eth::Instruction::ADD), - byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80) + - bytes({byte(eth::Instruction::ADD)})); + bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x80) + + bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x81) + + bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + + bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + + bytes({byte(eth::Instruction::PUSH1), 0x00, + byte(eth::Instruction::ADD), + byte(eth::Instruction::ADD), + byte(eth::Instruction::ADD), + byte(eth::Instruction::ADD)})); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); } @@ -376,11 +371,11 @@ BOOST_AUTO_TEST_CASE(negative_literals_16bits) "}\n"; bytes code = compileFirstExpression(sourceCode); - bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + + bytes expectation(bytes({byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x7f) + + bytes({byte(eth::Instruction::PUSH32)}) + bytes(32, 0xff) + bytes({byte(eth::Instruction::PUSH1), 0x00, byte(eth::Instruction::SIGNEXTEND), - byte(eth::Instruction::PUSH32)}) + bytes(31, 0xff) + bytes(1, 0x7f) + - bytes({byte(eth::Instruction::ADD), + byte(eth::Instruction::ADD), byte(eth::Instruction::PUSH1), 0x01, byte(eth::Instruction::SIGNEXTEND)})); BOOST_CHECK_EQUAL_COLLECTIONS(code.begin(), code.end(), expectation.begin(), expectation.end()); From fb9aeba3a3c5eec240676678122d9d6addd30c6e Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Fri, 7 Nov 2014 14:10:00 +0100 Subject: [PATCH 05/10] Clean up state tests --- test/TestHelper.h | 1 - test/state.cpp | 14 -------------- test/tmpFiller.json | 44 -------------------------------------------- 3 files changed, 59 deletions(-) delete mode 100644 test/tmpFiller.json diff --git a/test/TestHelper.h b/test/TestHelper.h index 622b83ac4..a4eb64d84 100644 --- a/test/TestHelper.h +++ b/test/TestHelper.h @@ -57,7 +57,6 @@ public: eth::State m_statePost; eth::ExtVMFace m_environment; eth::Transaction m_transaction; - bytes code; private: json_spirit::mObject& m_TestObject; diff --git a/test/state.cpp b/test/state.cpp index 4034b4b73..935869058 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -55,12 +55,6 @@ void doStateTests(json_spirit::mValue& v, bool _fillin) ImportTest importer(o, _fillin); - if (_fillin) - { - importer.code = importer.m_statePre.code(importer.m_environment.myAddress); - importer.m_environment.code = importer.code; - } - State theState = importer.m_statePre; bytes tx = importer.m_transaction.rlp(); bytes output; @@ -124,12 +118,4 @@ BOOST_AUTO_TEST_CASE(stSystemOperationsTest) dev::test::executeTests("stSystemOperationsTest", "/StateTests", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(tmp) -{ - int currentVerbosity = g_logVerbosity; - g_logVerbosity = 12; - dev::test::executeTests("tmp", "/StateTests", dev::test::doStateTests); - g_logVerbosity = currentVerbosity; -} - BOOST_AUTO_TEST_SUITE_END() diff --git a/test/tmpFiller.json b/test/tmpFiller.json deleted file mode 100644 index bd27b8907..000000000 --- a/test/tmpFiller.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "ABAcalls0": { - "env" : { - "previousHash" : "5e20a0453cecd065ea59c37ac63e079ee08998b6045136a8ce6635c7912ec0b6", - "currentNumber" : "0", - "currentGasLimit" : "10000000", - "currentDifficulty" : "256", - "currentTimestamp" : 1, - "currentCoinbase" : "2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" - }, - "pre" : { - "095e7baea6a6c7c4c2dfeb977efac326af552d87" : { - "balance" : "1000000000000000000", - "nonce" : 0, - "code" : "{ [[ (PC) ]] (CALL 1000 0x945304eb96065b2a98b57a48a06ae28d285a71b5 24 0 0 0 0) }", - "storage": {} - }, - "945304eb96065b2a98b57a48a06ae28d285a71b5" : { - "balance" : "23", - "code" : " { [[ (PC) ]] (ADD 1 (CALL 500 0x095e7baea6a6c7c4c2dfeb977efac326af552d87 23 0 0 0 0)) } ", - "nonce" : "0", - "storage" : { - } - }, - "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { - "balance" : "1000000000000000000", - "nonce" : 0, - "code" : "", - "storage": {} - } - - }, - "transaction" : { - "nonce" : "0", - "gasPrice" : "1", - "gasLimit" : "10000", - "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", - "value" : "100000", - "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", - "data" : "" - } - } - -} From 2b181378b5613f9bc855af24081837786e3ef6d4 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Fri, 7 Nov 2014 14:20:31 +0100 Subject: [PATCH 06/10] proper error handling, fixed #485 --- libjsqrc/main.js | 38 +++++++++++++++++++++----------------- libjsqrc/qt.js | 8 ++++---- libqethereum/QEthereum.cpp | 1 + 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/libjsqrc/main.js b/libjsqrc/main.js index 821de6382..b8c27060e 100644 --- a/libjsqrc/main.js +++ b/libjsqrc/main.js @@ -2,19 +2,19 @@ This file is part of ethereum.js. ethereum.js is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by + it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ethereum.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with ethereum.js. If not, see . */ -/** @file ethereum.js +/** @file main.js * @authors: * Marek Kotewicz * @date 2014 @@ -153,15 +153,15 @@ return {call: call, args: args}; }).then(function (request) { return new Promise(function (resolve, reject) { - web3.provider.send(request, function (result) { - if (result || typeof result === "boolean") { + web3.provider.send(request, function (err, result) { + if (!err) { resolve(result); return; } - reject(result); + reject(err); }); }); - }).catch(function( err) { + }).catch(function(err) { console.error(err); }); }; @@ -173,8 +173,12 @@ var proto = {}; proto.get = function () { return new Promise(function(resolve, reject) { - web3.provider.send({call: property.getter}, function(result) { - resolve(result); + web3.provider.send({call: property.getter}, function(err, result) { + if (!err) { + resolve(result); + return; + } + reject(err); }); }); }; @@ -182,12 +186,12 @@ proto.set = function (val) { return flattenPromise([val]).then(function (args) { return new Promise(function (resolve) { - web3.provider.send({call: property.setter, args: args}, function (result) { - if (result) { + web3.provider.send({call: property.setter, args: args}, function (err, result) { + if (!err) { resolve(result); - } else { - reject(result); + return; } + reject(err); }); }); }).catch(function (err) { @@ -218,7 +222,7 @@ var str = ""; var i = 0, l = hex.length; if (hex.substring(0, 2) == '0x') - i = 2; + i = 2; for(; i < l; i+=2) { var code = hex.charCodeAt(i) if(code == 0) { @@ -240,7 +244,7 @@ var hex = this.toHex(str); while(hex.length < pad*2) hex += "00"; - return "0x" + hex + return "0x" + hex; }, eth: { @@ -440,7 +444,7 @@ if(data._id) { var cb = web3._callbacks[data._id]; if (cb) { - cb.call(this, data.data) + cb.call(this, data.error, data.data); delete web3._callbacks[data._id]; } } diff --git a/libjsqrc/qt.js b/libjsqrc/qt.js index f0312eb2f..aedd34236 100644 --- a/libjsqrc/qt.js +++ b/libjsqrc/qt.js @@ -2,19 +2,19 @@ This file is part of ethereum.js. ethereum.js is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by + it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ethereum.js is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + GNU Lesser General Public License for more details. - You should have received a copy of the GNU General Public License + You should have received a copy of the GNU Lesser General Public License along with ethereum.js. If not, see . */ -/** @file ethereum.js +/** @file qt.js * @authors: * Marek Kotewicz * @date 2014 diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index 08165d9db..42e00958a 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -120,6 +120,7 @@ static QString formatOutput(QJsonObject const& _object) QJsonObject res; res["_id"] = _object["id"]; res["data"] = _object["result"]; + res["error"] = _object["error"]; return QString::fromUtf8(QJsonDocument(res).toJson()); } From 04f1b9434d330e155d124b82677b87502c30f026 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Fri, 7 Nov 2014 13:50:51 +0000 Subject: [PATCH 07/10] Fixes for warnings. Take note. --- test/solidityCompiler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/solidityCompiler.cpp b/test/solidityCompiler.cpp index 192fd61a4..ba2db67e6 100644 --- a/test/solidityCompiler.cpp +++ b/test/solidityCompiler.cpp @@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(different_argument_numbers) byte(Instruction::JUMPDEST), // beginning of g byte(Instruction::PUSH1), 0x0, byte(Instruction::DUP1), // initialized e and h - byte(Instruction::PUSH1), 0x29 + shift, // ret address + byte(Instruction::PUSH1), byte(0x29 + shift), // ret address byte(Instruction::PUSH1), 0x1, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x2, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), byte(Instruction::PUSH1), 0x3, byte(Instruction::PUSH1), 0xff, byte(Instruction::AND), From 28e7b6c6103d859e83bea39bec2d9f60ee956b5e Mon Sep 17 00:00:00 2001 From: Christoph Jentzsch Date: Fri, 7 Nov 2014 15:16:42 +0100 Subject: [PATCH 08/10] style --- libevm/ExtVMFace.cpp | 2 +- libevm/ExtVMFace.h | 2 +- test/createRandomTest.cpp | 2 +- test/vm.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libevm/ExtVMFace.cpp b/libevm/ExtVMFace.cpp index b30d3d77d..8a08a290c 100644 --- a/libevm/ExtVMFace.cpp +++ b/libevm/ExtVMFace.cpp @@ -25,7 +25,7 @@ using namespace std; using namespace dev; using namespace dev::eth; -ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth): +ExtVMFace::ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes const& _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth): myAddress(_myAddress), caller(_caller), origin(_origin), diff --git a/libevm/ExtVMFace.h b/libevm/ExtVMFace.h index 5252a062a..8a6b2edc9 100644 --- a/libevm/ExtVMFace.h +++ b/libevm/ExtVMFace.h @@ -104,7 +104,7 @@ public: ExtVMFace() = default; /// Full constructor. - ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth); + ExtVMFace(Address _myAddress, Address _caller, Address _origin, u256 _value, u256 _gasPrice, bytesConstRef _data, bytes const& _code, BlockInfo const& _previousBlock, BlockInfo const& _currentBlock, unsigned _depth); virtual ~ExtVMFace() = default; diff --git a/test/createRandomTest.cpp b/test/createRandomTest.cpp index a9a993776..f74be9304 100644 --- a/test/createRandomTest.cpp +++ b/test/createRandomTest.cpp @@ -134,7 +134,7 @@ void doMyTests(json_spirit::mValue& v) o["pre"] = mValue(fev.exportState()); fev.importExec(o["exec"].get_obj()); - if (!fev.code.size()) + if (fev.code.empty()) { fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress)); fev.code = fev.thisTxCode; diff --git a/test/vm.cpp b/test/vm.cpp index a093966d4..93cf121de 100644 --- a/test/vm.cpp +++ b/test/vm.cpp @@ -289,7 +289,7 @@ void doVMTests(json_spirit::mValue& v, bool _fillin) o["pre"] = mValue(fev.exportState()); fev.importExec(o["exec"].get_obj()); - if (!fev.code.size()) + if (fev.code.empty()) { fev.thisTxCode = get<3>(fev.addresses.at(fev.myAddress)); fev.code = fev.thisTxCode; From 0c40ba83f0c594d3febdc7e4c202cea42f90108f Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 7 Nov 2014 17:34:15 +0100 Subject: [PATCH 09/10] Bugfix: Bit width of address types. --- libsolidity/Types.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsolidity/Types.cpp b/libsolidity/Types.cpp index 7354255e1..4431a32f8 100644 --- a/libsolidity/Types.cpp +++ b/libsolidity/Types.cpp @@ -103,8 +103,8 @@ IntegerType::IntegerType(int _bits, IntegerType::Modifier _modifier): m_bits(_bits), m_modifier(_modifier) { if (isAddress()) - _bits = 160; - if (asserts(_bits > 0 && _bits <= 256 && _bits % 8 == 0)) + m_bits = 160; + if (asserts(m_bits > 0 && m_bits <= 256 && m_bits % 8 == 0)) BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Invalid bit number for integer type: " + dev::toString(_bits))); } From ac2b907a4f3a626b4354c607ef8248dcf862ca70 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 8 Nov 2014 18:14:18 +0000 Subject: [PATCH 10/10] Minor Instructions fix for PoC-7 renames. --- libevmcore/Instruction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libevmcore/Instruction.cpp b/libevmcore/Instruction.cpp index a55cc2242..ad27b28ef 100644 --- a/libevmcore/Instruction.cpp +++ b/libevmcore/Instruction.cpp @@ -172,13 +172,13 @@ static const std::map c_instructionInfo = { Instruction::MOD, { "MOD", 0, 2, 1 } }, { Instruction::SMOD, { "SMOD", 0, 2, 1 } }, { Instruction::EXP, { "EXP", 0, 2, 1 } }, - { Instruction::NOT, { "BNOT", 0, 1, 1 } }, + { Instruction::NOT, { "NOT", 0, 1, 1 } }, { Instruction::LT, { "LT", 0, 2, 1 } }, { Instruction::GT, { "GT", 0, 2, 1 } }, { Instruction::SLT, { "SLT", 0, 2, 1 } }, { Instruction::SGT, { "SGT", 0, 2, 1 } }, { Instruction::EQ, { "EQ", 0, 2, 1 } }, - { Instruction::ISZERO, { "NOT", 0, 1, 1 } }, + { Instruction::ISZERO, { "ISZERO", 0, 1, 1 } }, { Instruction::AND, { "AND", 0, 2, 1 } }, { Instruction::OR, { "OR", 0, 2, 1 } }, { Instruction::XOR, { "XOR", 0, 2, 1 } },