diff options
author | obscuren <geffobscura@gmail.com> | 2015-06-18 18:25:02 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-06-18 18:25:02 +0800 |
commit | 430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb (patch) | |
tree | 27cf31245ff3360432582666e1d894ee14c4463f | |
parent | 15e169e5b6566b77aba23cc04c2f19a94ff23738 (diff) | |
download | go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.tar go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.tar.gz go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.tar.bz2 go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.tar.lz go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.tar.xz go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.tar.zst go-tangerine-430bcdb21959e018fbc93bac0ccd8bbfa2fd5afb.zip |
core/vm: clarified SSTORE
-rw-r--r-- | core/vm/vm.go | 12 |
1 files 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()) { |