Skip to content

Commit a7de5c0

Browse files
committed
touch code
1 parent ece22af commit a7de5c0

File tree

10 files changed

+28
-18
lines changed

10 files changed

+28
-18
lines changed

execution_chain/constants.nim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ const
6262
# See EIP-170 (https://eips.ethereum.org/EIPS/eip-170) Maximum code size
6363
# that can be stored for a new contract. Init code when creating a new
6464
# contract is not subject to this limit.
65-
EIP170_SIZE_THRESHOLD* = 0x6000
66-
# See See EIP-170 (https://eips.ethereum.org/EIPS/eip-170). Update to limits
65+
EIP170_MAX_CODE_SIZE* = 0x6000
66+
# See See EIP-7907 (https://eips.ethereum.org/EIPS/eip-7907). Update to limits
6767
CODE_SIZE_THRESHOLD* = 0x6000
6868
EIP7907_MAX_CODE_SIZE* = 0x40000
6969

execution_chain/db/access_list.nim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type
2121

2222
AccessList* = object
2323
slots: Table[Address, SlotSet]
24-
codeAddrs: seq[Address]
24+
codeAddrs: HashSet[Address]
2525

2626
# ------------------------------------------------------------------------------
2727
# Private helpers
@@ -37,7 +37,7 @@ func toStorageKeys(slots: SlotSet): seq[Bytes32] =
3737

3838
proc init*(ac: var AccessList) =
3939
ac.slots = Table[Address, SlotSet]()
40-
ac.codeAddrs = newSeq[Address]()
40+
ac.codeAddrs = HashSet[Address]()
4141
4242
proc init*(_: type AccessList): AccessList {.inline.} =
4343
result.init()
@@ -73,12 +73,11 @@ proc add*(ac: var AccessList, address: Address, slot: UInt256) =
7373
ac.slots[address] = toHashSet([slot])
7474

7575
proc addCode*(ac: var AccessList, codeAddr: Address) =
76-
if codeAddr notin ac.codeAddrs:
77-
ac.codeAddrs.add(codeAddr)
76+
ac.codeAddrs.incl codeAddr
7877

7978
proc clear*(ac: var AccessList) {.inline.} =
8079
ac.slots.clear()
81-
ac.codeAddrs.setLen(0)
80+
ac.codeAddrs.clear()
8281

8382
# TODO: accesses code is still not a part of the transaction access list
8483
# but when it does trickle down into the transaction we will have to add

execution_chain/db/ledger.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ proc accessList*(ac: LedgerRef, address: Address) =
829829
proc accessList*(ac: LedgerRef, address: Address, slot: UInt256) =
830830
ac.savePoint.accessList.add(address, slot)
831831
832-
proc accessList*(ac: LedgerRef, codeAddr: Address) =
832+
proc codeAccessList*(ac: LedgerRef, codeAddr: Address) =
833833
ac.savePoint.accessList.addCode(codeAddr)
834834
835835
func inAccessList*(ac: LedgerRef, address: Address): bool =

execution_chain/evm/computation.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ proc writeContract*(c: Computation) =
219219
c.setError(StatusCode.OutOfGas, true)
220220
return
221221
# EIP-170 constraint (https://eips.ethereum.org/EIPS/eip-170).
222-
elif fork >= FkSpurious and len > EIP7907_MAX_CODE_SIZE:
222+
elif fork >= FkSpurious and len > EIP170_MAX_CODE_SIZE:
223223
withExtra trace, "New contract code exceeds EIP-170 limit",
224224
codeSize=len, maxSize=EIP170_MAX_CODE_SIZE
225225
c.setError(StatusCode.OutOfGas, true)

execution_chain/evm/interpreter/op_handlers/oph_create.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ proc createOp(cpt: VmCpt): EvmResultVoid =
117117
createMsgGas -= createMsgGas div 64
118118
? cpt.gasMeter.consumeGas(createMsgGas, reason = "CREATE msg gas")
119119

