Skip to content

Commit

Permalink
Fix t8n executionRequests output
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Dec 20, 2024
1 parent b5e3ebe commit 2ea4b9c
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 37 deletions.
4 changes: 3 additions & 1 deletion tools/t8n/t8n_test.nim
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ proc cmp(jsc: var JsonComparator; a, b: JsonNode, path: string): bool =
of JNull:
result = true
of JArray:
if a.len != b.len:
jsc.exit("ARRAY A.len($1) != B.len($2)" % [$a.len, $b.len])
for i, x in a.elems:
if not jsc.cmp(x, b.elems[i], path & "/" & $i):
return false
Expand Down Expand Up @@ -690,7 +692,7 @@ const
),
output: T8nOutput(alloc: true, result: true),
expOut: "exp.json",
),
),
]

proc main() =
Expand Down
6 changes: 1 addition & 5 deletions tools/t8n/testdata/00-525/exp1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requests": [
"0x",
"0x",
"0x"
]
"requests": []
}
}
6 changes: 1 addition & 5 deletions tools/t8n/testdata/00-525/exp2.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
"currentExcessBlobGas": "0x2b80000",
"blobGasUsed": "0x0",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requests": [
"0x",
"0x",
"0x"
]
"requests": []
}
}
4 changes: 1 addition & 3 deletions tools/t8n/testdata/00-525/exp3.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
"blobGasUsed": "0x0",
"requestsHash": "0xf34c7b46f404c6c6f91b540c098b6dfe3f59b7e50ad155807c8c7d2221e52241",
"requests": [
"0x81521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c020000000000000000000000332e43696a505ef45b9319973785f837ce5267b9000065cd1d0000008c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be20000000000000000",
"0x",
"0x"
"0x0081521c60874daf5b425c21e44caf045c4d475e8b33a557a28cee3c46ef9cf9bd95b4c75a0bb629981b40d0102452dd4c020000000000000000000000332e43696a505ef45b9319973785f837ce5267b9000065cd1d0000008c8f2647f342d2c3e8fd07c6b3b9b16383ac11c4be6a6962c7fc18a789daee5fac20ee0bbe4a10383759aaffacacb72b0d67f998730cdf4995fe73afe434dfce2803b343606f67fc4995597c0af9e0fe9ed00006e5889bec29171f670e7d9be20000000000000000",
]
}
}
6 changes: 1 addition & 5 deletions tools/t8n/testdata/00-526/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requests": [
"0x",
"0x",
"0x"
]
"requests": []
}
}
6 changes: 1 addition & 5 deletions tools/t8n/testdata/00-527/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requests": [
"0x",
"0x",
"0x"
]
"requests": []
}
}
6 changes: 1 addition & 5 deletions tools/t8n/testdata/33/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"requests": [
"0x",
"0x",
"0x"
]
"requests": []
}
}
21 changes: 14 additions & 7 deletions tools/t8n/transition.nim
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,23 @@ proc exec(ctx: TransContext,
var allLogs: seq[Log]
for rec in result.result.receipts:
allLogs.add rec.logs
let
var
depositReqs = parseDepositLogs(allLogs, vmState.com.depositContractAddress).valueOr:
raise newError(ErrorEVM, error)
requestsHash = calcRequestsHash([
(DEPOSIT_REQUEST_TYPE, depositReqs),
(WITHDRAWAL_REQUEST_TYPE, withdrawalReqs),
(CONSOLIDATION_REQUEST_TYPE, consolidationReqs)
])
executionRequests: seq[seq[byte]]

template append(dst, reqType, reqData) =
if reqData.len > 0:
reqData.insert(reqType)
dst.add(move(reqData))

executionRequests.append(DEPOSIT_REQUEST_TYPE, depositReqs)
executionRequests.append(WITHDRAWAL_REQUEST_TYPE, withdrawalReqs)
executionRequests.append(CONSOLIDATION_REQUEST_TYPE, consolidationReqs)

let requestsHash = calcRequestsHash(executionRequests)
result.result.requestsHash = Opt.some(requestsHash)
result.result.requests = Opt.some([depositReqs, withdrawalReqs, consolidationReqs])
result.result.requests = Opt.some(executionRequests)

template wrapException(body: untyped) =
when wrapExceptionEnabled:
Expand Down
2 changes: 1 addition & 1 deletion tools/t8n/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ type
blobGasUsed*: Opt[uint64]
currentExcessBlobGas*: Opt[uint64]
requestsHash*: Opt[Hash32]
requests*: Opt[array[3, seq[byte]]]
requests*: Opt[seq[seq[byte]]]

const
ErrorEVM* = 2.T8NExitCode
Expand Down

0 comments on commit 2ea4b9c

Please sign in to comment.