CALLDATALOAD return 32 byte at all times
This commit is contained in:
parent
7f94bd09ae
commit
3bc57fe5b5
@ -225,29 +225,41 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
|||||||
case ADD:
|
case ADD:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
// (x + y) % 2 ** 256
|
vm.Printf(" %v + %v", y, x)
|
||||||
|
|
||||||
base.Add(y, x)
|
base.Add(y, x)
|
||||||
|
|
||||||
|
vm.Printf(" = %v", base)
|
||||||
// Pop result back on the stack
|
// Pop result back on the stack
|
||||||
stack.Push(base)
|
stack.Push(base)
|
||||||
case SUB:
|
case SUB:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
// (x - y) % 2 ** 256
|
vm.Printf(" %v - %v", y, x)
|
||||||
|
|
||||||
base.Sub(y, x)
|
base.Sub(y, x)
|
||||||
|
|
||||||
|
vm.Printf(" = %v", base)
|
||||||
// Pop result back on the stack
|
// Pop result back on the stack
|
||||||
stack.Push(base)
|
stack.Push(base)
|
||||||
case MUL:
|
case MUL:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
// (x * y) % 2 ** 256
|
vm.Printf(" %v * %v", y, x)
|
||||||
|
|
||||||
base.Mul(y, x)
|
base.Mul(y, x)
|
||||||
|
|
||||||
|
vm.Printf(" = %v", base)
|
||||||
// Pop result back on the stack
|
// Pop result back on the stack
|
||||||
stack.Push(base)
|
stack.Push(base)
|
||||||
case DIV:
|
case DIV:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
// floor(x / y)
|
vm.Printf(" %v / %v", y, x)
|
||||||
|
|
||||||
base.Div(y, x)
|
base.Div(y, x)
|
||||||
|
|
||||||
|
vm.Printf(" = %v", base)
|
||||||
// Pop result back on the stack
|
// Pop result back on the stack
|
||||||
stack.Push(base)
|
stack.Push(base)
|
||||||
case SDIV:
|
case SDIV:
|
||||||
@ -270,7 +282,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
|||||||
case MOD:
|
case MOD:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
|
|
||||||
|
vm.Printf(" %v %% %v", y, x)
|
||||||
|
|
||||||
base.Mod(y, x)
|
base.Mod(y, x)
|
||||||
|
|
||||||
|
vm.Printf(" = %v", base)
|
||||||
stack.Push(base)
|
stack.Push(base)
|
||||||
case SMOD:
|
case SMOD:
|
||||||
require(2)
|
require(2)
|
||||||
@ -292,8 +309,13 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
|||||||
case EXP:
|
case EXP:
|
||||||
require(2)
|
require(2)
|
||||||
x, y := stack.Popn()
|
x, y := stack.Popn()
|
||||||
|
|
||||||
|
vm.Printf(" %v ** %v", y, x)
|
||||||
|
|
||||||
base.Exp(y, x, Pow256)
|
base.Exp(y, x, Pow256)
|
||||||
|
|
||||||
|
vm.Printf(" = %v", base)
|
||||||
|
|
||||||
stack.Push(base)
|
stack.Push(base)
|
||||||
case NEG:
|
case NEG:
|
||||||
require(1)
|
require(1)
|
||||||
@ -393,12 +415,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
|||||||
require(1)
|
require(1)
|
||||||
offset := stack.Pop().Int64()
|
offset := stack.Pop().Int64()
|
||||||
|
|
||||||
var data []byte
|
data := make([]byte, 32)
|
||||||
if len(closure.Args) >= int(offset) {
|
if len(closure.Args) >= int(offset) {
|
||||||
l := int64(math.Min(float64(offset+32), float64(len(closure.Args))))
|
l := int64(math.Min(float64(offset+32), float64(len(closure.Args))))
|
||||||
data = closure.Args[offset : offset+l]
|
|
||||||
} else {
|
copy(data, closure.Args[offset:l])
|
||||||
data = []byte{0}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vm.Printf(" => 0x%x", data)
|
vm.Printf(" => 0x%x", data)
|
||||||
@ -499,13 +520,12 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
|||||||
case SSTORE:
|
case SSTORE:
|
||||||
require(2)
|
require(2)
|
||||||
val, loc := stack.Popn()
|
val, loc := stack.Popn()
|
||||||
fmt.Println("storing", string(val.Bytes()), "@", string(loc.Bytes()))
|
|
||||||
closure.SetStorage(loc, ethutil.NewValue(val))
|
closure.SetStorage(loc, ethutil.NewValue(val))
|
||||||
|
|
||||||
// Add the change to manifest
|
// Add the change to manifest
|
||||||
vm.state.manifest.AddStorageChange(closure.Object(), loc.Bytes(), val)
|
vm.state.manifest.AddStorageChange(closure.Object(), loc.Bytes(), val)
|
||||||
|
|
||||||
vm.Printf(" => 0x%x", val)
|
vm.Printf(" {0x%x} 0x%x", loc, val)
|
||||||
case JUMP:
|
case JUMP:
|
||||||
require(1)
|
require(1)
|
||||||
pc = stack.Pop()
|
pc = stack.Pop()
|
||||||
@ -519,7 +539,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
|
|||||||
if cond.Cmp(ethutil.BigTrue) >= 0 {
|
if cond.Cmp(ethutil.BigTrue) >= 0 {
|
||||||
pc = pos
|
pc = pos
|
||||||
|
|
||||||
vm.Printf(" (t) ~> %v", pc).Endl()
|
vm.Printf(" ~> %v (t)", pc).Endl()
|
||||||
|
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user