Fixes related to Prague execution requests (#2847)

* Fixes related to Prague execution requests

Turn out the specs are changed:
- WITHDRAWAL_REQUEST_ADDRESS -> WITHDRAWAL_QUEUE_ADDRESS
- CONSOLIDATION_REQUEST_ADDRESS -> CONSOLIDATION_QUEUE_ADDRESS
- DEPOSIT_CONTRACT_ADDRESS -> only mainnet
- depositContractAddress can be configurable

Also fix bugs related to t8n tool

* Fix for evmc
This commit is contained in:
andri lim 2024-11-08 10:47:07 +07:00 committed by GitHub
parent c15647075d
commit 666f8d2cf1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
23 changed files with 349 additions and 52 deletions

View File

@ -445,7 +445,9 @@ func chainConfigForNetwork*(id: NetworkId): ChainConfig =
result = case id result = case id
of MainNet: of MainNet:
const mainNetTTD = parse("58750000000000000000000",UInt256) const
mainNetTTD = parse("58750000000000000000000",UInt256)
MAINNET_DEPOSIT_CONTRACT_ADDRESS = address"0x00000000219ab540356cbb839cbe05303d7705fa"
ChainConfig( ChainConfig(
chainId: MainNet.ChainId, chainId: MainNet.ChainId,
# Genesis (Frontier): # 2015-07-30 15:26:13 UTC # Genesis (Frontier): # 2015-07-30 15:26:13 UTC
@ -470,6 +472,7 @@ func chainConfigForNetwork*(id: NetworkId): ChainConfig =
terminalTotalDifficulty: Opt.some(mainNetTTD), terminalTotalDifficulty: Opt.some(mainNetTTD),
shanghaiTime: Opt.some(1_681_338_455.EthTime), # 2023-04-12 10:27:35 UTC shanghaiTime: Opt.some(1_681_338_455.EthTime), # 2023-04-12 10:27:35 UTC
cancunTime: Opt.some(1_710_338_135.EthTime), # 2024-03-13 13:55:35 UTC cancunTime: Opt.some(1_710_338_135.EthTime), # 2024-03-13 13:55:35 UTC
depositContractAddress: Opt.some(MAINNET_DEPOSIT_CONTRACT_ADDRESS),
) )
of SepoliaNet: of SepoliaNet:
const sepoliaTTD = parse("17000000000000000",UInt256) const sepoliaTTD = parse("17000000000000000",UInt256)

View File

@ -328,6 +328,9 @@ proc proofOfStake*(com: CommonRef, header: Header): bool =
# This costly check is only executed from test suite # This costly check is only executed from test suite
com.isBlockAfterTtd(header) com.isBlockAfterTtd(header)
func depositContractAddress*(com: CommonRef): Address =
com.config.depositContractAddress.get(default(Address))
proc syncReqNewHead*(com: CommonRef; header: Header) proc syncReqNewHead*(com: CommonRef; header: Header)
{.gcsafe, raises: [].} = {.gcsafe, raises: [].} =
## Used by RPC updater ## Used by RPC updater

View File

@ -176,6 +176,7 @@ type
terminalTotalDifficulty*: Opt[UInt256] terminalTotalDifficulty*: Opt[UInt256]
terminalTotalDifficultyPassed*: Opt[bool] terminalTotalDifficultyPassed*: Opt[bool]
depositContractAddress*: Opt[Address]
# These are used for checking that the values of the fields # These are used for checking that the values of the fields
# are in a valid order. # are in a valid order.

View File

@ -108,7 +108,6 @@ const
initAddress(3) initAddress(3)
HISTORY_STORAGE_ADDRESS* = address"0x0aae40965e6800cd9b1f4b05ff21581047e3f91e" HISTORY_STORAGE_ADDRESS* = address"0x0aae40965e6800cd9b1f4b05ff21581047e3f91e"
DEPOSIT_CONTRACT_ADDRESS* = address"0x00000000219ab540356cbb839cbe05303d7705fa" WITHDRAWAL_QUEUE_ADDRESS* = address"0x09Fc772D0857550724b07B850a4323f39112aAaA"
WITHDRAWAL_REQUEST_ADDRESS* = address"0x00A3ca265EBcb825B45F985A16CEFB49958cE017" CONSOLIDATION_QUEUE_ADDRESS* = address"0x01aBEa29659e5e97C95107F20bb753cD3e09bBBb"
CONSOLIDATION_REQUEST_ADDRESS* = address"0x00b42dbF2194e931E80326D950320f7d9Dbeac02"
# End # End

View File

@ -14,8 +14,7 @@ import
eth/common/receipts, eth/common/receipts,
stew/assign2, stew/assign2,
stew/arrayops, stew/arrayops,
results, results
../constants
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Private helpers # Private helpers
@ -71,14 +70,13 @@ func depositLogToRequest(data: openArray[byte]): DepositRequest =
# Public functions # Public functions
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
func parseDepositLogs*(logs: openArray[Log]): Result[seq[byte], string] = func parseDepositLogs*(logs: openArray[Log], depositContractAddress: Address): Result[seq[byte], string] =
var res = newSeq[byte](logs.len*depositRequestSize) var res = newSeqOfCap[byte](logs.len*depositRequestSize)
for i, log in logs: for i, log in logs:
if log.address == DEPOSIT_CONTRACT_ADDRESS: if log.address != depositContractAddress:
continue
if log.data.len != 576: if log.data.len != 576:
return err("deposit wrong length: want 576, have " & $log.data.len) return err("deposit wrong length: want 576, have " & $log.data.len)
let offset = i*depositRequestSize res.add depositLogToRequest(log.data)
assign(res.toOpenArray(offset, offset+depositRequestSize-1),
depositLogToRequest(log.data))
ok(move(res)) ok(move(res))

View File

@ -191,7 +191,7 @@ proc procBlkEpilogue(
if header.requestsHash.isSome: if header.requestsHash.isSome:
let let
depositReqs = ?parseDepositLogs(vmState.allLogs) depositReqs = ?parseDepositLogs(vmState.allLogs, vmState.com.depositContractAddress)
requestsHash = calcRequestsHash(depositReqs, withdrawalReqs, consolidationReqs) requestsHash = calcRequestsHash(depositReqs, withdrawalReqs, consolidationReqs)
if header.requestsHash.get != requestsHash: if header.requestsHash.get != requestsHash:

View File

@ -197,7 +197,7 @@ proc processDequeueWithdrawalRequests*(vmState: BaseVMState): seq[byte] =
sender : SYSTEM_ADDRESS, sender : SYSTEM_ADDRESS,
gasLimit : 30_000_000.GasInt, gasLimit : 30_000_000.GasInt,
gasPrice : 0.GasInt, gasPrice : 0.GasInt,
to : WITHDRAWAL_REQUEST_ADDRESS, to : WITHDRAWAL_QUEUE_ADDRESS,
# It's a systemCall, no need for other knicks knacks # It's a systemCall, no need for other knicks knacks
sysCall : true, sysCall : true,
@ -221,7 +221,7 @@ proc processDequeueConsolidationRequests*(vmState: BaseVMState): seq[byte] =
sender : SYSTEM_ADDRESS, sender : SYSTEM_ADDRESS,
gasLimit : 30_000_000.GasInt, gasLimit : 30_000_000.GasInt,
gasPrice : 0.GasInt, gasPrice : 0.GasInt,
to : CONSOLIDATION_REQUEST_ADDRESS, to : CONSOLIDATION_QUEUE_ADDRESS,
# It's a systemCall, no need for other knicks knacks # It's a systemCall, no need for other knicks knacks
sysCall : true, sysCall : true,

View File

@ -269,7 +269,7 @@ proc vmExecCommit(pst: var TxPacker): Result[void, string] =
if vmState.fork >= FkPrague: if vmState.fork >= FkPrague:
pst.withdrawalReqs = processDequeueWithdrawalRequests(vmState) pst.withdrawalReqs = processDequeueWithdrawalRequests(vmState)
pst.consolidationReqs = processDequeueConsolidationRequests(vmState) pst.consolidationReqs = processDequeueConsolidationRequests(vmState)
pst.depositReqs = ?parseDepositLogs(vmState.allLogs) pst.depositReqs = ?parseDepositLogs(vmState.allLogs, vmState.com.depositContractAddress)
# Finish up, then vmState.stateDB.stateRoot may be accessed # Finish up, then vmState.stateDB.stateRoot may be accessed
stateDB.persist(clearEmptyAccount = vmState.fork >= FkSpurious) stateDB.persist(clearEmptyAccount = vmState.fork >= FkSpurious)

View File

@ -14,7 +14,7 @@
{.push gcsafe, raises: [].} {.push gcsafe, raises: [].}
import import
std/[algorithm, sequtils], std/[sequtils],
chronicles, chronicles,
eth/[common, rlp], eth/[common, rlp],
stew/byteutils, stew/byteutils,

View File

@ -57,9 +57,8 @@ func storageCostSpec(): array[EVMFork, StorageCostSpec] {.compileTime.} =
netCost: true, warmAccess: WarmStorageReadCost, sset: 20000, netCost: true, warmAccess: WarmStorageReadCost, sset: 20000,
reset: 5000 - ColdSloadCost, clear: 4800) reset: 5000 - ColdSloadCost, clear: 4800)
result[FkParis] = result[FkLondon] for fork in FkParis..EVMFork.high:
result[FkShanghai] = result[FkLondon] result[fork] = result[FkLondon]
result[FkCancun] = result[FkLondon]
proc legacySStoreCost(e: var SstoreCosts, proc legacySStoreCost(e: var SstoreCosts,
c: StorageCostSpec) {.compileTime.} = c: StorageCostSpec) {.compileTime.} =

