aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-03 20:50:51 +0800
committerobscuren <geffobscura@gmail.com>2014-12-03 20:50:51 +0800
commit6095edac5843aa18e389ef2deaa49fe05b7fcfb9 (patch)
tree851b5616b2024248b6b9790199ef289e04725cbb /vm
parent64f35ba8d1f31d6821a0a1bf946c71396a996f30 (diff)
parent3d9a4e7084c33cb28a2265c0dd232a0ea3871c92 (diff)
downloadgo-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar
go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.gz
go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.bz2
go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.lz
go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.xz
go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.tar.zst
go-tangerine-6095edac5843aa18e389ef2deaa49fe05b7fcfb9.zip
merge
Diffstat (limited to 'vm')
-rw-r--r--vm/execution.go4
-rw-r--r--vm/stack.go3
-rw-r--r--vm/types.go13
-rw-r--r--vm/vm_debug.go15
4 files changed, 17 insertions, 18 deletions
diff --git a/vm/execution.go b/vm/execution.go
index f8a772a1d..4df77729e 100644
--- a/vm/execution.go
+++ b/vm/execution.go
@@ -26,7 +26,7 @@ func (self *Execution) Addr() []byte {
func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error) {
// Retrieve the executing code
- code := self.vm.Env().State().GetCode(codeAddr)
+ code := self.vm.Env().GetCode(codeAddr)
return self.exec(code, codeAddr, caller)
}
@@ -34,13 +34,11 @@ func (self *Execution) Exec(codeAddr []byte, caller ClosureRef) ([]byte, error)
func (self *Execution) exec(code, caddr []byte, caller ClosureRef) (ret []byte, err error) {
env := self.vm.Env()
- vmlogger.Debugf("pre state %x\n", env.State().Root())
snapshot := env.State().Copy()
defer func() {
if IsDepthErr(err) || IsOOGErr(err) {
env.State().Set(snapshot)
}
- vmlogger.Debugf("post state %x\n", env.State().Root())
}()
msg := env.State().Manifest().AddMessage(&state.Message{
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 0b20fb655..ec9c7e74e 100644
--- a/vm/types.go
+++ b/vm/types.go
@@ -163,8 +163,8 @@ const (
// 0xf0 range - closures
CREATE OpCode = 0xf0 + iota
CALL
- RETURN
CALLCODE
+ RETURN
// 0x70 range - other
SUICIDE = 0xff
@@ -308,12 +308,11 @@ var opCodeToString = map[OpCode]string{
SWAP14: "SWAP14",
SWAP15: "SWAP15",
SWAP16: "SWAP16",
-
- LOG0: "LOG0",
- LOG1: "LOG1",
- LOG2: "LOG2",
- LOG3: "LOG3",
- LOG4: "LOG4",
+ 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 0a95953b0..31345c555 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -41,7 +41,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) {
@@ -177,10 +177,13 @@ func (self *DebugVm) Run(call Options) (ret []byte, gas *big.Int, err error) {
n := int(op - LOG0)
require(n + 2)
- mSize, mStart := stack.Peekn()
- reqGs.Set(GasLog)
+ gas.Set(GasLog)
addStepGasUsage(new(big.Int).Mul(big.NewInt(int64(n)), GasLog))
- addStepGasUsage(new(big.Int).Add(mSize, mStart))
+
+ mSize, mStart := stack.Peekn()
+ addStepGasUsage(mSize)
+
+ newMemSize = calcMemSize(mStart, mSize)
case EXP:
require(2)
@@ -762,10 +765,10 @@ func (self *DebugVm) Run(call Options) (ret []byte, gas *big.Int, 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}