diff --git a/Instruction.cpp b/Instruction.cpp index 88e490a..4f2e0b9 100644 --- a/Instruction.cpp +++ b/Instruction.cpp @@ -74,6 +74,7 @@ static const std::map c_instructionInfo = { Instruction::MSIZE, { "MSIZE", 0, 1, Tier::Base } }, { Instruction::GAS, { "GAS", 0, 1, Tier::Base } }, { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, Tier::Special } }, + { Instruction::PUSH0, { "PUSH0", 0, 1, Tier::Base } }, { Instruction::PUSH1, { "PUSH1", 0, 1, Tier::VeryLow } }, { Instruction::PUSH2, { "PUSH2", 0, 1, Tier::VeryLow } }, { Instruction::PUSH3, { "PUSH3", 0, 1, Tier::VeryLow } }, diff --git a/Instruction.h b/Instruction.h index f86625d..009f19b 100644 --- a/Instruction.h +++ b/Instruction.h @@ -83,6 +83,7 @@ enum class Instruction : uint8_t GAS, ///< get the amount of available gas JUMPDEST, ///< set a potential jump destination + PUSH0 = 0x5f, ///< place the value 0 on stack PUSH1 = 0x60, ///< place 1 byte item on stack PUSH2, ///< place 2 byte item on stack PUSH3, ///< place 3 byte item on stack diff --git a/LegacyVM.cpp b/LegacyVM.cpp index f955971..45e7c3d 100644 --- a/LegacyVM.cpp +++ b/LegacyVM.cpp @@ -1492,6 +1492,17 @@ void LegacyVM::interpretCases() #endif } CONTINUE + // EIP-3855. Code PUSH0 is similar to PUSH1 but pushes 0 + // we need to increment program counter only by one since + // the value is not read from program code as in PUSH1 + CASE( PUSH0 ) { + if (!m_schedule->havePush0) + throwBadInstruction(); + ON_OP(); + updateIOGas(); + m_SPP[0] = 0; + ++m_PC; + }; CASE(PUSH1) { diff --git a/LegacyVMConfig.h b/LegacyVMConfig.h index 56bd220..a420b7e 100644 --- a/LegacyVMConfig.h +++ b/LegacyVMConfig.h @@ -245,7 +245,7 @@ namespace dev &&BEGINDATA, \ &&BEGINSUB, \ &&INVALID, \ - &&INVALID, \ + &&PUSH0, \ &&PUSH1, /* 60, */ \ &&PUSH2, \ &&PUSH3, \