View File

@ -37,6 +37,7 @@ template handleStopDirective(cpt: VmCpt, tracingEnabled: bool) =
if not cpt.code.atEnd(): if not cpt.code.atEnd():
# we only trace `REAL STOP` and ignore `FAKE STOP` # we only trace `REAL STOP` and ignore `FAKE STOP`
cpt.opIndex = cpt.traceOpCodeStarted(Stop) cpt.opIndex = cpt.traceOpCodeStarted(Stop)
?cpt.opcodeGasCost(Stop, 0, tracingEnabled, reason = $Stop)
cpt.traceOpCodeEnded(Stop, cpt.opIndex) cpt.traceOpCodeEnded(Stop, cpt.opIndex)
template handleFixedGasCostsDirective( template handleFixedGasCostsDirective(

View File

@ -115,7 +115,7 @@ proc showEvmcArgsExpr(fn: NimNode, callName: string): auto =
if (types[i].repr == "ptr byte" or types[i].repr == "ptr HostTopic") and if (types[i].repr == "ptr byte" or types[i].repr == "ptr HostTopic") and
(i < args.len-1 and types[i+1].repr == "HostSize"): (i < args.len-1 and types[i+1].repr == "HostSize"):
skip = i+1 skip = i+1
arg = newPar(args[i], args[i+1]) arg = newNimNode(nnkTupleConstr).add(args[i], args[i+1])
msgExpr = quote do: msgExpr = quote do:
`msgExpr` & `argNameString` & $(`arg`) `msgExpr` & `argNameString` & $(`arg`)
return (msgExpr, args) return (msgExpr, args)

View File

@ -191,6 +191,7 @@ proc readValue*(r: var JsonReader[T8Conv], val: var EnvStruct)
of "blockHashes": r.readValue(val.blockHashes) of "blockHashes": r.readValue(val.blockHashes)
of "ommers": r.readValue(val.ommers) of "ommers": r.readValue(val.ommers)
of "withdrawals": r.readValue(val.withdrawals) of "withdrawals": r.readValue(val.withdrawals)
of "depositContractAddress": r.readValue(val.depositContractAddress)
else: discard r.readValue(JsonString) else: discard r.readValue(JsonString)
if not currentCoinbaseParsed: if not currentCoinbaseParsed:
@ -235,10 +236,10 @@ proc parseTxJson(txo: TxObject, chainId: ChainId): Result[Transaction, string] =
required(value) required(value)
required(input, payload) required(input, payload)
tx.to = txo.to tx.to = txo.to
tx.chainId = chainId
case tx.txType case tx.txType
of TxLegacy: of TxLegacy:
tx.chainId = chainId
required(gasPrice) required(gasPrice)
of TxEip2930: of TxEip2930:
required(gasPrice) required(gasPrice)
@ -263,6 +264,9 @@ proc parseTxJson(txo: TxObject, chainId: ChainId): Result[Transaction, string] =
optional(accessList) optional(accessList)
required(authorizationList) required(authorizationList)
if tx.chainId != chainId:
return err("invalid chain id: have " & $tx.chainId & " want " & $chainId)
let eip155 = txo.protected.get(true) let eip155 = txo.protected.get(true)
if txo.secretKey.isSome: if txo.secretKey.isSome:
let secretKey = PrivateKey.fromRaw(txo.secretKey.get).valueOr: let secretKey = PrivateKey.fromRaw(txo.secretKey.get).valueOr:
@ -274,13 +278,17 @@ proc parseTxJson(txo: TxObject, chainId: ChainId): Result[Transaction, string] =
required(s, S) required(s, S)
ok(tx) ok(tx)
proc readNestedTx(rlp: var Rlp): Result[Transaction, string] = proc readNestedTx(rlp: var Rlp, chainId: ChainId): Result[Transaction, string] =
try: try:
ok if rlp.isList: let tx = if rlp.isList:
rlp.read(Transaction) rlp.read(Transaction)
else: else:
var rr = rlpFromBytes(rlp.read(seq[byte])) var rr = rlpFromBytes(rlp.read(seq[byte]))
rr.read(Transaction) rr.read(Transaction)
if tx.chainId == chainId:
ok(tx)
else:
err("invalid chain id: have " & $tx.chainId & " want " & $chainId)
except RlpError as exc: except RlpError as exc:
err(exc.msg) err(exc.msg)
@ -301,7 +309,7 @@ proc parseTxs*(ctx: var TransContext, chainId: ChainId)
if ctx.txsRlp.len > 0: if ctx.txsRlp.len > 0:
for item in rlp: for item in rlp:
ctx.txList.add rlp.readNestedTx() ctx.txList.add rlp.readNestedTx(chainId)
proc filterGoodTransactions*(ctx: TransContext): seq[Transaction] = proc filterGoodTransactions*(ctx: TransContext): seq[Transaction] =
for txRes in ctx.txList: for txRes in ctx.txList:
@ -433,6 +441,11 @@ proc `@@`[T](x: seq[T]): JsonNode =
for c in x: for c in x:
result.add @@(c) result.add @@(c)
proc `@@`[N, T](x: array[N, T]): JsonNode =
result = newJArray()
for c in x:
result.add @@(c)
proc `@@`[T](x: Opt[T]): JsonNode = proc `@@`[T](x: Opt[T]): JsonNode =
if x.isNone: if x.isNone:
newJNull() newJNull()
@ -462,3 +475,5 @@ proc `@@`*(x: ExecutionResult): JsonNode =
result["blobGasUsed"] = @@(x.blobGasUsed) result["blobGasUsed"] = @@(x.blobGasUsed)
if x.requestsHash.isSome: if x.requestsHash.isSome:
result["requestsHash"] = @@(x.requestsHash) result["requestsHash"] = @@(x.requestsHash)
if x.requests.isSome:
result["requests"] = @@(x.requests)

View File

@ -20,6 +20,7 @@ type
inEnv : string inEnv : string
stFork : string stFork : string
stReward: string stReward: string
chainid : string
T8nOutput = object T8nOutput = object
alloc : bool alloc : bool
@ -39,13 +40,15 @@ type
path: string path: string
error: string error: string
proc t8nInput(alloc, txs, env, fork, reward: string): T8nInput = proc t8nInput(alloc, txs, env, fork: string;
reward = "0"; chainid = ""): T8nInput =
T8nInput( T8nInput(
inAlloc : alloc, inAlloc : alloc,
inTxs : txs, inTxs : txs,
inEnv : env, inEnv : env,
stFork : fork, stFork : fork,
stReward: reward stReward: reward,
chainid : chainid,
) )
proc get(opt: T8nInput, base : string): string = proc get(opt: T8nInput, base : string): string =
@ -55,6 +58,8 @@ proc get(opt: T8nInput, base : string): string =
result.add(" --state.fork " & opt.stFork) result.add(" --state.fork " & opt.stFork)
if opt.stReward.len > 0: if opt.stReward.len > 0:
result.add(" --state.reward " & opt.stReward) result.add(" --state.reward " & opt.stReward)
if opt.chainid.len > 0:
result.add(" --state.chainid " & opt.chainid)
proc get(opt: T8nOutput): string = proc get(opt: T8nOutput): string =
if opt.alloc and not opt.trace: if opt.alloc and not opt.trace:
@ -165,6 +170,7 @@ proc runTest(appDir: string, spec: TestSpec): bool =
if spec.expOut.len > 0: if spec.expOut.len > 0:
if spec.expOut.endsWith(".json"): if spec.expOut.endsWith(".json"):
let path = base / spec.expOut let path = base / spec.expOut
try:
let want = json.parseFile(path) let want = json.parseFile(path)
let have = json.parseJson(res) let have = json.parseJson(res)
var jsc = JsonComparator() var jsc = JsonComparator()
@ -174,6 +180,10 @@ proc runTest(appDir: string, spec: TestSpec): bool =
echo "path: $1, error: $2" % echo "path: $1, error: $2" %
[jsc.path, jsc.error] [jsc.path, jsc.error]
return false return false
except JsonParsingError as exc:
echo "test $1: ERROR: $2" % [spec.name, exc.msg]
echo "test $1: OUTPUT: $2" % [spec.name, res]
return false
else: else:
# compare as regular text # compare as regular text
let path = base / spec.expOut let path = base / spec.expOut
@ -460,7 +470,7 @@ const
name : "Revert In Create In Init Create2", name : "Revert In Create In Init Create2",
base : "testdata/00-512", base : "testdata/00-512",
input : t8nInput( input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Berlin", "0" "alloc.json", "txs.rlp", "env.json", "Berlin", "0", "0"
), ),
output: T8nOutput(alloc: true, result: true), output: T8nOutput(alloc: true, result: true),
expOut: "exp.json", expOut: "exp.json",
@ -469,7 +479,7 @@ const
name : "Revert In Create In Init", name : "Revert In Create In Init",
base : "testdata/00-513", base : "testdata/00-513",
input : t8nInput( input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Berlin", "0" "alloc.json", "txs.rlp", "env.json", "Berlin", "0", "0"
), ),
output: T8nOutput(alloc: true, result: true), output: T8nOutput(alloc: true, result: true),
expOut: "exp.json", expOut: "exp.json",
@ -478,7 +488,7 @@ const
name : "Init collision 3", name : "Init collision 3",
base : "testdata/00-514", base : "testdata/00-514",
input : t8nInput( input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Berlin", "0" "alloc.json", "txs.rlp", "env.json", "Berlin", "0", "0"
), ),
output: T8nOutput(alloc: true, result: true), output: T8nOutput(alloc: true, result: true),
expOut: "exp.json", expOut: "exp.json",
@ -496,7 +506,7 @@ const
name : "GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideLast_Frontier", name : "GasUsedHigherThanBlockGasLimitButNotWithRefundsSuicideLast_Frontier",
base : "testdata/00-516", base : "testdata/00-516",
input : t8nInput( input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Frontier", "5000000000000000000", "alloc.json", "txs.rlp", "env.json", "Frontier", "5000000000000000000", "0"
), ),
output: T8nOutput(alloc: true, result: true), output: T8nOutput(alloc: true, result: true),
expOut: "exp.json", expOut: "exp.json",
@ -609,6 +619,33 @@ const
output: T8nOutput(result: true), output: T8nOutput(result: true),
expOut: "exp.json", expOut: "exp.json",
), ),
TestSpec(
name : "Different --state.chainid and tx.chainid",
base : "testdata/00-525",
input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Prague",
),
output: T8nOutput(result: true),
expOut: "exp1.json",
),
TestSpec(
name : "Prague execution requests",
base : "testdata/00-525",
input : t8nInput(
"alloc.json", "txs.rlp", "env.json", "Prague", "", "7078815900"
),
output: T8nOutput(result: true),
expOut: "exp2.json",
),
TestSpec(
name : "Prague depositContractAddress",
base : "testdata/00-525",
input : t8nInput(
"alloc.json", "txs.rlp", "env_dca.json", "Prague", "", "7078815900"
),
output: T8nOutput(result: true),
expOut: "exp3.json",
),
] ]
proc main() = proc main() =

