Skip to content

Commit

Permalink
Merge branch 'block_gas_overflow' of github.com:ethereum/evmone into …
Browse files Browse the repository at this point in the history
…analysis-overflow
  • Loading branch information
gumb0 committed Jul 16, 2019
2 parents e618944 + 27ef5b0 commit e1aaab3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/unittests/evm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,26 @@ TEST_F(evm, undefined_instructions)
}
}

TEST_F(evm, undefined_instruction_block_cost_negative)
{
// For undefined instructions EVMC instruction tables have cost -1.
// If naively counted block costs can become negative.

const auto max_gas = std::numeric_limits<int64_t>::max();

const auto code1 = bytecode{} + "0f"; // Block cost -1.
execute(max_gas, code1);
EXPECT_STATUS(EVMC_UNDEFINED_INSTRUCTION);

const auto code2 = bytecode{} + OP_JUMPDEST + "c6" + "4b" + OP_STOP; // Block cost -1.
execute(max_gas, code2);
EXPECT_STATUS(EVMC_UNDEFINED_INSTRUCTION);

const auto code3 = bytecode{} + OP_ADDRESS + "2a" + "2b" + "2c" + "2d"; // Block cost -2.
execute(max_gas, code3);
EXPECT_STATUS(EVMC_UNDEFINED_INSTRUCTION);
}

TEST_F(evm, undefined_instruction_analysis_overflow)
{
rev = EVMC_PETERSBURG;
Expand Down

0 comments on commit e1aaab3

Please sign in to comment.