2015-12-30 12:46:10 +01:00
|
|
|
//! Evm interface.
|
2015-12-28 22:37:15 +01:00
|
|
|
|
2016-01-11 16:33:08 +01:00
|
|
|
use common::*;
|
|
|
|
use evm::Ext;
|
2015-12-28 22:37:15 +01:00
|
|
|
|
2016-01-11 02:17:29 +01:00
|
|
|
/// Evm errors.
|
2016-01-11 14:08:03 +01:00
|
|
|
#[derive(Debug)]
|
2016-01-11 17:01:42 +01:00
|
|
|
pub enum Error {
|
2016-01-11 03:13:41 +01:00
|
|
|
/// `OutOfGas` is returned when transaction execution runs out of gas.
|
2016-01-11 02:17:29 +01:00
|
|
|
/// The state should be reverted to the state from before the
|
|
|
|
/// transaction execution. But it does not mean that transaction
|
|
|
|
/// was invalid. Balance still should be transfered and nonce
|
|
|
|
/// should be increased.
|
2015-12-28 22:37:15 +01:00
|
|
|
OutOfGas,
|
2016-01-13 00:13:09 +01:00
|
|
|
/// `BadJumpDestination` is returned when execution tried to move
|
|
|
|
/// to position that wasn't marked with JUMPDEST instruction
|
|
|
|
BadJumpDestination,
|
2016-01-11 02:17:29 +01:00
|
|
|
/// Returned on evm internal error. Should never be ignored during development.
|
|
|
|
/// Likely to cause consensus issues.
|
|
|
|
Internal,
|
2015-12-28 22:37:15 +01:00
|
|
|
}
|
|
|
|
|
2016-01-11 02:17:29 +01:00
|
|
|
/// Evm result.
|
|
|
|
///
|
|
|
|
/// Returns gas_left if execution is successfull, otherwise error.
|
2016-01-11 17:01:42 +01:00
|
|
|
pub type Result = result::Result<U256, Error>;
|
2016-01-11 02:17:29 +01:00
|
|
|
|
|
|
|
/// Evm interface.
|
2015-12-28 22:37:15 +01:00
|
|
|
pub trait Evm {
|
2016-01-11 02:17:29 +01:00
|
|
|
/// This function should be used to execute transaction.
|
2016-01-11 17:01:42 +01:00
|
|
|
fn exec(&self, params: &ActionParams, ext: &mut Ext) -> Result;
|
2015-12-28 22:37:15 +01:00
|
|
|
}
|