Replace raw throw with BOOST_THROW_EXCEPTION.

This commit is contained in:
Alexander Arlt
2021-02-18 20:23:59 -05:00
parent 5c6633f975
commit c44bb7e7ef
14 changed files with 70 additions and 67 deletions
@@ -95,7 +95,7 @@ u256 EVMInstructionInterpreter::eval(
switch (_instruction)
{
case Instruction::STOP:
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
// --------------- arithmetic ---------------
case Instruction::ADD:
return arg[0] + arg[1];
@@ -328,18 +328,18 @@ u256 EVMInstructionInterpreter::eval(
if (accessMemory(arg[0], arg[1]))
data = readMemory(arg[0], arg[1]);
logTrace(_instruction, arg, data);
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
}
case Instruction::REVERT:
accessMemory(arg[0], arg[1]);
logTrace(_instruction, arg);
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
case Instruction::INVALID:
logTrace(_instruction);
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
case Instruction::SELFDESTRUCT:
logTrace(_instruction, arg);
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
case Instruction::POP:
break;
// --------------- invalid in strict assembly ---------------
@@ -527,6 +527,6 @@ void EVMInstructionInterpreter::logTrace(std::string const& _pseudoInstruction,
if (m_state.maxTraceSize > 0 && m_state.trace.size() >= m_state.maxTraceSize)
{
m_state.trace.emplace_back("Trace size limit reached.");
throw TraceLimitReached();
BOOST_THROW_EXCEPTION(TraceLimitReached());
}
}
@@ -178,7 +178,7 @@ u256 EwasmBuiltinInterpreter::evalBuiltin(
else if (fun == "unreachable")
{
logTrace(evmasm::Instruction::INVALID, {});
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
}
else if (fun == "i64.store")
{
@@ -258,14 +258,14 @@ u256 EwasmBuiltinInterpreter::evalWasmBuiltin(string const& _fun, vector<Word> c
else if (_fun == "div_u")
{
if (arg[1] == 0)
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
else
return arg[0] / arg[1];
}
else if (_fun == "rem_u")
{
if (arg[1] == 0)
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
else
return arg[0] % arg[1];
}
@@ -337,7 +337,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
else if (_fun == "callDataCopy")
{
if (arg[1] + arg[2] < arg[1] || arg[1] + arg[2] > m_state.calldata.size())
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
accessMemory(arg[0], arg[2]);
copyZeroExtended(
m_state.memory, m_state.calldata,
@@ -446,7 +446,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
accessMemory(arg[0], arg[1]);
uint64_t numberOfTopics = arg[2];
if (numberOfTopics > 4)
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
if (numberOfTopics > 0)
readBytes32(arg[3]);
if (numberOfTopics > 1)
@@ -471,7 +471,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
accessMemory(arg[0], arg[1]);
data = readMemory(arg[0], arg[1]);
logTrace(evmasm::Instruction::RETURN, {}, data);
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
}
else if (_fun == "revert")
{
@@ -479,14 +479,14 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
accessMemory(arg[0], arg[1]);
data = readMemory(arg[0], arg[1]);
logTrace(evmasm::Instruction::REVERT, {}, data);
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
}
else if (_fun == "getReturnDataSize")
return m_state.returndata.size();
else if (_fun == "returnDataCopy")
{
if (arg[1] + arg[2] < arg[1] || arg[1] + arg[2] > m_state.returndata.size())
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
accessMemory(arg[0], arg[2]);
copyZeroExtended(
m_state.memory, m_state.calldata,
@@ -498,7 +498,7 @@ u256 EwasmBuiltinInterpreter::evalEthBuiltin(string const& _fun, vector<uint64_t
{
readAddress(arg[0]);
logTrace(evmasm::Instruction::SELFDESTRUCT, {});
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
}
else if (_fun == "getBlockTimestamp")
return m_state.timestamp;
@@ -516,7 +516,7 @@ void EwasmBuiltinInterpreter::accessMemory(u256 const& _offset, u256 const& _siz
if (((_offset + _size) < _offset) || ((_offset + _size) > m_state.msize))
// Ewasm throws out of bounds exception as opposed to the EVM.
throw ExplicitlyTerminated();
BOOST_THROW_EXCEPTION(ExplicitlyTerminated());
}
bytes EwasmBuiltinInterpreter::readMemory(uint64_t _offset, uint64_t _size)
@@ -604,6 +604,6 @@ void EwasmBuiltinInterpreter::logTrace(std::string const& _pseudoInstruction, st
if (m_state.maxTraceSize > 0 && m_state.trace.size() >= m_state.maxTraceSize)
{
m_state.trace.emplace_back("Trace size limit reached.");
throw TraceLimitReached();
BOOST_THROW_EXCEPTION(TraceLimitReached());
}
}
+2 -2
View File
@@ -241,7 +241,7 @@ void Interpreter::incrementStep()
if (m_state.maxSteps > 0 && m_state.numSteps >= m_state.maxSteps)
{
m_state.trace.emplace_back("Interpreter execution step limit reached.");
throw StepLimitReached();
BOOST_THROW_EXCEPTION(StepLimitReached());
}
}
@@ -351,6 +351,6 @@ void ExpressionEvaluator::incrementStep()
if (m_state.maxExprNesting > 0 && m_nestingLevel > m_state.maxExprNesting)
{
m_state.trace.emplace_back("Maximum expression nesting level reached.");
throw ExpressionNestingLimitReached();
BOOST_THROW_EXCEPTION(ExpressionNestingLimitReached());
}
}