Skip to content

Commit

Permalink
rm withdrawn EIP-2315 (#2309)
Browse files Browse the repository at this point in the history
* rm withdrawn EIP-2315

* copyright year linting

* EVMC
  • Loading branch information
tersec committed Jun 7, 2024
1 parent c5b3081 commit d937585
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 235 deletions.
18 changes: 0 additions & 18 deletions nimbus/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import
chronicles,
confutils,
confutils/defs,
stew/byteutils,
confutils/std/net
],
eth/[common, net/utils, net/nat, p2p/bootnodes, p2p/enode, p2p/discoveryv5/enr],
Expand Down Expand Up @@ -532,23 +531,6 @@ func parseCmdArg(T: type NetworkId, p: string): T
func completeCmdArg(T: type NetworkId, val: string): seq[string] =
return @[]

func parseCmdArg(T: type UInt256, p: string): T
{.gcsafe, raises: [ValueError].} =
parse(p, T)

func completeCmdArg(T: type UInt256, val: string): seq[string] =
return @[]

func parseCmdArg(T: type EthAddress, p: string): T
{.gcsafe, raises: [ValueError].}=
try:
result = hexToByteArray(p, 20)
except CatchableError:
raise newException(ValueError, "failed to parse EthAddress")

func completeCmdArg(T: type EthAddress, val: string): seq[string] =
return @[]

func parseCmdArg*(T: type enr.Record, p: string): T {.raises: [ValueError].} =
if not fromURI(result, p):
raise newException(ValueError, "Invalid ENR")
Expand Down
88 changes: 8 additions & 80 deletions nimbus/evm/interpreter/op_handlers/oph_memory.nim
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ template sstoreEvmcOrNetGasMetering(cpt, slot, newValue: untyped, coldAccess = 0
else:
sstoreNetGasMeteringImpl(cpt, slot, newValue, coldAccess)

proc jumpImpl(c: Computation; jumpTarget: UInt256) {.catchRaise.} =
func jumpImpl(c: Computation; jumpTarget: UInt256) {.catchRaise.} =
if jumpTarget >= c.code.len.u256:
raise newException(
InvalidJumpDestination, "Invalid Jump Destination")
Expand All @@ -126,7 +126,7 @@ proc jumpImpl(c: Computation; jumpTarget: UInt256) {.catchRaise.} =
# ------------------------------------------------------------------------------

const
popOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
popOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x50, Remove item from stack.
discard k.cpt.stack.popInt

Expand Down Expand Up @@ -256,35 +256,35 @@ const

# -------

jumpOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
jumpOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x56, Alter the program counter
let (jumpTarget) = k.cpt.stack.popInt(1)
jumpImpl(k.cpt, jumpTarget)

jumpIOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
jumpIOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x57, Conditionally alter the program counter.
let (jumpTarget, testedValue) = k.cpt.stack.popInt(2)
if testedValue.isZero.not:
jumpImpl(k.cpt, jumpTarget)

pcOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
pcOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x58, Get the value of the program counter prior to the increment
## corresponding to this instruction.
k.cpt.stack.push:
max(k.cpt.code.pc - 1, 0)

msizeOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
msizeOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x59, Get the size of active memory in bytes.
k.cpt.stack.push:
k.cpt.memory.len

gasOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
gasOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x5a, Get the amount of available gas, including the corresponding
## reduction for the cost of this instruction.
k.cpt.stack.push:
k.cpt.gasMeter.gasRemaining

jumpDestOp: Vm2OpFn = proc (k: var Vm2Ctx) =
jumpDestOp: Vm2OpFn = func (k: var Vm2Ctx) =
## 0x5b, Mark a valid destination for jumps. This operation has no effect
## on machine state during execution.
discard
Expand Down Expand Up @@ -318,50 +318,6 @@ const

k.cpt.memory.copy(dstPos, srcPos, len)

#[
EIP-2315: temporary disabled
Reason : not included in berlin hard fork
beginSubOp: Vm2OpFn = proc (k: var Vm2Ctx) =
## 0x5c, Marks the entry point to a subroutine
raise newException(
OutOfGas,
"Abort: Attempt to execute BeginSub opcode")
returnSubOp: Vm2OpFn = proc (k: var Vm2Ctx) =
## 0x5d, Returns control to the caller of a subroutine.
if k.cpt.returnStack.len == 0:
raise newException(
OutOfGas,
"Abort: invalid returnStack during ReturnSub")
k.cpt.code.pc = k.cpt.returnStack.pop()
jumpSubOp: Vm2OpFn = proc (k: var Vm2Ctx) =
## 0x5e, Transfers control to a subroutine.
let (jumpTarget) = k.cpt.stack.popInt(1)
if jumpTarget >= k.cpt.code.len.u256:
raise newException(
InvalidJumpDestination, "JumpSub destination exceeds code len")
let returnPC = k.cpt.code.pc
let jt = jumpTarget.truncate(int)
k.cpt.code.pc = jt
let nextOpcode = k.cpt.code.peek
if nextOpcode != BeginSub:
raise newException(
InvalidJumpDestination, "Invalid JumpSub destination")
if k.cpt.returnStack.len == 1023:
raise newException(
FullStack, "Out of returnStack")
k.cpt.returnStack.add returnPC
inc k.cpt.code.pc
]#

