Skip to content

Commit

Permalink
Update EIP-6404: Split RLP conversions from EIP-6493 for clarity
Browse files Browse the repository at this point in the history
EIP-6493 mixes the introduction of SSZ transactions converted from RLP
with native SSZ transactions, implying that the corresponding Receipt
definition and engine API changes also must be part of EIP-6493.

Splitting the RLP converted transactions into the other SSZ transaction
EIP-6404 achieves a clearer balance, and is also closer to practical
implementation order where an EL initially may choose to support only
RLP converted transactions before adding the native SSZ profiles.
  • Loading branch information
etan-status committed Sep 6, 2024
1 parent 226b17b commit 45f7ee4
Show file tree
Hide file tree
Showing 11 changed files with 854 additions and 1,123 deletions.
362 changes: 336 additions & 26 deletions EIPS/eip-6404.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions EIPS/eip-6465.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ title: SSZ Withdrawals Root
description: Migration of withdrawals MPT commitment to SSZ
author: Etan Kissling (@etan-status), Mikhail Kalinin (@mkalinin)
discussions-to: https://ethereum-magicians.org/t/eip-6465-ssz-withdrawals-root/12883
status: Stagnant
status: Draft
type: Standards Track
category: Core
created: 2023-02-08
requires: 2718, 4895, 6493
requires: 2718, 4895, 6404
---

