@@ -32,10 +32,17 @@ func New(env Environment) *Vm {
3232 return & Vm {debug : Debug , env : env , logTy : lt , Recoverable : true }
3333}
3434
35- func (self * Vm ) Run (me , caller ContextRef , code []byte , value , gas , price * big.Int , callData []byte ) (ret []byte , err error ) {
35+ func (self * Vm ) Run (context * Context , callData []byte ) (ret []byte , err error ) {
36+ //func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.Int, callData []byte) (ret []byte, err error) {
3637 self .env .SetDepth (self .env .Depth () + 1 )
3738
38- context := NewContext (caller , me , code , gas , price )
39+ //context := NewContext(caller, me, code, gas, price)
40+ var (
41+ caller = context .caller
42+ code = context .Code
43+ value = context .value
44+ price = context .Price
45+ )
3946
4047 self .Printf ("(%d) (%x) %x (code=%d) gas: %v (d) %x" , self .env .Depth (), caller .Address ()[:4 ], context .Address (), len (code ), context .Gas , callData ).Endl ()
4148
@@ -55,7 +62,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
5562 }()
5663 }
5764
58- if p := Precompiled [string (me . Address () )]; p != nil {
65+ if p := Precompiled [string (context . CodeAddr )]; p != nil {
5966 return self .RunPrecompiled (p , callData , context )
6067 }
6168
@@ -352,7 +359,7 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
352359 z := stack .pop ()
353360
354361 if z .Cmp (Zero ) > 0 {
355- add := U256 ( new (big.Int ).Add (x , y ) )
362+ add := new (big.Int ).Add (x , y )
356363 base .Mod (add , z )
357364
358365 base = U256 (base )
@@ -362,13 +369,12 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
362369
363370 stack .push (base )
364371 case MULMOD :
365-
366372 x := stack .pop ()
367373 y := stack .pop ()
368374 z := stack .pop ()
369375
370- mul := new (big. Int ). Mul ( x , y )
371- if len ( z . Bytes ()) > 0 { // NOT 0x0
376+ if z . Cmp ( Zero ) > 0 {
377+ mul := new (big. Int ). Mul ( x , y )
372378 base .Mod (mul , z )
373379
374380 U256 (base )
@@ -476,13 +482,12 @@ func (self *Vm) Run(me, caller ContextRef, code []byte, value, gas, price *big.I
476482 } else {
477483 code = context .Code
478484 }
479- context := NewContext (nil , nil , code , ethutil .Big0 , ethutil .Big0 )
480485 var (
481486 mOff = stack .pop ().Uint64 ()
482487 cOff = stack .pop ().Uint64 ()
483488 l = stack .pop ().Uint64 ()
484489 )
485- codeCopy := context . GetCode ( cOff , l )
490+ codeCopy := getCode ( code , cOff , l )
486491
487492 mem .Set (mOff , l , codeCopy )
488493
0 commit comments