@@ -94,6 +94,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu
9494 var (
9595 env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
9696 stack = newstack ()
97+ rstack = newReturnStack ()
9798 pc = uint64 (0 )
9899 evmInterpreter = env .interpreter .(* EVMInterpreter )
99100 )
@@ -109,7 +110,7 @@ func testTwoOperandOp(t *testing.T, tests []TwoOperandTestcase, opFn executionFu
109110 expected := new (big.Int ).SetBytes (common .Hex2Bytes (test .Expected ))
110111 stack .push (x )
111112 stack .push (y )
112- opFn (& pc , evmInterpreter , & callCtx {nil , stack , nil })
113+ opFn (& pc , evmInterpreter , & callCtx {nil , stack , rstack , nil })
113114 actual := stack .pop ()
114115
115116 if actual .Cmp (expected ) != 0 {
@@ -211,10 +212,10 @@ func TestSAR(t *testing.T) {
211212// getResult is a convenience function to generate the expected values
212213func getResult (args []* twoOperandParams , opFn executionFunc ) []TwoOperandTestcase {
213214 var (
214- env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
215- stack = newstack ()
216- pc = uint64 (0 )
217- interpreter = env .interpreter .(* EVMInterpreter )
215+ env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
216+ stack , rstack = newstack (), newReturnStack ()
217+ pc = uint64 (0 )
218+ interpreter = env .interpreter .(* EVMInterpreter )
218219 )
219220 interpreter .intPool = poolOfIntPools .get ()
220221 result := make ([]TwoOperandTestcase , len (args ))
@@ -223,7 +224,7 @@ func getResult(args []*twoOperandParams, opFn executionFunc) []TwoOperandTestcas
223224 y := new (big.Int ).SetBytes (common .Hex2Bytes (param .y ))
224225 stack .push (x )
225226 stack .push (y )
226- opFn (& pc , interpreter , & callCtx {nil , stack , nil })
227+ opFn (& pc , interpreter , & callCtx {nil , stack , rstack , nil })
227228 actual := stack .pop ()
228229 result [i ] = TwoOperandTestcase {param .x , param .y , fmt .Sprintf ("%064x" , actual )}
229230 }
@@ -263,7 +264,7 @@ func TestJsonTestcases(t *testing.T) {
263264func opBenchmark (bench * testing.B , op executionFunc , args ... string ) {
264265 var (
265266 env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
266- stack = newstack ()
267+ stack , rstack = newstack (), newReturnStack ()
267268 evmInterpreter = NewEVMInterpreter (env , env .vmConfig )
268269 )
269270
@@ -281,7 +282,7 @@ func opBenchmark(bench *testing.B, op executionFunc, args ...string) {
281282 a := new (big.Int ).SetBytes (arg )
282283 stack .push (a )
283284 }
284- op (& pc , evmInterpreter , & callCtx {nil , stack , nil })
285+ op (& pc , evmInterpreter , & callCtx {nil , stack , rstack , nil })
285286 stack .pop ()
286287 }
287288 poolOfIntPools .put (evmInterpreter .intPool )
@@ -498,7 +499,7 @@ func BenchmarkOpIsZero(b *testing.B) {
498499func TestOpMstore (t * testing.T ) {
499500 var (
500501 env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
501- stack = newstack ()
502+ stack , rstack = newstack (), newReturnStack ()
502503 mem = NewMemory ()
503504 evmInterpreter = NewEVMInterpreter (env , env .vmConfig )
504505 )
@@ -509,12 +510,12 @@ func TestOpMstore(t *testing.T) {
509510 pc := uint64 (0 )
510511 v := "abcdef00000000000000abba000000000deaf000000c0de00100000000133700"
511512 stack .pushN (new (big.Int ).SetBytes (common .Hex2Bytes (v )), big .NewInt (0 ))
512- opMstore (& pc , evmInterpreter , & callCtx {mem , stack , nil })
513+ opMstore (& pc , evmInterpreter , & callCtx {mem , stack , rstack , nil })
513514 if got := common .Bytes2Hex (mem .GetCopy (0 , 32 )); got != v {
514515 t .Fatalf ("Mstore fail, got %v, expected %v" , got , v )
515516 }
516517 stack .pushN (big .NewInt (0x1 ), big .NewInt (0 ))
517- opMstore (& pc , evmInterpreter , & callCtx {mem , stack , nil })
518+ opMstore (& pc , evmInterpreter , & callCtx {mem , stack , rstack , nil })
518519 if common .Bytes2Hex (mem .GetCopy (0 , 32 )) != "0000000000000000000000000000000000000000000000000000000000000001" {
519520 t .Fatalf ("Mstore failed to overwrite previous value" )
520521 }
@@ -524,7 +525,7 @@ func TestOpMstore(t *testing.T) {
524525func BenchmarkOpMstore (bench * testing.B ) {
525526 var (
526527 env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
527- stack = newstack ()
528+ stack , rstack = newstack (), newReturnStack ()
528529 mem = NewMemory ()
529530 evmInterpreter = NewEVMInterpreter (env , env .vmConfig )
530531 )
@@ -539,15 +540,15 @@ func BenchmarkOpMstore(bench *testing.B) {
539540 bench .ResetTimer ()
540541 for i := 0 ; i < bench .N ; i ++ {
541542 stack .pushN (value , memStart )
542- opMstore (& pc , evmInterpreter , & callCtx {mem , stack , nil })
543+ opMstore (& pc , evmInterpreter , & callCtx {mem , stack , rstack , nil })
543544 }
544545 poolOfIntPools .put (evmInterpreter .intPool )
545546}
546547
547548func BenchmarkOpSHA3 (bench * testing.B ) {
548549 var (
549550 env = NewEVM (Context {}, nil , params .TestChainConfig , Config {})
550- stack = newstack ()
551+ stack , rstack = newstack (), newReturnStack ()
551552 mem = NewMemory ()
552553 evmInterpreter = NewEVMInterpreter (env , env .vmConfig )
553554 )
@@ -560,7 +561,7 @@ func BenchmarkOpSHA3(bench *testing.B) {
560561 bench .ResetTimer ()
561562 for i := 0 ; i < bench .N ; i ++ {
562563 stack .pushN (big .NewInt (32 ), start )
563- opSha3 (& pc , evmInterpreter , & callCtx {mem , stack , nil })
564+ opSha3 (& pc , evmInterpreter , & callCtx {mem , stack , rstack , nil })
564565 }
565566 poolOfIntPools .put (evmInterpreter .intPool )
566567}
0 commit comments