EOF suite: rebase master branch

This commit is contained in:
jangko 2023-07-25 09:59:01 +07:00
parent 1720af4e2b
commit 343779415f
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
8 changed files with 43 additions and 22 deletions

View File

@ -11,10 +11,8 @@
import import
std/[tables, hashes, sets], std/[tables, hashes, sets],
eth/[common, rlp], eth/[common, rlp],
../constants, ../utils/[utils, eof], storage_types, ../constants, ../utils/[utils, eof],
../../stateless/multi_keys, ../../stateless/multi_keys,
../constants,
../utils/utils,
./access_list as ac_access_list, ./access_list as ac_access_list,
"."/[core_db, distinct_tries, storage_types, transient_storage] "."/[core_db, distinct_tries, storage_types, transient_storage]
@ -382,9 +380,9 @@ proc loadCode(acc: RefAccount, ac: AccountsCache) =
return return
when defined(geth): when defined(geth):
let data = ac.db.get(acc.account.codeHash.data) let data = ac.kvt.get(acc.account.codeHash.data)
else: else:
let data = ac.db.get(contractHashKey(acc.account.codeHash).toOpenArray) let data = ac.kvt.get(contractHashKey(acc.account.codeHash).toOpenArray)
acc.code = data acc.code = data
acc.flags.incl CodeLoaded acc.flags.incl CodeLoaded

View File

@ -10,7 +10,7 @@ import
chronicles, chronicles,
eth/common, eth/common,
stew/[results, endians2], stew/[results, endians2],
stew/ranges/ptr_arith, stew/ptrops,
../utils/eof, ../utils/eof,
./interpreter/op_codes ./interpreter/op_codes

View File

@ -145,7 +145,7 @@ const
cpt.gasCosts[CodeCopy].m_handler(cpt.memory.len, memPos, len), cpt.gasCosts[CodeCopy].m_handler(cpt.memory.len, memPos, len),
reason = "CodeCopy fee") reason = "CodeCopy fee")
cpt.memory.writePadded(k.cpt.code.legacyCode, memPos, copyPos, len) cpt.memory.writePadded(cpt.code.legacyCode, memPos, copyPos, len)
gasPriceOp: Vm2OpFn = proc (k: var Vm2Ctx) = gasPriceOp: Vm2OpFn = proc (k: var Vm2Ctx) =

View File

@ -14,12 +14,11 @@ const
lowMemoryCompileTime {.used.} = lowmem > 0 lowMemoryCompileTime {.used.} = lowmem > 0
import import
std/[macros, sets, strformat], std/[macros, strformat],
pkg/[chronicles, chronos, stew/byteutils],
".."/[constants, db/accounts_cache], ".."/[constants, db/accounts_cache],
"."/[code_stream, computation, validate], "."/[code_stream, computation, validate],
"."/[message, precompiles, state, types], "."/[message, precompiles, state, types],
../utils/[utils, eof], ../utils/eof,
./interpreter/[op_dispatcher, gas_costs], ./interpreter/[op_dispatcher, gas_costs],
pkg/[chronicles, chronos, eth/keys, stew/byteutils] pkg/[chronicles, chronos, eth/keys, stew/byteutils]
@ -366,6 +365,9 @@ else:
# to write the async version of the iterative one, but this one is # to write the async version of the iterative one, but this one is
# a bit shorter and feels cleaner, so if it works just as well I'd # a bit shorter and feels cleaner, so if it works just as well I'd
# rather use this one. --Adam # rather use this one. --Adam
import
async/operations
proc asyncExecCallOrCreate*(c: Computation): Future[void] {.async.} = proc asyncExecCallOrCreate*(c: Computation): Future[void] {.async.} =
defer: c.dispose() defer: c.dispose()

View File

