From 875b0251144ee24ef5b69d17e4ff68f303513f44 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Tue, 7 Oct 2014 18:00:10 +0200 Subject: [PATCH] PoC-7: Remove POST, move CALLSTATELESS -> CALLCODE = 0xf3. --- libevm/VM.h | 33 ++------------------------------- libevmface/Instruction.cpp | 6 ++---- libevmface/Instruction.h | 3 +-- 3 files changed, 5 insertions(+), 37 deletions(-) diff --git a/libevm/VM.h b/libevm/VM.h index 04804ffd5..33a40e6c6 100644 --- a/libevm/VM.h +++ b/libevm/VM.h @@ -171,18 +171,12 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); break; - case Instruction::CALLSTATELESS: + case Instruction::CALLCODE: require(7); runGas = c_callGas + m_stack[m_stack.size() - 1]; newTempSize = std::max(memNeed(m_stack[m_stack.size() - 6], m_stack[m_stack.size() - 7]), memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5])); break; - case Instruction::POST: - require(5); - runGas = c_callGas + m_stack[m_stack.size() - 1]; - newTempSize = memNeed(m_stack[m_stack.size() - 4], m_stack[m_stack.size() - 5]); - break; - case Instruction::CREATE: { require(3); @@ -611,7 +605,7 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con break; } case Instruction::CALL: - case Instruction::CALLSTATELESS: + case Instruction::CALLCODE: { require(7); @@ -662,29 +656,6 @@ template dev::bytesConstRef dev::eth::VM::go(Ext& _ext, OnOpFunc con } case Instruction::STOP: return bytesConstRef(); - case Instruction::POST: - { - require(5); - - u256 gas = m_stack.back(); - m_stack.pop_back(); - u160 receiveAddress = asAddress(m_stack.back()); - m_stack.pop_back(); - u256 value = m_stack.back(); - m_stack.pop_back(); - - unsigned inOff = (unsigned)m_stack.back(); - m_stack.pop_back(); - unsigned inSize = (unsigned)m_stack.back(); - m_stack.pop_back(); - - if (_ext.balance(_ext.myAddress) >= value) - { - _ext.subBalance(value); - _ext.post(receiveAddress, value, bytesConstRef(m_temp.data() + inOff, inSize), gas); - } - break; - } default: BOOST_THROW_EXCEPTION(BadInstruction()); } diff --git a/libevmface/Instruction.cpp b/libevmface/Instruction.cpp index f8c7f5078..b9ade2c2d 100644 --- a/libevmface/Instruction.cpp +++ b/libevmface/Instruction.cpp @@ -148,9 +148,8 @@ const std::map dev::eth::c_instructions = { "SWAP16", Instruction::SWAP16 }, { "CREATE", Instruction::CREATE }, { "CALL", Instruction::CALL }, - { "CALLSTATELESS", Instruction::CALLSTATELESS }, + { "CALLCODE", Instruction::CALLCODE }, { "RETURN", Instruction::RETURN }, - { "POST", Instruction::POST }, { "SUICIDE", Instruction::SUICIDE } }; @@ -275,9 +274,8 @@ static const std::map c_instructionInfo = { Instruction::SWAP16, { "SWAP16", 0, 17, 17 } }, { Instruction::CREATE, { "CREATE", 0, 3, 1 } }, { Instruction::CALL, { "CALL", 0, 7, 1 } }, - { Instruction::CALLSTATELESS, { "CALLSTATELESS",0, 7, 1 } }, + { Instruction::CALLCODE, { "CALLCODE",0, 7, 1 } }, { Instruction::RETURN, { "RETURN", 0, 2, 0 } }, - { Instruction::POST, { "POST", 0, 5, 0 } }, { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0} } }; diff --git a/libevmface/Instruction.h b/libevmface/Instruction.h index 6c87b7a76..001d778a8 100644 --- a/libevmface/Instruction.h +++ b/libevmface/Instruction.h @@ -163,8 +163,7 @@ enum class Instruction: uint8_t CREATE = 0xf0, ///< create a new account with associated code CALL, ///< message-call into an account RETURN, ///< halt execution returning output data - POST, ///< asynchronous call without output (adds a message to the post queue) - CALLSTATELESS, + CALLCODE, SUICIDE = 0xff ///< halt execution and register account for later deletion };