2019-01-07 11:33:07 +01:00
|
|
|
// Copyright 2015-2019 Parity Technologies (UK) Ltd.
|
|
|
|
// This file is part of Parity Ethereum.
|
2017-08-01 12:37:57 +02:00
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is free software: you can redistribute it and/or modify
|
2017-08-01 12:37:57 +02:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
2019-01-07 11:33:07 +01:00
|
|
|
// Parity Ethereum is distributed in the hope that it will be useful,
|
2017-08-01 12:37:57 +02:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2019-01-07 11:33:07 +01:00
|
|
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
2017-08-01 12:37:57 +02:00
|
|
|
|
|
|
|
//! Virtual machines support library
|
|
|
|
|
2018-01-10 13:35:18 +01:00
|
|
|
extern crate ethereum_types;
|
2017-08-01 12:37:57 +02:00
|
|
|
extern crate ethjson;
|
2017-11-10 19:04:55 +01:00
|
|
|
extern crate keccak_hash as hash;
|
2020-08-05 06:08:03 +02:00
|
|
|
extern crate parity_bytes as bytes;
|
2018-07-02 18:50:05 +02:00
|
|
|
extern crate patricia_trie_ethereum as ethtrie;
|
2020-08-05 06:08:03 +02:00
|
|
|
extern crate rlp;
|
2017-08-01 12:37:57 +02:00
|
|
|
|
|
|
|
mod action_params;
|
|
|
|
mod call_type;
|
|
|
|
mod env_info;
|
2020-08-05 06:08:03 +02:00
|
|
|
mod error;
|
2017-08-01 12:37:57 +02:00
|
|
|
mod ext;
|
|
|
|
mod return_data;
|
2020-08-05 06:08:03 +02:00
|
|
|
mod schedule;
|
2017-08-01 12:37:57 +02:00
|
|
|
|
2017-08-01 13:33:49 +02:00
|
|
|
pub mod tests;
|
|
|
|
|
2017-11-02 12:49:57 +01:00
|
|
|
pub use action_params::{ActionParams, ActionValue, ParamsType};
|
2017-08-01 12:37:57 +02:00
|
|
|
pub use call_type::CallType;
|
|
|
|
pub use env_info::{EnvInfo, LastHashes};
|
2020-08-05 06:08:03 +02:00
|
|
|
pub use error::{Error, ExecTrapError, ExecTrapResult, Result, TrapError, TrapKind, TrapResult};
|
|
|
|
pub use ext::{ContractCreateResult, CreateContractAddress, Ext, MessageCallResult};
|
|
|
|
pub use return_data::{GasLeft, ReturnData};
|
|
|
|
pub use schedule::{CleanDustMode, Schedule, WasmCosts};
|
2017-08-01 12:37:57 +02:00
|
|
|
|
|
|
|
/// Virtual Machine interface
|
2018-10-02 16:33:19 +02:00
|
|
|
pub trait Exec: Send {
|
2020-08-05 06:08:03 +02:00
|
|
|
/// This function should be used to execute transaction.
|
|
|
|
/// It returns either an error, a known amount of gas left, or parameters to be used
|
|
|
|
/// to compute the final gas left.
|
2020-07-29 10:36:15 +02:00
|
|
|
fn exec(self: Box<Self>, ext: &mut dyn Ext) -> ExecTrapResult<GasLeft>;
|
2018-10-02 16:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Resume call interface
|
|
|
|
pub trait ResumeCall: Send {
|
2020-08-05 06:08:03 +02:00
|
|
|
/// Resume an execution for call, returns back the Vm interface.
|
2020-07-29 10:36:15 +02:00
|
|
|
fn resume_call(self: Box<Self>, result: MessageCallResult) -> Box<dyn Exec>;
|
2018-10-02 16:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Resume create interface
|
|
|
|
pub trait ResumeCreate: Send {
|
2020-08-05 06:08:03 +02:00
|
|
|
/// Resume an execution from create, returns back the Vm interface.
|
2020-07-29 10:36:15 +02:00
|
|
|
fn resume_create(self: Box<Self>, result: ContractCreateResult) -> Box<dyn Exec>;
|
2017-08-30 19:18:28 +02:00
|
|
|
}
|