From 0414331d72ac2c361e5afad4f538cade3b20f85d Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 15 Oct 2018 07:17:07 +0800 Subject: [PATCH 1/6] Add signed refund --- ethcore/src/lib.rs | 1 + ethcore/src/signed.rs | 129 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 ethcore/src/signed.rs diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index fefa9b5e051..c9778999416 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -173,6 +173,7 @@ mod externalities; mod blockchain; mod factory; mod tx_filter; +mod signed; #[cfg(test)] mod tests; diff --git a/ethcore/src/signed.rs b/ethcore/src/signed.rs new file mode 100644 index 00000000000..b4bc11b29e7 --- /dev/null +++ b/ethcore/src/signed.rs @@ -0,0 +1,129 @@ +// Copyright 2015-2018 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// 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. + +// Parity is distributed in the hope that it will be useful, +// 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 +// along with Parity. If not, see . + +//! Small utility for signed 256-bit integer. + +use std::ops::{Add, AddAssign, Sub, SubAssign}; +use ethereum_types::U256; + +/// Sign of a 256-bit integer. +#[derive(Copy, Clone, Eq, PartialEq)] +pub enum Sign { + Positive, + Zero, + Negative +} + +/// Representation of a signed 256-bit integer. +#[derive(Copy, Clone, Eq, PartialEq)] +pub struct I256(Sign, U256); + +impl From for I256 { + fn from(value: U256) -> Self { + if value.is_zero() { + I256(Sign::Zero, value) + } else { + I256(Sign::Positive, value) + } + } +} + +impl Add for I256 { + type Output = Self; + + fn add(mut self, other: U256) -> Self { + self.add_assign(other); + self + } +} + +impl AddAssign for I256 { + fn add_assign(&mut self, other: U256) { + match self.0 { + Sign::Positive => { + self.1 += other; + }, + Sign::Zero => { + self.0 = Sign::Positive; + self.1 = other; + }, + Sign::Negative => { + if other > self.1 { + self.0 = Sign::Positive; + self.1 = other - self.1; + } else if other < self.1 { + self.1 -= other; + } else { + self.0 = Sign::Zero; + self.1 = U256::zero(); + } + }, + } + } +} + +impl Sub for I256 { + type Output = Self; + + fn sub(mut self, other: U256) -> Self { + self.sub_assign(other); + self + } +} + +impl SubAssign for I256 { + fn sub_assign(&mut self, other: U256) { + match self.0 { + Sign::Positive => { + if other > self.1 { + self.0 = Sign::Negative; + self.1 = other - self.1; + } else if other < self.1 { + self.1 -= other; + } else { + self.0 = Sign::Zero; + self.1 = U256::zero(); + } + }, + Sign::Zero => { + self.0 = Sign::Negative; + self.1 = other; + }, + Sign::Negative => { + self.1 += other; + }, + } + } +} + +impl Add for I256 { + type Output = Self; + + fn add(mut self, other: I256) -> Self { + self.add_assign(other); + self + } +} + +impl AddAssign for I256 { + fn add_assign(&mut self, other: I256) { + match other.0 { + Sign::Positive => *self += other.1, + Sign::Zero => (), + Sign::Negative => *self -= other.1, + } + } +} From e1453da722eee0eb7cae1e94db1313ed98a56a1b Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 15 Oct 2018 07:28:10 +0800 Subject: [PATCH 2/6] Use signed 256-bit integer for sstore gas refund substate --- ethcore/src/executive.rs | 3 ++- ethcore/src/externalities.rs | 4 ++-- ethcore/src/signed.rs | 27 +++++++++++++++++++++++++-- ethcore/src/state/substate.rs | 7 ++++--- 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index cc9ac9a0bae..9894ae3c6a5 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -1091,7 +1091,8 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> { let schedule = self.schedule; // refunds from SSTORE nonzero -> zero - let sstore_refunds = substate.sstore_clears_refund; + assert!(substate.sstore_clears_refund.is_nonnegative(), "On transaction level, sstore clears refund cannot go below zero."); + let sstore_refunds = substate.sstore_clears_refund.abs(); // refunds from contract suicides let suicide_refunds = U256::from(schedule.suicide_refund_gas) * U256::from(substate.suicides.len()); let refunds_bound = sstore_refunds + suicide_refunds; diff --git a/ethcore/src/externalities.rs b/ethcore/src/externalities.rs index df8a9c75a24..a8a051f185e 100644 --- a/ethcore/src/externalities.rs +++ b/ethcore/src/externalities.rs @@ -395,11 +395,11 @@ impl<'a, T: 'a, V: 'a, B: 'a> Ext for Externalities<'a, T, V, B> } fn add_sstore_refund(&mut self, value: U256) { - self.substate.sstore_clears_refund = self.substate.sstore_clears_refund.saturating_add(value); + self.substate.sstore_clears_refund += value; } fn sub_sstore_refund(&mut self, value: U256) { - self.substate.sstore_clears_refund = self.substate.sstore_clears_refund.saturating_sub(value); + self.substate.sstore_clears_refund -= value; } fn trace_next_instruction(&mut self, pc: usize, instruction: u8, current_gas: U256) -> bool { diff --git a/ethcore/src/signed.rs b/ethcore/src/signed.rs index b4bc11b29e7..da6f54f48a7 100644 --- a/ethcore/src/signed.rs +++ b/ethcore/src/signed.rs @@ -20,7 +20,7 @@ use std::ops::{Add, AddAssign, Sub, SubAssign}; use ethereum_types::U256; /// Sign of a 256-bit integer. -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum Sign { Positive, Zero, @@ -28,9 +28,32 @@ pub enum Sign { } /// Representation of a signed 256-bit integer. -#[derive(Copy, Clone, Eq, PartialEq)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] pub struct I256(Sign, U256); +impl I256 { + /// Get the absolute value of the signed integer. + pub fn abs(&self) -> U256 { + self.1 + } + + /// Get the sign of the integer. + pub fn sign(&self) -> Sign { + self.0 + } + + /// Check whether the signed integer is non-negative. + pub fn is_nonnegative(&self) -> bool { + self.0 != Sign::Negative + } +} + +impl Default for I256 { + fn default() -> Self { + I256(Sign::Zero, U256::zero()) + } +} + impl From for I256 { fn from(value: U256) -> Self { if value.is_zero() { diff --git a/ethcore/src/state/substate.rs b/ethcore/src/state/substate.rs index 054b8b384bb..f2fba3454b3 100644 --- a/ethcore/src/state/substate.rs +++ b/ethcore/src/state/substate.rs @@ -16,7 +16,8 @@ //! Execution environment substate. use std::collections::HashSet; -use ethereum_types::{U256, Address}; +use ethereum_types::Address; +use signed::I256; use log_entry::LogEntry; use evm::{Schedule, CleanDustMode}; use super::CleanupMode; @@ -35,7 +36,7 @@ pub struct Substate { pub logs: Vec, /// Refund counter of SSTORE. - pub sstore_clears_refund: U256, + pub sstore_clears_refund: I256, /// Created contracts. pub contracts_created: Vec
, @@ -52,7 +53,7 @@ impl Substate { self.suicides.extend(s.suicides); self.touched.extend(s.touched); self.logs.extend(s.logs); - self.sstore_clears_refund = self.sstore_clears_refund + s.sstore_clears_refund; + self.sstore_clears_refund += s.sstore_clears_refund; self.contracts_created.extend(s.contracts_created); } From b71e74b3f43f725f4e07b5fc52230ec0eac9bf12 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 15 Oct 2018 08:02:51 +0800 Subject: [PATCH 3/6] Fix tests --- ethcore/src/executive.rs | 6 ++++-- ethcore/src/signed.rs | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 9894ae3c6a5..dd4e059986b 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -2096,7 +2096,8 @@ mod tests { let gas_used = gas - gas_left; // sstore: 0 -> (1) -> () -> (1 -> 0 -> 1) assert_eq!(gas_used, U256::from(41860)); - assert_eq!(refund, U256::from(19800)); + assert!(refund.is_nonnegative()); + assert_eq!(refund.abs(), U256::from(19800)); assert_eq!(state.storage_at(&operating_address, &k).unwrap(), H256::from(U256::from(1))); // Test a call via top-level -> y2 -> x2 @@ -2114,7 +2115,8 @@ mod tests { let gas_used = gas - gas_left; // sstore: 1 -> (1) -> () -> (0 -> 1 -> 0) assert_eq!(gas_used, U256::from(11860)); - assert_eq!(refund, U256::from(19800)); + assert!(refund.is_nonnegative()); + assert_eq!(refund.abs(), U256::from(19800)); } fn wasm_sample_code() -> Arc> { diff --git a/ethcore/src/signed.rs b/ethcore/src/signed.rs index da6f54f48a7..2093115d628 100644 --- a/ethcore/src/signed.rs +++ b/ethcore/src/signed.rs @@ -54,6 +54,12 @@ impl Default for I256 { } } +impl From for I256 { + fn from(value: u64) -> Self { + I256::from(U256::from(value)) + } +} + impl From for I256 { fn from(value: U256) -> Self { if value.is_zero() { From d4c303a2fba578111b8fc5dca0024179efa8be2f Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 15 Oct 2018 15:56:32 +0800 Subject: [PATCH 4/6] Remove signed mod and use i128 directly --- ethcore/evm/src/interpreter/gasometer.rs | 6 +- ethcore/evm/src/interpreter/mod.rs | 2 +- ethcore/src/executive.rs | 10 +- ethcore/src/externalities.rs | 8 +- ethcore/src/lib.rs | 1 - ethcore/src/signed.rs | 158 ----------------------- ethcore/src/state/substate.rs | 3 +- ethcore/vm/src/ext.rs | 4 +- ethcore/vm/src/tests.rs | 10 +- ethcore/wasm/src/runtime.rs | 2 +- 10 files changed, 21 insertions(+), 183 deletions(-) delete mode 100644 ethcore/src/signed.rs diff --git a/ethcore/evm/src/interpreter/gasometer.rs b/ethcore/evm/src/interpreter/gasometer.rs index 524791fe95c..60ea30da042 100644 --- a/ethcore/evm/src/interpreter/gasometer.rs +++ b/ethcore/evm/src/interpreter/gasometer.rs @@ -403,7 +403,7 @@ fn calculate_eip1283_sstore_gas(schedule: &Schedule, origina } pub fn handle_eip1283_sstore_clears_refund(ext: &mut vm::Ext, original: &U256, current: &U256, new: &U256) { - let sstore_clears_schedule = U256::from(ext.schedule().sstore_refund_gas); + let sstore_clears_schedule = ext.schedule().sstore_refund_gas; if current == new { // 1. If current value equals new value (this is a no-op), 200 gas is deducted. @@ -438,11 +438,11 @@ pub fn handle_eip1283_sstore_clears_refund(ext: &mut vm::Ext, original: &U256, c // 2.2.2. If original value equals new value (this storage slot is reset) if original.is_zero() { // 2.2.2.1. If original value is 0, add 19800 gas to refund counter. - let refund = U256::from(ext.schedule().sstore_set_gas - ext.schedule().sload_gas); + let refund = ext.schedule().sstore_set_gas - ext.schedule().sload_gas; ext.add_sstore_refund(refund); } else { // 2.2.2.2. Otherwise, add 4800 gas to refund counter. - let refund = U256::from(ext.schedule().sstore_reset_gas - ext.schedule().sload_gas); + let refund = ext.schedule().sstore_reset_gas - ext.schedule().sload_gas; ext.add_sstore_refund(refund); } } diff --git a/ethcore/evm/src/interpreter/mod.rs b/ethcore/evm/src/interpreter/mod.rs index d1661532029..87f6aac815d 100644 --- a/ethcore/evm/src/interpreter/mod.rs +++ b/ethcore/evm/src/interpreter/mod.rs @@ -720,7 +720,7 @@ impl Interpreter { gasometer::handle_eip1283_sstore_clears_refund(ext, &original_val, ¤t_val, &val); } else { if !current_val.is_zero() && val.is_zero() { - let sstore_clears_schedule = U256::from(ext.schedule().sstore_refund_gas); + let sstore_clears_schedule = ext.schedule().sstore_refund_gas; ext.add_sstore_refund(sstore_clears_schedule); } } diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index dd4e059986b..9ad15c1aa4a 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -1091,8 +1091,8 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> { let schedule = self.schedule; // refunds from SSTORE nonzero -> zero - assert!(substate.sstore_clears_refund.is_nonnegative(), "On transaction level, sstore clears refund cannot go below zero."); - let sstore_refunds = substate.sstore_clears_refund.abs(); + assert!(substate.sstore_clears_refund >= 0, "On transaction level, sstore clears refund cannot go below zero."); + let sstore_refunds = U256::from(substate.sstore_clears_refund as u64); // refunds from contract suicides let suicide_refunds = U256::from(schedule.suicide_refund_gas) * U256::from(substate.suicides.len()); let refunds_bound = sstore_refunds + suicide_refunds; @@ -2096,8 +2096,7 @@ mod tests { let gas_used = gas - gas_left; // sstore: 0 -> (1) -> () -> (1 -> 0 -> 1) assert_eq!(gas_used, U256::from(41860)); - assert!(refund.is_nonnegative()); - assert_eq!(refund.abs(), U256::from(19800)); + assert_eq!(refund, 19800); assert_eq!(state.storage_at(&operating_address, &k).unwrap(), H256::from(U256::from(1))); // Test a call via top-level -> y2 -> x2 @@ -2115,8 +2114,7 @@ mod tests { let gas_used = gas - gas_left; // sstore: 1 -> (1) -> () -> (0 -> 1 -> 0) assert_eq!(gas_used, U256::from(11860)); - assert!(refund.is_nonnegative()); - assert_eq!(refund.abs(), U256::from(19800)); + assert_eq!(refund, 19800); } fn wasm_sample_code() -> Arc> { diff --git a/ethcore/src/externalities.rs b/ethcore/src/externalities.rs index a8a051f185e..778ef5cc746 100644 --- a/ethcore/src/externalities.rs +++ b/ethcore/src/externalities.rs @@ -394,12 +394,12 @@ impl<'a, T: 'a, V: 'a, B: 'a> Ext for Externalities<'a, T, V, B> self.depth } - fn add_sstore_refund(&mut self, value: U256) { - self.substate.sstore_clears_refund += value; + fn add_sstore_refund(&mut self, value: usize) { + self.substate.sstore_clears_refund += value as i128; } - fn sub_sstore_refund(&mut self, value: U256) { - self.substate.sstore_clears_refund -= value; + fn sub_sstore_refund(&mut self, value: usize) { + self.substate.sstore_clears_refund -= value as i128; } fn trace_next_instruction(&mut self, pc: usize, instruction: u8, current_gas: U256) -> bool { diff --git a/ethcore/src/lib.rs b/ethcore/src/lib.rs index c9778999416..fefa9b5e051 100644 --- a/ethcore/src/lib.rs +++ b/ethcore/src/lib.rs @@ -173,7 +173,6 @@ mod externalities; mod blockchain; mod factory; mod tx_filter; -mod signed; #[cfg(test)] mod tests; diff --git a/ethcore/src/signed.rs b/ethcore/src/signed.rs deleted file mode 100644 index 2093115d628..00000000000 --- a/ethcore/src/signed.rs +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright 2015-2018 Parity Technologies (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// 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. - -// Parity is distributed in the hope that it will be useful, -// 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 -// along with Parity. If not, see . - -//! Small utility for signed 256-bit integer. - -use std::ops::{Add, AddAssign, Sub, SubAssign}; -use ethereum_types::U256; - -/// Sign of a 256-bit integer. -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -pub enum Sign { - Positive, - Zero, - Negative -} - -/// Representation of a signed 256-bit integer. -#[derive(Copy, Clone, Eq, PartialEq, Debug)] -pub struct I256(Sign, U256); - -impl I256 { - /// Get the absolute value of the signed integer. - pub fn abs(&self) -> U256 { - self.1 - } - - /// Get the sign of the integer. - pub fn sign(&self) -> Sign { - self.0 - } - - /// Check whether the signed integer is non-negative. - pub fn is_nonnegative(&self) -> bool { - self.0 != Sign::Negative - } -} - -impl Default for I256 { - fn default() -> Self { - I256(Sign::Zero, U256::zero()) - } -} - -impl From for I256 { - fn from(value: u64) -> Self { - I256::from(U256::from(value)) - } -} - -impl From for I256 { - fn from(value: U256) -> Self { - if value.is_zero() { - I256(Sign::Zero, value) - } else { - I256(Sign::Positive, value) - } - } -} - -impl Add for I256 { - type Output = Self; - - fn add(mut self, other: U256) -> Self { - self.add_assign(other); - self - } -} - -impl AddAssign for I256 { - fn add_assign(&mut self, other: U256) { - match self.0 { - Sign::Positive => { - self.1 += other; - }, - Sign::Zero => { - self.0 = Sign::Positive; - self.1 = other; - }, - Sign::Negative => { - if other > self.1 { - self.0 = Sign::Positive; - self.1 = other - self.1; - } else if other < self.1 { - self.1 -= other; - } else { - self.0 = Sign::Zero; - self.1 = U256::zero(); - } - }, - } - } -} - -impl Sub for I256 { - type Output = Self; - - fn sub(mut self, other: U256) -> Self { - self.sub_assign(other); - self - } -} - -impl SubAssign for I256 { - fn sub_assign(&mut self, other: U256) { - match self.0 { - Sign::Positive => { - if other > self.1 { - self.0 = Sign::Negative; - self.1 = other - self.1; - } else if other < self.1 { - self.1 -= other; - } else { - self.0 = Sign::Zero; - self.1 = U256::zero(); - } - }, - Sign::Zero => { - self.0 = Sign::Negative; - self.1 = other; - }, - Sign::Negative => { - self.1 += other; - }, - } - } -} - -impl Add for I256 { - type Output = Self; - - fn add(mut self, other: I256) -> Self { - self.add_assign(other); - self - } -} - -impl AddAssign for I256 { - fn add_assign(&mut self, other: I256) { - match other.0 { - Sign::Positive => *self += other.1, - Sign::Zero => (), - Sign::Negative => *self -= other.1, - } - } -} diff --git a/ethcore/src/state/substate.rs b/ethcore/src/state/substate.rs index f2fba3454b3..5565c8f91ee 100644 --- a/ethcore/src/state/substate.rs +++ b/ethcore/src/state/substate.rs @@ -17,7 +17,6 @@ //! Execution environment substate. use std::collections::HashSet; use ethereum_types::Address; -use signed::I256; use log_entry::LogEntry; use evm::{Schedule, CleanDustMode}; use super::CleanupMode; @@ -36,7 +35,7 @@ pub struct Substate { pub logs: Vec, /// Refund counter of SSTORE. - pub sstore_clears_refund: I256, + pub sstore_clears_refund: i128, /// Created contracts. pub contracts_created: Vec
, diff --git a/ethcore/vm/src/ext.rs b/ethcore/vm/src/ext.rs index aa45066b86d..a437da53e14 100644 --- a/ethcore/vm/src/ext.rs +++ b/ethcore/vm/src/ext.rs @@ -151,10 +151,10 @@ pub trait Ext { fn depth(&self) -> usize; /// Increments sstore refunds counter. - fn add_sstore_refund(&mut self, value: U256); + fn add_sstore_refund(&mut self, value: usize); /// Decrements sstore refunds counter. - fn sub_sstore_refund(&mut self, value: U256); + fn sub_sstore_refund(&mut self, value: usize); /// Decide if any more operations should be traced. Passthrough for the VM trace. fn trace_next_instruction(&mut self, _pc: usize, _instruction: u8, _current_gas: U256) -> bool { false } diff --git a/ethcore/vm/src/tests.rs b/ethcore/vm/src/tests.rs index 687fef999cc..00c986af107 100644 --- a/ethcore/vm/src/tests.rs +++ b/ethcore/vm/src/tests.rs @@ -57,7 +57,7 @@ pub struct FakeExt { pub store: HashMap, pub suicides: HashSet
, pub calls: HashSet, - pub sstore_clears: U256, + pub sstore_clears: i128, pub depth: usize, pub blockhashes: HashMap, pub codes: HashMap>, @@ -231,12 +231,12 @@ impl Ext for FakeExt { self.is_static } - fn add_sstore_refund(&mut self, value: U256) { - self.sstore_clears = self.sstore_clears + value; + fn add_sstore_refund(&mut self, value: usize) { + self.sstore_clears += value as i128; } - fn sub_sstore_refund(&mut self, value: U256) { - self.sstore_clears = self.sstore_clears - value; + fn sub_sstore_refund(&mut self, value: usize) { + self.sstore_clears -= value as i128; } fn trace_next_instruction(&mut self, _pc: usize, _instruction: u8, _gas: U256) -> bool { diff --git a/ethcore/wasm/src/runtime.rs b/ethcore/wasm/src/runtime.rs index a48ac970954..b6de43e9f91 100644 --- a/ethcore/wasm/src/runtime.rs +++ b/ethcore/wasm/src/runtime.rs @@ -285,7 +285,7 @@ impl<'a> Runtime<'a> { self.ext.set_storage(key, val).map_err(|_| Error::StorageUpdateError)?; if former_val != H256::zero() && val == H256::zero() { - let sstore_clears_schedule = U256::from(self.schedule().sstore_refund_gas); + let sstore_clears_schedule = self.schedule().sstore_refund_gas; self.ext.add_sstore_refund(sstore_clears_schedule); } From fa6ff1e8c9ec285304909e5bc90e2f2ae212a5d2 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 15 Oct 2018 16:03:21 +0800 Subject: [PATCH 5/6] Fix evm test case casting --- ethcore/evm/src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethcore/evm/src/tests.rs b/ethcore/evm/src/tests.rs index 49599f91d90..af16ab1e542 100644 --- a/ethcore/evm/src/tests.rs +++ b/ethcore/evm/src/tests.rs @@ -716,7 +716,7 @@ fn test_jumps(factory: super::Factory) { test_finalize(vm.exec(&mut ext).ok().unwrap()).unwrap() }; - assert_eq!(ext.sstore_clears, U256::from(ext.schedule().sstore_refund_gas)); + assert_eq!(ext.sstore_clears, ext.schedule().sstore_refund_gas as i128); assert_store(&ext, 0, "0000000000000000000000000000000000000000000000000000000000000000"); // 5! assert_store(&ext, 1, "0000000000000000000000000000000000000000000000000000000000000078"); // 5! assert_eq!(gas_left, U256::from(54_117)); From 218987a9bcc255463b663618557af4189af4ba3b Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Mon, 15 Oct 2018 16:06:19 +0800 Subject: [PATCH 6/6] Fix jsontests ext signature --- ethcore/src/json_tests/executive.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ethcore/src/json_tests/executive.rs b/ethcore/src/json_tests/executive.rs index 0f8903aedaf..1999ee4d6c4 100644 --- a/ethcore/src/json_tests/executive.rs +++ b/ethcore/src/json_tests/executive.rs @@ -218,11 +218,11 @@ impl<'a, T: 'a, V: 'a, B: 'a> Ext for TestExt<'a, T, V, B> false } - fn add_sstore_refund(&mut self, value: U256) { + fn add_sstore_refund(&mut self, value: usize) { self.ext.add_sstore_refund(value) } - fn sub_sstore_refund(&mut self, value: U256) { + fn sub_sstore_refund(&mut self, value: usize) { self.ext.sub_sstore_refund(value) } }