Browse Source

Cleanups.

cl-refactor
Gav Wood 10 years ago
parent
commit
5cc2152dd0
  1. 25
      libethereum/Executive.cpp
  2. 2
      libethereum/Executive.h
  3. 2
      libethereum/ExtVM.h
  4. 3
      libethereum/State.cpp
  5. 2
      libevm/VM.h
  6. 2
      test/state.cpp

25
libethereum/Executive.cpp

@ -105,11 +105,13 @@ bool Executive::call(Address _receiveAddress, Address _codeAddress, Address _sen
if (_gas < g)
{
m_endGas = 0;
return false;
m_excepted = true;
}
else
{
m_endGas = (u256)(_gas - g);
it->second.exec(_data, bytesRef());
}
m_endGas = (u256)(_gas - g);
it->second.exec(_data, bytesRef());
return true;
}
else if (m_s.addressHasCode(_codeAddress))
{
@ -169,8 +171,6 @@ bool Executive::go(OnOpFunc const& _onOp)
{
m_out = m_vm->go(*m_ext, _onOp);
m_endGas = m_vm->gas();
m_endGas += min((m_t.gas() - m_endGas) / 2, m_ext->sub.refunds);
m_logs = m_ext->sub.logs;
if (m_isCreation)
{
@ -188,11 +188,10 @@ bool Executive::go(OnOpFunc const& _onOp)
{
clog(StateChat) << "Safe VM Exception: " << diagnostic_information(_e);
m_endGas = 0;//m_vm->gas();
m_excepted = true;
// Write state out only in the case of a non-excepted transaction.
m_ext->revert();
m_excepted = true;
}
catch (Exception const& _e)
{
@ -209,10 +208,10 @@ bool Executive::go(OnOpFunc const& _onOp)
return true;
}
u256 Executive::gas() const
/*u256 Executive::gas() const
{
return m_vm ? m_vm->gas() : m_endGas;
}
}*/
void Executive::finalize(OnOpFunc const&)
{
@ -220,6 +219,9 @@ void Executive::finalize(OnOpFunc const&)
// creation - put code in place.
m_s.m_cache[m_newAddress].setCode(m_out);
// SSTORE refunds.
m_endGas += min((m_t.gas() - m_endGas) / 2, m_ext->sub.refunds);
// cnote << "Refunding" << formatBalance(m_endGas * m_ext->gasPrice) << "to origin (=" << m_endGas << "*" << formatBalance(m_ext->gasPrice) << ")";
m_s.addBalance(m_sender, m_endGas * m_t.gasPrice());
@ -231,4 +233,7 @@ void Executive::finalize(OnOpFunc const&)
if (m_ext)
for (auto a: m_ext->sub.suicides)
m_s.m_cache[a].kill();
// Logs
m_logs = m_ext->sub.logs;
}

2
libethereum/Executive.h

@ -59,7 +59,7 @@ public:
Transaction const& t() const { return m_t; }
u256 gas() const;
u256 endGas() const { return m_endGas; }
bytesConstRef out() const { return m_out; }
h160 newAddress() const { return m_newAddress; }

2
libethereum/ExtVM.h

@ -55,7 +55,7 @@ public:
virtual bytes const& codeAt(Address _a) override final { return m_s.code(_a); }
/// Create a new contract.
virtual h160 create(u256 _endowment, u256& io_gas, bytesConstRef _code, OnOpFunc const& _onOp = OnOpFunc()) override final
virtual h160 create(u256 _endowment, u256& io_gas, bytesConstRef _code, OnOpFunc const& _onOp = {}) override final
{
// Increment associated nonce for sender.
m_s.noteSending(myAddress);

3
libethereum/State.cpp

@ -1187,10 +1187,9 @@ bool State::call(Address _receiveAddress, Address _codeAddress, Address _senderA
}
e.out().copyTo(_out);
io_gas = e.gas();
io_gas = e.endGas();
return !e.excepted();
#else
if (!_originAddress)
_originAddress = _senderAddress;

2
libevm/VM.h

@ -828,7 +828,7 @@ inline bytesConstRef VM::go(ExtVMFace& _ext, OnOpFunc const& _onOp, uint64_t _st
if (_ext.depth == 1024)
BOOST_THROW_EXCEPTION(OutOfGas());
_ext.subBalance(value);
m_stack.push_back(_ext.call(inst == Instruction::CALL ? receiveAddress : _ext.myAddress, value, bytesConstRef(m_temp.data() + inOff, inSize), gas, bytesRef(m_temp.data() + outOff, outSize), _onOp, Address(), receiveAddress));
m_stack.push_back(_ext.call(inst == Instruction::CALL ? receiveAddress : _ext.myAddress, value, bytesConstRef(m_temp.data() + inOff, inSize), gas, bytesRef(m_temp.data() + outOff, outSize), _onOp, {}, receiveAddress));
}
else
m_stack.push_back(0);

2
test/state.cpp

@ -45,7 +45,7 @@ void doStateTests(json_spirit::mValue& v, bool _fillin)
{
for (auto& i: v.get_obj())
{
cnote << i.first;
cerr << i.first << endl;
mObject& o = i.second.get_obj();
BOOST_REQUIRE(o.count("env") > 0);

Loading…
Cancel
Save