Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Very basic EVM binary. (#1574)
Browse files Browse the repository at this point in the history
* EVM binary - initial version

* Adding missing documentation

* Fixing warnings

* Basic evmbin options

* EVMbin crate.
  • Loading branch information
tomusdrw authored and gavofyork committed Jul 11, 2016
1 parent e15f631 commit 2ed09de
Show file tree
Hide file tree
Showing 7 changed files with 1,299 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ethcore/src/evm/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,17 @@ impl<'a> Finalize for Result<GasLeft<'a>> {
}
}

/// Cost calculation type. For low-gas usage we calculate costs using usize instead of U256
pub trait CostType: ops::Mul<Output=Self> + ops::Div<Output=Self> + ops::Add<Output=Self> + ops::Sub<Output=Self> + ops::Shr<usize, Output=Self> + ops::Shl<usize, Output=Self> + cmp::Ord + Sized + From<usize> + Copy {
/// Converts this cost into `U256`
fn as_u256(&self) -> U256;
/// Tries to fit `U256` into this `Cost` type
fn from_u256(val: U256) -> Result<Self>;
/// Convert to usize (may panic)
fn as_usize(&self) -> usize;
/// Add with overflow
fn overflow_add(self, other: Self) -> (Self, bool);
/// Multiple with overflow
fn overflow_mul(self, other: Self) -> (Self, bool);
}

Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/evm/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

///! Rust VM implementation
//! Rust VM implementation
#[cfg(not(feature = "evm-debug"))]
macro_rules! evm_debug {
Expand Down Expand Up @@ -182,6 +182,7 @@ impl<Cost: CostType> Interpreter<Cost> {
instruction: instruction
});
}

if info.tier == instructions::GasPriceTier::Invalid {
return Err(evm::Error::BadInstruction {
instruction: instruction
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ pub mod pod_state;
pub mod engine;
pub mod migrations;
pub mod miner;
#[macro_use] pub mod evm;
pub mod action_params;

mod blooms;
mod db;
mod common;
mod basic_types;
#[macro_use] mod evm;
mod env_info;
mod pod_account;
mod state;
mod account;
mod account_db;
mod action_params;
mod null_engine;
mod builtin;
mod substate;
Expand Down
Loading

0 comments on commit 2ed09de

Please sign in to comment.