Fix eth/common related deprecation warnings for t8n and evmstate tools (#2711)

* Fix eth/common related deprecation warnings for t8n

* Fix eth/common related deprecation warnings for evmstate
This commit is contained in:
andri lim 2024-10-08 12:52:32 +07:00 committed by GitHub
parent 22134fcf4c
commit 6f9fc3eced
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 110 additions and 109 deletions

View File

@ -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..<x.len: result[i] = x[i].byte
method getAncestorHash(vmState: TestVMState; blockNumber: BlockNumber): Hash256 =
keccakHash(toBytes($blockNumber))
method getAncestorHash(vmState: TestVMState; blockNumber: BlockNumber): Hash32 =
keccak256(toBytes($blockNumber))
proc verifyResult(ctx: var StateContext, vmState: BaseVMState, obtainedHash: Hash256) =
proc verifyResult(ctx: var StateContext, vmState: BaseVMState, obtainedHash: Hash32) =
ctx.error = ""
if obtainedHash != ctx.expectedHash:
ctx.error = "post state root mismatch: got $1, want $2" %
@ -99,7 +99,7 @@ proc writeResultToStdout(stateRes: seq[StateResult]) =
stdout.write(n.pretty)
stdout.write("\n")
proc writeRootHashToStderr(stateRoot: Hash256) =
proc writeRootHashToStderr(stateRoot: Hash32) =
let stateRoot = %{
"stateRoot": %(stateRoot)
}
@ -209,8 +209,8 @@ proc prepareAndRun(ctx: var StateContext, conf: StateConf): bool =
inc index
template runSubTest(subTest: JsonNode) =
ctx.expectedHash = Hash256.fromJson(subTest["hash"])
ctx.expectedLogs = Hash256.fromJson(subTest["logs"])
ctx.expectedHash = Hash32.fromJson(subTest["hash"])
ctx.expectedLogs = Hash32.fromJson(subTest["logs"])
ctx.tx = parseTx(txData, subTest["indexes"])
let res = ctx.runExecution(conf, pre)
stateRes.add res

View File

@ -10,7 +10,9 @@
import
std/[json, strutils],
eth/[common, keys],
eth/common/keys,
eth/common/headers,
eth/common/transactions,
eth/trie/trie_defs,
stint,
stew/byteutils,
@ -18,8 +20,8 @@ import
../../nimbus/db/ledger,
../../nimbus/common/chain_config
template fromJson(T: type EthAddress, n: JsonNode): EthAddress =
EthAddress.fromHex(n.getStr)
template fromJson(T: type Address, n: JsonNode): Address =
Address.fromHex(n.getStr)
proc fromJson(T: type UInt256, n: JsonNode): UInt256 =
# stTransactionTest/ValueOverflow.json
@ -33,10 +35,10 @@ proc fromJson(T: type UInt256, n: JsonNode): UInt256 =
template fromJson*(T: type Bytes32, n: JsonNode): Bytes32 =
Bytes32(hexToByteArray(n.getStr, 32))
template fromJson*(T: type Hash256, n: JsonNode): Hash256 =
template fromJson*(T: type Hash32, n: JsonNode): Hash32 =
Hash32(hexToByteArray(n.getStr, 32))
proc fromJson(T: type Blob, n: JsonNode): Blob =
proc fromJson(T: type seq[byte], n: JsonNode): T =
let hex = n.getStr
if hex.len == 0:
@[]
@ -60,16 +62,16 @@ proc fromJson(T: type AccessList, n: JsonNode): AccessList =
for x in n:
var ap = AccessPair(
address: EthAddress.fromJson(x["address"])
address: Address.fromJson(x["address"])
)
let sks = x["storageKeys"]
for sk in sks:
ap.storageKeys.add Bytes32.fromHex(sk.getStr)
result.add ap
proc fromJson(T: type VersionedHashes, list: JsonNode): VersionedHashes =
proc fromJson(T: type seq[Hash32], list: JsonNode): T =
for x in list:
result.add VersionedHash.fromHex(x.getStr)
result.add Hash32.fromHex(x.getStr)
template required(T: type, nField: string): auto =
fromJson(T, n[nField])
@ -104,9 +106,9 @@ proc txType(n: JsonNode): TxType =
return TxEip2930
TxLegacy
proc parseHeader*(n: JsonNode): BlockHeader =
BlockHeader(
coinbase : required(EthAddress, "currentCoinbase"),
proc parseHeader*(n: JsonNode): Header =
Header(
coinbase : required(Address, "currentCoinbase"),
difficulty : required(DifficultyInt, "currentDifficulty"),
number : required(BlockNumber, "currentNumber"),
gasLimit : required(GasInt, "currentGasLimit"),
@ -114,13 +116,13 @@ proc parseHeader*(n: JsonNode): BlockHeader =
stateRoot : emptyRlpHash,
mixHash : omitZero(Bytes32, "currentRandom"),
baseFeePerGas : optional(UInt256, "currentBaseFee"),
withdrawalsRoot: optional(Hash256, "currentWithdrawalsRoot"),
withdrawalsRoot: optional(Hash32, "currentWithdrawalsRoot"),
excessBlobGas : optional(uint64, "currentExcessBlobGas"),
parentBeaconBlockRoot: optional(Hash256, "currentBeaconRoot"),
parentBeaconBlockRoot: optional(Hash32, "currentBeaconRoot"),
)
proc parseParentHeader*(n: JsonNode): BlockHeader =
BlockHeader(
proc parseParentHeader*(n: JsonNode): Header =
Header(
stateRoot: emptyRlpHash,
excessBlobGas: optional(uint64, "parentExcessBlobGas"),
blobGasUsed: optional(uint64, "parentBlobGasUsed"),
@ -132,19 +134,19 @@ proc parseTx*(n: JsonNode, dataIndex, gasIndex, valueIndex: int): Transaction =
nonce : required(AccountNonce, "nonce"),
gasLimit: required(GasInt, "gasLimit", gasIndex),
value : required(UInt256, "value", valueIndex),
payload : required(Blob, "data", dataIndex),
payload : required(seq[byte], "data", dataIndex),
chainId : ChainId(1),
gasPrice: omitZero(GasInt, "gasPrice"),
maxFeePerGas : omitZero(GasInt, "maxFeePerGas"),
accessList : omitZero(AccessList, "accessLists", dataIndex),
maxPriorityFeePerGas: omitZero(GasInt, "maxPriorityFeePerGas"),
maxFeePerBlobGas : omitZero(UInt256, "maxFeePerBlobGas"),
versionedHashes : omitZero(VersionedHashes, "blobVersionedHashes")
versionedHashes : omitZero(seq[Hash32], "blobVersionedHashes")
)
let rawTo = n["to"].getStr
if rawTo != "":
tx.to = Opt.some(EthAddress.fromHex(rawTo))
tx.to = Opt.some(Address.fromHex(rawTo))
let secretKey = required(PrivateKey, "secretKey")
signTransaction(tx, secretKey, false)
@ -163,15 +165,15 @@ proc setupStateDB*(wantedState: JsonNode, stateDB: LedgerRef) =
stateDB.setStorage(account, fromHex(UInt256, slot), fromHex(UInt256, value.getStr))
stateDB.setNonce(account, fromJson(AccountNonce, accountData["nonce"]))
stateDB.setCode(account, fromJson(Blob, accountData["code"]))
stateDB.setCode(account, fromJson(seq[byte], accountData["code"]))
stateDB.setBalance(account, fromJson(UInt256, accountData["balance"]))
iterator postState*(node: JsonNode): (EthAddress, GenesisAccount) =
iterator postState*(node: JsonNode): (Address, GenesisAccount) =
for ac, accountData in node:
let account = EthAddress.fromHex(ac)
let account = Address.fromHex(ac)
var ga = GenesisAccount(
nonce : fromJson(AccountNonce, accountData["nonce"]),
code : fromJson(Blob, accountData["code"]),
code : fromJson(seq[byte], accountData["code"]),
balance: fromJson(UInt256, accountData["balance"]),
)

View File

@ -8,12 +8,5 @@
# at your option. This file may not be copied, modified, or distributed except
# according to those terms.
if defined(evmc_enabled):
# evmcLoadVMShowDetail log output will intefere with t8n ouput
switch("define", "chronicles_enabled=off")
else:
switch("define", "chronicles_enabled=off")
# TODO: redirect the logs to a custom stream?
# They are interfering with t8n_test
#switch("define", "chronicles_default_output_device=stderr")
#switch("define", "chronicles_runtime_filtering=on")
# chronicles log output will intefere with t8n ouput
switch("define", "chronicles_enabled=off")

View File

@ -12,7 +12,9 @@ import
std/[json, strutils, tables],
stew/byteutils,
stint,
eth/[common, rlp, keys],
eth/common/eth_types_rlp,
eth/common/keys,
eth/common/blocks,
../../nimbus/transaction,
../../nimbus/common/chain_config,
../common/helpers,
@ -33,13 +35,13 @@ proc parseHexOrInt[T](x: string): T =
else:
parseInt(x).T
proc fromJson(T: type EthAddress, n: JsonNode, field: string): EthAddress =
proc fromJson(T: type Address, n: JsonNode, field: string): Address =
try:
EthAddress.fromHex(n[field].getStr())
Address.fromHex(n[field].getStr())
except ValueError:
raise newError(ErrorJson, "malformed Eth address " & n[field].getStr)
template fromJson(T: type Blob, n: JsonNode, field: string): Blob =
template fromJson(T: type seq[byte], n: JsonNode, field: string): seq[byte] =
hexToSeqByte(n[field].getStr())
proc fromJson(T: type uint64, n: JsonNode, field: string): uint64 =
@ -64,14 +66,14 @@ proc fromJson(T: type Bytes32, n: JsonNode): Bytes32 =
proc fromJson(T: type Bytes32, n: JsonNode, field: string): Bytes32 =
fromJson(T, n[field])
proc fromJson(T: type Hash256, n: JsonNode): Hash256 =
proc fromJson(T: type Hash32, n: JsonNode): Hash32 =
var num = n.getStr()
num.removePrefix("0x")
if num.len < 64:
num = repeat('0', 64 - num.len) & num
Hash32(hexToByteArray(num, 32))
proc fromJson(T: type Hash256, n: JsonNode, field: string): Hash256 =
proc fromJson(T: type Hash32, n: JsonNode, field: string): Hash32 =
fromJson(T, n[field])
template fromJson(T: type EthTime, n: JsonNode, field: string): EthTime =
@ -84,7 +86,7 @@ proc fromJson(T: type AccessList, n: JsonNode, field: string): AccessList =
for x in z:
var ap = AccessPair(
address: EthAddress.fromJson(x, "address")
address: Address.fromJson(x, "address")
)
let sks = x["storageKeys"]
for sk in sks:
@ -94,21 +96,21 @@ proc fromJson(T: type AccessList, n: JsonNode, field: string): AccessList =
proc fromJson(T: type Ommer, n: JsonNode): Ommer =
Ommer(
delta: fromJson(uint64, n, "delta"),
address: fromJson(EthAddress, n, "address")
address: fromJson(Address, n, "address")
)
proc fromJson(T: type Withdrawal, n: JsonNode): Withdrawal =
Withdrawal(
index: fromJson(uint64, n, "index"),
validatorIndex: fromJson(uint64, n, "validatorIndex"),
address: fromJson(EthAddress, n, "address"),
address: fromJson(Address, n, "address"),
amount: fromJson(uint64, n, "amount")
)
proc fromJson(T: type Authorization, n: JsonNode): Authorization =
Authorization(
chainId: fromJson(ChainId, n, "chainId"),
address: fromJson(EthAddress, n, "address"),
address: fromJson(Address, n, "address"),
nonce: fromJson(uint64, n, "nonce"),
yParity: fromJson(uint64, n, "yParity"),
R: fromJson(UInt256, n, "R"),
@ -120,7 +122,7 @@ proc fromJson(T: type seq[Authorization], n: JsonNode, field: string): T =
for x in list:
result.add Authorization.fromJson(x)
proc fromJson(T: type VersionedHashes, n: JsonNode, field: string): VersionedHashes =
proc fromJson(T: type seq[VersionedHash], n: JsonNode, field: string): T =
let list = n[field]
for x in list:
result.add VersionedHash.fromHex(x.getStr)
@ -128,7 +130,7 @@ proc fromJson(T: type VersionedHashes, n: JsonNode, field: string): VersionedHas
template `gas=`(tx: var Transaction, x: GasInt) =
tx.gasLimit = x
template `input=`(tx: var Transaction, x: Blob) =
template `input=`(tx: var Transaction, x: seq[byte]) =
tx.payload = x
template `v=`(tx: var Transaction, x: uint64) =
@ -140,7 +142,7 @@ template `r=`(tx: var Transaction, x: UInt256) =
template `s=`(tx: var Transaction, x: UInt256) =
tx.S = x
template `blobVersionedHashes=`(tx: var Transaction, x: VersionedHashes) =
template `blobVersionedHashes=`(tx: var Transaction, x: seq[VersionedHash]) =
tx.versionedHashes = x
template required(o: untyped, T: type, oField: untyped) =
@ -161,10 +163,10 @@ template optional(o: untyped, T: type, oField: untyped) =
proc parseAlloc*(ctx: var TransContext, n: JsonNode) =
for accAddr, acc in n:
let address = EthAddress.fromHex(accAddr)
let address = Address.fromHex(accAddr)
var ga = GenesisAccount()
if acc.hasKey("code"):
ga.code = Blob.fromJson(acc, "code")
ga.code = seq[byte].fromJson(acc, "code")
if acc.hasKey("nonce"):
ga.nonce = AccountNonce.fromJson(acc, "nonce")
if acc.hasKey("balance"):
@ -178,7 +180,7 @@ proc parseAlloc*(ctx: var TransContext, n: JsonNode) =
ctx.alloc[address] = ga
proc parseEnv*(ctx: var TransContext, n: JsonNode) =
required(ctx.env, EthAddress, currentCoinbase)
required(ctx.env, Address, currentCoinbase)
required(ctx.env, GasInt, currentGasLimit)
required(ctx.env, BlockNumber, currentNumber)
required(ctx.env, EthTime, currentTimestamp)
@ -187,7 +189,7 @@ proc parseEnv*(ctx: var TransContext, n: JsonNode) =
optional(ctx.env, DifficultyInt, parentDifficulty)
omitZero(ctx.env, EthTime, parentTimestamp)
optional(ctx.env, UInt256, currentBaseFee)
omitZero(ctx.env, Hash256, parentUncleHash)
omitZero(ctx.env, Hash32, parentUncleHash)
optional(ctx.env, UInt256, parentBaseFee)
optional(ctx.env, GasInt, parentGasUsed)
optional(ctx.env, GasInt, parentGasLimit)
@ -195,12 +197,12 @@ proc parseEnv*(ctx: var TransContext, n: JsonNode) =
optional(ctx.env, uint64, currentExcessBlobGas)
optional(ctx.env, uint64, parentBlobGasUsed)
optional(ctx.env, uint64, parentExcessBlobGas)
optional(ctx.env, Hash256, parentBeaconBlockRoot)
optional(ctx.env, Hash32, parentBeaconBlockRoot)
if n.hasKey("blockHashes"):
let w = n["blockHashes"]
for k, v in w:
ctx.env.blockHashes[parseHexOrInt[uint64](k)] = Hash256.fromHex(v.getStr())
ctx.env.blockHashes[parseHexOrInt[uint64](k)] = Hash32.fromHex(v.getStr())
if n.hasKey("ommers"):
let w = n["ommers"]
@ -224,10 +226,10 @@ proc parseTx(n: JsonNode, chainId: ChainID): Transaction =
required(tx, AccountNonce, nonce)
required(tx, GasInt, gas)
required(tx, UInt256, value)
required(tx, Blob, input)
required(tx, seq[byte], input)
if n.hasKey("to"):
tx.to = Opt.some(EthAddress.fromJson(n, "to"))
tx.to = Opt.some(Address.fromJson(n, "to"))
tx.chainId = chainId
case tx.txType
@ -248,7 +250,7 @@ proc parseTx(n: JsonNode, chainId: ChainID): Transaction =
required(tx, GasInt, maxFeePerGas)
omitZero(tx, AccessList, accessList)
required(tx, UInt256, maxFeePerBlobGas)
required(tx, VersionedHashes, blobVersionedHashes)
required(tx, seq[VersionedHash], blobVersionedHashes)
of TxEip7702:
required(tx, ChainId, chainId)
required(tx, GasInt, maxPriorityFeePerGas)
@ -261,7 +263,7 @@ proc parseTx(n: JsonNode, chainId: ChainID): Transaction =
eip155 = n["protected"].bval
if n.hasKey("secretKey"):
let data = Blob.fromJson(n, "secretKey")
let data = seq[byte].fromJson(n, "secretKey")
let secretKey = PrivateKey.fromRaw(data).tryGet
signTransaction(tx, secretKey, eip155)
else:
@ -356,10 +358,10 @@ proc `@@`(x: uint64 | int64 | int): JsonNode =
proc `@@`(x: UInt256): JsonNode =
%("0x" & x.toHex)
proc `@@`(x: Hash256): JsonNode =
proc `@@`(x: Hash32): JsonNode =
%("0x" & x.data.toHex)
proc `@@`*(x: Blob): JsonNode =
proc `@@`*(x: seq[byte]): JsonNode =
%("0x" & x.toHex)
proc `@@`(x: bool): JsonNode =
@ -393,7 +395,7 @@ proc `@@`[K, V](x: Table[K, V]): JsonNode =
for k, v in x:
result[k.to0xHex] = @@(v)
proc `@@`(x: BloomFilter): JsonNode =
proc `@@`(x: Bloom): JsonNode =
%("0x" & toHex(x))
proc `@@`(x: Log): JsonNode =
@ -405,7 +407,7 @@ proc `@@`(x: Log): JsonNode =
proc `@@`(x: TxReceipt): JsonNode =
result = %{
"root" : if x.root == default(Hash256): %("0x") else: @@(x.root),
"root" : if x.root == default(Hash32): %("0x") else: @@(x.root),
"status" : @@(x.status),
"cumulativeGasUsed": @@(x.cumulativeGasUsed),
"logsBloom" : @@(x.logsBloom),

View File

@ -40,7 +40,7 @@ type
alloc: GenesisAlloc
TestVMState = ref object of BaseVMState
blockHashes: Table[uint64, Hash256]
blockHashes: Table[uint64, Hash32]
hashError: string
proc init(_: type Dispatch): Dispatch =
@ -85,13 +85,13 @@ proc dispatchOutput(ctx: var TransContext, conf: T8NConf, res: ExecOutput) =
stderr.write(dis.stderr.pretty)
stderr.write("\n")
proc calcWithdrawalsRoot(w: Opt[seq[Withdrawal]]): Opt[Hash256] =
proc calcWithdrawalsRoot(w: Opt[seq[Withdrawal]]): Opt[Hash32] =
if w.isNone:
return Opt.none(Hash256)
return Opt.none(Hash32)
Opt.some calcWithdrawalsRoot(w.get)
proc envToHeader(env: EnvStruct): BlockHeader =
BlockHeader(
proc envToHeader(env: EnvStruct): Header =
Header(
coinbase : env.currentCoinbase,
difficulty : env.currentDifficulty.get(0.u256),
mixHash : env.currentRandom.get(default(Bytes32)),
@ -130,7 +130,7 @@ proc toTxReceipt(rec: Receipt,
let contractAddress = genAddress(tx, sender)
TxReceipt(
txType: tx.txType,
root: if rec.isHash: rec.hash else: default(Hash256),
root: if rec.isHash: rec.hash else: default(Hash32),
status: rec.status,
cumulativeGasUsed: rec.cumulativeGasUsed,
logsBloom: rec.logsBloom,
@ -138,11 +138,11 @@ proc toTxReceipt(rec: Receipt,
transactionHash: rlpHash(tx),
contractAddress: contractAddress,
gasUsed: gasUsed,
blockHash: default(Hash256),
blockHash: default(Hash32),
transactionIndex: txIndex
)
proc calcLogsHash(receipts: openArray[Receipt]): Hash256 =
proc calcLogsHash(receipts: openArray[Receipt]): Hash32 =
var logs: seq[Log]
for rec in receipts:
logs.add rec.logs
@ -150,7 +150,7 @@ proc calcLogsHash(receipts: openArray[Receipt]): Hash256 =
proc defaultTraceStreamFilename(conf: T8NConf,
txIndex: int,
txHash: Hash256): (string, string) =
txHash: Hash32): (string, string) =
let
txHash = "0x" & toLowerAscii($txHash)
baseDir = if conf.outputBaseDir.len > 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

View File

@ -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]]