instructions: Rename .num_stack_arguments -> .stack_height_required

This commit is contained in:
Paweł Bylica 2019-09-26 12:03:52 +02:00
parent b0a3da0cf7
commit a9cc2483b4
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
3 changed files with 10 additions and 10 deletions

View File

@ -9,5 +9,5 @@
int main() int main()
{ {
return evmc_get_instruction_metrics_table(EVMC_BYZANTIUM)[OP_STOP].num_stack_returned_items; return evmc_get_instruction_metrics_table(EVMC_BYZANTIUM)[OP_STOP].gas_cost;
} }

View File

@ -188,8 +188,8 @@ struct evmc_instruction_metrics
/** The instruction gas cost. */ /** The instruction gas cost. */
int16_t gas_cost; int16_t gas_cost;
/** The number of items the instruction pops from the EVM stack before execution. */ /** The minimum number of the EVM stack items required for the instruction. */
int8_t num_stack_arguments; int8_t stack_height_required;
/** The number of items the instruction pushes to the EVM stack after execution. */ /** The number of items the instruction pushes to the EVM stack after execution. */
int8_t num_stack_returned_items; int8_t num_stack_returned_items;

View File

@ -8,7 +8,7 @@
bool operator==(const evmc_instruction_metrics& a, const evmc_instruction_metrics& b) noexcept bool operator==(const evmc_instruction_metrics& a, const evmc_instruction_metrics& b) noexcept
{ {
return a.gas_cost == b.gas_cost && a.num_stack_arguments == b.num_stack_arguments && return a.gas_cost == b.gas_cost && a.stack_height_required == b.stack_height_required &&
a.num_stack_returned_items == b.num_stack_returned_items; a.num_stack_returned_items == b.num_stack_returned_items;
} }
@ -159,7 +159,7 @@ TEST(instructions, byzantium_hard_fork)
} }
EXPECT_EQ(b[OP_REVERT].gas_cost, 0); EXPECT_EQ(b[OP_REVERT].gas_cost, 0);
EXPECT_EQ(b[OP_REVERT].num_stack_arguments, 2); EXPECT_EQ(b[OP_REVERT].stack_height_required, 2);
EXPECT_EQ(b[OP_REVERT].num_stack_returned_items, 0); EXPECT_EQ(b[OP_REVERT].num_stack_returned_items, 0);
EXPECT_EQ(sd[OP_REVERT].gas_cost, 0); EXPECT_EQ(sd[OP_REVERT].gas_cost, 0);
EXPECT_EQ(bn[OP_REVERT], std::string{"REVERT"}); EXPECT_EQ(bn[OP_REVERT], std::string{"REVERT"});
@ -209,19 +209,19 @@ TEST(instructions, constantinople_hard_fork)
{ {
const auto m = c[op]; const auto m = c[op];
EXPECT_EQ(m.gas_cost, 3); EXPECT_EQ(m.gas_cost, 3);
EXPECT_EQ(m.num_stack_arguments, 2); EXPECT_EQ(m.stack_height_required, 2);
EXPECT_EQ(m.num_stack_returned_items, 1); EXPECT_EQ(m.num_stack_returned_items, 1);
} }
EXPECT_EQ(c[OP_CREATE2].gas_cost, 32000); EXPECT_EQ(c[OP_CREATE2].gas_cost, 32000);
EXPECT_EQ(c[OP_CREATE2].num_stack_arguments, 4); EXPECT_EQ(c[OP_CREATE2].stack_height_required, 4);
EXPECT_EQ(c[OP_CREATE2].num_stack_returned_items, 1); EXPECT_EQ(c[OP_CREATE2].num_stack_returned_items, 1);
EXPECT_EQ(b[OP_CREATE2].gas_cost, 0); EXPECT_EQ(b[OP_CREATE2].gas_cost, 0);
EXPECT_EQ(cn[OP_CREATE2], std::string{"CREATE2"}); EXPECT_EQ(cn[OP_CREATE2], std::string{"CREATE2"});
EXPECT_TRUE(bn[OP_CREATE2] == nullptr); EXPECT_TRUE(bn[OP_CREATE2] == nullptr);
EXPECT_EQ(c[OP_EXTCODEHASH].gas_cost, 400); EXPECT_EQ(c[OP_EXTCODEHASH].gas_cost, 400);
EXPECT_EQ(c[OP_EXTCODEHASH].num_stack_arguments, 1); EXPECT_EQ(c[OP_EXTCODEHASH].stack_height_required, 1);
EXPECT_EQ(c[OP_EXTCODEHASH].num_stack_returned_items, 1); EXPECT_EQ(c[OP_EXTCODEHASH].num_stack_returned_items, 1);
EXPECT_EQ(b[OP_EXTCODEHASH].gas_cost, 0); EXPECT_EQ(b[OP_EXTCODEHASH].gas_cost, 0);
EXPECT_EQ(cn[OP_EXTCODEHASH], std::string{"EXTCODEHASH"}); EXPECT_EQ(cn[OP_EXTCODEHASH], std::string{"EXTCODEHASH"});
@ -267,14 +267,14 @@ TEST(instructions, istanbul_hard_fork)
} }
EXPECT_EQ(i[OP_CHAINID].gas_cost, 2); EXPECT_EQ(i[OP_CHAINID].gas_cost, 2);
EXPECT_EQ(i[OP_CHAINID].num_stack_arguments, 0); EXPECT_EQ(i[OP_CHAINID].stack_height_required, 0);
EXPECT_EQ(i[OP_CHAINID].num_stack_returned_items, 1); EXPECT_EQ(i[OP_CHAINID].num_stack_returned_items, 1);
EXPECT_EQ(p[OP_CHAINID].gas_cost, 0); EXPECT_EQ(p[OP_CHAINID].gas_cost, 0);
EXPECT_EQ(in[OP_CHAINID], std::string{"CHAINID"}); EXPECT_EQ(in[OP_CHAINID], std::string{"CHAINID"});
EXPECT_TRUE(pn[OP_CHAINID] == nullptr); EXPECT_TRUE(pn[OP_CHAINID] == nullptr);
EXPECT_EQ(i[OP_SELFBALANCE].gas_cost, 5); EXPECT_EQ(i[OP_SELFBALANCE].gas_cost, 5);
EXPECT_EQ(i[OP_SELFBALANCE].num_stack_arguments, 0); EXPECT_EQ(i[OP_SELFBALANCE].stack_height_required, 0);
EXPECT_EQ(i[OP_SELFBALANCE].num_stack_returned_items, 1); EXPECT_EQ(i[OP_SELFBALANCE].num_stack_returned_items, 1);
EXPECT_EQ(p[OP_SELFBALANCE].gas_cost, 0); EXPECT_EQ(p[OP_SELFBALANCE].gas_cost, 0);
EXPECT_EQ(in[OP_SELFBALANCE], std::string{"SELFBALANCE"}); EXPECT_EQ(in[OP_SELFBALANCE], std::string{"SELFBALANCE"});