Skip to content

Commit 3437794

Browse files
committed
EOF suite: rebase master branch
1 parent 1720af4 commit 3437794

File tree

8 files changed

+43
-22
lines changed

8 files changed

+43
-22
lines changed

nimbus/db/accounts_cache.nim

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
import
1212
std/[tables, hashes, sets],
1313
eth/[common, rlp],
14-
../constants, ../utils/[utils, eof], storage_types,
14+
../constants, ../utils/[utils, eof],
1515
../../stateless/multi_keys,
16-
../constants,
17-
../utils/utils,
1816
./access_list as ac_access_list,
1917
"."/[core_db, distinct_tries, storage_types, transient_storage]
2018

@@ -382,9 +380,9 @@ proc loadCode(acc: RefAccount, ac: AccountsCache) =
382380
return
383381

384382
when defined(geth):
385-
let data = ac.db.get(acc.account.codeHash.data)
383+
let data = ac.kvt.get(acc.account.codeHash.data)
386384
else:
387-
let data = ac.db.get(contractHashKey(acc.account.codeHash).toOpenArray)
385+
let data = ac.kvt.get(contractHashKey(acc.account.codeHash).toOpenArray)
388386

389387
acc.code = data
390388
acc.flags.incl CodeLoaded

nimbus/evm/code_stream.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import
1010
chronicles,
1111
eth/common,
1212
stew/[results, endians2],
13-
stew/ranges/ptr_arith,
13+
stew/ptrops,
1414
../utils/eof,
1515
./interpreter/op_codes
1616

nimbus/evm/interpreter/op_handlers/oph_envinfo.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const
145145
cpt.gasCosts[CodeCopy].m_handler(cpt.memory.len, memPos, len),
146146
reason = "CodeCopy fee")
147147

148-
cpt.memory.writePadded(k.cpt.code.legacyCode, memPos, copyPos, len)
148+
cpt.memory.writePadded(cpt.code.legacyCode, memPos, copyPos, len)
149149

150150

151151
gasPriceOp: Vm2OpFn = proc (k: var Vm2Ctx) =

nimbus/evm/interpreter_dispatch.nim

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ const
1414
lowMemoryCompileTime {.used.} = lowmem > 0
1515

1616
import
17-
std/[macros, sets, strformat],
18-
pkg/[chronicles, chronos, stew/byteutils],
17+
std/[macros, strformat],
1918
".."/[constants, db/accounts_cache],
2019
"."/[code_stream, computation, validate],
2120
"."/[message, precompiles, state, types],
22-
../utils/[utils, eof],
21+
../utils/eof,
2322
./interpreter/[op_dispatcher, gas_costs],
2423
pkg/[chronicles, chronos, eth/keys, stew/byteutils]
2524

@@ -366,6 +365,9 @@ else:
366365
# to write the async version of the iterative one, but this one is
367366
# a bit shorter and feels cleaner, so if it works just as well I'd
368367
# rather use this one. --Adam
368+
import
369+
async/operations
370+
369371
proc asyncExecCallOrCreate*(c: Computation): Future[void] {.async.} =
370372
defer: c.dispose()
371373

nimbus/evm/stack_table.nim

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,39 @@ proc mergeStackTable(): StackTable {.compileTime.} =
187187
result = londonStackTable()
188188
result[PrevRandao] = sp(0, 1)
189189

190-
proc cancunStackTable(): StackTable {.compileTime.} =
190+
proc shanghaiStackTable(): StackTable {.compileTime.} =
191191
result = mergeStackTable()
192+
# new opcodes EIP-3855
193+
result[Push0] = sp(0, 1)
194+
195+
proc cancunStackTable(): StackTable {.compileTime.} =
196+
result = shanghaiStackTable()
197+
# new opcodes EIP-4844
198+
result[BlobHash] = sp(1, 1)
199+
200+
# new opcodes EIP-1153
201+
result[TLoad] = sp(1, 1)
202+
result[TStore] = sp(2, 0)
203+
204+
# new opcodes EIP-5656
205+
result[Mcopy] = sp(3, 0)
206+
192207
# new opcodes EIP-4200
193208
result[Rjump] = sp(0, 0)
194209
result[RJumpI] = sp(1, 0)
195210
result[RJumpV] = sp(1, 0)
211+
196212
# new opcodes EIP-4750
197213
result[CallF] = sp(0, 0)
198214
result[RetF] = sp(0, 0)
199-
# new opcodes EIP-3855
200-
result[Push0] = sp(0, 1)
215+
216+
# new opcodes EIP-7516
217+
result[BlobBaseFee] = sp(1, 1)
201218

202219
# disable opcodes EIP-3670
203220
result[CallCode] = StackDesc()
204221
result[SelfDestruct] = StackDesc()
222+
205223
# disable opcodes EIP-5450
206224
result[Jump] = StackDesc()
207225
result[JumpI] = StackDesc()
@@ -220,6 +238,6 @@ const
220238
istanbulStackTable(),
221239
londonStackTable(),
222240
mergeStackTable(),
223-
mergeStackTable(),
241+
shanghaiStackTable(),
224242
cancunStackTable(),
225243
]

tests/customgenesis/eof.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"berlinBlock": 0,
1515
"londonBlock": 0,
1616
"mergeForkBlock": 0,
17-
"shanghaiBlock": 0,
18-
"cancunBlock": 0,
17+
"shanghaiTime": 0,
18+
"cancunTime": 0,
1919
"terminalTotalDifficulty": 0
2020
},
2121
"genesis": {

tests/test_eof.nim

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import
2-
std/[tables, math, times],
2+
std/[tables, math],
33
eth/[keys],
44
stew/byteutils,
55
unittest2,
@@ -230,7 +230,7 @@ proc initEnv(): TestEnv =
230230

231231
let
232232
com = CommonRef.new(
233-
newMemoryDb(),
233+
newCoreDbRef LegacyDbMemory,
234234
conf.pruneMode == PruneMode.Full,
235235
conf.networkId,
236236
conf.networkParams
@@ -278,6 +278,9 @@ proc eofMain*() =
278278
txs.add env.makeTx(some(cc), 0.u256, initCode)
279279

280280
suite "Test EOF code deployment":
281+
test "is EOF fork?":
282+
check com.forkGTE(EOFFork)
283+
281284
test "add txs to txpool":
282285
for tx in txs:
283286
let res = xp.addLocal(tx, force = true)
@@ -292,14 +295,15 @@ proc eofMain*() =
292295
test "generate POS block":
293296
com.pos.prevRandao = prevRandao
294297
com.pos.feeRecipient = aa
295-
com.pos.timestamp = getTime()
298+
com.pos.timestamp = EthTime.now()
296299

297300
let blk = xp.ethBlock()
298301
check com.isBlockAfterTtd(blk.header)
299302

300303
let body = BlockBody(
301304
transactions: blk.txs,
302-
uncles: blk.uncles
305+
uncles: blk.uncles,
306+
withdrawals: some[seq[Withdrawal]](@[])
303307
)
304308
check blk.txs.len == 4
305309

@@ -311,7 +315,7 @@ proc eofMain*() =
311315

312316
test "check flags and various deployment mechanisms":
313317
var state = AccountsCache.init(
314-
com.db.db,
318+
com.db,
315319
stateRoot,
316320
com.pruneTrie)
317321

tools/t8n/t8n_test.nim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ const
498498
expOut: "exp.json",
499499
),
500500
TestSpec(
501-
<<<<<<< HEAD
502501
name : "EVM tracer nil stack crash bug",
503502
base : "testdata/00-519",
504503
input : t8nInput(

0 commit comments

Comments
 (0)