Skip to content

Commit 7bc4f99

Browse files
committed
EOF suite: rebase master branch
1 parent a533710 commit 7bc4f99

File tree

8 files changed

+38
-17
lines changed

8 files changed

+38
-17
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

@@ -384,9 +382,9 @@ proc loadCode(acc: RefAccount, ac: AccountsCache) =
384382
return
385383

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

391389
acc.code = data
392390
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
@@ -169,7 +169,7 @@ const
169169
cpt.gasCosts[CodeCopy].m_handler(cpt.memory.len, memPos, len),
170170
reason = "CodeCopy fee")
171171

172-
cpt.memory.writePaddedResult(k.cpt.code.legacyCode, memPos, copyPos, len)
172+
cpt.memory.writePaddedResult(cpt.code.legacyCode, memPos, copyPos, len)
173173

174174
gasPriceOp: Vm2OpFn = proc (k: var Vm2Ctx) =
175175
## 0x3A, Get price of gas in current environment.

nimbus/evm/interpreter_dispatch.nim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ else:
361361
# to write the async version of the iterative one, but this one is
362362
# a bit shorter and feels cleaner, so if it works just as well I'd
363363
# rather use this one. --Adam
364+
import
365+
async/operations
366+
364367
proc asyncExecCallOrCreate*(c: Computation): Future[void] {.async.} =
365368
defer: c.dispose()
366369

nimbus/evm/stack_table.nim

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,36 @@ 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)
201215

202216
# disable opcodes EIP-3670
203217
result[CallCode] = StackDesc()
204218
result[SelfDestruct] = StackDesc()
219+
205220
# disable opcodes EIP-5450
206221
result[Jump] = StackDesc()
207222
result[JumpI] = StackDesc()
@@ -220,6 +235,6 @@ const
220235
istanbulStackTable(),
221236
londonStackTable(),
222237
mergeStackTable(),
223-
mergeStackTable(),
238+
shanghaiStackTable(),
224239
cancunStackTable(),
225240
]

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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -299,7 +302,8 @@ proc eofMain*() =
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/testdata/28/env.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@
77
"parentGasUsed": "0x0",
88
"parentGasLimit": "0x750a163df65e8a",
99
"currentNumber": "1",
10-
"currentTimestamp": "1000"
10+
"currentTimestamp": "1000",
11+
"withdrawals": []
1112
}

0 commit comments

Comments
 (0)