Skip to content

Commit 5044eb4

Browse files
committed
Merge pull request #1101 from obscuren/issue-1096
core/vm: Cleanups & SUB output fix. Closes #1096
2 parents cc318ff + b419e26 commit 5044eb4

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

core/vm/vm.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
128128
mem.Resize(newMemSize.Uint64())
129129

130130
switch op {
131-
// 0x20 range
132131
case ADD:
133132
x, y := stack.pop(), stack.pop()
134133
self.Printf(" %v + %v", y, x)
@@ -142,7 +141,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
142141
stack.push(base)
143142
case SUB:
144143
x, y := stack.pop(), stack.pop()
145-
self.Printf(" %v - %v", y, x)
144+
self.Printf(" %v - %v", x, y)
146145

147146
base.Sub(x, y)
148147

@@ -268,9 +267,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
268267
}
269268
case NOT:
270269
stack.push(U256(new(big.Int).Not(stack.pop())))
271-
//base.Sub(Pow256, stack.pop()).Sub(base, common.Big1)
272-
//base = U256(base)
273-
//stack.push(base)
274270
case LT:
275271
x, y := stack.pop(), stack.pop()
276272
self.Printf(" %v < %v", x, y)
@@ -329,7 +325,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
329325
stack.push(common.BigTrue)
330326
}
331327

332-
// 0x10 range
333328
case AND:
334329
x, y := stack.pop(), stack.pop()
335330
self.Printf(" %v & %v", y, x)
@@ -390,15 +385,13 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
390385

391386
stack.push(base)
392387

393-
// 0x20 range
394388
case SHA3:
395389
offset, size := stack.pop(), stack.pop()
396390
data := crypto.Sha3(mem.Get(offset.Int64(), size.Int64()))
397391

398392
stack.push(common.BigD(data))
399393

400394
self.Printf(" => (%v) %x", size, data)
401-
// 0x30 range
402395
case ADDRESS:
403396
stack.push(common.Bytes2Big(context.Address().Bytes()))
404397

@@ -486,7 +479,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
486479

487480
self.Printf(" => %x", context.Price)
488481

489-
// 0x40 range
490482
case BLOCKHASH:
491483
num := stack.pop()
492484

@@ -527,7 +519,6 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
527519

528520
stack.push(self.env.GasLimit())
529521

530-
// 0x50 range
531522
case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32:
532523
a := big.NewInt(int64(op - PUSH1 + 1))
533524
byts := getData(code, new(big.Int).Add(pc, big.NewInt(1)), a)
@@ -553,12 +544,11 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
553544
topics := make([]common.Hash, n)
554545
mStart, mSize := stack.pop(), stack.pop()
555546
for i := 0; i < n; i++ {
556-
topics[i] = common.BigToHash(stack.pop()) //common.LeftPadBytes(stack.pop().Bytes(), 32)
547+
topics[i] = common.BigToHash(stack.pop())
557548
}
558549

559550
data := mem.Get(mStart.Int64(), mSize.Int64())
560551
log := state.NewLog(context.Address(), topics, data, self.env.BlockNumber().Uint64())
561-
//log := &Log{context.Address(), topics, data, self.env.BlockNumber().Uint64()}
562552
self.env.AddLog(log)
563553

564554
self.Printf(" => %v", log)
@@ -568,7 +558,7 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
568558
stack.push(val)
569559

570560
self.Printf(" => 0x%x", val.Bytes())
571-
case MSTORE: // Store the value at stack top-1 in to memory at location stack top
561+
case MSTORE:
572562
// pop value of the stack
573563
mStart, val := stack.pop(), stack.pop()
574564
mem.Set(mStart.Uint64(), 32, common.BigToBytes(val, 256))
@@ -614,15 +604,13 @@ func (self *Vm) Run(context *Context, callData []byte) (ret []byte, err error) {
614604

615605
case JUMPDEST:
616606
case PC:
617-
//stack.push(big.NewInt(int64(pc)))
618607
stack.push(pc)
619608
case MSIZE:
620609
stack.push(big.NewInt(int64(mem.Len())))
621610
case GAS:
622611
stack.push(context.Gas)
623612

624613
self.Printf(" => %x", context.Gas)
625-
// 0x60 range
626614
case CREATE:
627615

628616
var (

0 commit comments

Comments
 (0)