@ -187,21 +187,39 @@ proc mergeStackTable(): StackTable {.compileTime.} =
result = londonStackTable() result = londonStackTable()
result[PrevRandao] = sp(0, 1) result[PrevRandao] = sp(0, 1)
proc cancunStackTable(): StackTable {.compileTime.} = proc shanghaiStackTable(): StackTable {.compileTime.} =
result = mergeStackTable() result = mergeStackTable()
# new opcodes EIP-3855
result[Push0] = sp(0, 1)
proc cancunStackTable(): StackTable {.compileTime.} =
result = shanghaiStackTable()
# new opcodes EIP-4844
result[BlobHash] = sp(1, 1)
# new opcodes EIP-1153
result[TLoad] = sp(1, 1)
result[TStore] = sp(2, 0)
# new opcodes EIP-5656
result[Mcopy] = sp(3, 0)
# new opcodes EIP-4200 # new opcodes EIP-4200
result[Rjump] = sp(0, 0) result[Rjump] = sp(0, 0)
result[RJumpI] = sp(1, 0) result[RJumpI] = sp(1, 0)
result[RJumpV] = sp(1, 0) result[RJumpV] = sp(1, 0)
# new opcodes EIP-4750 # new opcodes EIP-4750
result[CallF] = sp(0, 0) result[CallF] = sp(0, 0)
result[RetF] = sp(0, 0) result[RetF] = sp(0, 0)
# new opcodes EIP-3855
result[Push0] = sp(0, 1) # new opcodes EIP-7516
result[BlobBaseFee] = sp(1, 1)
# disable opcodes EIP-3670 # disable opcodes EIP-3670
result[CallCode] = StackDesc() result[CallCode] = StackDesc()
result[SelfDestruct] = StackDesc() result[SelfDestruct] = StackDesc()
# disable opcodes EIP-5450 # disable opcodes EIP-5450
result[Jump] = StackDesc() result[Jump] = StackDesc()
result[JumpI] = StackDesc() result[JumpI] = StackDesc()
@ -220,6 +238,6 @@ const
istanbulStackTable(), istanbulStackTable(),
londonStackTable(), londonStackTable(),
mergeStackTable(), mergeStackTable(),
mergeStackTable(), shanghaiStackTable(),
cancunStackTable(), cancunStackTable(),
] ]

View File

@ -14,8 +14,8 @@
"berlinBlock": 0, "berlinBlock": 0,
"londonBlock": 0, "londonBlock": 0,
"mergeForkBlock": 0, "mergeForkBlock": 0,
"shanghaiBlock": 0, "shanghaiTime": 0,
"cancunBlock": 0, "cancunTime": 0,
"terminalTotalDifficulty": 0 "terminalTotalDifficulty": 0
}, },
"genesis": { "genesis": {

View File

@ -1,5 +1,5 @@
import import
std/[tables, math, times], std/[tables, math],
eth/[keys], eth/[keys],
stew/byteutils, stew/byteutils,
unittest2, unittest2,
@ -230,7 +230,7 @@ proc initEnv(): TestEnv =
let let
com = CommonRef.new( com = CommonRef.new(
newMemoryDb(), newCoreDbRef LegacyDbMemory,
conf.pruneMode == PruneMode.Full, conf.pruneMode == PruneMode.Full,
conf.networkId, conf.networkId,
conf.networkParams conf.networkParams
@ -278,6 +278,9 @@ proc eofMain*() =
txs.add env.makeTx(some(cc), 0.u256, initCode) txs.add env.makeTx(some(cc), 0.u256, initCode)
suite "Test EOF code deployment": suite "Test EOF code deployment":
test "is EOF fork?":
check com.forkGTE(EOFFork)
test "add txs to txpool": test "add txs to txpool":
for tx in txs: for tx in txs:
let res = xp.addLocal(tx, force = true) let res = xp.addLocal(tx, force = true)
@ -292,14 +295,15 @@ proc eofMain*() =
test "generate POS block": test "generate POS block":
com.pos.prevRandao = prevRandao com.pos.prevRandao = prevRandao
com.pos.feeRecipient = aa com.pos.feeRecipient = aa
com.pos.timestamp = getTime() com.pos.timestamp = EthTime.now()
let blk = xp.ethBlock() let blk = xp.ethBlock()
check com.isBlockAfterTtd(blk.header) check com.isBlockAfterTtd(blk.header)
let body = BlockBody( let body = BlockBody(
transactions: blk.txs, transactions: blk.txs,
uncles: blk.uncles uncles: blk.uncles,
withdrawals: some[seq[Withdrawal]](@[])
) )
check blk.txs.len == 4 check blk.txs.len == 4
@ -311,7 +315,7 @@ proc eofMain*() =
test "check flags and various deployment mechanisms": test "check flags and various deployment mechanisms":
var state = AccountsCache.init( var state = AccountsCache.init(
com.db.db, com.db,
stateRoot, stateRoot,
com.pruneTrie) com.pruneTrie)

View File

@ -498,7 +498,6 @@ const
expOut: "exp.json", expOut: "exp.json",
), ),
TestSpec( TestSpec(
<<<<<<< HEAD
name : "EVM tracer nil stack crash bug", name : "EVM tracer nil stack crash bug",
base : "testdata/00-519", base : "testdata/00-519",
input : t8nInput( input : t8nInput(