From 2f3002610f92b957d9c58fffbd4fa02f8709a9e4 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 24 Jul 2019 15:44:36 +0100 Subject: [PATCH] instructions: add repricing from EIP-1884 --- lib/instructions/instruction_metrics.c | 6 +++--- test/unittests/test_instructions.cpp | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/instructions/instruction_metrics.c b/lib/instructions/instruction_metrics.c index bf168dee5..2dc7a9344 100644 --- a/lib/instructions/instruction_metrics.c +++ b/lib/instructions/instruction_metrics.c @@ -71,7 +71,7 @@ static struct evmc_instruction_metrics istanbul_metrics[256] = { /* = 0x2e */ {UNDEFINED, 0, 0}, /* = 0x2f */ {UNDEFINED, 0, 0}, /* ADDRESS = 0x30 */ {BASE, 0, 1}, - /* BALANCE = 0x31 */ {400, 1, 1}, + /* BALANCE = 0x31 */ {700, 1, 1}, /* ORIGIN = 0x32 */ {BASE, 0, 1}, /* CALLER = 0x33 */ {BASE, 0, 1}, /* CALLVALUE = 0x34 */ {BASE, 0, 1}, @@ -85,7 +85,7 @@ static struct evmc_instruction_metrics istanbul_metrics[256] = { /* EXTCODECOPY = 0x3c */ {700, 4, 0}, /* RETURNDATASIZE = 0x3d */ {BASE, 0, 1}, /* RETURNDATACOPY = 0x3e */ {VERYLOW, 3, 0}, - /* EXTCODEHASH = 0x3f */ {400, 1, 1}, + /* EXTCODEHASH = 0x3f */ {700, 1, 1}, /* BLOCKHASH = 0x40 */ {20, 1, 1}, /* COINBASE = 0x41 */ {BASE, 0, 1}, /* TIMESTAMP = 0x42 */ {BASE, 0, 1}, @@ -106,7 +106,7 @@ static struct evmc_instruction_metrics istanbul_metrics[256] = { /* MLOAD = 0x51 */ {VERYLOW, 1, 1}, /* MSTORE = 0x52 */ {VERYLOW, 2, 0}, /* MSTORE8 = 0x53 */ {VERYLOW, 2, 0}, - /* SLOAD = 0x54 */ {200, 1, 1}, + /* SLOAD = 0x54 */ {800, 1, 1}, /* SSTORE = 0x55 */ {0, 2, 0}, /* JUMP = 0x56 */ {MID, 1, 0}, /* JUMPI = 0x57 */ {HIGH, 2, 0}, diff --git a/test/unittests/test_instructions.cpp b/test/unittests/test_instructions.cpp index 1a5ed62f2..35835dd92 100644 --- a/test/unittests/test_instructions.cpp +++ b/test/unittests/test_instructions.cpp @@ -251,9 +251,21 @@ TEST(instructions, istanbul_hard_fork) for (int op{OP_STOP}; op <= OP_SELFDESTRUCT; ++op) { - if (op == OP_SELFBALANCE) + switch (op) + { + case OP_BALANCE: + case OP_EXTCODEHASH: + case OP_SELFBALANCE: + case OP_SLOAD: continue; - EXPECT_EQ(i[op], p[op]) << op; - EXPECT_STREQ(in[op], pn[op]) << op; + default: + EXPECT_EQ(i[op], p[op]) << op; + EXPECT_STREQ(in[op], pn[op]) << op; + break; + } } + + EXPECT_EQ(i[OP_BALANCE].gas_cost, 700); + EXPECT_EQ(i[OP_EXTCODEHASH].gas_cost, 700); + EXPECT_EQ(i[OP_SLOAD].gas_cost, 800); }