Browse Source

PoC-7: Remove POST, move CALLSTATELESS -> CALLCODE = 0xf3.

cl-refactor
Gav Wood 11 years ago
parent
commit
875b025114
  1. 33
      libevm/VM.h
  2. 6
      libevmface/Instruction.cpp
  3. 3
      libevmface/Instruction.h

33
libevm/VM.h

@ -171,18 +171,12 @@ template <class Ext> 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 <class Ext> 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 <class Ext> 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());
}

6
libevmface/Instruction.cpp

@ -148,9 +148,8 @@ const std::map<std::string, Instruction> 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<Instruction, InstructionInfo> 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} }
};

3
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
};

Loading…
Cancel
Save