@@ -29,9 +29,9 @@ import (
2929)
3030
3131var (
32- bigZero = new (big.Int )
33- errWriteProtection = errors .New ("evm: write protection" )
34- errReadOutOfBound = errors .New ("evm: read out of bound " )
32+ bigZero = new (big.Int )
33+ errWriteProtection = errors .New ("evm: write protection" )
34+ errReturnDataOutOfBounds = errors .New ("evm: return data out of bounds " )
3535)
3636
3737func opAdd (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
@@ -243,13 +243,15 @@ func opAnd(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stac
243243 evm .interpreter .intPool .put (y )
244244 return nil , nil
245245}
246+
246247func opOr (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
247248 x , y := stack .pop (), stack .pop ()
248249 stack .push (x .Or (x , y ))
249250
250251 evm .interpreter .intPool .put (y )
251252 return nil , nil
252253}
254+
253255func opXor (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
254256 x , y := stack .pop (), stack .pop ()
255257 stack .push (x .Xor (x , y ))
@@ -269,6 +271,7 @@ func opByte(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Sta
269271 evm .interpreter .intPool .put (th )
270272 return nil , nil
271273}
274+
272275func opAddmod (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
273276 x , y , z := stack .pop (), stack .pop (), stack .pop ()
274277 if z .Cmp (bigZero ) > 0 {
@@ -282,6 +285,7 @@ func opAddmod(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *S
282285 evm .interpreter .intPool .put (y , z )
283286 return nil , nil
284287}
288+
285289func opMulmod (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
286290 x , y , z := stack .pop (), stack .pop (), stack .pop ()
287291 if z .Cmp (bigZero ) > 0 {
@@ -339,25 +343,25 @@ func opCallValue(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack
339343 return nil , nil
340344}
341345
342- func opCalldataLoad (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
346+ func opCallDataLoad (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
343347 stack .push (new (big.Int ).SetBytes (getDataBig (contract .Input , stack .pop (), big32 )))
344348 return nil , nil
345349}
346350
347- func opCalldataSize (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
351+ func opCallDataSize (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
348352 stack .push (evm .interpreter .intPool .get ().SetInt64 (int64 (len (contract .Input ))))
349353 return nil , nil
350354}
351355
352- func opCalldataCopy (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
356+ func opCallDataCopy (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
353357 var (
354- mOff = stack .pop ()
355- cOff = stack .pop ()
356- l = stack .pop ()
358+ memOffset = stack .pop ()
359+ dataOffset = stack .pop ()
360+ length = stack .pop ()
357361 )
358- memory .Set (mOff .Uint64 (), l .Uint64 (), getDataBig (contract .Input , cOff , l ))
362+ memory .Set (memOffset .Uint64 (), length .Uint64 (), getDataBig (contract .Input , dataOffset , length ))
359363
360- evm .interpreter .intPool .put (mOff , cOff , l )
364+ evm .interpreter .intPool .put (memOffset , dataOffset , length )
361365 return nil , nil
362366}
363367
@@ -368,17 +372,17 @@ func opReturnDataSize(pc *uint64, evm *EVM, contract *Contract, memory *Memory,
368372
369373func opReturnDataCopy (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
370374 var (
371- mOff = stack .pop ()
372- cOff = stack .pop ()
373- l = stack .pop ()
375+ memOffset = stack .pop ()
376+ dataOffset = stack .pop ()
377+ length = stack .pop ()
374378 )
375- defer evm .interpreter .intPool .put (mOff , cOff , l )
379+ defer evm .interpreter .intPool .put (memOffset , dataOffset , length )
376380
377- cEnd := new (big.Int ).Add (cOff , l )
378- if cEnd .BitLen () > 64 || uint64 (len (evm .interpreter .returnData )) < cEnd .Uint64 () {
379- return nil , errReadOutOfBound
381+ end := new (big.Int ).Add (dataOffset , length )
382+ if end .BitLen () > 64 || uint64 (len (evm .interpreter .returnData )) < end .Uint64 () {
383+ return nil , errReturnDataOutOfBounds
380384 }
381- memory .Set (mOff .Uint64 (), l .Uint64 (), evm .interpreter .returnData [cOff .Uint64 ():cEnd .Uint64 ()])
385+ memory .Set (memOffset .Uint64 (), length .Uint64 (), evm .interpreter .returnData [dataOffset .Uint64 ():end .Uint64 ()])
382386
383387 return nil , nil
384388}
@@ -401,31 +405,28 @@ func opCodeSize(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack
401405
402406func opCodeCopy (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
403407 var (
404- mOff = stack .pop ()
405- cOff = stack .pop ()
406- l = stack .pop ()
408+ memOffset = stack .pop ()
409+ codeOffset = stack .pop ()
410+ length = stack .pop ()
407411 )
408- codeCopy := getDataBig (contract .Code , cOff , l )
409-
410- memory .Set (mOff .Uint64 (), l .Uint64 (), codeCopy )
412+ codeCopy := getDataBig (contract .Code , codeOffset , length )
413+ memory .Set (memOffset .Uint64 (), length .Uint64 (), codeCopy )
411414
412- evm .interpreter .intPool .put (mOff , cOff , l )
415+ evm .interpreter .intPool .put (memOffset , codeOffset , length )
413416 return nil , nil
414417}
415418
416419func opExtCodeCopy (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
417420 var (
418- addr = common .BigToAddress (stack .pop ())
419- mOff = stack .pop ()
420- cOff = stack .pop ()
421- l = stack .pop ()
421+ addr = common .BigToAddress (stack .pop ())
422+ memOffset = stack .pop ()
423+ codeOffset = stack .pop ()
424+ length = stack .pop ()
422425 )
423- codeCopy := getDataBig (evm .StateDB .GetCode (addr ), cOff , l )
424-
425- memory .Set (mOff .Uint64 (), l .Uint64 (), codeCopy )
426-
427- evm .interpreter .intPool .put (mOff , cOff , l )
426+ codeCopy := getDataBig (evm .StateDB .GetCode (addr ), codeOffset , length )
427+ memory .Set (memOffset .Uint64 (), length .Uint64 (), codeCopy )
428428
429+ evm .interpreter .intPool .put (memOffset , codeOffset , length )
429430 return nil , nil
430431}
431432
@@ -530,6 +531,7 @@ func opJump(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Sta
530531 evm .interpreter .intPool .put (pos )
531532 return nil , nil
532533}
534+
533535func opJumpi (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
534536 pos , cond := stack .pop (), stack .pop ()
535537 if cond .Sign () != 0 {
@@ -545,6 +547,7 @@ func opJumpi(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *St
545547 evm .interpreter .intPool .put (pos , cond )
546548 return nil , nil
547549}
550+
548551func opJumpdest (pc * uint64 , evm * EVM , contract * Contract , memory * Memory , stack * Stack ) ([]byte , error ) {
549552 return nil , nil
550553}
0 commit comments