Browse Source

Minor cleanup.

cl-refactor
Gav Wood 10 years ago
parent
commit
c9cea539b2
  1. 5
      libethereum/Executive.cpp
  2. 19
      libethereum/State.cpp

5
libethereum/Executive.cpp

@ -113,12 +113,13 @@ bool Executive::call(Address _receiveAddress, Address _senderAddress, u256 _valu
auto it = !(_receiveAddress & ~h160(0xffffffff)) ? State::precompiled().find((unsigned)(u160)_receiveAddress) : State::precompiled().end();
if (it != State::precompiled().end())
{
if (_gas < it->second.gas(_data))
bigint g = it->second.gas(_data);
if (_gas < g)
{
m_endGas = 0;
return false;
}
m_endGas = (u256)(_gas - it->second.gas(_data));
m_endGas = (u256)(_gas - g);
it->second.exec(_data, bytesRef());
return true;
}

19
libethereum/State.cpp

@ -1216,8 +1216,6 @@ bool State::call(Address _receiveAddress, Address _codeAddress, Address _senderA
{
VM vm(*_gas);
ExtVM evm(*this, _receiveAddress, _senderAddress, _originAddress, _value, _gasPrice, _data, &code(_codeAddress), o_ms, _level);
bool revert = false;
try
{
auto out = vm.go(evm, _onOp);
@ -1227,29 +1225,30 @@ bool State::call(Address _receiveAddress, Address _codeAddress, Address _senderA
if (o_ms)
o_ms->output = out.toBytes();
*_gas = vm.gas();
// Write state out only in the case of a non-excepted transaction.
return true;
}
catch (VMException const& _e)
{
clog(StateChat) << "Safe VM Exception: " << diagnostic_information(_e);
revert = true;
evm.revert();
*_gas = 0;
return false;
}
catch (Exception const& _e)
{
cwarn << "Unexpected exception in VM: " << diagnostic_information(_e) << ". This is exceptionally bad.";
// TODO: use fallback known-safe VM.
// AUDIT: THIS SHOULD NEVER HAPPEN! PROVE IT!
throw;
}
catch (std::exception const& _e)
{
cwarn << "Unexpected exception in VM: " << _e.what() << ". This is exceptionally bad.";
// TODO: use fallback known-safe VM.
// AUDIT: THIS SHOULD NEVER HAPPEN! PROVE IT!
throw;
}
// Write state out only in the case of a non-excepted transaction.
if (revert)
evm.revert();
return !revert;
}
return true;
}
@ -1305,11 +1304,13 @@ h160 State::create(Address _sender, u256 _endowment, u256 _gasPrice, u256* _gas,
{
// TODO: AUDIT: check that this can never reasonably happen. Consider what to do if it does.
cwarn << "Unexpected exception in VM. There may be a bug in this implementation. " << diagnostic_information(_e);
throw;
}
catch (std::exception const& _e)
{
// TODO: AUDIT: check that this can never reasonably happen. Consider what to do if it does.
cwarn << "Unexpected std::exception in VM. This is probably unrecoverable. " << _e.what();
throw;
}
return newAddress;

Loading…
Cancel
Save