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
std/[tables, hashes, sets],
eth/[common, rlp],
../constants, ../utils/[utils, eof], storage_types,
../constants, ../utils/[utils, eof],
../../stateless/multi_keys,
../constants,
../utils/utils,
./access_list as ac_access_list,
"."/[core_db, distinct_tries, storage_types, transient_storage]
@ -382,9 +380,9 @@ proc loadCode(acc: RefAccount, ac: AccountsCache) =
return
when defined(geth):
let data = ac.db.get(acc.account.codeHash.data)
let data = ac.kvt.get(acc.account.codeHash.data)
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.flags.incl CodeLoaded

View File

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

View File

@ -145,7 +145,7 @@ const
cpt.gasCosts[CodeCopy].m_handler(cpt.memory.len, memPos, len),
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) =

View File

@ -14,12 +14,11 @@ const
lowMemoryCompileTime {.used.} = lowmem > 0
import
std/[macros, sets, strformat],
pkg/[chronicles, chronos, stew/byteutils],
std/[macros, strformat],
".."/[constants, db/accounts_cache],
"."/[code_stream, computation, validate],
"."/[message, precompiles, state, types],
../utils/[utils, eof],
../utils/eof,
./interpreter/[op_dispatcher, gas_costs],
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
# a bit shorter and feels cleaner, so if it works just as well I'd
# rather use this one. --Adam
import
async/operations
proc asyncExecCallOrCreate*(c: Computation): Future[void] {.async.} =
defer: c.dispose()

View File

@ -187,21 +187,39 @@ proc mergeStackTable(): StackTable {.compileTime.} =
result = londonStackTable()
result[PrevRandao] = sp(0, 1)
proc cancunStackTable(): StackTable {.compileTime.} =
proc shanghaiStackTable(): StackTable {.compileTime.} =
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
result[Rjump] = sp(0, 0)
result[RJumpI] = sp(1, 0)
result[RJumpV] = sp(1, 0)
# new opcodes EIP-4750
result[CallF] = 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
result[CallCode] = StackDesc()
result[SelfDestruct] = StackDesc()
# disable opcodes EIP-5450
result[Jump] = StackDesc()
result[JumpI] = StackDesc()
@ -220,6 +238,6 @@ const
istanbulStackTable(),
londonStackTable(),
mergeStackTable(),
mergeStackTable(),
shanghaiStackTable(),
cancunStackTable(),
]

View File

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

View File

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

View File

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