Browse Source

enable debugging of excepted transactions

cl-refactor
arkpar 10 years ago
parent
commit
7d89b9530c
  1. 38
      mix/ClientModel.cpp
  2. 1
      mix/MachineStates.h
  3. 32
      mix/MixClient.cpp

38
mix/ClientModel.cpp

@ -449,6 +449,44 @@ void ClientModel::executeSequence(vector<TransactionSettings> const& _sequence)
}
m_gasCosts.append(m_client->lastExecution().gasUsed);
onNewTransaction();
TransactionException exception = m_client->lastExecution().excepted;
if (exception != TransactionException::None)
{
switch (m_client->lastExecution().excepted)
{
case TransactionException::None:
break;
case TransactionException::NotEnoughCash:
emit runFailed("Insufficient balance for contract deployment");
break;
case TransactionException::OutOfGasIntrinsic:
case TransactionException::OutOfGasBase:
case TransactionException::OutOfGas:
emit runFailed("Not enough gas");
break;
case TransactionException::BlockGasLimitReached:
emit runFailed("Block gas limit reached");
break;
case TransactionException::BadJumpDestination:
emit runFailed("Solidity exception (bad jump)");
break;
case TransactionException::OutOfStack:
emit runFailed("Out of stack");
break;
case TransactionException::StackUnderflow:
emit runFailed("Stack underflow");
//these should not happen in mix
case TransactionException::Unknown:
case TransactionException::BadInstruction:
case TransactionException::InvalidSignature:
case TransactionException::InvalidNonce:
case TransactionException::InvalidFormat:
case TransactionException::BadRLP:
emit runFailed("Internal execution error");
break;
}
break;
}
}
emit runComplete();
}

1
mix/MachineStates.h

@ -85,6 +85,7 @@ struct ExecutionResult
unsigned executonIndex = 0;
bytes inputParameters;
eth::LocalisedLogEntries logs;
eth::TransactionException excepted = eth::TransactionException::Unknown;
bool isCall() const { return transactionIndex == std::numeric_limits<unsigned>::max(); }
bool isConstructor() const { return !isCall() && !address; }

32
mix/MixClient.cpp

@ -199,35 +199,8 @@ ExecutionResult MixClient::debugTransaction(Transaction const& _t, State const&
execution.go(onOp);
execution.finalize();
switch (er.excepted)
{
case TransactionException::None:
break;
case TransactionException::NotEnoughCash:
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Insufficient balance for contract deployment"));
case TransactionException::OutOfGasIntrinsic:
case TransactionException::OutOfGasBase:
case TransactionException::OutOfGas:
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Not enough gas"));
case TransactionException::BlockGasLimitReached:
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Block gas limit reached"));
case TransactionException::BadJumpDestination:
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Solidity exception (bad jump)"));
case TransactionException::OutOfStack:
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Out of stack"));
case TransactionException::StackUnderflow:
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Stack underflow"));
//these should not happen in mix
case TransactionException::Unknown:
case TransactionException::BadInstruction:
case TransactionException::InvalidSignature:
case TransactionException::InvalidNonce:
case TransactionException::InvalidFormat:
case TransactionException::BadRLP:
BOOST_THROW_EXCEPTION(Exception() << errinfo_comment("Internal execution error"));
}
ExecutionResult d;
d.excepted = er.excepted;
d.inputParameters = _t.data();
d.result = er;
d.machineStates = machineStates;
@ -257,7 +230,8 @@ void MixClient::executeTransaction(Transaction const& _t, Block& _block, bool _c
// execute on a state
if (!_call)
{
t = _gasAuto ? replaceGas(_t, d.gasUsed, _secret) : _t;
u256 useGas = min(d.gasUsed, _block.gasLimitRemaining());
t = _gasAuto ? replaceGas(_t, useGas, _secret) : _t;
eth::ExecutionResult const& er = _block.execute(envInfo.lastHashes(), t);
if (t.isCreation() && _block.state().code(d.contractAddress).empty())
BOOST_THROW_EXCEPTION(OutOfGas() << errinfo_comment("Not enough gas for contract deployment"));

Loading…
Cancel
Save