diff --git a/tools/evmstate/evmstate.nim b/tools/evmstate/evmstate.nim index 3b3ddef80..306ec48a2 100644 --- a/tools/evmstate/evmstate.nim +++ b/tools/evmstate/evmstate.nim @@ -11,7 +11,7 @@ import std/[json, strutils, sets, tables, options, streams], chronicles, - eth/keys, + eth/common/keys, eth/common/transaction_utils, stew/byteutils, results, @@ -32,11 +32,11 @@ import type StateContext = object name: string - parent: BlockHeader - header: BlockHeader + parent: Header + header: Header tx: Transaction - expectedHash: Hash256 - expectedLogs: Hash256 + expectedHash: Hash32 + expectedLogs: Hash32 forkStr: string chainConfig: ChainConfig index: int @@ -47,7 +47,7 @@ type StateResult = object name : string pass : bool - root : Hash256 + root : Hash32 fork : string error: string state: StateDump @@ -65,10 +65,10 @@ proc toBytes(x: string): seq[byte] = result = newSeq[byte](x.len) for i in 0.. 0: @@ -160,7 +160,7 @@ proc defaultTraceStreamFilename(conf: T8NConf, fName = "$1/trace-$2-$3.jsonl" % [baseDir, $txIndex, txHash] (baseDir, fName) -proc defaultTraceStream(conf: T8NConf, txIndex: int, txHash: Hash256): Stream = +proc defaultTraceStream(conf: T8NConf, txIndex: int, txHash: Hash32): Stream = let (baseDir, fName) = defaultTraceStreamFilename(conf, txIndex, txHash) createDir(baseDir) newFileStream(fName, fmWrite) @@ -173,7 +173,7 @@ proc traceToFileStream(path: string, txIndex: int): Stream = createDir(file.dir) newFileStream(fName, fmWrite) -proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash256, vmState: BaseVMState) = +proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMState) = var tracerFlags = { TracerFlags.DisableMemory, TracerFlags.DisableStorage, @@ -214,7 +214,7 @@ proc closeTrace(vmState: BaseVMState) = proc exec(ctx: var TransContext, vmState: BaseVMState, stateReward: Option[UInt256], - header: BlockHeader, + header: Header, conf: T8NConf): ExecOutput = let txList = ctx.parseTxs(vmState.com.chainId) @@ -242,7 +242,7 @@ proc exec(ctx: var TransContext, prevNumber = ctx.env.currentNumber - 1 prevHash = ctx.env.blockHashes.getOrDefault(prevNumber) - if prevHash == static(default(Hash256)): + if prevHash == static(default(Hash32)): raise newError(ErrorConfig, "previous block hash not found for block number: " & $prevNumber) vmState.processParentBlockHash(prevHash).isOkOr: @@ -394,10 +394,10 @@ proc setupAlloc(stateDB: LedgerRef, alloc: GenesisAlloc) = for slot, value in acc.storage: stateDB.setStorage(accAddr, slot, value) -method getAncestorHash(vmState: TestVMState; blockNumber: BlockNumber): Hash256 = +method getAncestorHash(vmState: TestVMState; blockNumber: BlockNumber): Hash32 = # we can't raise exception here, it'll mess with EVM exception handler. # so, store the exception for later using `hashError` - var h = default(Hash256) + var h = default(Hash32) if vmState.blockHashes.len == 0: vmState.hashError = "getAncestorHash(" & $blockNumber & ") invoked, no blockhashes provided" @@ -465,12 +465,12 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) = let n = json.parseFile(conf.inputTxs) ctx.parseTxs(n) - let uncleHash = if ctx.env.parentUncleHash == default(Hash256): + let uncleHash = if ctx.env.parentUncleHash == default(Hash32): EMPTY_UNCLE_HASH else: ctx.env.parentUncleHash - let parent = BlockHeader( + let parent = Header( stateRoot: emptyRlpHash, timestamp: ctx.env.parentTimestamp, difficulty: ctx.env.parentDifficulty.get(0.u256), @@ -502,7 +502,7 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) = raise newError(ErrorConfig, res.error) else: # un-set it if it has been set too early - ctx.env.parentBeaconBlockRoot = Opt.none(Hash256) + ctx.env.parentBeaconBlockRoot = Opt.none(Hash32) let isMerged = config.terminalTotalDifficulty.isSome and config.terminalTotalDifficulty.value == 0.u256 diff --git a/tools/t8n/types.nim b/tools/t8n/types.nim index b93c435b6..2c5af7f76 100644 --- a/tools/t8n/types.nim +++ b/tools/t8n/types.nim @@ -10,7 +10,11 @@ import std/[tables, json], - eth/common, + eth/common/blocks, + eth/common/receipts, + eth/rlp, + results, + stint, ../../nimbus/common/chain_config, ../common/types @@ -25,21 +29,21 @@ type Ommer* = object delta*: uint64 - address*: EthAddress + address*: Address EnvStruct* = object - currentCoinbase*: EthAddress - currentDifficulty*: Opt[DifficultyInt] + currentCoinbase*: Address + currentDifficulty*: Opt[UInt256] currentRandom*: Opt[Bytes32] - parentDifficulty*: Opt[DifficultyInt] + parentDifficulty*: Opt[UInt256] currentGasLimit*: GasInt currentNumber*: BlockNumber currentTimestamp*: EthTime parentTimestamp*: EthTime - blockHashes*: Table[uint64, Hash256] + blockHashes*: Table[uint64, Hash32] ommers*: seq[Ommer] currentBaseFee*: Opt[UInt256] - parentUncleHash*: Hash256 + parentUncleHash*: Hash32 parentBaseFee*: Opt[UInt256] parentGasUsed*: Opt[GasInt] parentGasLimit*: Opt[GasInt] @@ -48,7 +52,7 @@ type currentExcessBlobGas*: Opt[uint64] parentBlobGasUsed*: Opt[uint64] parentExcessBlobGas*: Opt[uint64] - parentBeaconBlockRoot*: Opt[Hash256] + parentBeaconBlockRoot*: Opt[Hash32] TxsType* = enum TxsNone @@ -72,34 +76,34 @@ type TxReceipt* = object txType*: TxType - root*: Hash256 + root*: Hash32 status*: bool cumulativeGasUsed*: GasInt - logsBloom*: BloomFilter + logsBloom*: Bloom logs*: seq[Log] - transactionHash*: Hash256 - contractAddress*: EthAddress + transactionHash*: Hash32 + contractAddress*: Address gasUsed*: GasInt - blockHash*: Hash256 + blockHash*: Hash32 transactionIndex*: int # ExecutionResult contains the execution status after running a state test, any # error that might have occurred and a dump of the final state if requested. ExecutionResult* = object - stateRoot*: Hash256 - txRoot*: Hash256 - receiptsRoot*: Hash256 - logsHash*: Hash256 - logsBloom*: BloomFilter + stateRoot*: Hash32 + txRoot*: Hash32 + receiptsRoot*: Hash32 + logsHash*: Hash32 + logsBloom*: Bloom receipts*: seq[TxReceipt] rejected*: seq[RejectedTx] - currentDifficulty*: Opt[DifficultyInt] + currentDifficulty*: Opt[UInt256] gasUsed*: GasInt currentBaseFee*: Opt[UInt256] - withdrawalsRoot*: Opt[Hash256] + withdrawalsRoot*: Opt[Hash32] blobGasUsed*: Opt[uint64] currentExcessBlobGas*: Opt[uint64] - requestsRoot*: Opt[Hash256] + requestsRoot*: Opt[Hash32] depositRequests*: Opt[seq[DepositRequest]] withdrawalRequests*: Opt[seq[WithdrawalRequest]] consolidationRequests*: Opt[seq[ConsolidationRequest]]