@@ -57,3 +57,70 @@ TEST_P(evm, eof_function_example2)
57
57
EXPECT_GAS_USED (EVMC_SUCCESS, 44544 );
58
58
EXPECT_EQ (output, " 0000000000000000000000000000000000000000000000000000000000000262" _hex);
59
59
}
60
+
61
+ TEST_P (evm, callf_stack_size_1024)
62
+ {
63
+ // CALLF is not implemented in Advanced.
64
+ if (is_advanced ())
65
+ return ;
66
+
67
+ rev = EVMC_CANCUN;
68
+ const auto code = bytecode{" ef0001 010008 020002 0BFF 0004 030000 00 000003FF 00000001" _hex} +
69
+ 1023 * push (1 ) + OP_CALLF + bytecode{" 0x0001" _hex} + 1021 * OP_POP +
70
+ OP_RETURN + push (1 ) + OP_POP + OP_RETF;
71
+
72
+ ASSERT_EQ (evmone::validate_eof (rev, code), evmone::EOFValidationError::success);
73
+ execute (bytecode{code});
74
+ EXPECT_STATUS (EVMC_SUCCESS);
75
+ }
76
+
77
+ TEST_P (evm, callf_stack_overflow)
78
+ {
79
+ // CALLF is not implemented in Advanced.
80
+ if (is_advanced ())
81
+ return ;
82
+
83
+ rev = EVMC_CANCUN;
84
+ const auto code =
85
+ bytecode{" ef0001 010008 020002 0BFF 0007 030000 00 000003FF 00000002" _hex} + // EOF header
86
+ 1023 * push (1 ) + OP_CALLF + bytecode{" 0x0001" _hex} + 1021 * OP_POP + OP_RETURN +
87
+ 2 * push (1 ) + 2 * OP_POP + OP_RETF;
88
+
89
+ ASSERT_EQ (evmone::validate_eof (rev, code), evmone::EOFValidationError::success);
90
+ execute (bytecode{code});
91
+ EXPECT_STATUS (EVMC_STACK_OVERFLOW);
92
+ }
93
+
94
+ TEST_P (evm, callf_call_stack_size_1024)
95
+ {
96
+ // CALLF is not implemented in Advanced.
97
+ if (is_advanced ())
98
+ return ;
99
+
100
+ rev = EVMC_CANCUN;
101
+ const auto code = bytecode{" ef0001 010008 020002 0007 000e 030000 00 00000001 01000002" _hex} +
102
+ push (1023 ) + OP_CALLF + bytecode{" 0x0001" _hex} + OP_STOP + OP_DUP1 +
103
+ OP_RJUMPI + bytecode{" 0x0002" _hex} + OP_POP + OP_RETF + push (1 ) + OP_SWAP1 +
104
+ OP_SUB + OP_CALLF + bytecode{" 0x0001" _hex} + OP_RETF;
105
+
106
+ ASSERT_EQ (evmone::validate_eof (rev, code), evmone::EOFValidationError::success);
107
+ execute (bytecode{code});
108
+ EXPECT_STATUS (EVMC_SUCCESS);
109
+ }
110
+
111
+ TEST_P (evm, callf_call_stack_size_1025)
112
+ {
113
+ // CALLF is not implemented in Advanced.
114
+ if (is_advanced ())
115
+ return ;
116
+
117
+ rev = EVMC_CANCUN;
118
+ const auto code = bytecode{" ef0001 010008 020002 0007 000e 030000 00 00000001 01000002" _hex} +
119
+ push (1024 ) + OP_CALLF + bytecode{" 0x0001" _hex} + OP_STOP + OP_DUP1 +
120
+ OP_RJUMPI + bytecode{" 0x0002" _hex} + OP_POP + OP_RETF + push (1 ) + OP_SWAP1 +
121
+ OP_SUB + OP_CALLF + bytecode{" 0x0001" _hex} + OP_RETF;
122
+
123
+ ASSERT_EQ (evmone::validate_eof (rev, code), evmone::EOFValidationError::success);
124
+ execute (bytecode{code});
125
+ EXPECT_STATUS (EVMC_STACK_OVERFLOW);
126
+ }
0 commit comments