72
tools/t8n/testdata/00-525/alloc.json vendored Normal file

File diff suppressed because one or more lines are too long

23
tools/t8n/testdata/00-525/env.json vendored Normal file
View File

@ -0,0 +1,23 @@
{
"blockHashes": {
},
"currentBaseFee": "0x7",
"currentBlobGasUsed": "0x0",
"currentCoinbase": "0xf97e180c050e5ab072211ad2c213eb5aee4df134",
"currentDifficulty": "0x0",
"currentExcessBlobGas": "0x2b80000",
"currentGasLimit": "0x1c9c380",
"currentNumber": "0x1",
"currentRandom": "0x89e03b95990c23f0dbc63247c17d9699464d25d10f9d24a676265bdd82bfb18a",
"currentTimestamp": "0x672bc100",
"parentBaseFee": "0x7",
"parentBeaconBlockRoot": "0x4368de4abb7ed9d11d92d42713a3b3c6e0a271e20d6de882161c2ae1b3a9051f",
"parentBlobGasUsed": "0xc0000",
"parentDifficulty": "0x0",
"parentExcessBlobGas": "0x2b20000",
"parentGasLimit": "0x1c9c380",
"parentGasUsed": "0x430f97",
"parentTimestamp": "0x672bc0f4",
"withdrawals": [
]
}

