aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-03 20:29:52 +0800
committerobscuren <geffobscura@gmail.com>2015-03-03 20:29:52 +0800
commitfa831206c617b398c3b74a1b6589893cd9dde6bd (patch)
treec975ff97f4af816e3c768a57d5a9c538abe4eabb /vm
parentffa6b99ab638af7bb6753b663612bad48019c334 (diff)
downloadgo-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.tar
go-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.tar.gz
go-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.tar.bz2
go-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.tar.lz
go-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.tar.xz
go-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.tar.zst
go-tangerine-fa831206c617b398c3b74a1b6589893cd9dde6bd.zip
Updated gast costs
Diffstat (limited to 'vm')
-rw-r--r--vm/common.go7
-rw-r--r--vm/vm.go16
2 files changed, 9 insertions, 14 deletions
diff --git a/vm/common.go b/vm/common.go
index af458e599..919153335 100644
--- a/vm/common.go
+++ b/vm/common.go
@@ -45,7 +45,7 @@ var (
GasLogTopic = big.NewInt(375)
GasLogByte = big.NewInt(8)
GasCreate = big.NewInt(32000)
- GasCreateByte = big.NewInt(300)
+ GasCreateByte = big.NewInt(200)
GasCall = big.NewInt(40)
GasCallValueTransfer = big.NewInt(9000)
GasStipend = big.NewInt(2300)
@@ -61,8 +61,9 @@ var (
GasQuadCoeffDenom = big.NewInt(512)
GasContractByte = big.NewInt(200)
GasTransaction = big.NewInt(21000)
- GasTxDataNonzeroByte = big.NewInt(37)
- GasTxZeroByte = big.NewInt(2)
+ GasTxDataNonzeroByte = big.NewInt(68)
+ GasTxDataZeroByte = big.NewInt(4)
+ GasTx = big.NewInt(21000)
GasExp = big.NewInt(10)
GasExpByte = big.NewInt(10)
diff --git a/vm/vm.go b/vm/vm.go
index 03acb72d2..bce8088ef 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -931,9 +931,9 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
words := toWordSize(stack.data[stack.Len()-4])
gas.Add(gas, words.Mul(words, GasCopyWord))
+
case CREATE:
- size := new(big.Int).Set(stack.data[stack.Len()-2])
- gas.Add(gas, size.Mul(size, GasCreateByte))
+ newMemSize = calcMemSize(stack.data[stack.Len()-2], stack.data[stack.Len()-3])
case CALL, CALLCODE:
gas.Add(gas, stack.data[stack.Len()-1])
@@ -941,17 +941,16 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
if self.env.State().GetStateObject(stack.data[stack.Len()-2].Bytes()) == nil {
gas.Add(gas, GasCallNewAccount)
}
+ }
- if len(stack.data[stack.Len()-3].Bytes()) > 0 {
- gas.Add(gas, GasCallValueTransfer)
- }
+ if len(stack.data[stack.Len()-3].Bytes()) > 0 {
+ gas.Add(gas, GasCallValueTransfer)
}
x := calcMemSize(stack.data[stack.Len()-6], stack.data[stack.Len()-7])
y := calcMemSize(stack.data[stack.Len()-4], stack.data[stack.Len()-5])
newMemSize = ethutil.BigMax(x, y)
- newMemSize = calcMemSize(stack.data[stack.Len()-2], stack.data[stack.Len()-3])
}
if newMemSize.Cmp(ethutil.Big0) > 0 {
@@ -959,11 +958,6 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
newMemSize.Mul(newMemSizeWords, u256(32))
if newMemSize.Cmp(u256(int64(mem.Len()))) > 0 {
- //memGasUsage := new(big.Int).Sub(newMemSize, u256(int64(mem.Len())))
- //memGasUsage.Mul(GasMemWord, memGasUsage)
- //memGasUsage.Div(memGasUsage, u256(32))
-
- //Old: full_memory_gas_cost = W + floor(W*W / 1024), W = words in memory
oldSize := toWordSize(big.NewInt(int64(mem.Len())))
pow := new(big.Int).Exp(oldSize, ethutil.Big2, Zero)
linCoef := new(big.Int).Mul(oldSize, GasMemWord)