aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-03-27 23:53:05 +0800
committerobscuren <geffobscura@gmail.com>2015-03-27 23:53:05 +0800
commit3ea8c7301e6227467e39ae3daa0f382f06b16fba (patch)
treefe6876e4d80a5811243747dacd4d4fea3c53b2fb /core/vm
parentdf648cbc60f53dd334bd41b713e08ceac08212a0 (diff)
downloadgo-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.tar
go-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.tar.gz
go-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.tar.bz2
go-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.tar.lz
go-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.tar.xz
go-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.tar.zst
go-tangerine-3ea8c7301e6227467e39ae3daa0f382f06b16fba.zip
PUSH gas fix
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/gas.go8
-rw-r--r--core/vm/vm.go18
2 files changed, 5 insertions, 21 deletions
diff --git a/core/vm/gas.go b/core/vm/gas.go
index e64810cd5..2d5d7ae18 100644
--- a/core/vm/gas.go
+++ b/core/vm/gas.go
@@ -61,8 +61,8 @@ func baseCheck(op OpCode, stack *stack, gas *big.Int) error {
if op >= PUSH1 && op <= PUSH32 {
op = PUSH1
}
- if op >= SWAP1 && op <= SWAP16 {
- op = SWAP1
+ if op >= DUP1 && op <= DUP16 {
+ op = DUP1
}
if r, ok := _baseCheck[op]; ok {
@@ -71,7 +71,7 @@ func baseCheck(op OpCode, stack *stack, gas *big.Int) error {
return err
}
- if r.stackPush && len(stack.data)-r.stackPop == 1024 {
+ if r.stackPush && len(stack.data)-r.stackPop+1 > 1024 {
return fmt.Errorf("stack limit reached (%d)", maxStack)
}
@@ -154,6 +154,6 @@ var _baseCheck = map[OpCode]req{
JUMPDEST: {0, GasJumpDest, false},
SUICIDE: {1, Zero, false},
RETURN: {2, Zero, false},
- PUSH1: {0, GasFastStep, true},
+ PUSH1: {0, GasFastestStep, true},
DUP1: {0, Zero, true},
}
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 0618446c2..88fbdf763 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -45,23 +45,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
self.Printf("(%d) (%x) %x (code=%d) gas: %v (d) %x", self.env.Depth(), caller.Address().Bytes()[:4], context.Address(), len(code), context.Gas, callData).Endl()
- /*
- if self.Recoverable {
- // Recover from any require exception
- defer func() {
- if r := recover(); r != nil {
- self.Printf(" %v", r).Endl()
-
- context.UseGas(context.Gas)
-
- ret = context.Return(nil)
-
- err = fmt.Errorf("%v", r)
- }
- }()
- }
- */
-
+ // User defer pattern to check for an error and, based on the error being nil or not, use all gas and return.
defer func() {
if err != nil {
self.Printf(" %v", err).Endl()