120+
if cpt.fork >= FkOsaka:
121+
cpt.vmState.mutateLedger:
122+
db.codeAccessList(cpt.msg.contractAddress)
123+
120124
var
121125
childMsg = Message(
122126
kind: CallKind.Create,
@@ -187,6 +191,11 @@ proc create2Op(cpt: VmCpt): EvmResultVoid =
187191
balance = senderBalance
188192
return ok()
189193

194+
if cpt.fork >= FkOsaka:
195+
cpt.vmState.mutateLedger:
196+
db.codeAccessList(cpt.msg.contractAddress)
197+
198+
190199
var createMsgGas = cpt.gasMeter.gasRemaining
191200
if cpt.fork >= FkTangerine:
192201
createMsgGas -= createMsgGas div 64

execution_chain/evm/interpreter/op_handlers/oph_defs.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ const
8282
VmOpCancunAndLater* =
8383
VmOpShanghaiAndLater - {FkShanghai}
8484

85-
VmOpOsakaAndLater* =
85+
VmOpPragueAndLater* =
8686
VmOpCancunAndLater - {FkCancun}
8787

88+
VmOpOsakaAndLater* =
89+
VmOpPragueAndLater - {FkPrague}
90+
8891

8992
# ------------------------------------------------------------------------------
9093
# End

execution_chain/evm/interpreter/op_handlers/oph_envinfo.nim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ proc extCodeCopyEIP7907Op(cpt: VmCpt): EvmResultVoid =
198198
codePos = cpt.stack.lsPeekMemRef(^3)
199199
len = cpt.stack.lsPeekMemRef(^4)
200200
gasCost = cpt.gasCosts[ExtCodeCopy].m_handler(cpt.memory.len, memPos, len) +
201-
cpt.gasEip2929AccountCheck(address) + cpt.gasCallEIP7907(addresss)
201+
cpt.gasEip2929AccountCheck(address) + cpt.gasCallEIP7907(address)
202202

203203
cpt.stack.lsShrink(4)
204204
? cpt.opcodeGasCost(ExtCodeCopy, gasCost, reason = "ExtCodeCopy EIP7907")
@@ -207,7 +207,6 @@ proc extCodeCopyEIP7907Op(cpt: VmCpt): EvmResultVoid =
207207
cpt.memory.writePadded(code.bytes(), memPos, codePos, len)
208208
ok()
209209

210-
211210
# -----------
212211

213212
func returnDataSizeOp(cpt: VmCpt): EvmResultVoid =
@@ -364,7 +363,7 @@ const
364363

365364

366365
(opCode: ExtCodeCopy, ## 0x3c, Account Code-copy for Berlin through Cancun
367-
forks: VmOpBerlinAndLater,
366+
forks: VmOpBerlinAndLater - VmOpOsakaAndLater,
368367
name: "extCodeCopyEIP2929",
369368
info: "EIP2929: Copy an account's code to memory",
370369
exec: extCodeCopyEIP2929Op),

execution_chain/evm/interpreter/op_handlers/oph_helpers.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
{.push raises: [].}
1616

1717
import
18+
../../../constants,
1819
../../../core/eip7702,
1920
../../evm_errors,
21+
../../interpreter/utils/utils_numeric,
2022
../../types,
2123
../gas_costs,
2224
eth/common/[addresses, base],
@@ -68,10 +70,9 @@ proc gasEip7702CodeCheck*(c: Computation; address: Address): GasInt =
6870

6971
proc gasCallEIP7907*(c: Computation, codeAddress: Address): GasInt =
7072
c.vmState.mutateLedger:
71-
let codeHash = db.getCodeHash(codeAddress)
7273

73-
if not db.inAccessList(codeHash):
74-
db.accessList(codeHash)
74+
if not db.inCodeAccessList(codeAddress):
75+
db.codeAccessList(codeAddress)
7576

7677
let
7778
code = db.getCode(codeAddress)

hive_integration/nodocker/engine/withdrawals/wd_max_init_code_spec.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type
3232
overflowMaxInitcodeTxCountAfterFork *: uint64
3333

3434
const
35-
MAX_INITCODE_SIZE = EIP170_MAX_INITCODE_SIZE
35+
MAX_INITCODE_SIZE = EIP3860_MAX_INITCODE_SIZE
3636

3737
proc execute*(ws: MaxInitcodeSizeSpec, env: TestEnv): bool =
3838
testCond waitFor env.clMock.waitForTTD()

vendor/constantine

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)