Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rm withdrawn EIP-2315 #2309

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Next Next commit
rm withdrawn EIP-2315
  • Loading branch information
tersec committed Jun 6, 2024
commit 88b14069129d28f52a5c0cf44af6c17573bd309f
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
92 changes: 10 additions & 82 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,47 +256,47 @@ 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

tloadOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
tloadOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x5c, Load word from transient storage.
let
slot = k.cpt.stack.popInt()
val = k.cpt.getTransientStorage(slot)
k.cpt.stack.push: val

tstoreOp: Vm2OpFn = proc (k: var Vm2Ctx) {.catchRaise.} =
tstoreOp: Vm2OpFn = func (k: var Vm2Ctx) {.catchRaise.} =
## 0x5d, Save word to transient storage.
checkInStaticContext(k.cpt)

Expand All @@ -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.

3 changes: 2 additions & 1 deletion tests/test_helpers.nim
Original file line number Diff line number Diff line change
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