Skip to content

Commit

Permalink
Merge pull request #5 from harishbm34/upgrade-10
Browse files Browse the repository at this point in the history
upgraded the files to sputnikvm-0.10
  • Loading branch information
Mike Lubinets authored Sep 20, 2018
2 parents e326fba + c72fea0 commit ed82639
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
15 changes: 13 additions & 2 deletions c/ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,16 @@ crate-type = ["staticlib", "cdylib"]

[dependencies]
libc = "0.2"
etcommon-bigint = { version = "0.2", default-features = false, features = ["rlp"] }
sputnikvm = { version = "0.9", default-features = false, features = ["std", "rust-secp256k1"] }
etcommon-bigint = { version = "0.2", default-features = false }
sputnikvm = { version = "0.10", default-features = false }
sputnikvm-network-classic = { version = "0.10.1", default-features = false }
etcommon-block = "0.3"
etcommon-hexutil = "0.2"
clap = "2.22"

[features]
default = ["std", "c-secp256k1", "rlp"]
rlp = ["etcommon-bigint/rlp", "sputnikvm-network-classic/rlp"]
c-secp256k1 = ["sputnikvm/c-secp256k1", "sputnikvm-network-classic/c-secp256k1"]
rust-secp256k1 = ["sputnikvm/rust-secp256k1", "sputnikvm-network-classic/rust-secp256k1"]
std = ["sputnikvm/std", "sputnikvm-network-classic/std"]
36 changes: 20 additions & 16 deletions c/ffi/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
extern crate libc;
extern crate bigint;
extern crate clap;
extern crate sputnikvm;
extern crate sputnikvm_network_classic;
extern crate hexutil;
extern crate block;


mod common;

Expand All @@ -12,11 +17,17 @@ use std::rc::Rc;
use std::ops::DerefMut;
use std::collections::HashMap;
use libc::{c_uchar, c_uint, c_longlong};
use bigint::{U256, M256};
use sputnikvm::{TransactionAction, ValidTransaction, HeaderParams, SeqTransactionVM, Patch,
MainnetFrontierPatch, MainnetHomesteadPatch, MainnetEIP150Patch, MainnetEIP160Patch,
VM, VMStatus, RequireError, AccountCommitment, AccountChange,
FrontierPatch, HomesteadPatch, EIP150Patch, EIP160Patch, AccountPatch};
use bigint::{Gas, Address, U256, M256, H256};
use block::TransactionAction;

use sputnikvm::{HeaderParams, Context, SeqTransactionVM, ValidTransaction, VM, Log, Patch,
AccountCommitment, AccountChange, VMStatus};
use sputnikvm_network_classic::{MainnetFrontierPatch, MainnetHomesteadPatch,
MainnetEIP150Patch, MainnetEIP160Patch};
use sputnikvm::errors::RequireError;
use sputnikvm::AccountPatch;
use sputnikvm_network_classic::{FrontierPatch, HomesteadPatch, EIP150Patch, EIP160Patch};


type c_action = c_uchar;
#[no_mangle]
Expand All @@ -27,6 +38,8 @@ pub static CREATE_ACTION: c_action = 1;
pub struct MordenAccountPatch;
impl AccountPatch for MordenAccountPatch {
fn initial_nonce() -> U256 { U256::from(1048576) }
fn initial_create_nonce() -> U256 { Self::initial_nonce() }
fn empty_considered_exists() -> bool { true }
}

pub type MordenFrontierPatch = FrontierPatch<MordenAccountPatch>;
Expand All @@ -39,6 +52,8 @@ static mut CUSTOM_INITIAL_NONCE: Option<U256> = None;
pub struct CustomAccountPatch;
impl AccountPatch for CustomAccountPatch {
fn initial_nonce() -> U256 { U256::from(unsafe { CUSTOM_INITIAL_NONCE.unwrap() }) }
fn initial_create_nonce() -> U256 { Self::initial_nonce() }
fn empty_considered_exists() -> bool { true }
}

pub type CustomFrontierPatch = FrontierPatch<CustomAccountPatch>;
Expand Down Expand Up @@ -609,17 +624,6 @@ pub extern "C" fn sputnikvm_account_changes_copy_info(
}
}
},
&AccountChange::DecreaseBalance(address, amount) => {
c_account_change {
typ: c_account_change_type::decrease_balance,
value: c_account_change_value {
balance: c_account_change_value_balance {
address: address.into(),
amount: amount.into(),
},
}
}
},
}
}
}
Expand Down

0 comments on commit ed82639

Please sign in to comment.