From b754313ad8eff3ffcb5982065c1bd64a7d18ed7b Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 15 Jan 2016 01:20:08 +0100 Subject: [PATCH 1/4] out_of_gas -> excepted --- src/executive.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/executive.rs b/src/executive.rs index edbad0887..7fc529d4a 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -22,7 +22,7 @@ pub struct Substate { /// Refund counter of SSTORE nonzero->zero. refunds_count: U256, /// True if transaction, or one of its subcalls runs out of gas. - out_of_gas: bool, + excepted: bool, /// Created contracts. contracts_created: Vec
} @@ -34,7 +34,7 @@ impl Substate { suicides: HashSet::new(), logs: vec![], refunds_count: U256::zero(), - out_of_gas: false, + excepted: false, contracts_created: vec![] } } @@ -43,11 +43,11 @@ impl Substate { self.suicides.extend(s.suicides.into_iter()); self.logs.extend(s.logs.into_iter()); self.refunds_count = self.refunds_count + s.refunds_count; - self.out_of_gas |= s.out_of_gas; + self.excepted |= s.excepted; self.contracts_created.extend(s.contracts_created.into_iter()); } - pub fn out_of_gas(&self) -> bool { self.out_of_gas } + pub fn excepted(&self) -> bool { self.excepted } } /// Transaction execution receipt. @@ -69,7 +69,7 @@ pub struct Executed { /// Vector of logs generated by transaction. pub logs: Vec, /// Execution ended running out of gas. - pub out_of_gas: bool, + pub excepted: bool, /// Addresses of contracts created during execution of transaction. /// Ordered from earliest creation. /// @@ -288,7 +288,7 @@ impl<'a> Executive<'a> { refunded: refund, cumulative_gas_used: self.info.gas_used + gas_used, logs: substate.logs, - out_of_gas: substate.out_of_gas, + excepted: substate.excepted, contracts_created: substate.contracts_created }) }, @@ -299,7 +299,7 @@ impl<'a> Executive<'a> { refunded: U256::zero(), cumulative_gas_used: self.info.gas_used + t.gas, logs: vec![], - out_of_gas: true, + excepted: true, contracts_created: vec![] }) } @@ -310,7 +310,7 @@ impl<'a> Executive<'a> { // TODO: handle other evm::Errors same as OutOfGas once they are implemented match result { &Err(evm::Error::OutOfGas) => { - substate.out_of_gas = true; + substate.excepted = true; self.state.revert(backup); }, &Ok(_) | &Err(evm::Error::Internal) => substate.accrue(un_substate) @@ -894,7 +894,7 @@ mod tests { assert_eq!(executed.refunded, U256::from(58_699)); assert_eq!(executed.cumulative_gas_used, U256::from(41_301)); assert_eq!(executed.logs.len(), 0); - assert_eq!(executed.out_of_gas, false); + assert_eq!(executed.excepted, false); assert_eq!(executed.contracts_created.len(), 0); assert_eq!(state.balance(&sender), U256::from(1)); assert_eq!(state.balance(&contract), U256::from(17)); From d674c7520e0bf466918dc4d811a8b0287610b523 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 15 Jan 2016 02:01:07 +0100 Subject: [PATCH 2/4] updated to rocksdb wrapper version 0.3 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index bffab3ac3..d9092de53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ env_logger = "0.3" ethcore-util = { path = "../ethcore-util" } rustc-serialize = "0.3" flate2 = "0.2" -rocksdb = "0.2" +rocksdb = "0.3" heapsize = "0.2.0" rust-crypto = "0.2.34" time = "0.1" From 952efb93ac10bf65eaab7adae97a645697364562 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 15 Jan 2016 11:39:10 +0100 Subject: [PATCH 3/4] fixed builtin outofgas --- src/executive.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/executive.rs b/src/executive.rs index 75195dc06..d229f9894 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -207,7 +207,10 @@ impl<'a> Executive<'a> { Ok(params.gas - cost) }, // just drain the whole gas - false => Ok(U256::zero()) + false => { + substate.excepted = true; + Ok(params.gas) + } } } else if params.code.len() > 0 { // if destination is a contract, do normal message call From 87539234e31e6067be21561b1ce1452c7caeaaf6 Mon Sep 17 00:00:00 2001 From: debris Date: Fri, 15 Jan 2016 11:59:05 +0100 Subject: [PATCH 4/4] builin fail should return 0 gas left --- src/executive.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/executive.rs b/src/executive.rs index de4d3d10f..04f22bd74 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -209,7 +209,7 @@ impl<'a> Executive<'a> { // just drain the whole gas false => { substate.excepted = true; - Ok(params.gas) + Ok(U256::zero()) } } } else if params.code.len() > 0 {