Browse Source

Throw BadInstruction exception in FeeStructure::getInstructionFee() when instruction code is ivalid

cl-refactor
Paweł Bylica 10 years ago
parent
commit
dea94c669b
  1. 8
      libevm/FeeStructure.cpp
  2. 4
      libevm/FeeStructure.h

8
libevm/FeeStructure.cpp

@ -24,18 +24,22 @@
#include <libevmface/Instruction.h> #include <libevmface/Instruction.h>
#include "VM.h"
namespace dev namespace dev
{ {
namespace eth namespace eth
{ {
uint32_t FeeStructure::getInstructionFee(Instruction _inst) BOOST_NOEXCEPT_OR_NOTHROW uint32_t FeeStructure::getInstructionFee(Instruction _inst)
{ {
switch (_inst) switch (_inst)
{ {
default:
BOOST_THROW_EXCEPTION(BadInstruction());
case Instruction::STOP: case Instruction::STOP:
case Instruction::SUICIDE: case Instruction::SUICIDE:
default: // In case of bad instruction return 0
return 0; return 0;
case Instruction::SSTORE: case Instruction::SSTORE:

4
libevm/FeeStructure.h

@ -45,8 +45,8 @@ struct FeeStructure
static uint32_t const c_txGas = 500; ///< Per transaction. NOTE: Not payable on data of calls between transactions. static uint32_t const c_txGas = 500; ///< Per transaction. NOTE: Not payable on data of calls between transactions.
/// Returns step fee of the instruction. /// Returns step fee of the instruction.
/// In case of bad instruction code, returns 0. /// In case of bad instruction code, throws BadInstruction exception.
static uint32_t getInstructionFee(Instruction _inst) BOOST_NOEXCEPT_OR_NOTHROW; static uint32_t getInstructionFee(Instruction _inst);
}; };
} }

Loading…
Cancel
Save