24
tools/t8n/testdata/00-525/env_dca.json vendored Normal file
View File

@ -0,0 +1,24 @@
{
"blockHashes": {
},
"currentBaseFee": "0x7",
"currentBlobGasUsed": "0x0",
"currentCoinbase": "0xf97e180c050e5ab072211ad2c213eb5aee4df134",
"currentDifficulty": "0x0",
"currentExcessBlobGas": "0x2b80000",
"currentGasLimit": "0x1c9c380",
"currentNumber": "0x1",
"currentRandom": "0x89e03b95990c23f0dbc63247c17d9699464d25d10f9d24a676265bdd82bfb18a",
"currentTimestamp": "0x672bc100",
"parentBaseFee": "0x7",
"parentBeaconBlockRoot": "0x4368de4abb7ed9d11d92d42713a3b3c6e0a271e20d6de882161c2ae1b3a9051f",
"parentBlobGasUsed": "0xc0000",
"parentDifficulty": "0x0",
"parentExcessBlobGas": "0x2b20000",
"parentGasLimit": "0x1c9c380",
"parentGasUsed": "0x430f97",
"parentTimestamp": "0x672bc0f4",
"withdrawals": [
],
"depositContractAddress": "0x4242424242424242424242424242424242424242"
}

28
tools/t8n/testdata/00-525/exp1.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
"result": {
"stateRoot": "0x08fd46faf1bc68f8f3b6c78710d91b825cb22375aa8a3db99ddd9084cbbbfd75",
"txRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"receipts": [],
"currentDifficulty": null,
"gasUsed": "0x0",
"rejected": [
{
"index": 0,
"error": "invalid chain id: have 7078815900 want 1"
}
],
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f",
"requests": [
"0x",
"0x",
"0x"
]
}
}