# ------------------------------------------------------------------------------
# Public, op exec table entries
# ------------------------------------------------------------------------------
Expand Down Expand Up @@ -532,34 +488,6 @@ const
run: mCopyOp,
post: vm2OpIgnore))]

#[
EIP-2315: temporary disabled
Reason : not included in berlin hard fork
(opCode: BeginSub, ## 0x5c, Begin subroutine
forks: Vm2OpBerlinAndLater,
name: "beginSub",
info: " Marks the entry point to a subroutine",
exec: (prep: vm2OpIgnore,
run: beginSubOp,
post: vm2OpIgnore)),
(opCode: ReturnSub, ## 0x5d, Return
forks: Vm2OpBerlinAndLater,
name: "returnSub",
info: "Returns control to the caller of a subroutine",
exec: (prep: vm2OpIgnore,
run: returnSubOp,
post: vm2OpIgnore)),
(opCode: JumpSub, ## 0x5e, Call subroutine
forks: Vm2OpBerlinAndLater,
name: "jumpSub",
info: "Transfers control to a subroutine",
exec: (prep: vm2OpIgnore,
run: jumpSubOp,
post: vm2OpIgnore))]
]#

# ------------------------------------------------------------------------------
# End
# ------------------------------------------------------------------------------
7 changes: 1 addition & 6 deletions nimbus/evm/state_transactions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,12 @@ proc setupTxContext*(vmState: BaseVMState,
vmState.determineFork
vmState.gasCosts = vmState.fork.forkToSchedule

# FIXME-awkwardFactoring: the factoring out of the pre and
# post parts feels awkward to me, but for now I'd really like
# not to have too much duplicated code between sync and async.
# --Adam

proc preExecComputation(c: Computation) =
if not c.msg.isCreate:
c.vmState.mutateStateDB:
db.incNonce(c.msg.sender)

proc postExecComputation(c: Computation) =
func postExecComputation(c: Computation) =
if c.isSuccess:
if c.fork < FkLondon:
# EIP-3529: Reduction in refunds
Expand Down
1 change: 0 additions & 1 deletion tests/amphora/.gitignore

This file was deleted.

41 changes: 0 additions & 41 deletions tests/amphora/amphora-interop-genesis-m1.json

This file was deleted.

32 changes: 0 additions & 32 deletions tests/amphora/check-merge-test-vectors.sh

This file was deleted.

26 changes: 0 additions & 26 deletions tests/amphora/connect-to-hacknet-v2.sh

This file was deleted.

28 changes: 0 additions & 28 deletions tests/amphora/launch-nimbus.sh

This file was deleted.

1 change: 0 additions & 1 deletion tests/amphora/signer-key.txt

This file was deleted.

5 changes: 3 additions & 2 deletions tests/test_helpers.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Nimbus
# Copyright (c) 2018-2023 Status Research & Development GmbH
# Copyright (c) 2018-2024 Status Research & Development GmbH
# Licensed under either of
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http:https://www.apache.org/licenses/LICENSE-2.0)
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http:https://opensource.org/licenses/MIT)
Expand Down Expand Up @@ -31,7 +31,8 @@ const
FkIstanbul: "Istanbul",
FkBerlin: "Berlin",
FkLondon: "London",
FkParis: "Merge"
FkParis: "Merge",
FkPrague: "Prague",
}.toTable

nameToFork* = revmap(forkNames)
Expand Down

0 comments on commit d937585

Please sign in to comment.