more concise RLP decoding syntax in EL helpers (#6514)

The comment in `readExecutionTransaction` is not actually relevant when
the `rlp.decode` template is called from a non-generic function.
The function still cannot be simply inlined; `is_valid_versioned_hashes`
is itself generic and would require an `export eth_types_rlp` to work
properly (generic sandwich issue). The non-generic function wrapper
seems simpler and avoids injecting RLP into importing modules.
This commit is contained in:
Etan Kissling 2024-08-28 14:21:28 +02:00 committed by GitHub
parent 14f3584a0b
commit 73be2af0d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 1 additions and 6 deletions

View File

@ -14,13 +14,8 @@ import
func readExecutionTransaction( func readExecutionTransaction(
txBytes: bellatrix.Transaction): Result[ExecutionTransaction, string] = txBytes: bellatrix.Transaction): Result[ExecutionTransaction, string] =
# Nim 2.0.8: `rlp.decode(distinctBase(txBytes), ExecutionTransaction)`
# uses the generic `read` from `rlp.nim` instead of the specific `read`
# from `eth_types_rlp.nim`, leading to compilation error.
# Doing this in two steps works around this resolution order issue.
var rlp = rlpFromBytes(distinctBase(txBytes))
try: try:
ok rlp.read(ExecutionTransaction) ok rlp.decode(distinctBase(txBytes), ExecutionTransaction)
except RlpError as exc: except RlpError as exc:
err("Invalid transaction: " & exc.msg) err("Invalid transaction: " & exc.msg)