This commit is contained in:
Etan Kissling 2023-10-24 23:08:39 +02:00
parent 6948dc5673
commit efadecfb10
No known key found for this signature in database
GPG Key ID: B21DA824C5A3D03D
1 changed files with 13 additions and 13 deletions

View File

@ -1557,6 +1557,9 @@ proc ETHTransactionsCreateFromJson(
value: UInt256
input: List[byte, Limit MAX_CALLDATA_SIZE]
# EIP-2718
`type`: Opt[uint8]
# EIP-2930
access_list: Opt[List[Eip6493AccessTuple, Limit MAX_ACCESS_LIST_SIZE]]
@ -1572,9 +1575,6 @@ proc ETHTransactionsCreateFromJson(
`from`: ExecutionAddress
ecdsa_signature: array[65, byte]
# EIP-2718
`type`: Opt[uint8]
Eip6493Transaction = object
payload: PartialContainer[Eip6493TransactionPayload, 32]
signature: PartialContainer[Eip6493TransactionSignature, 16]
@ -1591,6 +1591,16 @@ proc ETHTransactionsCreateFromJson(
return nil
eip6493Tx.payload.input =
List[byte, Limit MAX_CALLDATA_SIZE].init(tx.payload)
case tx.txType
of TxLegacy:
if tx.V notin [27'i64, 28'i64]: # With replay protection
`.`(eip6493Tx.payload, `type`).ok(0x00)
of TxEip2930:
`.`(eip6493Tx.payload, `type`).ok(0x01)
of TxEip1559:
`.`(eip6493Tx.payload, `type`).ok(0x02)
of TxEip4844:
`.`(eip6493Tx.payload, `type`).ok(0x03)
if tx.txType >= TxEip2930:
if tx.accessList.len > MAX_ACCESS_LIST_SIZE:
return nil
@ -1608,16 +1618,6 @@ proc ETHTransactionsCreateFromJson(
eip6493Tx.signature.`from` = ExecutionAddress(data: fromAddress)
eip6493Tx.signature.ecdsa_signature = rawSig
case tx.txType
of TxLegacy:
if tx.V notin [27'i64, 28'i64]: # With replay protection
`.`(eip6493Tx.signature, `type`).ok(0x00)
of TxEip2930:
`.`(eip6493Tx.signature, `type`).ok(0x01)
of TxEip1559:
`.`(eip6493Tx.signature, `type`).ok(0x02)
of TxEip4844:
`.`(eip6493Tx.signature, `type`).ok(0x03)
# Nim 1.6.14: Inlining `SSZ.encode` into constructor may corrupt memory.
let eip6493Bytes = SSZ.encode(eip6493Tx)