From 430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb Mon Sep 17 00:00:00 2001 From: obscuren Date: Thu, 18 Jun 2015 12:25:02 +0200 Subject: [PATCH] core/vm: clarified SSTORE --- core/vm/vm.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/core/vm/vm.go b/core/vm/vm.go index 336f6cf95..9e092300d 100644 --- a/core/vm/vm.go +++ b/core/vm/vm.go @@ -686,6 +686,11 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo var g *big.Int y, x := stack.data[stack.len()-2], stack.data[stack.len()-1] val := statedb.GetState(context.Address(), common.BigToHash(x)) + + // This checks for 3 scenario's and calculates gas accordingly + // 1. From a zero-value address to a non-zero value (NEW VALUE) + // 2. From a non-zero value address to a zero-value address (DELETE) + // 3. From a nen-zero to a non-zero (CHANGE) if common.EmptyHash(val) && !common.EmptyHash(common.BigToHash(y)) { // 0 => non 0 g = params.SstoreSetGas @@ -697,13 +702,6 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo // non 0 => non 0 (or 0 => 0) g = params.SstoreClearGas } - - /* - if len(val) == 0 && len(y.Bytes()) > 0 { - } else if len(val) > 0 && len(y.Bytes()) == 0 { - } else { - } - */ gas.Set(g) case SUICIDE: if !statedb.IsDeleted(context.Address()) {