44
tools/t8n/testdata/00-525/exp2.json vendored Normal file
View File

@ -0,0 +1,44 @@
{
"result": {
"stateRoot": "0xdbeeef4c53f45167aea35bccfa9329f4a9b59fa7b115dc2f6462eea7316c2600",
"txRoot": "0xe67cc7032923c32bc107773c80dbe2afc754eeed4203ccee50605b9fe15a5bb5",
"receiptsRoot": "0xead5884f735e5e8e703878f0c89b54919d06c2cee8e373d632e730d42b380e0c",
"logsHash": "0x6fb31d3ef4580565e54b679a3bb580d1a4c345faab2cfc7868304e0e5da23f4c",
"logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000",
"receipts": [
{
"root": "0x",
"status": "0x1",
"cumulativeGasUsed": "0x14aea",
"logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000",
"logs": [
{
"address": "0x4242424242424242424242424242424242424242",
"topics": [
"0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003081521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020020000000000000000000000332e43696a505ef45b9319973785f837ce5267b90000000000000000000000000000000000000000000000000000000000000008000065cd1d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000608c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000"
}
],
"transactionHash": "0x75b5508fdcec7682f238fb1ccdc9a087f3f8b601fd52d5c0684123698d89f0a6",
"contractAddress": "0x0000000000000000000000000000000000000000",
"gasUsed": "0x14aea",
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionIndex": "0x0",
"type": "0x2"
}
],
"currentDifficulty": null,
"gasUsed": "0x14aea",
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0x6036c41849da9c076ed79654d434017387a88fb833c2856b32e18218b3341c5f",
"requests": [
"0x",
"0x",
"0x"
]
}
}

44
tools/t8n/testdata/00-525/exp3.json vendored Normal file
View File

@ -0,0 +1,44 @@
{
"result": {
"stateRoot": "0xdbeeef4c53f45167aea35bccfa9329f4a9b59fa7b115dc2f6462eea7316c2600",
"txRoot": "0xe67cc7032923c32bc107773c80dbe2afc754eeed4203ccee50605b9fe15a5bb5",
"receiptsRoot": "0xead5884f735e5e8e703878f0c89b54919d06c2cee8e373d632e730d42b380e0c",
"logsHash": "0x6fb31d3ef4580565e54b679a3bb580d1a4c345faab2cfc7868304e0e5da23f4c",
"logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000",
"receipts": [
{
"root": "0x",
"status": "0x1",
"cumulativeGasUsed": "0x14aea",
"logsBloom": "0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000",
"logs": [
{
"address": "0x4242424242424242424242424242424242424242",
"topics": [
"0x649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c5"
],
"data": "0x00000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000001800000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003081521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020020000000000000000000000332e43696a505ef45b9319973785f837ce5267b90000000000000000000000000000000000000000000000000000000000000008000065cd1d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000608c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be200000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000"
}
],
"transactionHash": "0x75b5508fdcec7682f238fb1ccdc9a087f3f8b601fd52d5c0684123698d89f0a6",
"contractAddress": "0x0000000000000000000000000000000000000000",
"gasUsed": "0x14aea",
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionIndex": "0x0",
"type": "0x2"
}
],
"currentDifficulty": null,
"gasUsed": "0x14aea",
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0xa5c19ed76c01fe25a67b7ef8c227caa34951e8c7e74168408b5be0861dac686d",
"requests": [
"0x81521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c020000000000000000000000332e43696a505ef45b9319973785f837ce5267b9000065cd1d0000008c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be20000000000000000",
"0x",
"0x"
]
}
}

1
tools/t8n/testdata/00-525/txs.rlp vendored Normal file
View File

@ -0,0 +1 @@
"0xf90226b9022302f9021f8501a5ee289c07840e07899f840e07899f8302c0c19442424242424242424242424242424242424242428906f05b59d3b2000000b901a422895118000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001206c240a071b7048221c3f53bb0e66debee5330def076d51c9958c776e3f13d5d4000000000000000000000000000000000000000000000000000000000000003081521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020020000000000000000000000332e43696a505ef45b9319973785f837ce5267b900000000000000000000000000000000000000000000000000000000000000608c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be2c001a0e36549b612e7fd2c1b0635025782f6c4841317a1a4b4614b3a39b95754fca7f6a014ca51a1714612ee97e1b5a785bd0c8e388f46539d36cc8ef014127a0bfcf05a"

View File

@ -150,7 +150,7 @@ proc defaultTraceStreamFilename(conf: T8NConf,
txIndex: int, txIndex: int,
txHash: Hash32): (string, string) = txHash: Hash32): (string, string) =
let let
txHash = "0x" & toLowerAscii($txHash) txHash = toLowerAscii($txHash)
baseDir = if conf.outputBaseDir.len > 0: baseDir = if conf.outputBaseDir.len > 0:
conf.outputBaseDir conf.outputBaseDir
else: else:
@ -167,8 +167,9 @@ proc traceToFileStream(path: string, txIndex: int): Stream =
# replace whatever `.ext` to `-${txIndex}.jsonl` # replace whatever `.ext` to `-${txIndex}.jsonl`
let let
file = path.splitFile file = path.splitFile
fName = "$1/$2-$3.jsonl" % [file.dir, file.name, $txIndex] folder = if file.dir.len == 0: "." else: file.dir
createDir(file.dir) fName = "$1/$2-$3.jsonl" % [folder, file.name, $txIndex]
if file.dir.len > 0: createDir(file.dir)
newFileStream(fName, fmWrite) newFileStream(fName, fmWrite)
proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMState): bool = proc setupTrace(conf: T8NConf, txIndex: int, txHash: Hash32, vmState: BaseVMState): bool =
@ -355,10 +356,11 @@ proc exec(ctx: TransContext,
for rec in result.result.receipts: for rec in result.result.receipts:
allLogs.add rec.logs allLogs.add rec.logs
let let
depositReqs = parseDepositLogs(allLogs).valueOr: depositReqs = parseDepositLogs(allLogs, vmState.com.depositContractAddress).valueOr:
raise newError(ErrorEVM, error) raise newError(ErrorEVM, error)
requestsHash = calcRequestsHash(depositReqs, withdrawalReqs, consolidationReqs) requestsHash = calcRequestsHash(depositReqs, withdrawalReqs, consolidationReqs)
result.result.requestsHash = Opt.some(requestsHash) result.result.requestsHash = Opt.some(requestsHash)
result.result.requests = Opt.some([depositReqs, withdrawalReqs, consolidationReqs])
template wrapException(body: untyped) = template wrapException(body: untyped) =
when wrapExceptionEnabled: when wrapExceptionEnabled:
@ -424,11 +426,6 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) =
if conf.inputAlloc.len == 0 and conf.inputEnv.len == 0 and conf.inputTxs.len == 0: if conf.inputAlloc.len == 0 and conf.inputEnv.len == 0 and conf.inputTxs.len == 0:
raise newError(ErrorConfig, "either one of input is needeed(alloc, txs, or env)") raise newError(ErrorConfig, "either one of input is needeed(alloc, txs, or env)")
let config = parseChainConfig(conf.stateFork)
config.chainId = conf.stateChainId.ChainId
let com = CommonRef.new(newCoreDbRef DefaultDbMemory, config)
# We need to load three things: alloc, env and transactions. # We need to load three things: alloc, env and transactions.
# May be either in stdin input or in files. # May be either in stdin input or in files.
@ -446,7 +443,7 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) =
if conf.inputTxs != stdinSelector and conf.inputTxs.len > 0: if conf.inputTxs != stdinSelector and conf.inputTxs.len > 0:
if conf.inputTxs.endsWith(".rlp"): if conf.inputTxs.endsWith(".rlp"):
let data = readFile(conf.inputTxs) let data = readFile(conf.inputTxs)
ctx.parseTxsRlp(data.strip(chars={'"'})) ctx.parseTxsRlp(data.strip(chars={'"', ' ', '\r', '\n', '\t'}))
else: else:
ctx.parseTxsJson(conf.inputTxs) ctx.parseTxsJson(conf.inputTxs)
@ -465,6 +462,12 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) =
excessBlobGas: ctx.env.parentExcessBlobGas, excessBlobGas: ctx.env.parentExcessBlobGas,
) )
let config = parseChainConfig(conf.stateFork)
config.depositContractAddress = ctx.env.depositContractAddress
config.chainId = conf.stateChainId.ChainId
let com = CommonRef.new(newCoreDbRef DefaultDbMemory, config)
# Sanity check, to not `panic` in state_transition # Sanity check, to not `panic` in state_transition
if com.isLondonOrLater(ctx.env.currentNumber): if com.isLondonOrLater(ctx.env.currentNumber):
if ctx.env.currentBaseFee.isSome: if ctx.env.currentBaseFee.isSome:

View File

@ -52,6 +52,7 @@ type
parentBlobGasUsed*: Opt[uint64] parentBlobGasUsed*: Opt[uint64]
parentExcessBlobGas*: Opt[uint64] parentExcessBlobGas*: Opt[uint64]
parentBeaconBlockRoot*: Opt[Hash32] parentBeaconBlockRoot*: Opt[Hash32]
depositContractAddress*: Opt[Address]
TxObject* = object TxObject* = object
`type`*: Opt[uint64] `type`*: Opt[uint64]
@ -117,6 +118,7 @@ type
blobGasUsed*: Opt[uint64] blobGasUsed*: Opt[uint64]
currentExcessBlobGas*: Opt[uint64] currentExcessBlobGas*: Opt[uint64]
requestsHash*: Opt[Hash32] requestsHash*: Opt[Hash32]
requests*: Opt[array[3, seq[byte]]]
const const
ErrorEVM* = 2.T8NExitCode ErrorEVM* = 2.T8NExitCode