Skip to content

Commit ece22af

Browse files
committed
add 7907 for ext code copy
1 parent 4511c49 commit ece22af

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

execution_chain/evm/interpreter/op_handlers/oph_defs.nim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ const
8282
VmOpCancunAndLater* =
8383
VmOpShanghaiAndLater - {FkShanghai}
8484

85+
VmOpOsakaAndLater* =
86+
VmOpCancunAndLater - {FkCancun}
87+
88+
8589
# ------------------------------------------------------------------------------
8690
# End
8791
# ------------------------------------------------------------------------------

execution_chain/evm/interpreter/op_handlers/oph_envinfo.nim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ proc extCodeCopyEIP2929Op(cpt: VmCpt): EvmResultVoid =
189189
cpt.memory.writePadded(code.bytes(), memPos, codePos, len)
190190
ok()
191191

192+
proc extCodeCopyEIP7907Op(cpt: VmCpt): EvmResultVoid =
193+
## 0x3c, Copy an account's code to memory (EIP-2929).
194+
? cpt.stack.lsCheck(4)
195+
let
196+
address = cpt.stack.lsPeekAddress(^1)
197+
memPos = cpt.stack.lsPeekMemRef(^2)
198+
codePos = cpt.stack.lsPeekMemRef(^3)
199+
len = cpt.stack.lsPeekMemRef(^4)
200+
gasCost = cpt.gasCosts[ExtCodeCopy].m_handler(cpt.memory.len, memPos, len) +
201+
cpt.gasEip2929AccountCheck(address) + cpt.gasCallEIP7907(addresss)
202+
203+
cpt.stack.lsShrink(4)
204+
? cpt.opcodeGasCost(ExtCodeCopy, gasCost, reason = "ExtCodeCopy EIP7907")
205+
206+
let code = cpt.getCode(address)
207+
cpt.memory.writePadded(code.bytes(), memPos, codePos, len)
208+
ok()
209+
210+
192211
# -----------
193212

194213
func returnDataSizeOp(cpt: VmCpt): EvmResultVoid =
@@ -350,6 +369,13 @@ const
350369
info: "EIP2929: Copy an account's code to memory",
351370
exec: extCodeCopyEIP2929Op),
352371

372+
(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin through Cancun
373+
forks: VmOpOsakaAndLater,
374+
name: "extCodeCopyEIP7907",
375+
info: "EIP7907: Copy an account's code to memory",
376+
exec: extCodeCopyEIP7907Op),
377+
378+
353379

354380
(opCode: ReturnDataSize, ## 0x3d, Previous call output data size
355381
forks: VmOpByzantiumAndLater,

0 commit comments

Comments
 (0)