From 387a74af59bb523fa376dab9f45a039122bfb39a Mon Sep 17 00:00:00 2001 From: Paul <41552663+molecula451@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:17:08 -0400 Subject: [PATCH 1/5] Update Instruction.cpp --- Instruction.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Instruction.cpp b/Instruction.cpp index 88e490a..7bdd5eb 100644 --- a/Instruction.cpp +++ b/Instruction.cpp @@ -73,6 +73,7 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 1, Tier::Base } }, { Instruction::MSIZE, { "MSIZE", 0, 1, Tier::Base } }, { Instruction::GAS, { "GAS", 0, 1, Tier::Base } }, + { Instruction::PUSH0, { "PUSH0", 0, 1, Tier::Base } }, { Instruction::JUMPDEST, { "JUMPDEST", 0, 0, Tier::Special } }, { Instruction::PUSH1, { "PUSH1", 0, 1, Tier::VeryLow } }, { Instruction::PUSH2, { "PUSH2", 0, 1, Tier::VeryLow } }, From f0ed4e32523eea24dc7239b0da8f05979545ab56 Mon Sep 17 00:00:00 2001 From: Paul <41552663+molecula451@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:18:01 -0400 Subject: [PATCH 2/5] Update Instruction.h --- Instruction.h | 1 + 1 file changed, 1 insertion(+) 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 From 3e90df1d001b53aa5f53626e4e1b331f2f5258a8 Mon Sep 17 00:00:00 2001 From: Paul <41552663+molecula451@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:18:42 -0400 Subject: [PATCH 3/5] Update LegacyVMConfig.h --- LegacyVMConfig.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, \ From ba330713c229be41a63bb12c53b49db7e997cfb5 Mon Sep 17 00:00:00 2001 From: Paul <41552663+molecula451@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:21:18 -0400 Subject: [PATCH 4/5] Update Instruction.cpp --- Instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Instruction.cpp b/Instruction.cpp index 7bdd5eb..4f2e0b9 100644 --- a/Instruction.cpp +++ b/Instruction.cpp @@ -73,8 +73,8 @@ static const std::map c_instructionInfo = { Instruction::PC, { "PC", 0, 1, Tier::Base } }, { Instruction::MSIZE, { "MSIZE", 0, 1, Tier::Base } }, { Instruction::GAS, { "GAS", 0, 1, Tier::Base } }, - { Instruction::PUSH0, { "PUSH0", 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 } }, From cf42861eaba732ef8f7c5b6aa73df2a0c27d8daf Mon Sep 17 00:00:00 2001 From: Paul <41552663+molecula451@users.noreply.github.com> Date: Sun, 5 Jan 2025 21:25:18 -0400 Subject: [PATCH 5/5] add push0 --- LegacyVM.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) 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) {