From a9cc2483b42b367c2fab83c6ece87477b6c2a4e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 26 Sep 2019 12:03:52 +0200 Subject: [PATCH] instructions: Rename .num_stack_arguments -> .stack_height_required --- .../use_instructions_in_cmake.c | 2 +- include/evmc/instructions.h | 4 ++-- test/unittests/test_instructions.cpp | 14 +++++++------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/use_instructions_in_cmake/use_instructions_in_cmake.c b/examples/use_instructions_in_cmake/use_instructions_in_cmake.c index 6ebd362..c8d1536 100644 --- a/examples/use_instructions_in_cmake/use_instructions_in_cmake.c +++ b/examples/use_instructions_in_cmake/use_instructions_in_cmake.c @@ -9,5 +9,5 @@ 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; } diff --git a/include/evmc/instructions.h b/include/evmc/instructions.h index 42b5a49..8348af0 100644 --- a/include/evmc/instructions.h +++ b/include/evmc/instructions.h @@ -188,8 +188,8 @@ struct evmc_instruction_metrics /** The instruction gas cost. */ int16_t gas_cost; - /** The number of items the instruction pops from the EVM stack before execution. */ - int8_t num_stack_arguments; + /** The minimum number of the EVM stack items required for the instruction. */ + int8_t stack_height_required; /** The number of items the instruction pushes to the EVM stack after execution. */ int8_t num_stack_returned_items; diff --git a/test/unittests/test_instructions.cpp b/test/unittests/test_instructions.cpp index 2f8b3c5..a064f45 100644 --- a/test/unittests/test_instructions.cpp +++ b/test/unittests/test_instructions.cpp @@ -8,7 +8,7 @@ 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; } @@ -159,7 +159,7 @@ TEST(instructions, byzantium_hard_fork) } 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(sd[OP_REVERT].gas_cost, 0); EXPECT_EQ(bn[OP_REVERT], std::string{"REVERT"}); @@ -209,19 +209,19 @@ TEST(instructions, constantinople_hard_fork) { const auto m = c[op]; 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(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(b[OP_CREATE2].gas_cost, 0); EXPECT_EQ(cn[OP_CREATE2], std::string{"CREATE2"}); EXPECT_TRUE(bn[OP_CREATE2] == nullptr); 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(b[OP_EXTCODEHASH].gas_cost, 0); 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].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(p[OP_CHAINID].gas_cost, 0); EXPECT_EQ(in[OP_CHAINID], std::string{"CHAINID"}); EXPECT_TRUE(pn[OP_CHAINID] == nullptr); 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(p[OP_SELFBALANCE].gas_cost, 0); EXPECT_EQ(in[OP_SELFBALANCE], std::string{"SELFBALANCE"});