Browse Source

PoC-5 new protocol changes.

cl-refactor
Gav Wood 11 years ago
parent
commit
632db94cca
  1. 10
      libethereum/State.cpp
  2. 15
      libethereum/VM.h

10
libethereum/State.cpp

@ -665,8 +665,8 @@ bytes const& State::code(Address _contract) const
u256 State::execute(bytesConstRef _rlp) u256 State::execute(bytesConstRef _rlp)
{ {
cnote << m_state.root() << m_state; // cnote << m_state.root() << m_state;
cnote << *this; // cnote << *this;
Executive e(*this); Executive e(*this);
e.setup(_rlp); e.setup(_rlp);
@ -680,9 +680,9 @@ u256 State::execute(bytesConstRef _rlp)
commit(); commit();
cnote << "Done TX"; // cnote << "Done TX";
cnote << m_state.root() << m_state; // cnote << m_state.root() << m_state;
cnote << *this; // cnote << *this;
// Add to the user-originated transactions that we've executed. // Add to the user-originated transactions that we've executed.
m_transactions.push_back(TransactionReceipt(e.t(), m_state.root(), startGasUSed + e.gasUsed())); m_transactions.push_back(TransactionReceipt(e.t(), m_state.root(), startGasUSed + e.gasUsed()));

15
libethereum/VM.h

@ -97,6 +97,10 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps)
runGas = 0; runGas = 0;
break; break;
case Instruction::SUICIDE:
runGas = 0;
break;
case Instruction::SSTORE: case Instruction::SSTORE:
require(2); require(2);
if (!_ext.store(m_stack.back()) && m_stack[m_stack.size() - 2]) if (!_ext.store(m_stack.back()) && m_stack[m_stack.size() - 2])
@ -148,7 +152,7 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps)
case Instruction::CALL: case Instruction::CALL:
require(7); require(7);
runGas = c_callGas + (unsigned)m_stack[m_stack.size() - 3]; runGas = c_callGas + (unsigned)m_stack[m_stack.size() - 1];
newTempSize = std::max((unsigned)m_stack[m_stack.size() - 6] + (unsigned)m_stack[m_stack.size() - 7], (unsigned)m_stack[m_stack.size() - 4] + (unsigned)m_stack[m_stack.size() - 5]); newTempSize = std::max((unsigned)m_stack[m_stack.size() - 6] + (unsigned)m_stack[m_stack.size() - 7], (unsigned)m_stack[m_stack.size() - 4] + (unsigned)m_stack[m_stack.size() - 5]);
break; break;
@ -529,12 +533,12 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps)
{ {
require(7); require(7);
u256 gas = m_stack.back();
m_stack.pop_back();
u160 receiveAddress = asAddress(m_stack.back()); u160 receiveAddress = asAddress(m_stack.back());
m_stack.pop_back(); m_stack.pop_back();
u256 value = m_stack.back(); u256 value = m_stack.back();
m_stack.pop_back(); m_stack.pop_back();
u256 gas = m_stack.back();
m_stack.pop_back();
unsigned inOff = (unsigned)m_stack.back(); unsigned inOff = (unsigned)m_stack.back();
m_stack.pop_back(); m_stack.pop_back();
@ -545,11 +549,6 @@ template <class Ext> eth::bytesConstRef eth::VM::go(Ext& _ext, uint64_t _steps)
unsigned outSize = (unsigned)m_stack.back(); unsigned outSize = (unsigned)m_stack.back();
m_stack.pop_back(); m_stack.pop_back();
if (!gas)
{
gas = m_gas;
m_gas = 0;
}
if (_ext.balance(_ext.myAddress) >= value) if (_ext.balance(_ext.myAddress) >= value)
{ {
_ext.subBalance(value); _ext.subBalance(value);

Loading…
Cancel
Save