diff options
author | obscuren <geffobscura@gmail.com> | 2015-01-12 23:13:30 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-01-12 23:13:30 +0800 |
commit | 8a1b51c716abdc21a8af43282e106d77eda3706b (patch) | |
tree | 27ba3d93e330f7dfb51fcc0f8fc1959e7b7f1c09 /vm | |
parent | 75cd9cd2de315f8680ff6a382e9b3bd48e17ecad (diff) | |
download | dexon-8a1b51c716abdc21a8af43282e106d77eda3706b.tar.gz dexon-8a1b51c716abdc21a8af43282e106d77eda3706b.tar.zst dexon-8a1b51c716abdc21a8af43282e106d77eda3706b.zip |
updated tests
Diffstat (limited to 'vm')
-rw-r--r-- | vm/vm_debug.go | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/vm/vm_debug.go b/vm/vm_debug.go index fee42d3d8..81db45f19 100644 --- a/vm/vm_debug.go +++ b/vm/vm_debug.go @@ -48,6 +48,12 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price * }) context := NewContext(caller, me, code, gas, price) + vmlogger.Debugf("(%d) (%x) %x (code=%d) gas: %v (d) %x\n", self.env.Depth(), caller.Address()[:4], context.Address(), len(code), context.Gas, callData) + + if p := Precompiled[string(me.Address())]; p != nil { + return self.RunPrecompiled(p, callData, context) + } + if self.Recoverable { // Recover from any require exception defer func() { @@ -64,10 +70,6 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price * }() } - if p := Precompiled[string(me.Address())]; p != nil { - return self.RunPrecompiled(p, callData, context) - } - var ( op OpCode @@ -94,8 +96,6 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price * } ) - vmlogger.Debugf("(%d) (%x) %x (code=%d) gas: %v (d) %x\n", self.env.Depth(), caller.Address()[:4], context.Address(), len(code), context.Gas, callData) - // Don't bother with the execution if there's no code. if len(code) == 0 { return context.Return(nil), nil @@ -368,12 +368,14 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price * y := stack.Pop() z := stack.Pop() - base.Add(x, y) - base.Mod(base, z) + add := new(big.Int).Add(x, y) + if len(z.Bytes()) > 0 { // NOT 0x0 + base.Mod(add, z) - U256(base) + U256(base) + } - self.Printf(" = %v", base) + self.Printf(" %v + %v %% %v = %v", x, y, z, base) stack.Push(base) case MULMOD: @@ -382,12 +384,14 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price * y := stack.Pop() z := stack.Pop() - base.Mul(x, y) - base.Mod(base, z) + mul := new(big.Int).Mul(x, y) + if len(z.Bytes()) > 0 { // NOT 0x0 + base.Mod(mul, z) - U256(base) + U256(base) + } - self.Printf(" = %v", base) + self.Printf(" %v + %v %% %v = %v", x, y, z, base) stack.Push(base) @@ -541,6 +545,8 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price * self.Printf(" => 0x%x", difficulty.Bytes()) case GASLIMIT: + self.Printf(" => %v", self.env.GasLimit()) + stack.Push(self.env.GasLimit()) // 0x50 range @@ -933,13 +939,11 @@ func (self *DebugVm) RunPrecompiled(p *PrecompiledAccount, callData []byte, cont return context.Return(ret), nil } else { - self.Endl() + self.Printf("NATIVE_FUNC => failed").Endl() tmp := new(big.Int).Set(context.Gas) - context.UseGas(context.Gas) - - return context.Return(nil), OOG(gas, tmp) + panic(OOG(gas, tmp).Error()) } } |