aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-03 19:21:12 +0800
committerobscuren <geffobscura@gmail.com>2014-12-03 19:21:12 +0800
commit3d9a4e7084c33cb28a2265c0dd232a0ea3871c92 (patch)
tree84b7ccf6ea1ccc4eca0b8ded0a382c1bfe98e190 /vm
parentf7789220862f67c2aadaf7b6a44fcd54152dd234 (diff)
downloadgo-tangerine-3d9a4e7084c33cb28a2265c0dd232a0ea3871c92.tar.gz
go-tangerine-3d9a4e7084c33cb28a2265c0dd232a0ea3871c92.tar.zst
go-tangerine-3d9a4e7084c33cb28a2265c0dd232a0ea3871c92.zip
Fixed mem error in vm. Fixed logs tests
Diffstat (limited to 'vm')
-rw-r--r--vm/stack.go3
-rw-r--r--vm/types.go5
-rw-r--r--vm/vm_debug.go10
3 files changed, 12 insertions, 6 deletions
diff --git a/vm/stack.go b/vm/stack.go
index 2eca60ad1..98795cc03 100644
--- a/vm/stack.go
+++ b/vm/stack.go
@@ -147,9 +147,8 @@ func (m *Memory) Get(offset, size int64) []byte {
func (self *Memory) Geti(offset, size int64) (cpy []byte) {
if len(self.store) > int(offset) {
- s := int64(math.Min(float64(len(self.store)), float64(offset+size)))
cpy = make([]byte, size)
- copy(cpy, self.store[offset:offset+s])
+ copy(cpy, self.store[offset:offset+size])
return
}
diff --git a/vm/types.go b/vm/types.go
index 530dbf400..ec9c7e74e 100644
--- a/vm/types.go
+++ b/vm/types.go
@@ -308,6 +308,11 @@ var opCodeToString = map[OpCode]string{
SWAP14: "SWAP14",
SWAP15: "SWAP15",
SWAP16: "SWAP16",
+ LOG0: "LOG0",
+ LOG1: "LOG1",
+ LOG2: "LOG2",
+ LOG3: "LOG3",
+ LOG4: "LOG4",
// 0xf0 range
CREATE: "CREATE",
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index dbab8fbcb..91d3c55c1 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -35,7 +35,7 @@ func NewDebugVm(env Environment) *DebugVm {
lt = LogTyDiff
}
- return &DebugVm{env: env, logTy: lt, Recoverable: true}
+ return &DebugVm{env: env, logTy: lt, Recoverable: false}
}
func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
@@ -168,8 +168,10 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
gas.Set(GasLog)
addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog))
- mSize, _ := stack.Peekn()
+ mSize, mStart := stack.Peekn()
addStepGasUsage(mSize)
+
+ newMemSize = calcMemSize(mStart, mSize)
case EXP:
require(2)
@@ -755,10 +757,10 @@ func (self *DebugVm) RunClosure(closure *Closure) (ret []byte, err error) {
case LOG0, LOG1, LOG2, LOG3, LOG4:
n := int(op - LOG0)
topics := make([][]byte, n)
- mStart, mSize := stack.Pop().Int64(), stack.Pop().Int64()
+ mSize, mStart := stack.Pop().Int64(), stack.Pop().Int64()
data := mem.Geti(mStart, mSize)
for i := 0; i < n; i++ {
- topics[i] = stack.Pop().Bytes()
+ topics[i] = ethutil.LeftPadBytes(stack.Pop().Bytes(), 32)
}
log := &state.Log{closure.Address(), topics, data}