Adding instruction name to BadInstruction
This commit is contained in:
parent
e9cc821969
commit
4d41c3352e
@ -14,9 +14,13 @@ pub enum Error {
|
|||||||
OutOfGas,
|
OutOfGas,
|
||||||
/// `BadJumpDestination` is returned when execution tried to move
|
/// `BadJumpDestination` is returned when execution tried to move
|
||||||
/// to position that wasn't marked with JUMPDEST instruction
|
/// to position that wasn't marked with JUMPDEST instruction
|
||||||
BadJumpDestination,
|
BadJumpDestination {
|
||||||
|
destination: usize
|
||||||
|
},
|
||||||
/// `BadInstructions` is returned when given instruction is not supported
|
/// `BadInstructions` is returned when given instruction is not supported
|
||||||
BadInstruction,
|
BadInstruction {
|
||||||
|
instruction: &'static str,
|
||||||
|
},
|
||||||
/// `StackUnderflow` when there is not enough stack elements to execute instruction
|
/// `StackUnderflow` when there is not enough stack elements to execute instruction
|
||||||
/// First parameter says how many elements were needed and the second how many were actually on Stack
|
/// First parameter says how many elements were needed and the second how many were actually on Stack
|
||||||
StackUnderflow {
|
StackUnderflow {
|
||||||
|
@ -243,10 +243,14 @@ impl Interpreter {
|
|||||||
let info = instructions::get_info(instruction);
|
let info = instructions::get_info(instruction);
|
||||||
|
|
||||||
if !schedule.have_delegate_call && instruction == instructions::DELEGATECALL {
|
if !schedule.have_delegate_call && instruction == instructions::DELEGATECALL {
|
||||||
return Err(evm::Error::BadInstruction);
|
return Err(evm::Error::BadInstruction {
|
||||||
|
instruction: info.name
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if info.tier == instructions::GasPriceTier::InvalidTier {
|
if info.tier == instructions::GasPriceTier::InvalidTier {
|
||||||
return Err(evm::Error::BadInstruction);
|
return Err(evm::Error::BadInstruction {
|
||||||
|
instruction: info.name
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(self.verify_instructions_requirements(&info, schedule.stack_limit, stack));
|
try!(self.verify_instructions_requirements(&info, schedule.stack_limit, stack));
|
||||||
@ -656,7 +660,9 @@ impl Interpreter {
|
|||||||
if valid_jump_destinations.contains(&jump) {
|
if valid_jump_destinations.contains(&jump) {
|
||||||
Ok(jump)
|
Ok(jump)
|
||||||
} else {
|
} else {
|
||||||
Err(evm::Error::BadJumpDestination)
|
Err(evm::Error::BadJumpDestination {
|
||||||
|
destination: jump
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,8 +219,8 @@ impl<'a> Executive<'a> {
|
|||||||
Err(evm::Error::Internal) => Err(ExecutionError::Internal),
|
Err(evm::Error::Internal) => Err(ExecutionError::Internal),
|
||||||
// TODO [ToDr] BadJumpDestination @debris - how to handle that?
|
// TODO [ToDr] BadJumpDestination @debris - how to handle that?
|
||||||
Err(evm::Error::OutOfGas)
|
Err(evm::Error::OutOfGas)
|
||||||
| Err(evm::Error::BadJumpDestination)
|
| Err(evm::Error::BadJumpDestination { destination: _ })
|
||||||
| Err(evm::Error::BadInstruction)
|
| Err(evm::Error::BadInstruction { instruction: _ })
|
||||||
| Err(evm::Error::StackUnderflow {instruction: _, wanted: _, on_stack: _})
|
| Err(evm::Error::StackUnderflow {instruction: _, wanted: _, on_stack: _})
|
||||||
| Err(evm::Error::OutOfStack {instruction: _, wanted: _, limit: _}) => {
|
| Err(evm::Error::OutOfStack {instruction: _, wanted: _, limit: _}) => {
|
||||||
*self.state = backup;
|
*self.state = backup;
|
||||||
|
Loading…
Reference in New Issue
Block a user