From ef7532caec8ffb9e3069e216b17a3823ecea562f Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 3 Apr 2014 00:48:31 -0400 Subject: [PATCH] Various VM & LLL bugs fixed. --- libethereum/ExtVMFace.h | 1 + libethereum/Instruction.cpp | 6 +++--- libethereum/State.cpp | 4 ++-- libethereum/VM.h | 7 ++++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libethereum/ExtVMFace.h b/libethereum/ExtVMFace.h index 92310e7f1..3d05ef514 100644 --- a/libethereum/ExtVMFace.h +++ b/libethereum/ExtVMFace.h @@ -73,6 +73,7 @@ public: Address myAddress; Address txSender; + Address origin; u256 txValue; u256 gasPrice; bytesConstRef txData; diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 8671e97b0..994c0c2b7 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -493,6 +493,8 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes // First fragment - predicate appendCode(o_code, o_locs, codes[0], locs[0]); + if (t == "WHEN") + o_code.push_back((byte)Instruction::NOT); // Push the positive location. unsigned endLocation = (unsigned)o_code.size(); @@ -500,8 +502,6 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes pushLocation(o_code, 0); // Jump to end... - if (t == "WHEN") - o_code.push_back((byte)Instruction::NOT); o_code.push_back((byte)Instruction::JUMPI); // Second fragment - negative. @@ -532,6 +532,7 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes // First fragment - predicate appendCode(o_code, o_locs, codes[0], locs[0]); + o_code.push_back((byte)Instruction::NOT); // Push the positive location. unsigned endInsertion = (unsigned)o_code.size(); @@ -539,7 +540,6 @@ static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes pushLocation(o_code, 0); // Jump to positive if true. - o_code.push_back((byte)Instruction::NOT); o_code.push_back((byte)Instruction::JUMPI); // Second fragment - negative. diff --git a/libethereum/State.cpp b/libethereum/State.cpp index 0f468f8f7..5f17bb236 100644 --- a/libethereum/State.cpp +++ b/libethereum/State.cpp @@ -616,14 +616,14 @@ void State::execute(bytesConstRef _rlp) throw InvalidNonce(nonceReq, t.nonce); } - // Don't like transactions whose gas price is too low. + // Don't like transactions whose gas price is too low. NOTE: this won't stay here forever - it's just until we get a proper gas proce discovery protocol going. if (t.gasPrice < 10 * szabo) { clog(StateChat) << "Offered gas-price is too low."; throw GasPriceTooLow(); } - // Entry point for a contract-originated transaction. + // Check gas cost is enough. u256 gasCost; if (t.isCreation()) gasCost = (t.init.size() + t.data.size()) * c_txDataGas + c_createGas; diff --git a/libethereum/VM.h b/libethereum/VM.h index b5d4df738..374d0a2c2 100644 --- a/libethereum/VM.h +++ b/libethereum/VM.h @@ -41,8 +41,8 @@ inline Address asAddress(u256 _item) inline u256 fromAddress(Address _a) { - u256 ret; - memcpy(&_a, &ret, sizeof(_a)); + h256 ret; + memcpy(&ret, &_a, sizeof(_a)); return ret; } @@ -176,7 +176,8 @@ template eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps) m_gas = (u256)((bigint)m_gas - runGas); - m_temp.resize(newTempSize); + if (newTempSize > m_temp.size()) + m_temp.resize(newTempSize); // EXECUTE... switch (inst)