## Abstract
Expand Down Expand Up @@ -41,7 +41,7 @@ Definitions from existing specifications that are used throughout this document
| Name | Value |
| - | - |
| [`MAX_WITHDRAWALS_PER_PAYLOAD`](https://github.com/ethereum/consensus-specs/blob/ef434e87165e9a4c82a99f54ffd4974ae113f732/specs/capella/beacon-chain.md#execution) | `uint64(2**4)` (= 16) |
| [`TRANSACTION_TYPE_SSZ`](./eip-6493.md#eip-2718-transaction-types) | `0x04` |
| [`SSZ_TX_TYPE`](./eip-6404.md#networking) | `0x04` |

### SSZ `Withdrawal` container

Expand Down Expand Up @@ -95,7 +95,7 @@ typed-withdrawal = withdrawal-type || withdrawal-data

When exchanging SSZ withdrawals via the [Ethereum Wire Protocol](https://github.com/ethereum/devp2p/blob/6b259a7003b4bfb18365ba690f4b00ba8a26393b/caps/eth.md), the following withdrawal envelope is used:

- `Withdrawal`: `TRANSACTION_TYPE_SSZ || snappyFramed(ssz(Withdrawal))`
- `Withdrawal`: `SSZ_TX_TYPE || snappyFramed(ssz(Withdrawal))`

Objects are encoded using [SSZ](https://github.com/ethereum/consensus-specs/blob/ef434e87165e9a4c82a99f54ffd4974ae113f732/ssz/simple-serialize.md) and compressed using the Snappy framing format, matching the encoding of consensus objects as defined in the [consensus networking specification](https://github.com/ethereum/consensus-specs/blob/ef434e87165e9a4c82a99f54ffd4974ae113f732/specs/phase0/p2p-interface.md#ssz-snappy-encoding-strategy). As part of the encoding, the uncompressed object length is emitted; the RECOMMENDED limit to enforce per object is `8 + 8 + 20 + 8` (= 44) bytes.

Expand Down
461 changes: 61 additions & 400 deletions EIPS/eip-6493.md

Large diffs are not rendered by default.

149 changes: 149 additions & 0 deletions assets/eip-6404/convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
from rlp import decode
from rlp_types import *
from ssz_types import *

def upgrade_rlp_transaction_to_ssz(pre_bytes: bytes):
type_ = pre_bytes[0]

if type_ == 0x03: # EIP-4844
pre = decode(pre_bytes[1:], BlobRlpTransaction)
assert pre.y_parity in (0, 1)
ecdsa_signature = ecdsa_pack_signature(
pre.y_parity != 0,
pre.r,
pre.s,
)
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_blob_sig_hash(pre))

return RlpBlobTransaction(
payload=RlpBlobTransactionPayload(
type_=BLOB_TX_TYPE,
chain_id=pre.chain_id,
nonce=pre.nonce,
max_fees_per_gas=BlobFeesPerGas(
regular=pre.max_fee_per_gas,
blob=pre.max_fee_per_blob_gas,
),
gas=pre.gas,
to=ExecutionAddress(pre.to),
value=pre.value,
input_=pre.data,
access_list=[AccessTuple(
address=access_tuple[0],
storage_keys=access_tuple[1]
) for access_tuple in pre.access_list],
max_priority_fees_per_gas=BlobFeesPerGas(
regular=pre.max_priority_fee_per_gas,
blob=FeePerGas(0),
),
blob_versioned_hashes=pre.blob_versioned_hashes,
),
signature=EcdsaExecutionSignature(
from_=from_,
ecdsa_signature=ecdsa_signature,
),
)

if type_ == 0x02: # EIP-1559
pre = decode(pre_bytes[1:], FeeMarketRlpTransaction)
assert pre.y_parity in (0, 1)
ecdsa_signature = ecdsa_pack_signature(
pre.y_parity != 0,
pre.r,
pre.s,
)
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_fee_market_sig_hash(pre))

return RlpFeeMarketTransaction(
payload=RlpFeeMarketTransactionPayload(
type_=FEE_MARKET_TX_TYPE,
chain_id=pre.chain_id,
nonce=pre.nonce,
max_fees_per_gas=BasicFeesPerGas(
regular=pre.max_fee_per_gas,
),
gas=pre.gas,
to=ExecutionAddress(pre.to) if len(pre.to) > 0 else None,
value=pre.value,
input_=pre.data,
access_list=[AccessTuple(
address=access_tuple[0],
storage_keys=access_tuple[1]
) for access_tuple in pre.access_list],
max_priority_fees_per_gas=BasicFeesPerGas(
regular=pre.max_priority_fee_per_gas,
),
),
signature=EcdsaExecutionSignature(
from_=from_,
ecdsa_signature=ecdsa_signature,
),
)

if type_ == 0x01: # EIP-2930
pre = decode(pre_bytes[1:], AccessListRlpTransaction)
assert pre.y_parity in (0, 1)
ecdsa_signature = ecdsa_pack_signature(
pre.y_parity != 0,
pre.r,
pre.s
)
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_access_list_sig_hash(pre))

return RlpAccessListTransaction(
payload=RlpAccessListTransactionPayload(
type_=ACCESS_LIST_TX_TYPE,
chain_id=pre.chain_id,
nonce=pre.nonce,
max_fees_per_gas=BasicFeesPerGas(
regular=pre.gas_price,
),
gas=pre.gas,
to=ExecutionAddress(pre.to) if len(pre.to) > 0 else None,
value=pre.value,
input_=pre.data,
access_list=[AccessTuple(
address=access_tuple[0],
storage_keys=access_tuple[1]
) for access_tuple in pre.access_list],
),
signature=EcdsaExecutionSignature(
from_=from_,
ecdsa_signature=ecdsa_signature,
),
)

if 0xc0 <= type_ <= 0xfe: # Legacy
pre = decode(pre_bytes, LegacyRlpTransaction)
ecdsa_signature = ecdsa_pack_signature(
(pre.v & 0x1) == 0,
pre.r,
pre.s,
)
from_ = ecdsa_recover_from_address(ecdsa_signature, compute_legacy_sig_hash(pre))

if (pre.v not in (27, 28)): # EIP-155
chain_id = ((pre.v - 35) >> 1)
else:
chain_id = None

return RlpLegacyTransaction(
payload=RlpLegacyTransactionPayload(
type_=LEGACY_TX_TYPE,
chain_id=chain_id,
nonce=pre.nonce,
max_fees_per_gas=BasicFeesPerGas(
regular=pre.gas_price,
),
gas=pre.gas,
to=ExecutionAddress(pre.to) if len(pre.to) > 0 else None,
value=pre.value,
input_=pre.data,
),
signature=EcdsaExecutionSignature(
from_=from_,
ecdsa_signature=ecdsa_signature,
),
)

assert False
Loading

0 comments on commit 45f7ee4

Please sign in to comment.